<commit_before>/* eslint-disable no-inline-comments, no-magic-numbers */

'use strict';

module.exports = {
  env: {
    commonjs: true,
    node: true,
  },

  settings: {
    'import/ignore': [
      'node_modules',
      '\\.json$',
      '\\.(scss|less|css)$',
    ],
  },

  plugins: [
    'filenames',
    'import',
    'security',
    '@scottnonnenberg/thehelp',
  ],

  rules: {
    'accessor-pairs': 'error',
    'array-bracket-spacing': 'error',
    'array-callback-return': 'error',
    'arrow-body-style': 'error',
    'arrow-parens': ['error', 'as-needed'],
    'arrow-spacing': 'error',
    'block-scoped-var': 'error',
    'block-spacing': 'error',
    'brace-style': ['error', 'stroustrup'],
    'callback-return': 'error',
    'camelcase': 'error',
    'comma-dangle': ['error', 'always-multiline'],
    'comma-spacing': 'error',
    'comma-style': 'error',
    'complexity': ['error', { max: 8 }],
    'computed-property-spacing': 'error',
    'consistent-return': 'error', // NOTE: this does conflict with notate/breadcrumbs
    'consistent-this': ['error', '_this'],
    'constructor-super': 'error',
    'curly': 'error',
    'default-case': 'error',
    'dot-location': ['error', 'property'],
    'dot-notation': 'error',
    'eol-last': 'error',
    'eqeqeq': ['error', 'allow-null'],
    'func-names': 'off', // ES5
    'func-style': ['error', 'declaration'],
    'generator-star-spacing': 'error',
    'global-require': 'error',
    'guard-for-in': 'error',
    'handle-callback-err': ['error', '^.*(e|E)rr'],
    'id-blacklist': 'off', // http://eslint.org/docs/rules/id-blacklist
    'id-length': 'off', // http://eslint.org/docs/rules/id-length
    'id-match': 'off', // http://eslint.org/docs/rules/id-match
    'indent': ['error', 2, { SwitchCase: 1 }],
    'init-declarations': 'off', // a bad option; doesn't catch dynamic variable updates
    'jsx-quotes': 'error',
    'key-spacing': 'error',
    'keyword-spacing': 'error',
    'linebreak-style': 'error',
    'lines-around-comment': 'off', // too restricting; conflicts with eslint-disable
    'max-depth': ['error', { max: 3 }],
    'max-len': ['error', 90, 2, {
      ignoreUrls: true,
      ignoreComments: true,
    }],
    'max-nested-callbacks': ['error', { max: 3 }],
    'max-params': 'error',
    'max-statements': ['error', { max: 12 }],
    'max-statements-per-line': 'error',
    'new-cap': 'error',
    'new-parens': 'error',
    'newline-after-var': 'off', // I'm not consistent enough on this
    'newline-before-return': 'off', // Also not consistent enough here
    'newline-per-chained-call': 'error',
    'no-alert': 'error',
    'no-array-constructor': 'error',
    'no-bitwise': 'error',
    'no-caller': 'error',
    'no-case-declarations': 'error',
    'no-catch-shadow': 'error',
    'no-class-assign': 'error',
    'no-cond-assign': ['error', 'always'],
    'no-confusing-arrow': 'error',
    'no-console': 'error',
    'no-const-assign': 'error',
    'no-constant-condition': 'error',
    'no-continue': 'error',
    'no-control-regex': 'error',
    'no-debugger': 'error',
    'no-delete-var': 'error',
    'no-div-regex': 'error',
    'no-dupe-args': 'error',
    'no-dupe-class-members': 'error',
    'no-dupe-keys': 'error',
    'no-duplicate-case': 'error',
    'no-duplicate-imports': 'error',
    'no-else-return': 'error',
    'no-empty': 'error',
    'no-empty-character-class': 'error',
    'no-empty-function': 'off', // ES5
    'no-empty-pattern': 'error',
    'no-eq-null': 'off', // this space already covered by eqeqeq
    'no-eval': 'error',
    'no-ex-assign': 'error',
    'no-extend-native': 'error',
    'no-extra-bind': 'error',
    'no-extra-boolean-cast': 'error',
    'no-extra-label': 'error',
    'no-extra-parens': 'error',
    'no-extra-semi': 'error',
    'no-fallthrough': 'error',
    'no-floating-decimal': 'error',
    'no-func-assign': 'error',
    'no-implicit-coercion': 'error',
    'no-implicit-globals': 'error',
    'no-implied-eval': 'error',
    'no-inline-comments': 'error',
    'no-inner-declarations': 'error',
    'no-invalid-regexp': 'error',
    'no-invalid-this': 'error',
    'no-irregular-whitespace': 'error',
    'no-iterator': 'error',
    'no-label-var': 'error',
    'no-labels': 'error',
    'no-lone-blocks': 'error',
    'no-lonely-if': 'error',
    'no-loop-func': 'error',
    'no-magic-numbers': ['error', { // this matches up with config in es2015
      ignore: [-2, -1, 0, 1, 2],
      ignoreArrayIndexes: true,
      enforceConst: false,
      detectObjects: false,
    }],
    'no-mixed-requires': 'error',
    'no-mixed-spaces-and-tabs': 'error',
    'no-multi-spaces': 'error',
    'no-multi-str': 'error',
    'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }],
    'no-native-reassign': 'error',
    'no-negated-condition': 'off', // no, I like breaking out of functions early
    'no-negated-in-lhs': 'error',
    'no-nested-ternary': 'error',
    'no-new': 'error',
    'no-new-func': 'error',
    'no-new-object': 'error',
    'no-new-require': 'error',
    'no-new-symbol': 'error',
    'no-new-wrappers': 'error',
    'no-obj-calls': 'error',
    'no-octal': 'error',
    'no-octal-escape': 'error',
    'no-param-reassign': 'off', // options = options || {} is useful
    'no-path-concat': 'error',
    'no-plusplus': 'error',
    'no-process-env': 'error',
    'no-process-exit': 'error',
    'no-proto': 'error',
    'no-prototype-builtins': 'error',
    'no-redeclare': 'error',
    'no-regex-spaces': 'error',
    'no-restricted-globals': 'off', // http://eslint.org/docs/rules/no-restricted-globals
    'no-restricted-imports': 'off', // http://eslint.org/docs/rules/no-restricted-imports
    'no-restricted-modules': 'off', // http://eslint.org/docs/rules/no-restricted-modules
    'no-restricted-syntax': [
      'error',
      'DebuggerStatement',
      'ForInStatement',
      'LabeledStatement',
      'WithStatement',
    ],
    'no-return-assign': 'error',
    'no-script-url': 'error',
    'no-self-assign': 'error',
    'no-self-compare': 'error',
    'no-sequences': 'error',
    'no-shadow': ['error', {
      allow: ['err'],
    }],
    'no-shadow-restricted-names': 'error',
    'no-spaced-func': 'error',
    'no-sparse-arrays': 'error',
    'no-sync': 'error',
    'no-ternary': 'off', // I do use it, but I try not to do it often
    'no-this-before-super': 'error',
    'no-throw-literal': 'error',
    'no-trailing-spaces': 'error',
    'no-undef': 'error',
    'no-undef-init': 'error',
    'no-undefined': 'error',
    'no-underscore-dangle': 'off', // sometimes I'll export internals prefixed with _
    'no-unexpected-multiline': 'error',
    'no-unmodified-loop-condition': 'error',
    'no-unneeded-ternary': 'error',
    'no-unreachable': 'error',
    'no-unsafe-finally': 'error',
    'no-unused-expressions': 'error',
    'no-unused-labels': 'error',
    'no-unused-vars': ['error', { vars: 'local' }],
    'no-use-before-define': 'off', // I use function declaration hoisting for readability
    'no-useless-call': 'error',
    'no-useless-computed-key': 'error',
    'no-useless-concat': 'error',
    'no-useless-constructor': 'error',
    'no-useless-escape': 'error',
    'no-useless-rename': 'off', // https://github.com/eslint/eslint/issues/6266
    'no-var': 'off', // ES5
    'no-void': 'error',
    'no-warning-comments': ['error', {
      terms: ['todo'],
      location: 'start',
    }],
    'no-whitespace-before-property': 'error',
    'no-with': 'error',
    'object-curly-spacing': ['error', 'always'],
    'object-property-newline': 'off', // wish there was a limit of two keys
    'object-shorthand': 'off', // ES5
    'one-var': ['error', 'never'],
    'one-var-declaration-per-line': 'error',
    'operator-assignment': 'error',
    'operator-linebreak': ['error', 'before', {
      overrides: {
        '=': 'after',
      },
    }],
    'padded-blocks': ['error', 'never'],
    'prefer-arrow-callback': 'off', // ES6
    'prefer-const': 'error',
    'prefer-reflect': 'off', // don't think we want to move to these new methods yet
    'prefer-rest-params': 'off', // ES5
    'prefer-spread': 'off', // ES5
    'prefer-template': 'off', // ES5
    'quote-props': ['error', 'consistent-as-needed'],
    'quotes': ['error', 'single', {
      avoidEscape: true,
    }],
    'radix': 'error',
    'require-jsdoc': 'off', // when I decide how to do docs
    'require-yield': 'error',
    'semi': 'error',
    'semi-spacing': 'error',
    'sort-imports': 'off',
    'sort-vars': 'off', // relying on the import plugin for imports ordering
    'space-before-blocks': 'error',
    'space-before-function-paren': ['error', 'never'],
    'space-in-parens': 'error',
    'space-infix-ops': 'error',
    'space-unary-ops': 'error',
    'spaced-comment': 'error',
    'strict': 'error',
    'template-curly-spacing': 'error',
    'unicode-bom': 'error',
    'use-isnan': 'error',
    'valid-jsdoc': 'error', // when I decide how to do docs
    'valid-typeof': 'error',
    'vars-on-top': 'off', // yes, var scope can be confusing, but this is too limiting
    'wrap-iife': 'error',
    'wrap-regex': 'error',
    'yield-star-spacing': 'error',
    'yoda': 'error',

    'filenames/match-exported': ['off', { // will re-enable this when PR is accepted
      transform: 'snake',
    }],
    'filenames/match-regex': ['error', /^[a-z0-9_]+$/],
    'filenames/no-index': 'off',

    'import/default': 'error',
    'import/no-commonjs': 'off', // ES5
    'import/export': 'error',
    'import/extensions': ['error', {
      json: 'always',
      js: 'never',
    }],
    'import/imports-first': 'error',
    'import/named': 'error',
    'import/namespace': 'error',
    'import/newline-after-import': 'off', // breaks for require() https://github.com/benmosher/eslint-plugin-import/pull/326
    'import/no-amd': 'error',
    // I don't use jsdoc right now, and this rule still under active development
    // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md
    'import/no-deprecated': 'off',
    'import/no-duplicates': 'error',
    'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
    'import/no-mutable-exports': 'error',
    'import/no-named-as-default': 'error',
    'import/no-named-as-default-member': 'error',
    'import/no-namespace': 'error',
    'import/no-nodejs-modules': 'off', // We're definitely using the builtins
    'import/no-unresolved': ['error', { commonjs: true }],
    // documented default is not correct, specifying manually
    // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md#options
    'import/order': ['error', {
      groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
    }],
    'import/prefer-default-export': 'error',

    'security/detect-buffer-noassert': 'error',
    'security/detect-child-process': 'error',
    'security/detect-disable-mustache-escape': 'error',
    'security/detect-eval-with-expression': 'error',
    'security/detect-new-buffer': 'error',
    'security/detect-no-csrf-before-method-override': 'error',
    'security/detect-non-literal-fs-filename': 'error',
    'security/detect-non-literal-regexp': 'error',
    'security/detect-non-literal-require': 'error',
    'security/detect-object-injection': 'error',
    'security/detect-possible-timing-attacks': 'error',
    'security/detect-pseudoRandomBytes': 'error',
    'security/detect-unsafe-regex': 'error',

    'thehelp/absolute-or-current-dir': 'off',
    'thehelp/no-array-mutation': 'off',
    'thehelp/no-mutation': 'off',
  },
};
<commit_msg>feat(core): Allow ++ and -- inside loops. Fixes #3<commit_after>/* eslint-disable no-inline-comments, no-magic-numbers */

