Skip to content

Commit e7b9a5a

Browse files
authored
Merge pull request #187 from chrisben/2.x
Update to 2.x
2 parents 84f9c83 + 545b99f commit e7b9a5a

23 files changed

+2749
-3270
lines changed

.circleci/config.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Javascript Node CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
4+
#
5+
version: 2
6+
jobs:
7+
build:
8+
docker:
9+
# specify the version you desire here
10+
- image: circleci/node:7.10
11+
12+
# Specify service dependencies here if necessary
13+
# CircleCI maintains a library of pre-built images
14+
# documented at https://circleci.com/docs/2.0/circleci-images/
15+
# - image: circleci/mongo:3.4.4
16+
17+
working_directory: ~/repo
18+
19+
steps:
20+
- checkout
21+
22+
# Download and cache dependencies
23+
- restore_cache:
24+
keys:
25+
- v1-dependencies-{{ checksum "package.json" }}
26+
# fallback to using the latest cache if no exact match is found
27+
- v1-dependencies-
28+
29+
- run: yarn install
30+
31+
- save_cache:
32+
paths:
33+
- node_modules
34+
key: v1-dependencies-{{ checksum "package.json" }}
35+
36+
# run tests!
37+
- run: yarn test
38+
39+

.eslintrc.json

+236
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
{
2+
"env": {
3+
"browser": true
4+
},
5+
"extends": "eslint:recommended",
6+
"rules": {
7+
"accessor-pairs": "error",
8+
"array-bracket-spacing": [
9+
"error",
10+
"never"
11+
],
12+
"array-callback-return": "error",
13+
"arrow-body-style": "error",
14+
"arrow-parens": "error",
15+
"arrow-spacing": "error",
16+
"block-scoped-var": "error",
17+
"block-spacing": "off",
18+
"brace-style": "off",
19+
"callback-return": "off",
20+
"camelcase": "off",
21+
"comma-dangle": "error",
22+
"comma-spacing": "off",
23+
"comma-style": [
24+
"error",
25+
"last"
26+
],
27+
"complexity": "error",
28+
"computed-property-spacing": [
29+
"error",
30+
"never"
31+
],
32+
"consistent-return": "off",
33+
"consistent-this": "error",
34+
"curly": "off",
35+
"default-case": "error",
36+
"dot-location": [
37+
"error",
38+
"property"
39+
],
40+
"dot-notation": [
41+
"error",
42+
{
43+
"allowKeywords": true
44+
}
45+
],
46+
"eol-last": "error",
47+
"eqeqeq": "off",
48+
"func-names": "off",
49+
"func-style": "off",
50+
"generator-star-spacing": "error",
51+
"global-require": "error",
52+
"guard-for-in": "off",
53+
"handle-callback-err": "error",
54+
"id-blacklist": "error",
55+
"id-length": "off",
56+
"id-match": "error",
57+
"indent": "off",
58+
"init-declarations": "off",
59+
"jsx-quotes": "error",
60+
"key-spacing": "off",
61+
"keyword-spacing": "off",
62+
"linebreak-style": [
63+
"error",
64+
"unix"
65+
],
66+
"lines-around-comment": "off",
67+
"max-depth": "error",
68+
"max-len": "off",
69+
"max-lines": "off",
70+
"max-nested-callbacks": "error",
71+
"max-params": "off",
72+
"max-statements": "off",
73+
"max-statements-per-line": "off",
74+
"multiline-ternary": "off",
75+
"new-parens": "error",
76+
"newline-after-var": "off",
77+
"newline-before-return": "off",
78+
"newline-per-chained-call": "error",
79+
"no-alert": "error",
80+
"no-array-constructor": "error",
81+
"no-bitwise": "off",
82+
"no-caller": "error",
83+
"no-catch-shadow": "error",
84+
"no-confusing-arrow": "error",
85+
"no-console": "off",
86+
"no-continue": "error",
87+
"no-div-regex": "error",
88+
"no-duplicate-imports": "error",
89+
"no-else-return": "off",
90+
"no-empty-function": "error",
91+
"no-eq-null": "error",
92+
"no-eval": "error",
93+
"no-extend-native": "error",
94+
"no-extra-bind": "error",
95+
"no-extra-label": "error",
96+
"no-extra-parens": "off",
97+
"no-floating-decimal": "error",
98+
"no-implicit-coercion": "error",
99+
"no-implicit-globals": "off",
100+
"no-implied-eval": "error",
101+
"no-inline-comments": "off",
102+
"no-inner-declarations": [
103+
"error",
104+
"functions"
105+
],
106+
"no-invalid-this": "error",
107+
"no-iterator": "error",
108+
"no-label-var": "error",
109+
"no-labels": "error",
110+
"no-lone-blocks": "error",
111+
"no-lonely-if": "off",
112+
"no-loop-func": "error",
113+
"no-magic-numbers": "off",
114+
"no-mixed-operators": "error",
115+
"no-mixed-requires": "error",
116+
"no-multi-spaces": "off",
117+
"no-multi-str": "error",
118+
"no-multiple-empty-lines": "off",
119+
"no-negated-condition": "off",
120+
"no-nested-ternary": "off",
121+
"no-new": "error",
122+
"no-new-func": "error",
123+
"no-new-object": "error",
124+
"no-new-require": "error",
125+
"no-new-wrappers": "error",
126+
"no-octal-escape": "error",
127+
"no-param-reassign": "off",
128+
"no-path-concat": "error",
129+
"no-plusplus": "off",
130+
"no-process-env": "error",
131+
"no-process-exit": "error",
132+
"no-proto": "error",
133+
"no-prototype-builtins": "off",
134+
"no-restricted-globals": "error",
135+
"no-restricted-imports": "error",
136+
"no-restricted-modules": "error",
137+
"no-restricted-syntax": "error",
138+
"no-return-assign": "error",
139+
"no-script-url": "error",
140+
"no-self-compare": "error",
141+
"no-sequences": "error",
142+
"no-shadow": "off",
143+
"no-shadow-restricted-names": "error",
144+
"no-spaced-func": "off",
145+
"no-sync": "error",
146+
"no-tabs": "error",
147+
"no-ternary": "off",
148+
"no-throw-literal": "off",
149+
"no-trailing-spaces": "error",
150+
"no-undef": [
151+
"error",
152+
{
153+
"typeof": false
154+
}
155+
],
156+
"no-undef-init": "error",
157+
"no-undefined": "off",
158+
"no-underscore-dangle": "off",
159+
"no-unmodified-loop-condition": "error",
160+
"no-unneeded-ternary": "off",
161+
"no-unused-expressions": "error",
162+
"no-use-before-define": "off",
163+
"no-useless-call": "error",
164+
"no-useless-computed-key": "error",
165+
"no-useless-concat": "error",
166+
"no-useless-constructor": "error",
167+
"no-useless-escape": "off",
168+
"no-useless-rename": "error",
169+
"no-var": "off",
170+
"no-void": "error",
171+
"no-warning-comments": "off",
172+
"no-whitespace-before-property": "error",
173+
"no-with": "error",
174+
"object-curly-newline": "error",
175+
"object-curly-spacing": "off",
176+
"object-property-newline": [
177+
"error",
178+
{
179+
"allowMultiplePropertiesPerLine": true
180+
}
181+
],
182+
"object-shorthand": "off",
183+
"one-var": "off",
184+
"one-var-declaration-per-line": "off",
185+
"operator-assignment": [
186+
"error",
187+
"always"
188+
],
189+
"operator-linebreak": "error",
190+
"padded-blocks": "off",
191+
"prefer-arrow-callback": "off",
192+
"prefer-const": "error",
193+
"prefer-reflect": "error",
194+
"prefer-rest-params": "error",
195+
"prefer-spread": "error",
196+
"prefer-template": "off",
197+
"quote-props": "off",
198+
"quotes": "off",
199+
"radix": [
200+
"error",
201+
"always"
202+
],
203+
"require-jsdoc": "off",
204+
"rest-spread-spacing": "error",
205+
"semi": "off",
206+
"semi-spacing": [
207+
"error",
208+
{
209+
"after": false,
210+
"before": false
211+
}
212+
],
213+
"sort-imports": "error",
214+
"sort-vars": "off",
215+
"space-before-blocks": "off",
216+
"space-before-function-paren": "off",
217+
"space-in-parens": "off",
218+
"space-infix-ops": "off",
219+
"space-unary-ops": "error",
220+
"spaced-comment": "off",
221+
"strict": "off",
222+
"template-curly-spacing": "error",
223+
"unicode-bom": [
224+
"error",
225+
"never"
226+
],
227+
"valid-jsdoc": "error",
228+
"vars-on-top": "off",
229+
"wrap-iife": [
230+
"error",
231+
"any"
232+
],
233+
"wrap-regex": "error",
234+
"yield-star-spacing": "error"
235+
}
236+
}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
*.log

