Skip to content

Commit

Permalink
Merge pull request #187 from chrisben/2.x
Browse files Browse the repository at this point in the history
Update to 2.x
  • Loading branch information
chrisben authored Nov 9, 2017
2 parents 84f9c83 + 545b99f commit e7b9a5a
Show file tree
Hide file tree
Showing 23 changed files with 2,749 additions and 3,270 deletions.
39 changes: 39 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/node:7.10

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/mongo:3.4.4

working_directory: ~/repo

steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: yarn install

- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

# run tests!
- run: yarn test


236 changes: 236 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
{
"env": {
"browser": true
},
"extends": "eslint:recommended",
"rules": {
"accessor-pairs": "error",
"array-bracket-spacing": [
"error",
"never"
],
"array-callback-return": "error",
"arrow-body-style": "error",
"arrow-parens": "error",
"arrow-spacing": "error",
"block-scoped-var": "error",
"block-spacing": "off",
"brace-style": "off",
"callback-return": "off",
"camelcase": "off",
"comma-dangle": "error",
"comma-spacing": "off",
"comma-style": [
"error",
"last"
],
"complexity": "error",
"computed-property-spacing": [
"error",
"never"
],
"consistent-return": "off",
"consistent-this": "error",
"curly": "off",
"default-case": "error",
"dot-location": [
"error",
"property"
],
"dot-notation": [
"error",
{
"allowKeywords": true
}
],
"eol-last": "error",
"eqeqeq": "off",
"func-names": "off",
"func-style": "off",
"generator-star-spacing": "error",
"global-require": "error",
"guard-for-in": "off",
"handle-callback-err": "error",
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
"indent": "off",
"init-declarations": "off",
"jsx-quotes": "error",
"key-spacing": "off",
"keyword-spacing": "off",
"linebreak-style": [
"error",
"unix"
],
"lines-around-comment": "off",
"max-depth": "error",
"max-len": "off",
"max-lines": "off",
"max-nested-callbacks": "error",
"max-params": "off",
"max-statements": "off",
"max-statements-per-line": "off",
"multiline-ternary": "off",
"new-parens": "error",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": "error",
"no-alert": "error",
"no-array-constructor": "error",
"no-bitwise": "off",
"no-caller": "error",
"no-catch-shadow": "error",
"no-confusing-arrow": "error",
"no-console": "off",
"no-continue": "error",
"no-div-regex": "error",
"no-duplicate-imports": "error",
"no-else-return": "off",
"no-empty-function": "error",
"no-eq-null": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-extra-parens": "off",
"no-floating-decimal": "error",
"no-implicit-coercion": "error",
"no-implicit-globals": "off",
"no-implied-eval": "error",
"no-inline-comments": "off",
"no-inner-declarations": [
"error",
"functions"
],
"no-invalid-this": "error",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-lonely-if": "off",
"no-loop-func": "error",
"no-magic-numbers": "off",
"no-mixed-operators": "error",
"no-mixed-requires": "error",
"no-multi-spaces": "off",
"no-multi-str": "error",
"no-multiple-empty-lines": "off",
"no-negated-condition": "off",
"no-nested-ternary": "off",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-require": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-param-reassign": "off",
"no-path-concat": "error",
"no-plusplus": "off",
"no-process-env": "error",
"no-process-exit": "error",
"no-proto": "error",
"no-prototype-builtins": "off",
"no-restricted-globals": "error",
"no-restricted-imports": "error",
"no-restricted-modules": "error",
"no-restricted-syntax": "error",
"no-return-assign": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "off",
"no-shadow-restricted-names": "error",
"no-spaced-func": "off",
"no-sync": "error",
"no-tabs": "error",
"no-ternary": "off",
"no-throw-literal": "off",
"no-trailing-spaces": "error",
"no-undef": [
"error",
{
"typeof": false
}
],
"no-undef-init": "error",
"no-undefined": "off",
"no-underscore-dangle": "off",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "off",
"no-unused-expressions": "error",
"no-use-before-define": "off",
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-escape": "off",
"no-useless-rename": "error",
"no-var": "off",
"no-void": "error",
"no-warning-comments": "off",
"no-whitespace-before-property": "error",
"no-with": "error",
"object-curly-newline": "error",
"object-curly-spacing": "off",
"object-property-newline": [
"error",
{
"allowMultiplePropertiesPerLine": true
}
],
"object-shorthand": "off",
"one-var": "off",
"one-var-declaration-per-line": "off",
"operator-assignment": [
"error",
"always"
],
"operator-linebreak": "error",
"padded-blocks": "off",
"prefer-arrow-callback": "off",
"prefer-const": "error",
"prefer-reflect": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "off",
"quote-props": "off",
"quotes": "off",
"radix": [
"error",
"always"
],
"require-jsdoc": "off",
"rest-spread-spacing": "error",
"semi": "off",
"semi-spacing": [
"error",
{
"after": false,
"before": false
}
],
"sort-imports": "error",
"sort-vars": "off",
"space-before-blocks": "off",
"space-before-function-paren": "off",
"space-in-parens": "off",
"space-infix-ops": "off",
"space-unary-ops": "error",
"spaced-comment": "off",
"strict": "off",
"template-curly-spacing": "error",
"unicode-bom": [
"error",
"never"
],
"valid-jsdoc": "error",
"vars-on-top": "off",
"wrap-iife": [
"error",
"any"
],
"wrap-regex": "error",
"yield-star-spacing": "error"
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
*.log
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@

## master ##

## 2.0.0 ##

### NEW ###
* Add static-server node implementation to run html examples from a local server (`npm start`)
* Add Circle-CI with lint checks for now

### FIXED ###
* Fix some tests
* Fix xhr timeout issues (#209 thanks altelante)

### IMPROVED ###

* Move main library folder to `lib/`
* Use 2 characters spacing convention
* Add eslint (`npm test`)
* Replace qimgcache with imgcache-promise: using new ES6/Bluebird Promises
* Improve Cordova documentation (#222 thanks jQrgen)

## 1.2.0 ##
Expand Down
1 change: 0 additions & 1 deletion CORDOVA.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ imgcache.js requires the following Cordova plugins:
* [Device](http://cordova.apache.org/docs/en/latest/reference/cordova-plugin-device/index.html)
* [FileTransfer](http://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file-transfer/index.html)


```
cordova plugin add cordova-plugin-file --save
cordova plugin add cordova-plugin-device --save
Expand Down
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ Installation

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`).

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

```html
<script src="js/imgcache.js"></script>
<script src="lib/imgcache.js"></script>
```

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

Promises
--------
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.
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.

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

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

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

Code samples
------------
Open `index.html` to check out several examples.
```shell
npm install
npm start
```

Then open the given url in your Chrome browser (`index.html`) and click 'Start unit tests' to launch unit tests.

You will be able to find several code samples.

To lint the main javascript code, you can run `npm test` to start [eslint](http://eslint.org/)

Release Notes
-------------
Expand Down
8 changes: 4 additions & 4 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "imgcache.js",
"version": "1.1.0",
"version": "2.0.0",
"homepage": "https://github.com/chrisben/imgcache.js",
"authors": [
{
"name": "Christophe Benoit"
}
],
"repository": {
"type": "git",
"url": "git://github.com/chrisben/imgcache.js.git"
"type": "git",
"url": "git://github.com/chrisben/imgcache.js.git"
},
"description": "JS library that stores images locally for offline apps using PhoneGap/Cordova or browsers supporting the new html5 File API",
"main": "js/imgcache.js",
"main": "lib/imgcache.js",
"keywords": [
"cordova",
"phonegap",
Expand Down
4 changes: 2 additions & 2 deletions examples/example1.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<title>Examples</title>
<script src="jquery-1.6.4.min.js"></script>
<script src="../js/imgcache.js"></script>
<script src="../lib/imgcache.js"></script>
<!-- only for cordova (replace by phonegap.js for phonegap) - ignore on desktop browser -->
<script src="../cordova.js"></script>
<script>
Expand Down Expand Up @@ -168,7 +168,7 @@ <h3>Local image</h3>
<div>
<h3>Remote image</h3>
<!-- random image on domain with CORS enabled -->
<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">
<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">
<p id="remote_cors_desc"></p>
<p id="remote_cors_cached"></p>
</div>
Expand Down
Loading

0 comments on commit e7b9a5a

Please sign in to comment.