'use strict';

module.exports = {
  env: {
    commonjs: true,
    node: true,
  },

  settings: {
    'import/ignore': [
      'node_modules',
      '\\.json$',
      '\\.(scss|less|css)$',
    ],
  },

  plugins: [
    'filenames',
    'import',
    'security',
    '@scottnonnenberg/thehelp',
  ],

  rules: {
    'accessor-pairs': 'error',
    'array-bracket-spacing': 'error',
    'array-callback-return': 'error',
    'arrow-body-style': 'error',
    'arrow-parens': ['error', 'as-needed'],
    'arrow-spacing': 'error',
    'block-scoped-var': 'error',
    'block-spacing': 'error',
    'brace-style': ['error', 'stroustrup'],
    'callback-return': 'error',
    'camelcase': 'error',
    'comma-dangle': ['error', 'always-multiline'],
    'comma-spacing': 'error',
    'comma-style': 'error',
    'complexity': ['error', { max: 8 }],
    'computed-property-spacing': 'error',
    'consistent-return': 'error', // NOTE: this does conflict with notate/breadcrumbs
    'consistent-this': ['error', '_this'],
    'constructor-super': 'error',
    'curly': 'error',
    'default-case': 'error',
    'dot-location': ['error', 'property'],
    'dot-notation': 'error',
    'eol-last': 'error',
    'eqeqeq': ['error', 'allow-null'],
    'func-names': 'off', // ES5
    'func-style': ['error', 'declaration'],
    'generator-star-spacing': 'error',
    'global-require': 'error',
    'guard-for-in': 'error',
    'handle-callback-err': ['error', '^.*(e|E)rr'],
    'id-blacklist': 'off', // http://eslint.org/docs/rules/id-blacklist
    'id-length': 'off', // http://eslint.org/docs/rules/id-length
    'id-match': 'off', // http://eslint.org/docs/rules/id-match
    'indent': ['error', 2, { SwitchCase: 1 }],
    'init-declarations': 'off', // a bad option; doesn't catch dynamic variable updates
    'jsx-quotes': 'error',
    'key-spacing': 'error',
    'keyword-spacing': 'error',
    'linebreak-style': 'error',
    'lines-around-comment': 'off', // too restricting; conflicts with eslint-disable
    'max-depth': ['error', { max: 3 }],
    'max-len': ['error', 90, 2, {
      ignoreUrls: true,
      ignoreComments: true,
    }],
    'max-nested-callbacks': ['error', { max: 3 }],
    'max-params': 'error',
    'max-statements': ['error', { max: 12 }],
    'max-statements-per-line': 'error',
    'new-cap': 'error',
    'new-parens': 'error',
    'newline-after-var': 'off', // I'm not consistent enough on this
    'newline-before-return': 'off', // Also not consistent enough here
    'newline-per-chained-call': 'error',
    'no-alert': 'error',
    'no-array-constructor': 'error',
    'no-bitwise': 'error',
    'no-caller': 'error',
    'no-case-declarations': 'error',
    'no-catch-shadow': 'error',
    'no-class-assign': 'error',
    'no-cond-assign': ['error', 'always'],
    'no-confusing-arrow': 'error',
    'no-console': 'error',
    'no-const-assign': 'error',
    'no-constant-condition': 'error',
    'no-continue': 'error',
    'no-control-regex': 'error',
    'no-debugger': 'error',
    'no-delete-var': 'error',
    'no-div-regex': 'error',
    'no-dupe-args': 'error',
    'no-dupe-class-members': 'error',
    'no-dupe-keys': 'error',
    'no-duplicate-case': 'error',
    'no-duplicate-imports': 'error',
    'no-else-return': 'error',
    'no-empty': 'error',
    'no-empty-character-class': 'error',
    'no-empty-function': 'off', // ES5
    'no-empty-pattern': 'error',
    'no-eq-null': 'off', // this space already covered by eqeqeq
    'no-eval': 'error',
    'no-ex-assign': 'error',
    'no-extend-native': 'error',
    'no-extra-bind': 'error',
    'no-extra-boolean-cast': 'error',
    'no-extra-label': 'error',
    'no-extra-parens': 'error',
    'no-extra-semi': 'error',
    'no-fallthrough': 'error',
    'no-floating-decimal': 'error',
    'no-func-assign': 'error',
    'no-implicit-coercion': 'error',
    'no-implicit-globals': 'error',
    'no-implied-eval': 'error',
    'no-inline-comments': 'error',
    'no-inner-declarations': 'error',
    'no-invalid-regexp': 'error',
    'no-invalid-this': 'error',
    'no-irregular-whitespace': 'error',
    'no-iterator': 'error',
    'no-label-var': 'error',
    'no-labels': 'error',
    'no-lone-blocks': 'error',
    'no-lonely-if': 'error',
    'no-loop-func': 'error',
    'no-magic-numbers': ['error', { // this matches up with config in es2015
      ignore: [-2, -1, 0, 1, 2],
      ignoreArrayIndexes: true,
      enforceConst: false,
      detectObjects: false,
    }],
    'no-mixed-requires': 'error',
    'no-mixed-spaces-and-tabs': 'error',
    'no-multi-spaces': 'error',
    'no-multi-str': 'error',
    'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }],
    'no-native-reassign': 'error',
    'no-negated-condition': 'off', // no, I like breaking out of functions early
    'no-negated-in-lhs': 'error',
    'no-nested-ternary': 'error',
    'no-new': 'error',
    'no-new-func': 'error',
    'no-new-object': 'error',
    'no-new-require': 'error',
    'no-new-symbol': 'error',
    'no-new-wrappers': 'error',
    'no-obj-calls': 'error',
    'no-octal': 'error',
    'no-octal-escape': 'error',
    'no-param-reassign': 'off', // options = options || {} is useful
    'no-path-concat': 'error',
    'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
    'no-process-env': 'error',
    'no-process-exit': 'error',
    'no-proto': 'error',
    'no-prototype-builtins': 'error',
    'no-redeclare': 'error',
    'no-regex-spaces': 'error',
    'no-restricted-globals': 'off', // http://eslint.org/docs/rules/no-restricted-globals
    'no-restricted-imports': 'off', // http://eslint.org/docs/rules/no-restricted-imports
    'no-restricted-modules': 'off', // http://eslint.org/docs/rules/no-restricted-modules
    'no-restricted-syntax': [
      'error',
      'DebuggerStatement',
      'ForInStatement',
      'LabeledStatement',
      'WithStatement',
    ],
    'no-return-assign': 'error',
    'no-script-url': 'error',
    'no-self-assign': 'error',
    'no-self-compare': 'error',
    'no-sequences': 'error',
    'no-shadow': ['error', {
      allow: ['err'],
    }],
    'no-shadow-restricted-names': 'error',
    'no-spaced-func': 'error',
    'no-sparse-arrays': 'error',
    'no-sync': 'error',
    'no-ternary': 'off', // I do use it, but I try not to do it often
    'no-this-before-super': 'error',
    'no-throw-literal': 'error',
    'no-trailing-spaces': 'error',
    'no-undef': 'error',
    'no-undef-init': 'error',
    'no-undefined': 'error',
    'no-underscore-dangle': 'off', // sometimes I'll export internals prefixed with _
    'no-unexpected-multiline': 'error',
    'no-unmodified-loop-condition': 'error',
    'no-unneeded-ternary': 'error',
    'no-unreachable': 'error',
    'no-unsafe-finally': 'error',
    'no-unused-expressions': 'error',
    'no-unused-labels': 'error',
    'no-unused-vars': ['error', { vars: 'local' }],
    'no-use-before-define': 'off', // I use function declaration hoisting for readability
    'no-useless-call': 'error',
    'no-useless-computed-key': 'error',
    'no-useless-concat': 'error',
    'no-useless-constructor': 'error',
    'no-useless-escape': 'error',
    'no-useless-rename': 'off', // https://github.com/eslint/eslint/issues/6266
    'no-var': 'off', // ES5
    'no-void': 'error',
    'no-warning-comments': ['error', {
      terms: ['todo'],
      location: 'start',
    }],
    'no-whitespace-before-property': 'error',
    'no-with': 'error',
    'object-curly-spacing': ['error', 'always'],
    'object-property-newline': 'off', // wish there was a limit of two keys
    'object-shorthand': 'off', // ES5
    'one-var': ['error', 'never'],
    'one-var-declaration-per-line': 'error',
    'operator-assignment': 'error',
    'operator-linebreak': ['error', 'before', {
      overrides: {
        '=': 'after',
      },
    }],
    'padded-blocks': ['error', 'never'],
    'prefer-arrow-callback': 'off', // ES6
    'prefer-const': 'error',
    'prefer-reflect': 'off', // don't think we want to move to these new methods yet
    'prefer-rest-params': 'off', // ES5
    'prefer-spread': 'off', // ES5
    'prefer-template': 'off', // ES5
    'quote-props': ['error', 'consistent-as-needed'],
    'quotes': ['error', 'single', {
      avoidEscape: true,
    }],
    'radix': 'error',
    'require-jsdoc': 'off', // when I decide how to do docs
    'require-yield': 'error',
    'semi': 'error',
    'semi-spacing': 'error',
    'sort-imports': 'off',
    'sort-vars': 'off', // relying on the import plugin for imports ordering
    'space-before-blocks': 'error',
    'space-before-function-paren': ['error', 'never'],
    'space-in-parens': 'error',
    'space-infix-ops': 'error',
    'space-unary-ops': 'error',
    'spaced-comment': 'error',
    'strict': 'error',
    'template-curly-spacing': 'error',
    'unicode-bom': 'error',
    'use-isnan': 'error',
    'valid-jsdoc': 'error', // when I decide how to do docs
    'valid-typeof': 'error',
    'vars-on-top': 'off', // yes, var scope can be confusing, but this is too limiting
    'wrap-iife': 'error',
    'wrap-regex': 'error',
    'yield-star-spacing': 'error',
    'yoda': 'error',

    'filenames/match-exported': ['off', { // will re-enable this when PR is accepted
      transform: 'snake',
    }],
    'filenames/match-regex': ['error', /^[a-z0-9_]+$/],
    'filenames/no-index': 'off',

    'import/default': 'error',
    'import/no-commonjs': 'off', // ES5
    'import/export': 'error',
    'import/extensions': ['error', {
      json: 'always',
      js: 'never',
    }],
    'import/imports-first': 'error',
    'import/named': 'error',
    'import/namespace': 'error',
    'import/newline-after-import': 'off', // breaks for require() https://github.com/benmosher/eslint-plugin-import/pull/326
    'import/no-amd': 'error',
    // I don't use jsdoc right now, and this rule still under active development
    // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md
    'import/no-deprecated': 'off',
    'import/no-duplicates': 'error',
    'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
    'import/no-mutable-exports': 'error',
    'import/no-named-as-default': 'error',
    'import/no-named-as-default-member': 'error',
    'import/no-namespace': 'error',
    'import/no-nodejs-modules': 'off', // We're definitely using the builtins
    'import/no-unresolved': ['error', { commonjs: true }],
    // documented default is not correct, specifying manually
    // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md#options
    'import/order': ['error', {
      groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
    }],
    'import/prefer-default-export': 'error',

    'security/detect-buffer-noassert': 'error',
    'security/detect-child-process': 'error',
    'security/detect-disable-mustache-escape': 'error',
    'security/detect-eval-with-expression': 'error',
    'security/detect-new-buffer': 'error',
    'security/detect-no-csrf-before-method-override': 'error',
    'security/detect-non-literal-fs-filename': 'error',
    'security/detect-non-literal-regexp': 'error',
    'security/detect-non-literal-require': 'error',
    'security/detect-object-injection': 'error',
    'security/detect-possible-timing-attacks': 'error',
    'security/detect-pseudoRandomBytes': 'error',
    'security/detect-unsafe-regex': 'error',

    'thehelp/absolute-or-current-dir': 'off',
    'thehelp/no-array-mutation': 'off',
    'thehelp/no-mutation': 'off',
  },
};
<|endoftext|>