CHANGELOG.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@
22

33
## master ##
44

5+
## 2.0.0 ##
6+
7+
### NEW ###
8+
* Add static-server node implementation to run html examples from a local server (`npm start`)
9+
* Add Circle-CI with lint checks for now
10+
11+
### FIXED ###
12+
* Fix some tests
513
* Fix xhr timeout issues (#209 thanks altelante)
614

715
### IMPROVED ###
8-
16+
* Move main library folder to `lib/`
17+
* Use 2 characters spacing convention
18+
* Add eslint (`npm test`)
19+
* Replace qimgcache with imgcache-promise: using new ES6/Bluebird Promises
920
* Improve Cordova documentation (#222 thanks jQrgen)
1021

1122
## 1.2.0 ##

CORDOVA.md

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ imgcache.js requires the following Cordova plugins:
2626
* [Device](http://cordova.apache.org/docs/en/latest/reference/cordova-plugin-device/index.html)
2727
* [FileTransfer](http://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file-transfer/index.html)
2828

29-
3029
```
3130
cordova plugin add cordova-plugin-file --save
3231
cordova plugin add cordova-plugin-device --save

README.md

+15-8
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ Installation
3434

3535
Note: You can use [bower](http://bower.io/) or [npm](https://www.npmjs.com/) to add this library as a dependency to your project (repository name: `imgcache.js`).
3636

37-
To start to use this library, import `js/imgcache.js` within your html file:
37+
To start to use this library, import `lib/imgcache.js` within your html file:
3838

3939
```html
40-
<script src="js/imgcache.js"></script>
40+
<script src="lib/imgcache.js"></script>
4141
```
4242

4343
Using with PhoneGap/Cordova: see [CORDOVA.md](CORDOVA.md).
@@ -203,19 +203,26 @@ Overridable methods
203203

204204
Promises
205205
--------
206-
Include also [qimgcache.js](js/qimgcache.js) in your html files to be able to use its [Q Promises](https://github.com/kriskowal/q) interface if you don't like callbacks and prefer to use the simpler then/fail/progress methods.
206+
Include the [imgcache-promise.js](lib/imgcache-promise.js) wrapper into your project to be able to use ES6-compatible Promises (using [Bluebird](http://bluebirdjs.com/) for instance) if you don't like callbacks and prefer to use the simpler then/catch methods.
207207

208208
This wrapper also makes sure the init method is always called first, so you SHOULDN'T call this method yourself when using this wrapper.
209209

210210
Check out the [sample code](examples/promises.html).
211211

212-
Unit tests
212+
Unit tests and code samples
213213
----------
214-
Open `index.html` and click 'Start unit tests' to launch unit tests.
214+
Run a local server:
215215

216-
Code samples
217-
------------
218-
Open `index.html` to check out several examples.
216+
```shell
217+
npm install
218+
npm start
219+
```
220+
221+
Then open the given url in your Chrome browser (`index.html`) and click 'Start unit tests' to launch unit tests.
222+
223+
You will be able to find several code samples.
224+
225+
To lint the main javascript code, you can run `npm test` to start [eslint](http://eslint.org/)
219226

220227
Release Notes
221228
-------------

bower.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"name": "imgcache.js",
3-
"version": "1.1.0",
3+
"version": "2.0.0",
44
"homepage": "https://github.com/chrisben/imgcache.js",
55
"authors": [
66
{
77
"name": "Christophe Benoit"
88
}
99
],
1010
"repository": {
11-
"type": "git",
12-
"url": "git://github.com/chrisben/imgcache.js.git"
11+
"type": "git",
12+
"url": "git://github.com/chrisben/imgcache.js.git"
1313
},
1414
"description": "JS library that stores images locally for offline apps using PhoneGap/Cordova or browsers supporting the new html5 File API",
15-
"main": "js/imgcache.js",
15+
"main": "lib/imgcache.js",
1616
"keywords": [
1717
"cordova",
1818
"phonegap",

examples/example1.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf-8">
55
<title>Examples</title>
66
<script src="jquery-1.6.4.min.js"></script>
7-
<script src="../js/imgcache.js"></script>
7+
<script src="../lib/imgcache.js"></script>
88
<!-- only for cordova (replace by phonegap.js for phonegap) - ignore on desktop browser -->
99
<script src="../cordova.js"></script>
1010
<script>
@@ -168,7 +168,7 @@ <h3>Local image</h3>
168168
<div>
169169
<h3>Remote image</h3>
170170
<!-- random image on domain with CORS enabled -->
171-
<img src="http://data-gov.tw.rpi.edu/w/images/thumb/b/b1/State-lib-sum.png/120px-State-lib-sum.png" width="120" height="82" id="remote_cors" data-desc="remote_cors_desc" data-is-cached="remote_cors_cached">
171+
<img src="https://data-gov.tw.rpi.edu/w/images/thumb/b/b1/State-lib-sum.png/120px-State-lib-sum.png" width="120" height="82" id="remote_cors" data-desc="remote_cors_desc" data-is-cached="remote_cors_cached">
172172
<p id="remote_cors_desc"></p>
173173
<p id="remote_cors_cached"></p>
174174
</div>

0 commit comments

Comments
 (0)