<commit_before>//Copyright (C) 2012 Kory Nunn

//Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

//The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

/*

    This code is not formatted for readability, but rather run-speed and to assist compilers.

    However, the code's intention should be transparent.

*/

(function (root, factory) {
    if (typeof exports === 'object') {
        module.exports = factory();
    } else if (typeof define === 'function' && define.amd) {
        define(factory);
    } else {
        root.crel = factory();
    }
}(this, function () {
    var isType = function(a, type){ // A helper function used throughout the script, so declare it early
            return typeof a === type;
        },
        fn = 'function',
        obj = 'object',
        setAttribute = 'setAttribute',
        attrMapString = 'attrMap',
        isNodeString = 'isNode',
        isElementString = 'isElement',
        d = document,
        isNode = function (object) {
            return object instanceof Node;
        },
        isElement = function (object) {
            return object instanceof Element;
        },
        appendChild = function(element, child) {
            if (Array.isArray(child)) {
                child.map(function(subChild){
                    appendChild(element, subChild);
                });
                return;
            }
            if(!crel[isNodeString](child)){
                child = d.createTextNode(child);
            }
            element.appendChild(child);
        };

    function crel(){
        var args = arguments, //Note: assigned to a variable to assist compilers. Saves about 40 bytes in closure compiler. Has negligable effect on performance.
            element = args[0],
            child,
            settings = args[1],
            childIndex = 2,
            argumentsLength = args.length,
            attributeMap = crel[attrMapString];

        element = crel[isElementString](element) ? element : d.createElement(element);
        // shortcut
        if(argumentsLength > 1){
            if(!isType(settings,obj) || crel[isNodeString](settings) || Array.isArray(settings)) {
                --childIndex;
                settings = null;
            }

            // shortcut if there is only one child that is a string
            if((argumentsLength - childIndex) === 1 && isType(args[childIndex], 'string')){
                element.textContent = args[childIndex];
            }else{
                for(; childIndex < argumentsLength; ++childIndex){
                    child = args[childIndex];

                    if(child !== null){
                        appendChild(element, child);
                    }
                }
            }

            for(var key in settings){
                if(!attributeMap[key]){
                    if(isType(settings[key],fn)){
                        element[key] = settings[key];
                    }else{
                        element[setAttribute](key, settings[key]);
                    }
                }else{
                    var attr = attributeMap[key];
                    if(isType(attr, fn)){
                        attr(element, settings[key]);
                    }else{
                        element[setAttribute](attr, settings[key]);
                    }
                }
            }
        }

        return element;
    }

    // Used for mapping one kind of attribute to the supported version of that in bad browsers.
    crel[attrMapString] = {};

    crel[isElementString] = isElement;

    crel[isNodeString] = isNode;

    if(!isType(Proxy, 'undefined')){
        crel.proxy = new Proxy(crel, {
            get: function(target, key){
                !(key in crel) && (crel[key] = crel.bind(null, key));
                return crel[key];
            }
        });
    }

    return crel;
}));
<commit_msg>Crel: Remove unnecessary declaration of `element`<commit_after>//Copyright (C) 2012 Kory Nunn

//Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

//The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

/*

    This code is not formatted for readability, but rather run-speed and to assist compilers.

    However, the code's intention should be transparent.

*/

(function (root, factory) {
    if (typeof exports === 'object') {
        module.exports = factory();
    } else if (typeof define === 'function' && define.amd) {
        define(factory);
    } else {
        root.crel = factory();
    }
}(this, function () {
    var isType = function(a, type){ // A helper function used throughout the script, so declare it early
            return typeof a === type;
        },
        fn = 'function',
        obj = 'object',
        setAttribute = 'setAttribute',
        attrMapString = 'attrMap',
        isNodeString = 'isNode',
        isElementString = 'isElement',
        d = document,
        isNode = function (object) {
            return object instanceof Node;
        },
        isElement = function (object) {
            return object instanceof Element;
        },
        appendChild = function(element, child) {
            if (Array.isArray(child)) {
                child.map(function(subChild){
                    appendChild(element, subChild);
                });
                return;
            }
            if(!crel[isNodeString](child)){
                child = d.createTextNode(child);
            }
            element.appendChild(child);
        };

    function crel(element){
        var args = arguments, //Note: assigned to a variable to assist compilers. Saves about 40 bytes in closure compiler. Has negligable effect on performance.
            child,
            settings = args[1],
            childIndex = 2,
            argumentsLength = args.length,
            attributeMap = crel[attrMapString];

        element = crel[isElementString](element) ? element : d.createElement(element);
        // shortcut
        if(argumentsLength > 1){
            if(!isType(settings,obj) || crel[isNodeString](settings) || Array.isArray(settings)) {
                --childIndex;
                settings = null;
            }

            // shortcut if there is only one child that is a string
            if((argumentsLength - childIndex) === 1 && isType(args[childIndex], 'string')){
                element.textContent = args[childIndex];
            }else{
                for(; childIndex < argumentsLength; ++childIndex){
                    child = args[childIndex];

                    if(child !== null){
                        appendChild(element, child);
                    }
                }
            }

            for(var key in settings){
                if(!attributeMap[key]){
                    if(isType(settings[key],fn)){
                        element[key] = settings[key];
                    }else{
                        element[setAttribute](key, settings[key]);
                    }
                }else{
                    var attr = attributeMap[key];
                    if(isType(attr, fn)){
                        attr(element, settings[key]);
                    }else{
                        element[setAttribute](attr, settings[key]);
                    }
                }
            }
        }

        return element;
    }

    // Used for mapping one kind of attribute to the supported version of that in bad browsers.
    crel[attrMapString] = {};

    crel[isElementString] = isElement;

    crel[isNodeString] = isNode;

    if(!isType(Proxy, 'undefined')){
        crel.proxy = new Proxy(crel, {
            get: function(target, key){
                !(key in crel) && (crel[key] = crel.bind(null, key));
                return crel[key];
            }
        });
    }

    return crel;
}));
<|endoftext|>


<commit_before>var locationX = 31.8772;
var locationY = 35.2402;//18

var shabbosStart = moment(SunCalc.getTimes(moment().startOf('week').day(5), locationX, locationY).sunset).subtract(40,'minute');
var shabbosEnd = moment(SunCalc.getTimes(moment().startOf('week').day(6), locationX, locationY).dusk).add(10,'minute');

var storeData = {
	PostOffice: {name: 'TZ Doar #2', info: 'Corner of Mekor Baruch and Ahavas Yisroel', coordX:31.879313, coordY: 35.239771}
	,RavFichel: {name: 'Rav Fichel Food Sale', info: 'Corner of Mekor Baruch and Ahavas Yisroel Parking Lot', coordX:31.879413, coordY: 35.239728}
	,PharmacyMeuchedet: {name: 'Meuchedet Pharmacy', info: 'Above TZ Makolet', coordX:31.880311, coordY: 35.239828}
	,BDStore:  {name: 'B&D Store', info: 'Ahavat Yisroel 18', coordX:31.878580, coordY: 35.239553}
	,ChadPaamit: {name: 'Chad Paamit', info: 'Ahavat Yisroel 14', coordX:31.878945, coordY: 35.239718}
	,EggsMB1: {name: 'Egg Sale MB1', info: 'Mekor Baruch 1, up 1/2 flight', coordX:31.878198, coordY: 35.240136}
	,WeberBakeStore: {name: 'Weber Bake Store', info: '5/1 Ahavat Yisroel (down 2 floors)\n997-9386 and 052-767-0471', coordX:31.879281, coordY: 35.240036}
	,KeiliMikvaTZ: {name: 'Keili Mikva TZ', info: 'Kehilat Yaakov 9\nOther time: Azulay on Ahavat Emet 17/2, 02-997-1490 until 3pm, by appointment.', coordX:31.881570, coordY: 35.239375}
	,KikarNetanelSweetsStand: {name: 'Kikar Netanel Sweets Store', info: 'Next to Kikar Netanel', coordX:31.879945, coordY: 35.242878}
	};

var storeHours = {
	PostOffice: [
		{day: 'Sunday', open: '15:30', close: 17}
		,{day: 'Monday', open: '8:30', close: 10}
		,{day: 'Tuesday', open: '15:30', close: 17}
		,{day: 'Wednesday', open: '1700', close: 18}
		,{day: 'Thursday', open: '15:30', close: 17}
		,{day: 'Friday', open: 11, close: 13}
		]
	,PharmacyMeuchedet: [
		{day: 'Sunday', open: 8, close: 14}
		,{day: 'Monday', open: 14, close: 19}
		,{day: 'Tuesday', open: 8, close: 15}
		,{day: 'Wednesday', open: 8, close: 13}
		,{day: 'Thursday', open: 13, close: 19}
		,{day: 'Friday', open: 8, close: 11}
		]
	,BDStore: [
		{day: 'Sunday', open: 16, close: 21}
		,{day: 'Monday', open: 16, close: 21}
		,{day: 'Tuesday', open: 16, close: 21}
		,{day: 'Wednesday', open: 13, close: 21}
		,{day: 'Thursday', open: 16, close: 21}
		,{day: 'Friday', open: 9, close: 13}
		]
	,LeumiRamatEshkol: [
		{day: 'Monday', open: 8.5, close: 13}
		,{day: 'Thursday', open: 8.5, close: 13}
		,{day: 'Monday', open: 16, close: '18:15'}
		,{day: 'Thursday', open: 16, close: '18:15'}

		,{day: 'Tuesday', open: 8.5, close: 14.5}
		,{day: 'Wednesday', open: 8.5, close: 14.5}

		,{day: 'Friday', open: 8.5, close: 12.5}
		]
	,RavFichel: [
		{day: 'Wednesday', open: 12, close: 22}
		]
	,WeberBakeStore: [
		{day: 'Thursday', open: 15.5, close: 17}

		,{day: 'Tuesday', open: 20.5, close: 22}
		,{day: 'Wednesday', open: 20.5, close: 22}
		,{day: 'Thursday', open: 20.5, close: 22}

		,{day: 'Friday', open: 10, close: 13}
		]
	,ChadPaamit: [
		{day: 'Monday', open: 17, close: 19}
		,{day: 'Tuesday', open: 17, close: 19}
		,{day: 'Wednesday', open: 16, close: 21}
		,{day: 'Thursday', open: 16, close: 21}
		,{day: 'Friday', open: 8.5, close: 13}
		]
	,EggsMB1: [
		{day: 'Sunday', open: 19, close: 20}
		,{day: 'Wednesday', open: 16, close: 18}
		]
	,KikarNetanelSweetsStand: [
		{day: 'Sunday', open: 12, close: 23}
		,{day: 'Monday', open: 12, close: 23}
		,{day: 'Tuesday', open: 12, close: 23}
		,{day: 'Wednesday', open: 12, close: 23}
		,{day: 'Thursday', open: 12, close: 23}
		,{day: 'Friday', open: 11, closeText: '1½ hours before Shabbos', close: shabbosStart.clone().subtract(90,'minutes').format('HHmm')}
		,{day: 'Saturday', openText: '40minutes after Tzeits', open: shabbosEnd.clone().add(40,'minutes').format('HHmm'), close: 23.5}
		]
	,KeiliMikvaTZ: [
		,{day: 'Friday', open: 6, closeText: 'until Shabbos', close: shabbosStart.clone().format('HHmm')}
		]
};

var daysOfWeek = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];
var daysOfWeekHuman = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];

var storeList = Object.keys(storeHours);//since object, make list of stores

storeList.forEach(function(name){//iterate list of stores, and overwrite data to normalize it.
	storeHours[name] = storeHours[name].map(function(timeEntry){
		timeEntry.day= daysOfWeek.indexOf(timeEntry.day.toLowerCase());//convert date to numbers in 0-6 format.
		['open','close'].forEach(function(which){//dumb stuff to make it DRY
			timeEntry[which] = normalizeTime(timeEntry[which]);//normalize
			//console.log('just normalized: '+typeof timeEntry[which] + timeEntry[which])
			//timeEntry[which+'Minutes'] = hoursToMinutes(timeEntry[which]);//then create calc minutes
			timeEntry[which+'Human'] = showTime(timeEntry[which]);//and also human readable time
			});

		return timeEntry;
		});
	})

function normalizeTime(time){
	//console.log('about to normalize:' +typeof time + time);
	var arr=[0,0];
	if(typeof time === 'number' && Number.isInteger(time)) arr[0]=time;//if ints, just *60 to get minutes.
	else if(typeof time === 'number') arr= [Math.floor(time), time%1*60];//e.g. open at 8.5 = 8:30
	else if(time.indexOf(':')!==-1) arr = time.split(':');//hh:mm format
	else if(time.length==4) arr = [time.substring(0,2), time.substring(2,4)];//hhmm format
	else arr = [time.substring(0,1), time.substring(1,3)];//hmm format
	//console.log(arr);
	return arr;
	}

function showTime (arr){
	var time=arr.slice(0);//clone it, don't overwrite.
	if(typeof time[1]==='number' && time[1]<10) time[1]='0'+time[1];//left pad for readability
	var zone='am';
	if(time[0]>12) {//show AM/PM
		time[0]-=12;
		zone = 'pm';
		}
	else if (time[0]==12) zone = 'pm';
	return time.join(':')+zone;
	}
<commit_msg>don't need<commit_after>var locationX = 31.8772;
var locationY = 35.2402;//18

var shabbosStart = moment(SunCalc.getTimes(moment().startOf('week').day(5), locationX, locationY).sunset).subtract(40,'minute');
var shabbosEnd = moment(SunCalc.getTimes(moment().startOf('week').day(6), locationX, locationY).dusk).add(10,'minute');

var storeData = {
	PostOffice: {name: 'TZ Doar #2', info: 'Corner of Mekor Baruch and Ahavas Yisroel', coordX:31.879313, coordY: 35.239771}
	,RavFichel: {name: 'Rav Fichel Food Sale', info: 'Corner of Mekor Baruch and Ahavas Yisroel Parking Lot', coordX:31.879413, coordY: 35.239728}
	,PharmacyMeuchedet: {name: 'Meuchedet Pharmacy', info: 'Above TZ Makolet', coordX:31.880311, coordY: 35.239828}
	,BDStore:  {name: 'B&D Store', info: 'Ahavat Yisroel 18', coordX:31.878580, coordY: 35.239553}
	,ChadPaamit: {name: 'Chad Paamit', info: 'Ahavat Yisroel 14', coordX:31.878945, coordY: 35.239718}
	,EggsMB1: {name: 'Egg Sale MB1', info: 'Mekor Baruch 1, up 1/2 flight', coordX:31.878198, coordY: 35.240136}
	,WeberBakeStore: {name: 'Weber Bake Store', info: '5/1 Ahavat Yisroel (down 2 floors)\n997-9386 and 052-767-0471', coordX:31.879281, coordY: 35.240036}
	,KeiliMikvaTZ: {name: 'Keili Mikva TZ', info: 'Kehilat Yaakov 9\nOther time: Azulay on Ahavat Emet 17/2, 02-997-1490 until 3pm, by appointment.', coordX:31.881570, coordY: 35.239375}
	,KikarNetanelSweetsStand: {name: 'Kikar Netanel Sweets Store', info: 'Next to Kikar Netanel', coordX:31.879945, coordY: 35.242878}
	};

var storeHours = {
	PostOffice: [
		{day: 'Sunday', open: '15:30', close: 17}
		,{day: 'Monday', open: '8:30', close: 10}
		,{day: 'Tuesday', open: '15:30', close: 17}
		,{day: 'Wednesday', open: '1700', close: 18}
		,{day: 'Thursday', open: '15:30', close: 17}
		,{day: 'Friday', open: 11, close: 13}
		]
	,PharmacyMeuchedet: [
		{day: 'Sunday', open: 8, close: 14}
		,{day: 'Monday', open: 14, close: 19}
		,{day: 'Tuesday', open: 8, close: 15}
		,{day: 'Wednesday', open: 8, close: 13}
		,{day: 'Thursday', open: 13, close: 19}
		,{day: 'Friday', open: 8, close: 11}
		]
	,BDStore: [
		{day: 'Sunday', open: 16, close: 21}
		,{day: 'Monday', open: 16, close: 21}
		,{day: 'Tuesday', open: 16, close: 21}
		,{day: 'Wednesday', open: 13, close: 21}
		,{day: 'Thursday', open: 16, close: 21}
		,{day: 'Friday', open: 9, close: 13}
		]
	,LeumiRamatEshkol: [
		{day: 'Monday', open: 8.5, close: 13}
		,{day: 'Thursday', open: 8.5, close: 13}
		,{day: 'Monday', open: 16, close: '18:15'}
		,{day: 'Thursday', open: 16, close: '18:15'}

		,{day: 'Tuesday', open: 8.5, close: 14.5}
		,{day: 'Wednesday', open: 8.5, close: 14.5}

		,{day: 'Friday', open: 8.5, close: 12.5}
		]
	,RavFichel: [
		{day: 'Wednesday', open: 12, close: 22}
		]
	,WeberBakeStore: [
		{day: 'Thursday', open: 15.5, close: 17}

		,{day: 'Tuesday', open: 20.5, close: 22}
		,{day: 'Wednesday', open: 20.5, close: 22}
		,{day: 'Thursday', open: 20.5, close: 22}

		,{day: 'Friday', open: 10, close: 13}
		]
	,ChadPaamit: [
		{day: 'Monday', open: 17, close: 19}
		,{day: 'Tuesday', open: 17, close: 19}
		,{day: 'Wednesday', open: 16, close: 21}
		,{day: 'Thursday', open: 16, close: 21}
		,{day: 'Friday', open: 8.5, close: 13}
		]
	,EggsMB1: [
		{day: 'Sunday', open: 19, close: 20}
		,{day: 'Wednesday', open: 16, close: 18}
		]
	,KikarNetanelSweetsStand: [
		{day: 'Sunday', open: 12, close: 23}
		,{day: 'Monday', open: 12, close: 23}
		,{day: 'Tuesday', open: 12, close: 23}
		,{day: 'Wednesday', open: 12, close: 23}
		,{day: 'Thursday', open: 12, close: 23}
		,{day: 'Friday', open: 11, closeText: '1½ hours before Shabbos', close: shabbosStart.clone().subtract(90,'minutes').format('HHmm')}
		,{day: 'Saturday', openText: '40minutes after Tzeits', open: shabbosEnd.clone().add(40,'minutes').format('HHmm'), close: 23.5}
		]
	,KeiliMikvaTZ: [
		,{day: 'Friday', open: 6, closeText: 'until Shabbos', close: shabbosStart.clone().format('HHmm')}
		]
};

var daysOfWeek = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];
var daysOfWeekHuman = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];

var storeList = Object.keys(storeHours);//since object, make list of stores

storeList.forEach(function(name){//iterate list of stores, and overwrite data to normalize it.
	storeHours[name] = storeHours[name].map(function(timeEntry){
		timeEntry.day= daysOfWeek.indexOf(timeEntry.day.toLowerCase());//convert date to numbers in 0-6 format.
		['open','close'].forEach(function(which){//dumb stuff to make it DRY
			timeEntry[which] = normalizeTime(timeEntry[which]);//normalize
			//console.log('just normalized: '+typeof timeEntry[which] + timeEntry[which])
			timeEntry[which+'Human'] = showTime(timeEntry[which]);//and also human readable time
			});

		return timeEntry;
		});
	})

function normalizeTime(time){
	//console.log('about to normalize:' +typeof time + time);
	var arr=[0,0];
	if(typeof time === 'number' && Number.isInteger(time)) arr[0]=time;//if ints, just *60 to get minutes.
	else if(typeof time === 'number') arr= [Math.floor(time), time%1*60];//e.g. open at 8.5 = 8:30
	else if(time.indexOf(':')!==-1) arr = time.split(':');//hh:mm format
	else if(time.length==4) arr = [time.substring(0,2), time.substring(2,4)];//hhmm format
	else arr = [time.substring(0,1), time.substring(1,3)];//hmm format
	//console.log(arr);
	return arr;
	}

function showTime (arr){
	var time=arr.slice(0);//clone it, don't overwrite.
	if(typeof time[1]==='number' && time[1]<10) time[1]='0'+time[1];//left pad for readability
	var zone='am';
	if(time[0]>12) {//show AM/PM
		time[0]-=12;
		zone = 'pm';
		}
	else if (time[0]==12) zone = 'pm';
	return time.join(':')+zone;
	}
<|endoftext|>


<commit_before>var groups = [

    {
        label: "Blood Pressure",
        measurements:[
            {
                min: 90,
                max: 129,
                yellow_min: 80,
                yellow_max: 130,
                red_min: 70,
                red_max: 140,
                units: "mmHg",
                label: "Systolic",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 132
                    },
                    {
                        timestamp: 1423742720,
                        value: 133
                    }
                ]
            },
            {
                min: 60,
                max: 80,
                yellow_min: 50,
                yellow_max: 85,
                red_min: 40,
                red_max: 90,
                units: "mmHg",
                label: "Diastolic",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 91
                    },
                    {
                        timestamp: 1423742720,
                        value: 92
                    }
                ]
            }
        ]
    },
    {
        label: "Composition",
        measurements:[
            {
                min: 18.5,
                max: 24.9,
                yellow_min: 18,
                yellow_max: 30,
                red_min: 16,
                red_max: 35,
                units: "",
                label: "Body Mass Index",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 24
                    },
                    {
                        timestamp: 1423742720,
                        value: 24.5
                    }
                ]
            },
            {
                min: 70,
                max: 88,
                yellow_max: 88,
                red_max: 90,
                units: "cm",
                label: "Waist Diameter",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 75.3
                    },
                    {
                        timestamp: 1423742720,
                        value: 75.8
                    }
                ]
            }
        ]
    },

    {
        label: "Activity",
        measurements:[
            {
                min: 8000,
                max: 12000,
                yellow_min: 5000,
                red_min: 3000,
                units: "steps",
                label: "Steps per day",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 4952
                    },
                    {
                        timestamp: 1423742720,
                        value: 5013
                    }
                ]
            },
            {
                min: 150,
                max: 300,
                yellow_min: 75,
                red_min: 40,
                units: "minutes per week",
                label: "Weekly moderate exercise",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 20
                    },
                    {
                        timestamp: 1423742720,
                        value: 0
                    }
                ]
            }
        ]
    },

    {
        label: "Lab Tests",
        measurements:[
            {
                min: 0,
                max: 1,
                yellow_min: 1,
                units: "mmol/L",
                label: "HDL (good cholesterol)",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 1.35
                    },
                    {
                        timestamp: 1423742720,
                        value: 1.32
                    }
                ]
            },
            {
                min: 0,
                max: 3,
                units: "mmol/L",
                label: "LDL (bad cholesterol)",
                yellow_max: 3,
                red_max: 3.33,
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 3.25
                    },
                    {
                        timestamp: 1423742720,
                        value: 3.53
                    }
                ]
            },
            {
                min: 0,
                max: 2,
                yellow_max: 2,
                red_max: 2.2,
                units: "mmol/L",
                label: "Triglycerides",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 1.55
                    },
                    {
                        timestamp: 1423742720,
                        value: 1.62
                    }
                ]
            }
        ]
    },

    {
        label: "Sleep",
        measurements:[
            {
                min: 7,
                max: 9,
                yellow_min: 6,
                yellow_max: 11,
                red_min: 5,
                red_max: 12,
                units: "hours",
                label: "Time in Bed",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 6.5
                    },
                    {
                        timestamp: 1423742720,
                        value: 7
                    }
                ]
            },
            {
                min: 85,
                max: 100,
                yellow_min: 75,
                red_min: 65,
                units: "%",
                label: "Sleep efficiency",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 78
                    },
                    {
                        timestamp: 1423742720,
                        value: 76
                    }
                ]
            }
        ]
    },
    {
        label: "Blood Pressure",
        measurements:[
            {
                min: 90,
                max: 129,
                yellow_min: 80,
                yellow_max: 130,
                red_min: 70,
                red_max: 140,
                units: "mmHg",
                label: "Systolic",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 132
                    },
                    {
                        timestamp: 1423742720,
                        value: 133
                    }
                ]
            },
            {
                min: 60,
                max: 80,
                yellow_min: 50,
                yellow_max: 85,
                red_min: 40,
                red_max: 90,
                units: "mmHg",
                label: "Diastolic",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 91
                    },
                    {
                        timestamp: 1423742720,
                        value: 92
                    }
                ]
            }
        ]
    },
    {
        label: "Composition",
        measurements:[
            {
                min: 18.5,
                max: 24.9,
                yellow_min: 18,
                yellow_max: 30,
                red_min: 16,
                red_max: 35,
                units: "",
                label: "Body Mass Index",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 24
                    },
                    {
                        timestamp: 1423742720,
                        value: 24.5
                    }
                ]
            },
            {
                min: 70,
                max: 88,
                yellow_max: 88,
                red_max: 90,
                units: "cm",
                label: "Waist Diameter",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 75.3
                    },
                    {
                        timestamp: 1423742720,
                        value: 75.8
                    }
                ]
            }
        ]
    },

    {
        label: "Activity",
        measurements:[
            {
                min: 8000,
                max: 12000,
                yellow_min: 5000,
                red_min: 3000,
                units: "steps",
                label: "Steps per day",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 4952
                    },
                    {
                        timestamp: 1423742720,
                        value: 5013
                    }
                ]
            },
            {
                min: 150,
                max: 300,
                yellow_min: 75,
                red_min: 40,
                units: "minutes per week",
                label: "Weekly moderate exercise",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 20
                    },
                    {
                        timestamp: 1423742720,
                        value: 0
                    }
                ]
            }
        ]
    },

    {
        label: "Lab Tests",
        measurements:[
            {
                min: 0,
                max: 1,
                yellow_min: 1,
                units: "mmol/L",
                label: "HDL (good cholesterol)",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 1.35
                    },
                    {
                        timestamp: 1423742720,
                        value: 1.32
                    }
                ]
            },
            {
                min: 0,
                max: 3,
                units: "mmol/L",
                label: "LDL (bad cholesterol)",
                yellow_max: 3,
                red_max: 3.33,
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 3.25
                    },
                    {
                        timestamp: 1423742720,
                        value: 3.53
                    }
                ]
            },
            {
                min: 0,
                max: 2,
                yellow_max: 2,
                red_max: 2.2,
                units: "mmol/L",
                label: "Triglycerides",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 1.55
                    },
                    {
                        timestamp: 1423742720,
                        value: 1.62
                    }
                ]
            }
        ]
    },

    {
        label: "Sleep",
        measurements:[
            {
                min: 7,
                max: 9,
                yellow_min: 6,
                yellow_max: 11,
                red_min: 5,
                red_max: 12,
                units: "hours",
                label: "Time in Bed",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 6.5
                    },
                    {
                        timestamp: 1423742720,
                        value: 7
                    }
                ]
            },
            {
                min: 85,
                max: 100,
                yellow_min: 75,
                red_min: 65,
                units: "%",
                label: "Sleep efficiency",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 78
                    },
                    {
                        timestamp: 1423742720,
                        value: 76
                    }
                ]
            }
        ]
    },

];<commit_msg>Added the real data set<commit_after>var groups = [

    {
        label: "Blood Pressure",
        measurements:[
            {
                min: 90,
                max: 129,
                yellow_min: 80,
                yellow_max: 130,
                red_min: 70,
                red_max: 140,
                units: "mmHg",
                label: "Systolic",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 132
                    },
                    {
                        timestamp: 1423742720,
                        value: 133
                    }
                ]
            },
            {
                min: 60,
                max: 80,
                yellow_min: 50,
                yellow_max: 85,
                red_min: 40,
                red_max: 90,
                units: "mmHg",
                label: "Diastolic",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 91
                    },
                    {
                        timestamp: 1423742720,
                        value: 92
                    }
                ]
            }
        ]
    },
    {
        label: "Composition",
        measurements:[
            {
                min: 18.5,
                max: 24.9,
                yellow_min: 18,
                yellow_max: 30,
                red_min: 16,
                red_max: 35,
                units: "",
                label: "Body Mass Index",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 24
                    },
                    {
                        timestamp: 1423742720,
                        value: 24.5
                    }
                ]
            },
            {
                min: 70,
                max: 88,
                yellow_max: 88,
                red_max: 90,
                units: "cm",
                label: "Waist Diameter",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 75.3
                    },
                    {
                        timestamp: 1423742720,
                        value: 75.8
                    }
                ]
            }
        ]
    },

    {
        label: "Activity",
        measurements:[
            {
                min: 8000,
                max: 12000,
                yellow_min: 5000,
                red_min: 3000,
                units: "steps",
                label: "Steps per day",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 4952
                    },
                    {
                        timestamp: 1423742720,
                        value: 5013
                    }
                ]
            },
            {
                min: 150,
                max: 300,
                yellow_min: 75,
                red_min: 40,
                units: "minutes per week",
                label: "Weekly moderate exercise",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 20
                    },
                    {
                        timestamp: 1423742720,
                        value: 0
                    }
                ]
            }
        ]
    },

    {
        label: "Lab Tests",
        measurements:[
            {
                min: 0,
                max: 1,
                yellow_min: 1,
                units: "mmol/L",
                label: "HDL (good cholesterol)",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 1.35
                    },
                    {
                        timestamp: 1423742720,
                        value: 1.32
                    }
                ]
            },
            {
                min: 0,
                max: 3,
                units: "mmol/L",
                label: "LDL (bad cholesterol)",
                yellow_max: 3,
                red_max: 3.33,
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 3.25
                    },
                    {
                        timestamp: 1423742720,
                        value: 3.53
                    }
                ]
            },
            {
                min: 0,
                max: 2,
                yellow_max: 2,
                red_max: 2.2,
                units: "mmol/L",
                label: "Triglycerides",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 1.55
                    },
                    {
                        timestamp: 1423742720,
                        value: 1.62
                    }
                ]
            }
        ]
    },

    {
        label: "Sleep",
        measurements:[
            {
                min: 7,
                max: 9,
                yellow_min: 6,
                yellow_max: 11,
                red_min: 5,
                red_max: 12,
                units: "hours",
                label: "Time in Bed",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 6.5
                    },
                    {
                        timestamp: 1423742720,
                        value: 7
                    }
                ]
            },
            {
                min: 85,
                max: 100,
                yellow_min: 75,
                red_min: 65,
                units: "%",
                label: "Sleep efficiency",
                samples: [
                    {
                        timestamp: 1420798224,
                        value: 78
                    },
                    {
                        timestamp: 1423742720,
                        value: 76
                    }
                ]
            }
        ]
    },

];<|endoftext|>


<commit_before>var safetyData = {
	"US" : 0,
	"DE" : 0,
	"IS" : 2,
	"GB" : 1,
	"RU" : 1,
	"CN" : 1,
	"CA" : 2,
	"CH" : 2,
	"SE" : 0,
};

var infoData = {
	"US" : "Multiple cases of forced compliance with a requirement for secrecy.",
	"DE" : "Germany has laws which force every mail provider to install an access point to the German authorities and intelligence agencies",
	"IS" : "No rumours as yet?",
	"GB" : "Rumored to be worse than USA?",
	"RU" : "Likely a bad bet",
	"CN" : "Likely a bad bad",
	"CA" : "Data privacy laws appear to apply to government spying? http://en.wikipedia.org/wiki/Canadian_privacy_law",
	"CH" : "Generally believed to be a privacy safe haven",
	"SE" : "Unsafe for hosting. Sweden's FRA law allows snooping and recording all border-crossing traffic and more. Wikileaks diplomatic cables confirm far-reaching intelligence cooperation between FRA and NSA. Swedish police can also raid a datacenter and seize all servers, from all companies, in the DC, even when the target is only one company. Sweden has also shut down political web sites (over a cartoon) on at least one occasion.  http://en.wikipedia.org/wiki/FRA_law http://en.wikipedia.org/wiki/The_Pirate_Bay_raid http://news.bbc.co.uk/2/hi/europe/4700414.stm http://falkvinge.net/2013/07/07/documents-sweden-wiretapping-russias-international-traffic-for-the-nsa/ "
};
<commit_msg>Added some data from HN user deerpig<commit_after>var safetyData = {
	"US" : 0,
	"DE" : 0,
	"IS" : 2,
	"GB" : 1,
	"RU" : 1,
	"CN" : 1,
	"CA" : 2,
	"CH" : 2,
	"SE" : 0,
	"TH" : 0,
	"VN" : 0,
	"LA" : 0,
	"KH" : 1,
	"MM" : 1,
	"SG" : 0,
	"HK" : 1,
	"ID" : 1,
	"MY" : 1,
};

var infoData = {
	"US" : "Multiple cases of forced compliance with a requirement for secrecy.",
	"DE" : "Germany has laws which force every mail provider to install an access point to the German authorities and intelligence agencies",
	"IS" : "No rumours as yet?",
	"GB" : "Rumored to be worse than USA?",
	"RU" : "Likely a bad bet",
	"CN" : "Likely a bad bad",
	"CA" : "Data privacy laws appear to apply to government spying? http://en.wikipedia.org/wiki/Canadian_privacy_law",
	"CH" : "Generally believed to be a privacy safe haven",
	"SE" : "Unsafe for hosting. Sweden's FRA law allows snooping and recording all border-crossing traffic and more. Wikileaks diplomatic cables confirm far-reaching intelligence cooperation between FRA and NSA. Swedish police can also raid a datacenter and seize all servers, from all companies, in the DC, even when the target is only one company. Sweden has also shut down political web sites (over a cartoon) on at least one occasion.  http://en.wikipedia.org/wiki/FRA_law http://en.wikipedia.org/wiki/The_Pirate_Bay_raid http://news.bbc.co.uk/2/hi/europe/4700414.stm http://falkvinge.net/2013/07/07/documents-sweden-wiretapping-russias-international-traffic-for-the-nsa/ ",
	"TH" : "Not Safe (USA has massive infrastructure in the country, look for Voice of America radio stations which bristle with more sat dishes and antennas than BBC or CNN could use in their headquarters and you can guess what they really are",
	"VN" : "Not Safe - https://news.ycombinator.com/item?id=6183893",
	"LA" : "Not sure, but the Laos government is not terribly warm to the American government. However I expect that they are open to the Vietnam and Chinese governments. Either way, no place to host.",
	"KH" : "Not sure, their recent extradition of the Pirate Bay co-founder on trumped up visa issues was likely from a simple bribe paid to a government official. And anyway, services and infrastructure is still thin on the ground. There still isn't even one data center in the country that is independent of an ISP (I'm working to change that :) - https://news.ycombinator.com/item?id=6183893",
	"MM" : "No infrastructure and won't be safe from local snooping when it is, though I don't think they will share with the West either.",
	"SG" : "Not safe. - https://news.ycombinator.com/item?id=6183893",
	"HK" : "Was safe before the handover in 1997, I owned an ISP there at the time and there was no meddling that I could see. But it's a very different world now. I would tend to stay away.",
	"ID" : "Not sure",
	"MY" : "Not sure",
};
<|endoftext|>


<commit_before>/*
 * Copyright (C) 2013 Andrey “A.I.” Sitnik <andrey@sitnik.ru>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

const Lang   = imports.lang;
const Main   = imports.ui.main;
const Status = imports.ui.status;

// Main extension API
function init() {
};
function enable() {
    battery.bind().update();
};
function disable() {
    battery.unbind().show();
};

// Namespace for extension logic
let battery = {
    // Watcher ID to disable listening
    watching: null,

    // Start listen to battery status changes
    bind: function () {
        this.getBattery(function (proxy) {
            let update = Lang.bind(this, this.update);
            this.watching = proxy.connect('g-properties-changed', update);
        });
        return this;
    },

    // Stop listen to battery status changes
    unbind: function () {
        this.getBattery(function (proxy) {
            proxy.disconnect(this.watching);
        });
        return this;
    },

    // Show battery icon in status area
    show: function () {
        this.getBattery(function (proxy, icon) {
            icon.show();
        });
        return this;
    },

    // Hide battery icon in status area
    hide: function () {
        this.getBattery(function (proxy, icon) {
            icon.hide();
        });
        return this;
    },

    // Check current battery state and hide or show icon
    update: function () {
        this.getDevice(function (device) {
            if ( device.state == Status.power.UPDeviceState.FULLY_CHARGED ) {
                this.hide();
            } else {
                this.show();
            }
        });
        return this;
    },

    // Execute `callback` on every battery device
    getDevice: function (callback) {
        this.getBattery(function (proxy) {
            proxy.GetDevicesRemote(Lang.bind(this, function(result, error) {
                if ( error ) {
                    return;
                }

                let devices = result[0];
                for ( let i = 0; i < devices.length; i++ ) {
                    let device = {
                        id:      devices[i][0],
                        type:    devices[i][1],
                        icon:    devices[i][2],
                        percent: devices[i][3],
                        state:   devices[i][4],
                        time:    devices[i][5]
                    };

                    if ( device.type == Status.power.UPDeviceType.BATTERY ) {
                        callback.call(this, device);
                        break;
                    }
                }
            }));
        });
    },

    // Run `callback`, only if battery is avaiable. First argument will be icon,
    // second will be it proxy.
    getBattery: function (callback) {
        let batteryArea = Main.panel.statusArea.battery;
        if ( batteryArea ) {
            callback.call(this, batteryArea._proxy, batteryArea.actor);
        }
    }
};
<commit_msg>Fix copyright<commit_after>/*
 * Copyright 2013 Andrey Sitnik <andrey@sitnik.ru>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

const Lang   = imports.lang;
const Main   = imports.ui.main;
const Status = imports.ui.status;

// Main extension API
function init() {
};
function enable() {
    battery.bind().update();
};
function disable() {
    battery.unbind().show();
};

// Namespace for extension logic
let battery = {
    // Watcher ID to disable listening
    watching: null,

    // Start listen to battery status changes
    bind: function () {
        this.getBattery(function (proxy) {
            let update = Lang.bind(this, this.update);
            this.watching = proxy.connect('g-properties-changed', update);
        });
        return this;
    },

    // Stop listen to battery status changes
    unbind: function () {
        this.getBattery(function (proxy) {
            proxy.disconnect(this.watching);
        });
        return this;
    },

    // Show battery icon in status area
    show: function () {
        this.getBattery(function (proxy, icon) {
            icon.show();
        });
        return this;
    },

    // Hide battery icon in status area
    hide: function () {
        this.getBattery(function (proxy, icon) {
            icon.hide();
        });
        return this;
    },

    // Check current battery state and hide or show icon
    update: function () {
        this.getDevice(function (device) {
            if ( device.state == Status.power.UPDeviceState.FULLY_CHARGED ) {
                this.hide();
            } else {
                this.show();
            }
        });
        return this;
    },

    // Execute `callback` on every battery device
    getDevice: function (callback) {
        this.getBattery(function (proxy) {
            proxy.GetDevicesRemote(Lang.bind(this, function(result, error) {
                if ( error ) {
                    return;
                }

                let devices = result[0];
                for ( let i = 0; i < devices.length; i++ ) {
                    let device = {
                        id:      devices[i][0],
                        type:    devices[i][1],
                        icon:    devices[i][2],
                        percent: devices[i][3],
                        state:   devices[i][4],
                        time:    devices[i][5]
                    };

                    if ( device.type == Status.power.UPDeviceType.BATTERY ) {
                        callback.call(this, device);
                        break;
                    }
                }
            }));
        });
    },

    // Run `callback`, only if battery is avaiable. First argument will be icon,
    // second will be it proxy.
    getBattery: function (callback) {
        let batteryArea = Main.panel.statusArea.battery;
        if ( batteryArea ) {
            callback.call(this, batteryArea._proxy, batteryArea.actor);
        }
    }
};
<|endoftext|>