<commit_before>var arrprot$=Array.prototype;
arrprot$.ser$$=function(d){
  var targ=this._elemTarg();
  d.putValue(OpenValue$jsint(lmp$(ex$,'$'),this.$prop$getSize),this.length,{Instance$putValue:{t:Integer}});
  var elemtarg={Instance$putElement:targ};
  for (var i=0; i < this.length; i++) {
    d.putElement(i,this[i],elemtarg);
  }
}
var origArrToString = arrprot$.toString;
arrprot$.toString = origArrToString;
arrprot$.rt$=function(t,ne) {
    if (t===null || t===undefined)t={t:Anything};
    if (this.$$targs$$===undefined)this.$$targs$$=={};
    add_type_arg(this,'Element$Iterable',t);
    add_type_arg(this,'Element$Array',t);
    add_type_arg(this,'Element$List',t);
    add_type_arg(this,'Element$Sequential',t);
    add_type_arg(this,'Absent$Iterable',ne?{t:Nothing}:{t:Null});
    return this;
}
arrprot$._elemTarg=function(){
  var t = this.$$targs$$ && this.$$targs$$.Element$Array;
  if (t===undefined)t = this.$$targs$$ && this.$$targs$$.Element$Iterable;
  if (t===undefined)t = this.$$targs$$ && this.$$targs$$.Element$List;
  if (t===undefined)t = {t:Anything};
  if (this.$$targs$$===undefined)this.$$targs$$={
    Element$Array:t, Element$List:t, Element$Iterable:t,
    Element$Collection:t, Item$Correspondence:t,Element$Ranged:t,
    Absent$Iterable:Null, Key$Correspondence:{t:Integer},
    Index$Ranged:{t:Integer}, Subrange$Ranged:{t:$_Array,a:{Element$Array:'Element$Array'}}
  };
  return t;
}
arrprot$.getT$name = function() {
    return $_Array.$$.T$name;
}
arrprot$.getT$all = function() {
    return $_Array.$$.T$all;
}

atr$(arrprot$,'reversed', function() {
  this._elemTarg();
  return this.Reversed$List();
},undefined,List.$$.prototype.$prop$getReversed.$crtmm$);
atr$(arrprot$,'rest', function() {
  this._elemTarg();
  return this.Rest$List(1);
},undefined,List.$$.prototype.$prop$getRest.$crtmm$);

//for sequenced enumerations
function sarg$(elems,spread,$$targs$$){
  $init$sarg();
  that=new sarg$.$$;
  Iterable($$targs$$,that);
  that.e=elems;
  that.s=spread;
  return that;
}
sarg$.$crtmm$=function(){return{mod:$CCMM$,'super':{t:Basic},ps:[],tp:{T$LazyIterable:{dv:'out'}},sts:[{t:Iterable,a:{Element$Iterable:'T$LazyIterable',Absent$Iterable:{t:Null}}}],pa:1,d:['$','LazyIterable']};};
ex$.sarg$=sarg$;
function $init$sarg(){if(sarg$.$$===undefined){
  initTypeProto(sarg$,'ceylon.language::LazyIterable',Basic,Iterable);
  (function(that){
    function iter(sarg){
      var $$4=new iter.$$;
      $$4.outer$=sarg;
      $$4.$$targs$$={Element$Iterator:sarg.$$targs$$.Element$Iterable};
      Iterator($$4.$$targs$$,$$4);
      $$4.i=0;
      return $$4;
    };
    iter.$crtmm$=function(){return{mod:$CCMM$,'super':{t:Basic},$cont:iterator,sts:[{t:Iterator,a:{Element$Iterator:'T$LazyIterable'}}],d:['$','LazyIterable','$m','iterator','$o','it']};};
    if(iter.$$===undefined){
      initTypeProto(iter,'LazyIterable.iterator',Basic,Iterator);
      iter.$$.prototype.next=function(){
        if (this.sp)return this.sp.next();
        var e=this.outer$.e(this.i);
        if (e===finished() && this.outer$.s) {
          this.sp=this.outer$.s().iterator();
          e=this.sp.next();
        } else {
          this.i++;
        }
        return e;
      };
      iter.$$.prototype.next.$crtmm$=function(){return{mod:$CCMM$,$t:{t:'u',l:['T$LazyIterable',{t:Finished}]},ps:[],$cont:iter,an:function(){return[shared(),actual()];},d:['$','LazyIterable','$m','iterator','$o','it','$m','next']};};
    }
    that.iterator=function(){
      return iter(this);
    };
    that.iterator.$crtmm$=function(){return{mod:$CCMM$,$t:{t:Iterator,a:{Element$Iterator:'T$LazyIterable'}},ps:[],$cont:$sarg,an:function(){return[shared(),actual()];},d:['$','LazyIterable','$m','iterator']};};
  })(sarg$.$$.prototype);
}
return sarg$;
}
$init$sarg();
ex$.$init$sarg=$init$sarg;
$init$sarg();
//Turn a comprehension into a native array
function nfor$(c) {
  var a = [];
  var item;
  for (var iter = c.iterator();(item=iter.next())!==finished();){
    a.push(item);
  }
  return a;
}
ex$.nfor$=nfor$;

function variadicness(t) {
  if (extendsType(t,{t:Tuple})) {
    if (t.t==='T' && t.l.length>0) {
      return t.l[t.l.length-1].seq || 0;
    }
  } else if (extendsType(t,{t:Sequence})) {
    return 2;
  } else if (extendsType(t,{t:Sequential})) {
    return 1;
  }
  return 0;
}
<commit_msg>missing `var`<commit_after>var arrprot$=Array.prototype;
arrprot$.ser$$=function(d){
  var targ=this._elemTarg();
  d.putValue(OpenValue$jsint(lmp$(ex$,'$'),this.$prop$getSize),this.length,{Instance$putValue:{t:Integer}});
  var elemtarg={Instance$putElement:targ};
  for (var i=0; i < this.length; i++) {
    d.putElement(i,this[i],elemtarg);
  }
}
var origArrToString = arrprot$.toString;
arrprot$.toString = origArrToString;
arrprot$.rt$=function(t,ne) {
    if (t===null || t===undefined)t={t:Anything};
    if (this.$$targs$$===undefined)this.$$targs$$=={};
    add_type_arg(this,'Element$Iterable',t);
    add_type_arg(this,'Element$Array',t);
    add_type_arg(this,'Element$List',t);
    add_type_arg(this,'Element$Sequential',t);
    add_type_arg(this,'Absent$Iterable',ne?{t:Nothing}:{t:Null});
    return this;
}
arrprot$._elemTarg=function(){
  var t = this.$$targs$$ && this.$$targs$$.Element$Array;
  if (t===undefined)t = this.$$targs$$ && this.$$targs$$.Element$Iterable;
  if (t===undefined)t = this.$$targs$$ && this.$$targs$$.Element$List;
  if (t===undefined)t = {t:Anything};
  if (this.$$targs$$===undefined)this.$$targs$$={
    Element$Array:t, Element$List:t, Element$Iterable:t,
    Element$Collection:t, Item$Correspondence:t,Element$Ranged:t,
    Absent$Iterable:Null, Key$Correspondence:{t:Integer},
    Index$Ranged:{t:Integer}, Subrange$Ranged:{t:$_Array,a:{Element$Array:'Element$Array'}}
  };
  return t;
}
arrprot$.getT$name = function() {
    return $_Array.$$.T$name;
}
arrprot$.getT$all = function() {
    return $_Array.$$.T$all;
}

atr$(arrprot$,'reversed', function() {
  this._elemTarg();
  return this.Reversed$List();
},undefined,List.$$.prototype.$prop$getReversed.$crtmm$);
atr$(arrprot$,'rest', function() {
  this._elemTarg();
  return this.Rest$List(1);
},undefined,List.$$.prototype.$prop$getRest.$crtmm$);

//for sequenced enumerations
function sarg$(elems,spread,$$targs$$){
  $init$sarg();
  var that=new sarg$.$$;
  Iterable($$targs$$,that);
  that.e=elems;
  that.s=spread;
  return that;
}
sarg$.$crtmm$=function(){return{mod:$CCMM$,'super':{t:Basic},ps:[],tp:{T$LazyIterable:{dv:'out'}},sts:[{t:Iterable,a:{Element$Iterable:'T$LazyIterable',Absent$Iterable:{t:Null}}}],pa:1,d:['$','LazyIterable']};};
ex$.sarg$=sarg$;
function $init$sarg(){if(sarg$.$$===undefined){
  initTypeProto(sarg$,'ceylon.language::LazyIterable',Basic,Iterable);
  (function(that){
    function iter(sarg){
      var $$4=new iter.$$;
      $$4.outer$=sarg;
      $$4.$$targs$$={Element$Iterator:sarg.$$targs$$.Element$Iterable};
      Iterator($$4.$$targs$$,$$4);
      $$4.i=0;
      return $$4;
    };
    iter.$crtmm$=function(){return{mod:$CCMM$,'super':{t:Basic},$cont:iterator,sts:[{t:Iterator,a:{Element$Iterator:'T$LazyIterable'}}],d:['$','LazyIterable','$m','iterator','$o','it']};};
    if(iter.$$===undefined){
      initTypeProto(iter,'LazyIterable.iterator',Basic,Iterator);
      iter.$$.prototype.next=function(){
        if (this.sp)return this.sp.next();
        var e=this.outer$.e(this.i);
        if (e===finished() && this.outer$.s) {
          this.sp=this.outer$.s().iterator();
          e=this.sp.next();
        } else {
          this.i++;
        }
        return e;
      };
      iter.$$.prototype.next.$crtmm$=function(){return{mod:$CCMM$,$t:{t:'u',l:['T$LazyIterable',{t:Finished}]},ps:[],$cont:iter,an:function(){return[shared(),actual()];},d:['$','LazyIterable','$m','iterator','$o','it','$m','next']};};
    }
    that.iterator=function(){
      return iter(this);
    };
    that.iterator.$crtmm$=function(){return{mod:$CCMM$,$t:{t:Iterator,a:{Element$Iterator:'T$LazyIterable'}},ps:[],$cont:$sarg,an:function(){return[shared(),actual()];},d:['$','LazyIterable','$m','iterator']};};
  })(sarg$.$$.prototype);
}
return sarg$;
}
$init$sarg();
ex$.$init$sarg=$init$sarg;
$init$sarg();
//Turn a comprehension into a native array
function nfor$(c) {
  var a = [];
  var item;
  for (var iter = c.iterator();(item=iter.next())!==finished();){
    a.push(item);
  }
  return a;
}
ex$.nfor$=nfor$;

function variadicness(t) {
  if (extendsType(t,{t:Tuple})) {
    if (t.t==='T' && t.l.length>0) {
      return t.l[t.l.length-1].seq || 0;
    }
  } else if (extendsType(t,{t:Sequence})) {
    return 2;
  } else if (extendsType(t,{t:Sequential})) {
    return 1;
  }
  return 0;
}
<|endoftext|>


<commit_before>/**
 * Copyright (c) 2015-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

'use strict';

// Inspired by https://github.com/airbnb/javascript but less opinionated.

// We use eslint-loader so even warnings are very visible.
// This is why we only use "WARNING" level for potential errors,
// and we don't use "ERROR" level at all.

// In the future, we might create a separate list of rules for production.
// It would probably be more strict.

// The ESLint browser environment defines all browser globals as valid,
// even though most people don't know some of them exist (e.g. `name` or `status`).
// This is dangerous as it hides accidentally undefined variables.
// We blacklist the globals that we deem potentially confusing.
// To use them, explicitly reference them, e.g. `window.name` or `window.status`.
var restrictedGlobals = require('confusing-browser-globals');

module.exports = {
  root: true,

  parser: 'babel-eslint',

  plugins: ['import', 'flowtype', 'jsx-a11y', 'react'],

  env: {
    browser: true,
    commonjs: true,
    es6: true,
    jest: true,
    node: true,
  },

  parserOptions: {
    ecmaVersion: 2018,
    sourceType: 'module',
    ecmaFeatures: {
      jsx: true,
    },
  },

  rules: {
    // http://eslint.org/docs/rules/
    'array-callback-return': 'warn',
    'default-case': ['warn', { commentPattern: '^no default$' }],
    'dot-location': ['warn', 'property'],
    eqeqeq: ['warn', 'smart'],
    'new-parens': 'warn',
    'no-array-constructor': 'warn',
    'no-caller': 'warn',
    'no-cond-assign': ['warn', 'except-parens'],
    'no-const-assign': 'warn',
    'no-control-regex': 'warn',
    'no-delete-var': 'warn',
    'no-dupe-args': 'warn',
    'no-dupe-class-members': 'warn',
    'no-dupe-keys': 'warn',
    'no-duplicate-case': 'warn',
    'no-empty-character-class': 'warn',
    'no-empty-pattern': 'warn',
    'no-eval': 'warn',
    'no-ex-assign': 'warn',
    'no-extend-native': 'warn',
    'no-extra-bind': 'warn',
    'no-extra-label': 'warn',
    'no-fallthrough': 'warn',
    'no-func-assign': 'warn',
    'no-implied-eval': 'warn',
    'no-invalid-regexp': 'warn',
    'no-iterator': 'warn',
    'no-label-var': 'warn',
    'no-labels': ['warn', { allowLoop: true, allowSwitch: false }],
    'no-lone-blocks': 'warn',
    'no-loop-func': 'warn',
    'no-mixed-operators': [
      'warn',
      {
        groups: [
          ['&', '|', '^', '~', '<<', '>>', '>>>'],
          ['==', '!=', '===', '!==', '>', '>=', '<', '<='],
          ['&&', '||'],
          ['in', 'instanceof'],
        ],
        allowSamePrecedence: false,
      },
    ],
    'no-multi-str': 'warn',
    'no-native-reassign': 'warn',
    'no-negated-in-lhs': 'warn',
    'no-new-func': 'warn',
    'no-new-object': 'warn',
    'no-new-symbol': 'warn',
    'no-new-wrappers': 'warn',
    'no-obj-calls': 'warn',
    'no-octal': 'warn',
    'no-octal-escape': 'warn',
    'no-redeclare': 'warn',
    'no-regex-spaces': 'warn',
    'no-restricted-syntax': ['warn', 'WithStatement'],
    'no-script-url': 'warn',
    'no-self-assign': 'warn',
    'no-self-compare': 'warn',
    'no-sequences': 'warn',
    'no-shadow-restricted-names': 'warn',
    'no-sparse-arrays': 'warn',
    'no-template-curly-in-string': 'warn',
    'no-this-before-super': 'warn',
    'no-throw-literal': 'warn',
    'no-undef': 'error',
    'no-restricted-globals': ['error'].concat(restrictedGlobals),
    'no-unexpected-multiline': 'warn',
    'no-unreachable': 'warn',
    'no-unused-expressions': [
      'error',
      {
        allowShortCircuit: true,
        allowTernary: true,
        allowTaggedTemplates: true,
      },
    ],
    'no-unused-labels': 'warn',
    'no-unused-vars': [
      'warn',
      {
        args: 'none',
        ignoreRestSiblings: true,
      },
    ],
    'no-use-before-define': [
      'warn',
      {
        functions: false,
        classes: false,
        variables: false,
      },
    ],
    'no-useless-computed-key': 'warn',
    'no-useless-concat': 'warn',
    'no-useless-constructor': 'warn',
    'no-useless-escape': 'warn',
    'no-useless-rename': [
      'warn',
      {
        ignoreDestructuring: false,
        ignoreImport: false,
        ignoreExport: false,
      },
    ],
    'no-with': 'warn',
    'no-whitespace-before-property': 'warn',
    'require-yield': 'warn',
    'rest-spread-spacing': ['warn', 'never'],
    strict: ['warn', 'never'],
    'unicode-bom': ['warn', 'never'],
    'use-isnan': 'warn',
    'valid-typeof': 'warn',
    'no-restricted-properties': [
      'error',
      {
        object: 'require',
        property: 'ensure',
        message:
          'Please use import() instead. More info: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting',
      },
      {
        object: 'System',
        property: 'import',
        message:
          'Please use import() instead. More info: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting',
      },
    ],
    'getter-return': 'warn',

    // https://github.com/benmosher/eslint-plugin-import/tree/master/docs/rules
    'import/first': 'error',
    'import/no-amd': 'error',
    'import/no-webpack-loader-syntax': 'error',

    // https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
    'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }],
    'react/jsx-no-comment-textnodes': 'warn',
    'react/jsx-no-duplicate-props': ['warn', { ignoreCase: true }],
    'react/jsx-no-target-blank': 'warn',
    'react/jsx-no-undef': 'error',
    'react/jsx-pascal-case': [
      'warn',
      {
        allowAllCaps: true,
        ignore: [],
      },
    ],
    'react/jsx-uses-react': 'warn',
    'react/jsx-uses-vars': 'warn',
    'react/no-danger-with-children': 'warn',
    'react/no-deprecated': 'warn',
    'react/no-direct-mutation-state': 'warn',
    'react/no-is-mounted': 'warn',
    'react/react-in-jsx-scope': 'error',
    'react/require-render-return': 'error',
    'react/style-prop-object': 'warn',

    // https://github.com/evcohen/eslint-plugin-jsx-a11y/tree/master/docs/rules
    'jsx-a11y/accessible-emoji': 'warn',
    'jsx-a11y/alt-text': 'warn',
    'jsx-a11y/anchor-has-content': 'warn',
    'jsx-a11y/anchor-is-valid': [
      'warn',
      {
        aspects: ['noHref', 'invalidHref'],
      },
    ],
    'jsx-a11y/aria-activedescendant-has-tabindex': 'warn',
    'jsx-a11y/aria-props': 'warn',
    'jsx-a11y/aria-proptypes': 'warn',
    'jsx-a11y/aria-role': 'warn',
    'jsx-a11y/aria-unsupported-elements': 'warn',
    'jsx-a11y/heading-has-content': 'warn',
    'jsx-a11y/iframe-has-title': 'warn',
    'jsx-a11y/img-redundant-alt': 'warn',
    'jsx-a11y/no-access-key': 'warn',
    'jsx-a11y/no-distracting-elements': 'warn',
    'jsx-a11y/no-redundant-roles': 'warn',
    'jsx-a11y/role-has-required-aria-props': 'warn',
    'jsx-a11y/role-supports-aria-props': 'warn',
    'jsx-a11y/scope': 'warn',

    // https://github.com/gajus/eslint-plugin-flowtype
    'flowtype/define-flow-type': 'warn',
    'flowtype/require-valid-file-annotation': 'warn',
    'flowtype/use-flow-type': 'warn',
  },
};
<commit_msg>Disable react/no-deprecated rule (#5205)<commit_after>/**
 * Copyright (c) 2015-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

'use strict';

// Inspired by https://github.com/airbnb/javascript but less opinionated.

// We use eslint-loader so even warnings are very visible.
// This is why we only use "WARNING" level for potential errors,
// and we don't use "ERROR" level at all.

// In the future, we might create a separate list of rules for production.
// It would probably be more strict.

// The ESLint browser environment defines all browser globals as valid,
// even though most people don't know some of them exist (e.g. `name` or `status`).
// This is dangerous as it hides accidentally undefined variables.
// We blacklist the globals that we deem potentially confusing.
// To use them, explicitly reference them, e.g. `window.name` or `window.status`.
var restrictedGlobals = require('confusing-browser-globals');

module.exports = {
  root: true,

  parser: 'babel-eslint',

  plugins: ['import', 'flowtype', 'jsx-a11y', 'react'],

  env: {
    browser: true,
    commonjs: true,
    es6: true,
    jest: true,
    node: true,
  },

  parserOptions: {
    ecmaVersion: 2018,
    sourceType: 'module',
    ecmaFeatures: {
      jsx: true,
    },
  },

  rules: {
    // http://eslint.org/docs/rules/
    'array-callback-return': 'warn',
    'default-case': ['warn', { commentPattern: '^no default$' }],
    'dot-location': ['warn', 'property'],
    eqeqeq: ['warn', 'smart'],
    'new-parens': 'warn',
    'no-array-constructor': 'warn',
    'no-caller': 'warn',
    'no-cond-assign': ['warn', 'except-parens'],
    'no-const-assign': 'warn',
    'no-control-regex': 'warn',
    'no-delete-var': 'warn',
    'no-dupe-args': 'warn',
    'no-dupe-class-members': 'warn',
    'no-dupe-keys': 'warn',
    'no-duplicate-case': 'warn',
    'no-empty-character-class': 'warn',
    'no-empty-pattern': 'warn',
    'no-eval': 'warn',
    'no-ex-assign': 'warn',
    'no-extend-native': 'warn',
    'no-extra-bind': 'warn',
    'no-extra-label': 'warn',
    'no-fallthrough': 'warn',
    'no-func-assign': 'warn',
    'no-implied-eval': 'warn',
    'no-invalid-regexp': 'warn',
    'no-iterator': 'warn',
    'no-label-var': 'warn',
    'no-labels': ['warn', { allowLoop: true, allowSwitch: false }],
    'no-lone-blocks': 'warn',
    'no-loop-func': 'warn',
    'no-mixed-operators': [
      'warn',
      {
        groups: [
          ['&', '|', '^', '~', '<<', '>>', '>>>'],
          ['==', '!=', '===', '!==', '>', '>=', '<', '<='],
          ['&&', '||'],
          ['in', 'instanceof'],
        ],
        allowSamePrecedence: false,
      },
    ],
    'no-multi-str': 'warn',
    'no-native-reassign': 'warn',
    'no-negated-in-lhs': 'warn',
    'no-new-func': 'warn',
    'no-new-object': 'warn',
    'no-new-symbol': 'warn',
    'no-new-wrappers': 'warn',
    'no-obj-calls': 'warn',
    'no-octal': 'warn',
    'no-octal-escape': 'warn',
    'no-redeclare': 'warn',
    'no-regex-spaces': 'warn',
    'no-restricted-syntax': ['warn', 'WithStatement'],
    'no-script-url': 'warn',
    'no-self-assign': 'warn',
    'no-self-compare': 'warn',
    'no-sequences': 'warn',
    'no-shadow-restricted-names': 'warn',
    'no-sparse-arrays': 'warn',
    'no-template-curly-in-string': 'warn',
    'no-this-before-super': 'warn',
    'no-throw-literal': 'warn',
    'no-undef': 'error',
    'no-restricted-globals': ['error'].concat(restrictedGlobals),
    'no-unexpected-multiline': 'warn',
    'no-unreachable': 'warn',
    'no-unused-expressions': [
      'error',
      {
        allowShortCircuit: true,
        allowTernary: true,
        allowTaggedTemplates: true,
      },
    ],
    'no-unused-labels': 'warn',
    'no-unused-vars': [
      'warn',
      {
        args: 'none',
        ignoreRestSiblings: true,
      },
    ],
    'no-use-before-define': [
      'warn',
      {
        functions: false,
        classes: false,
        variables: false,
      },
    ],
    'no-useless-computed-key': 'warn',
    'no-useless-concat': 'warn',
    'no-useless-constructor': 'warn',
    'no-useless-escape': 'warn',
    'no-useless-rename': [
      'warn',
      {
        ignoreDestructuring: false,
        ignoreImport: false,
        ignoreExport: false,
      },
    ],
    'no-with': 'warn',
    'no-whitespace-before-property': 'warn',
    'require-yield': 'warn',
    'rest-spread-spacing': ['warn', 'never'],
    strict: ['warn', 'never'],
    'unicode-bom': ['warn', 'never'],
    'use-isnan': 'warn',
    'valid-typeof': 'warn',
    'no-restricted-properties': [
      'error',
      {
        object: 'require',
        property: 'ensure',
        message:
          'Please use import() instead. More info: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting',
      },
      {
        object: 'System',
        property: 'import',
        message:
          'Please use import() instead. More info: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting',
      },
    ],
    'getter-return': 'warn',

    // https://github.com/benmosher/eslint-plugin-import/tree/master/docs/rules
    'import/first': 'error',
    'import/no-amd': 'error',
    'import/no-webpack-loader-syntax': 'error',

    // https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
    'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }],
    'react/jsx-no-comment-textnodes': 'warn',
    'react/jsx-no-duplicate-props': ['warn', { ignoreCase: true }],
    'react/jsx-no-target-blank': 'warn',
    'react/jsx-no-undef': 'error',
    'react/jsx-pascal-case': [
      'warn',
      {
        allowAllCaps: true,
        ignore: [],
      },
    ],
    'react/jsx-uses-react': 'warn',
    'react/jsx-uses-vars': 'warn',
    'react/no-danger-with-children': 'warn',
    // Disabled because of undesirable warnings
    // See https://github.com/facebook/create-react-app/issues/5204 for
    // blockers until its re-enabled
    // 'react/no-deprecated': 'warn',
    'react/no-direct-mutation-state': 'warn',
    'react/no-is-mounted': 'warn',
    'react/react-in-jsx-scope': 'error',
    'react/require-render-return': 'error',
    'react/style-prop-object': 'warn',

    // https://github.com/evcohen/eslint-plugin-jsx-a11y/tree/master/docs/rules
    'jsx-a11y/accessible-emoji': 'warn',
    'jsx-a11y/alt-text': 'warn',
    'jsx-a11y/anchor-has-content': 'warn',
    'jsx-a11y/anchor-is-valid': [
      'warn',
      {
        aspects: ['noHref', 'invalidHref'],
      },
    ],
    'jsx-a11y/aria-activedescendant-has-tabindex': 'warn',
    'jsx-a11y/aria-props': 'warn',
    'jsx-a11y/aria-proptypes': 'warn',
    'jsx-a11y/aria-role': 'warn',
    'jsx-a11y/aria-unsupported-elements': 'warn',
    'jsx-a11y/heading-has-content': 'warn',
    'jsx-a11y/iframe-has-title': 'warn',
    'jsx-a11y/img-redundant-alt': 'warn',
    'jsx-a11y/no-access-key': 'warn',
    'jsx-a11y/no-distracting-elements': 'warn',
    'jsx-a11y/no-redundant-roles': 'warn',
    'jsx-a11y/role-has-required-aria-props': 'warn',
    'jsx-a11y/role-supports-aria-props': 'warn',
    'jsx-a11y/scope': 'warn',

    // https://github.com/gajus/eslint-plugin-flowtype
    'flowtype/define-flow-type': 'warn',
    'flowtype/require-valid-file-annotation': 'warn',
    'flowtype/use-flow-type': 'warn',
  },
};
<|endoftext|>


<commit_before>import createSchema from 'part:@sanity/base/schema-creator'

// Example of a custom slugify function that
// makes a slug-string and prefixes it with something in the
// schema definition for that slug field
function slugifyWithPrefix(prefix) {
  return function(type, slug) {
    return `${prefix}-` + slug.toString()
      .replace(`${prefix.toLowerCase()}-`, '')
      .toLowerCase()
      .replace(/\s+/g, '-')
      .replace(/[^\w-]+/g, '')
      .replace(/--+/g, '-')
      .replace(/--+/g, '-')
      .substring(0, type.options.maxLength)
  }
}

export default createSchema({
  name: 'example-blog',
  types: [
    {
      name: 'blogpost',
      type: 'object',
      title: 'Blogpost',
      fields: [
        {
          name: 'title',
          title: 'Title',
          type: 'string',
          required: true
        },
        {
          name: 'slug',
          title: 'Slug',
          type: 'slug',
          required: true,
          options: {
            source: 'title',
            maxLength: 64,
            slugifyFn: slugifyWithPrefix('blogpost')
          }
        },
        {
          name: 'priority',
          title: 'Priority',
          type: 'number'
        },
        {
          name: 'checked',
          title: 'Checked',
          type: 'boolean'
        },
        {
          name: 'select',
          title: 'Select',
          type: 'string',
          options: {
            list: [
              {
                title: 'One (1)',
                value: 'one'
              },
              {
                title: 'Two (2)',
                value: 'two'
              },
              {
                title: 'Three (3)',
                value: 'three'
              }
            ]
          }
        },
        {
          name: 'radioSelect',
          title: 'Select (layout: radio)',
          type: 'string',
          options: {
            layout: 'radio',
            list: [
              {
                title: 'One (1)',
                value: 'one'
              },
              {
                title: 'Two (2)',
                value: 'two'
              },
              {
                title: 'Three (3)',
                value: 'three'
              }
            ]
          }
        },
        {
          name: 'lead',
          title: 'Lead',
          type: 'text',
          format: 'html',
          required: true
        },
        {
          name: 'email',
          title: 'Email',
          type: 'email'
        },
        {
          name: 'location',
          title: 'Location',
          type: 'geopoint'
        },
        {
          name: 'content',
          title: 'Content tags',
          type: 'array',
          title: 'Content tags',
          of: [
            {
              title: 'String',
              type: 'string'
            }
          ]
        },
        {
          name: 'authors',
          title: 'Authors',
          type: 'array',
          of: [
            {
              type: 'author'
            }
          ],
          required: true
        },
        {
          name: 'authorRef',
          title: 'Author reference',
          type: 'reference',
          to: {
            type: 'author'
          },
          required: true
        }
      ]
    },
    {
      name: 'author',
      type: 'object',
      title: 'Author',
      fields: [
        {
          name: 'name',
          title: 'Title',
          type: 'string'
        },
        {
          name: 'awards',
          title: 'Awards',
          type: 'array',
          of: [
            {
              type: 'string'
            }
          ]
        }
      ]
    }
  ]
})
<commit_msg>[example-studio] Remove duplicated line<commit_after>import createSchema from 'part:@sanity/base/schema-creator'

// Example of a custom slugify function that
// makes a slug-string and prefixes it with something in the
// schema definition for that slug field
function slugifyWithPrefix(prefix) {
  return function(type, slug) {
    return `${prefix}-` + slug.toString()
      .replace(`${prefix.toLowerCase()}-`, '')
      .toLowerCase()
      .replace(/\s+/g, '-')
      .replace(/[^\w-]+/g, '')
      .replace(/--+/g, '-')
      .substring(0, type.options.maxLength)
  }
}

export default createSchema({
  name: 'example-blog',
  types: [
    {
      name: 'blogpost',
      type: 'object',
      title: 'Blogpost',
      fields: [
        {
          name: 'title',
          title: 'Title',
          type: 'string',
          required: true
        },
        {
          name: 'slug',
          title: 'Slug',
          type: 'slug',
          required: true,
          options: {
            source: 'title',
            maxLength: 64,
            slugifyFn: slugifyWithPrefix('blogpost')
          }
        },
        {
          name: 'priority',
          title: 'Priority',
          type: 'number'
        },
        {
          name: 'checked',
          title: 'Checked',
          type: 'boolean'
        },
        {
          name: 'select',
          title: 'Select',
          type: 'string',
          options: {
            list: [
              {
                title: 'One (1)',
                value: 'one'
              },
              {
                title: 'Two (2)',
                value: 'two'
              },
              {
                title: 'Three (3)',
                value: 'three'
              }
            ]
          }
        },
        {
          name: 'radioSelect',
          title: 'Select (layout: radio)',
          type: 'string',
          options: {
            layout: 'radio',
            list: [
              {
                title: 'One (1)',
                value: 'one'
              },
              {
                title: 'Two (2)',
                value: 'two'
              },
              {
                title: 'Three (3)',
                value: 'three'
              }
            ]
          }
        },
        {
          name: 'lead',
          title: 'Lead',
          type: 'text',
          format: 'html',
          required: true
        },
        {
          name: 'email',
          title: 'Email',
          type: 'email'
        },
        {
          name: 'location',
          title: 'Location',
          type: 'geopoint'
        },
        {
          name: 'content',
          title: 'Content tags',
          type: 'array',
          title: 'Content tags',
          of: [
            {
              title: 'String',
              type: 'string'
            }
          ]
        },
        {
          name: 'authors',
          title: 'Authors',
          type: 'array',
          of: [
            {
              type: 'author'
            }
          ],
          required: true
        },
        {
          name: 'authorRef',
          title: 'Author reference',
          type: 'reference',
          to: {
            type: 'author'
          },
          required: true
        }
      ]
    },
    {
      name: 'author',
      type: 'object',
      title: 'Author',
      fields: [
        {
          name: 'name',
          title: 'Title',
          type: 'string'
        },
        {
          name: 'awards',
          title: 'Awards',
          type: 'array',
          of: [
            {
              type: 'string'
            }
          ]
        }
      ]
    }
  ]
})
<|endoftext|>


<commit_before>goog.provide('gmf.QueryManager');

goog.require('gmf');
goog.require('gmf.Themes');
goog.require('ngeo.Query');

/**
 * The QueryManager service, uses the
 * c2cgeoportal's themes to configure ngeo's query service with each layer
 * found.
 *
 * Used UI metadata:
 *
 *  * identifierAttributeField: Field used to identify the feature (like a title).
 *  * queryLayers: The alternate layers used to do the query.
 *  * wmsLayers: The layers used to do the query, used if queryLayers is not provided.
 *  * wmsUrl: An alternate wmsUrl used to do the query (essential to query WMTS layer).
 *
 * @constructor
 * @struct
 * @param {ngeo.Query} ngeoQuery The ngeo Query service.
 * @param {gmf.Themes} gmfThemes The gmf Themes service.
 * @param {angular.$q} $q Angular q service
 * @ngInject
 * @ngdoc service
 * @ngname gmfThemes
 */
gmf.QueryManager = function(ngeoQuery, gmfThemes, $q) {

  /**
   * @type {ngeo.Query}
   * @private
   */
  this.ngeoQuery_ = ngeoQuery;

  /**
   * @type {gmf.Themes}
   * @private
   */
  this.gmfThemes_ = gmfThemes;

  /**
   * @type {angular.$q}
   * @private
   */
  this.$q_ = $q;

  /**
   * @type {Array.<ngeox.QuerySource>}
   * @private
   */
  this.sources_ = [];

  /**
   * @type {Object.<number|string, ngeox.QuerySource>}
   * @private
   */
  this.cache_ = {};

  ol.events.listen(this.gmfThemes_, gmf.ThemesEventType.CHANGE,
    this.handleThemesChange_, this);
};

/**
 * @param {Object.<string, string>} dimensions The global dimensions object.
 * @export
 */
gmf.QueryManager.prototype.setDimensions = function(dimensions) {
  this.ngeoQuery_.dimensions = dimensions;
};

/**
 * Called when the themes change. Remove any existing sources first, then
 * create and add sources from the loaded themes.
 * @private
 */
gmf.QueryManager.prototype.handleThemesChange_ = function() {

  this.sources_.length = 0;
  this.cache_ = {};
  this.ngeoQuery_.removeAllSources();

  this.gmfThemes_.getOgcServersObject().then(function(ogcServers) {
    var promiseThemes = this.gmfThemes_.getThemesObject().then(function(themes) {
      // create sources for each themes
      for (var i = 0, leni = themes.length; i < leni; i++) {
        var theme = themes[i];
        for (var j = 0, lenj = theme.children.length; j < lenj; j++) {
          this.createSources_(theme.children[j], theme.children[j], ogcServers);
        }
      }
    }.bind(this));

    var promiseBgLayers = this.gmfThemes_.getBackgroundLayersObject().then(function(backgroundLayers) {
      // create a source for each background layer
      for (var i = 0, len = backgroundLayers.length; i < len; i++) {
        this.createSources_(backgroundLayers[i], backgroundLayers[i], ogcServers);
      }
    }.bind(this));

    // then add all sources to the query service
    this.$q_.all([promiseThemes, promiseBgLayers]).then(function() {
      this.ngeoQuery_.addSources(this.sources_);
    }.bind(this));
  }.bind(this));
};

/**
 * Create and add a source for the query service from the GMF theme node if
 * it has no children, otherwise create the sources for each child node if
 * it has any.
 * @param {GmfGroup} firstLevelGroup A node.
 * @param {GmfGroup|GmfLayer} node A node.
 * @param {GmfOgcServers} ogcServers OGC servers.
 * @private
 */
gmf.QueryManager.prototype.createSources_ = function(firstLevelGroup, node, ogcServers) {
  var children = node.children;

  // First we handle the groups
  if (children) {
    for (var i = 0, len = children.length; i < len; i++) {
      this.createSources_(firstLevelGroup, children[i], ogcServers);
    }
    return;
  }

  // We are now on a leaf so we can cast node.metadata to the typed
  // (and non minified) version.

  var id = node.id;
  var meta = /** @type {GmfMetaData} */ (node.metadata);
  var identifierAttributeField = meta.identifierAttributeField;
  var layers;
  var name = node.name;
  var validateLayerParams = false;
  var gmfLayer = /** @type GmfLayer */ (node);
  var ogcServer;

  // Don't create sources for WMTS layers without wmsUrl and ogcServer,
  // they are not queryable.
  if (gmfLayer.type === 'WMTS') {
    layers = meta.queryLayers || meta.wmsLayers;
    if (layers && meta.ogcServer && ogcServers[meta.ogcServer]) {
      ogcServer = ogcServers[meta.ogcServer];
    } else {
      return;
    }
  }

  validateLayerParams = gmfLayer.type === 'WMS';
  var gmfLayerWMS;
  if (gmfLayer.type === 'WMS') {
    gmfLayerWMS = /** @type GmfLayerWMS */ (gmfLayer);
    layers = gmfLayerWMS.layers;
    if (firstLevelGroup.mixed) {
      goog.asserts.assert(gmfLayerWMS.ogcServer);
      ogcServer = ogcServers[/** @type string */ (gmfLayerWMS.ogcServer)];
    } else {
      goog.asserts.assert(firstLevelGroup.ogcServer);
      ogcServer = ogcServers[/** @type string */ (firstLevelGroup.ogcServer)];
    }
  }
  if (!this.cache_[id] && validateLayerParams) {
    // Some nodes have child layers, i.e. a list of layer names that are
    // part of a group. The name of the group itself can't be used 'as-is'
    // as an identifier of the layers for this source. For example, a
    // group named 'osm' might result in returning 'restaurant' features.
    // This override makes sure that those layer names are used instead of
    // the original one.
    if (gmfLayerWMS.childLayers && gmfLayerWMS.childLayers.length) {
      // skip layers with no queryable childLayer
      var isQueryable = function(item) {
        return item.queryable;
      };
      if (!gmfLayerWMS.childLayers.some(isQueryable)) {
        return;
      }

      var childLayerNames = [];
      gmfLayerWMS.childLayers.forEach(function(childLayer) {
        if (childLayer.queryable) {
          childLayerNames.push(childLayer.name);
        }
      }, this);
      layers = childLayerNames.join(',');
    }

    goog.asserts.assert(ogcServer.urlWfs);
    goog.asserts.assert(layers);

    var source = {
      'id': id,
      'identifierAttributeField': identifierAttributeField,
      'label': name,
      'params': {'LAYERS': layers},
      'dimensions': node.dimensions || firstLevelGroup.dimensions,
      'url': ogcServer.urlWfs,
      'validateLayerParams': validateLayerParams,
      'wfsQuery': ogcServer.wfsSupport
    };
    this.cache_[id] = source;
    this.sources_.push(source);
  }
};

gmf.module.service('gmfQueryManager', gmf.QueryManager);
<commit_msg>Fix query source creation for WMTS layers<commit_after>goog.provide('gmf.QueryManager');

goog.require('gmf');
goog.require('gmf.Themes');
goog.require('ngeo.Query');

/**
 * The QueryManager service, uses the
 * c2cgeoportal's themes to configure ngeo's query service with each layer
 * found.
 *
 * Used UI metadata:
 *
 *  * identifierAttributeField: Field used to identify the feature (like a title).
 *  * queryLayers: The alternate layers used to do the query.
 *  * wmsLayers: The layers used to do the query, used if queryLayers is not provided.
 *  * wmsUrl: An alternate wmsUrl used to do the query (essential to query WMTS layer).
 *
 * @constructor
 * @struct
 * @param {ngeo.Query} ngeoQuery The ngeo Query service.
 * @param {gmf.Themes} gmfThemes The gmf Themes service.
 * @param {angular.$q} $q Angular q service
 * @ngInject
 * @ngdoc service
 * @ngname gmfThemes
 */
gmf.QueryManager = function(ngeoQuery, gmfThemes, $q) {

  /**
   * @type {ngeo.Query}
   * @private
   */
  this.ngeoQuery_ = ngeoQuery;

  /**
   * @type {gmf.Themes}
   * @private
   */
  this.gmfThemes_ = gmfThemes;

  /**
   * @type {angular.$q}
   * @private
   */
  this.$q_ = $q;

  /**
   * @type {Array.<ngeox.QuerySource>}
   * @private
   */
  this.sources_ = [];

  /**
   * @type {Object.<number|string, ngeox.QuerySource>}
   * @private
   */
  this.cache_ = {};

  ol.events.listen(this.gmfThemes_, gmf.ThemesEventType.CHANGE,
    this.handleThemesChange_, this);
};

/**
 * @param {Object.<string, string>} dimensions The global dimensions object.
 * @export
 */
gmf.QueryManager.prototype.setDimensions = function(dimensions) {
  this.ngeoQuery_.dimensions = dimensions;
};

/**
 * Called when the themes change. Remove any existing sources first, then
 * create and add sources from the loaded themes.
 * @private
 */
gmf.QueryManager.prototype.handleThemesChange_ = function() {

  this.sources_.length = 0;
  this.cache_ = {};
  this.ngeoQuery_.removeAllSources();

  this.gmfThemes_.getOgcServersObject().then(function(ogcServers) {
    var promiseThemes = this.gmfThemes_.getThemesObject().then(function(themes) {
      // create sources for each themes
      for (var i = 0, leni = themes.length; i < leni; i++) {
        var theme = themes[i];
        for (var j = 0, lenj = theme.children.length; j < lenj; j++) {
          this.createSources_(theme.children[j], theme.children[j], ogcServers);
        }
      }
    }.bind(this));

    var promiseBgLayers = this.gmfThemes_.getBackgroundLayersObject().then(function(backgroundLayers) {
      // create a source for each background layer
      for (var i = 0, len = backgroundLayers.length; i < len; i++) {
        this.createSources_(backgroundLayers[i], backgroundLayers[i], ogcServers);
      }
    }.bind(this));

    // then add all sources to the query service
    this.$q_.all([promiseThemes, promiseBgLayers]).then(function() {
      this.ngeoQuery_.addSources(this.sources_);
    }.bind(this));
  }.bind(this));
};

/**
 * Create and add a source for the query service from the GMF theme node if
 * it has no children, otherwise create the sources for each child node if
 * it has any.
 * @param {GmfGroup} firstLevelGroup A node.
 * @param {GmfGroup|GmfLayer} node A node.
 * @param {GmfOgcServers} ogcServers OGC servers.
 * @private
 */
gmf.QueryManager.prototype.createSources_ = function(firstLevelGroup, node, ogcServers) {
  var children = node.children;

  // First we handle the groups
  if (children) {
    for (var i = 0, len = children.length; i < len; i++) {
      this.createSources_(firstLevelGroup, children[i], ogcServers);
    }
    return;
  }

  // We are now on a leaf so we can cast node.metadata to the typed
  // (and non minified) version.

  var id = node.id;
  var meta = /** @type {GmfMetaData} */ (node.metadata);
  var identifierAttributeField = meta.identifierAttributeField;
  var layers;
  var name = node.name;
  var validateLayerParams = false;
  var gmfLayer = /** @type GmfLayer */ (node);
  var ogcServer;

  // Don't create sources for WMTS layers without wmsUrl and ogcServer,
  // they are not queryable.
  if (gmfLayer.type === 'WMTS') {
    layers = meta.queryLayers || meta.wmsLayers;
    if (layers && meta.ogcServer && ogcServers[meta.ogcServer]) {
      ogcServer = ogcServers[meta.ogcServer];
    } else {
      return;
    }
  }

  validateLayerParams = gmfLayer.type === 'WMS';
  var gmfLayerWMS;
  if (gmfLayer.type === 'WMS') {
    gmfLayerWMS = /** @type GmfLayerWMS */ (gmfLayer);
    layers = gmfLayerWMS.layers;
    if (firstLevelGroup.mixed) {
      goog.asserts.assert(gmfLayerWMS.ogcServer);
      ogcServer = ogcServers[/** @type string */ (gmfLayerWMS.ogcServer)];
    } else {
      goog.asserts.assert(firstLevelGroup.ogcServer);
      ogcServer = ogcServers[/** @type string */ (firstLevelGroup.ogcServer)];
    }
  }
  if (!this.cache_[id]) {
    if (validateLayerParams) {
      // Some nodes have child layers, i.e. a list of layer names that are
      // part of a group. The name of the group itself can't be used 'as-is'
      // as an identifier of the layers for this source. For example, a
      // group named 'osm' might result in returning 'restaurant' features.
      // This override makes sure that those layer names are used instead of
      // the original one.
      if (gmfLayerWMS.childLayers && gmfLayerWMS.childLayers.length) {
        // skip layers with no queryable childLayer
        var isQueryable = function(item) {
          return item.queryable;
        };
        if (!gmfLayerWMS.childLayers.some(isQueryable)) {
          return;
        }

        var childLayerNames = [];
        gmfLayerWMS.childLayers.forEach(function(childLayer) {
          if (childLayer.queryable) {
            childLayerNames.push(childLayer.name);
          }
        }, this);
        layers = childLayerNames.join(',');
      }
    }

    goog.asserts.assert(ogcServer.urlWfs);
    goog.asserts.assert(layers);

    var source = {
      'id': id,
      'identifierAttributeField': identifierAttributeField,
      'label': name,
      'params': {'LAYERS': layers},
      'dimensions': node.dimensions || firstLevelGroup.dimensions,
      'url': ogcServer.urlWfs,
      'validateLayerParams': validateLayerParams,
      'wfsQuery': ogcServer.wfsSupport
    };
    this.cache_[id] = source;
    this.sources_.push(source);
  }
};

gmf.module.service('gmfQueryManager', gmf.QueryManager);
<|endoftext|>


<commit_before>function uploadFiles(url, files) {
    var formData = new FormData();
    var file = files[0];
    formData.append(file.name, file);
    formData.append('csrf_token', csrf_token[0].value);
    var xhr = new XMLHttpRequest();
    xhr.open('POST', url, true);
    xhr.onload = function(e) {
        if (xhr.readyState === 4) {
            if (xhr.status === 200) {
                showMessage(xhr.responseText, 'success', 8000);
                $('#delete').prop('disabled', false);
            } else {
                showMessage(xhr.statusText, 'warning', 8000);
                $('#delete').prop('disabled', true);
            }
        }
    };
    var progressBar = document.querySelector('progress');
    xhr.upload.onprogress = function(e) {
        if (e.lengthComputable) {
            progressBar.value = (e.loaded / e.total) * 100;
            progressBar.textContent = progressBar.value; // Fallback for unsupported browsers.
        }
    };
    xhr.send(formData); //multipart/form-data
}

$(document).ready(function() {
    $('input[type="file"]').get(0).addEventListener('change', function(e) {
        uploadFiles('upload', this.files);
    }, false);

    $('#delete').on('click', function (e) {
        var xhr = new XMLHttpRequest();
        xhr.open('DELETE', 'delete', true);
        xhr.onload = function(e) {
            if (xhr.readyState === 4) {
                if (xhr.status === 200) {
                    showMessage(xhr.responseText, 'success', 8000);
                    $('#delete').prop('disabled', true);
                } else {
                    showMessage(xhr.statusText, 'warning', 8000);
                    $('#delete').prop('disabled', false);
                }
            }
        };
        xhr.send(csrf_token[0].value);
    });
});
<commit_msg>Updates update and delete url to contain window language.<commit_after>function uploadFiles(url, files) {
    var formData = new FormData();
    var file = files[0];
    formData.append(file.name, file);
    formData.append('csrf_token', csrf_token[0].value);
    var xhr = new XMLHttpRequest();
    xhr.open('POST', url, true);
    xhr.onload = function(e) {
        if (xhr.readyState === 4) {
            if (xhr.status === 200) {
                showMessage(xhr.responseText, 'success', 8000);
                $('#delete').prop('disabled', false);
            } else {
                showMessage(xhr.statusText, 'warning', 8000);
                $('#delete').prop('disabled', true);
            }
        }
    };
    var progressBar = document.querySelector('progress');
    xhr.upload.onprogress = function(e) {
        if (e.lengthComputable) {
            progressBar.value = (e.loaded / e.total) * 100;
            progressBar.textContent = progressBar.value; // Fallback for unsupported browsers.
        }
    };
    xhr.send(formData); //multipart/form-data
}

$(document).ready(function() {
    $('input[type="file"]').get(0).addEventListener('change', function(e) {
        uploadFiles('/'+window.lang+'/scholar/admin/article/upload', this.files);
    }, false);

    $('#delete').on('click', function (e) {
        var xhr = new XMLHttpRequest();
        xhr.open('DELETE', '/'+window.lang+'/scholar/admin/article/delete', true);
        xhr.onload = function(e) {
            if (xhr.readyState === 4) {
                if (xhr.status === 200) {
                    showMessage(xhr.responseText, 'success', 8000);
                    $('#delete').prop('disabled', true);
                } else {
                    showMessage(xhr.statusText, 'warning', 8000);
                    $('#delete').prop('disabled', false);
                }
            }
        };
        xhr.send(csrf_token[0].value);
    });
});
<|endoftext|>


<commit_before>import { socket, GameItems } from 'APP/app/sockets'

/* global StackQuest */

const itemCollision = (playerObject, itemGraveyard) => {
  Object.keys(GameItems).forEach(itemKey => {
    const item = GameItems[itemKey]
    StackQuest.game.physics.arcade.collide(playerObject, item, (player, item) => {
      if (item.type === 'loot') {
        playerObject.lootCount++
        const lootCount = StackQuest.game.add.text(player.x, player.y + 20, 'Loot acquired ' + playerObject.lootCount, { font: '22px Times New Roman', fill: '#ffffff' })
        setTimeout(() => { lootCount.destroy() }, 3000)
      } else if (item.type === 'weapon') {
        const weaponNotice = StackQuest.game.add.text(player.x, player.y + 20, 'Weapon acquired, 2X Damage! ', { font: '22px Times New Roman', fill: '#ffffff' })
        // for now, doubling our projectile damage
        playerObject.getProjectile().damage *= 2
        setTimeout(() => { weaponNotice.destroy() }, 3000)
      } else {
        const armorNotice = StackQuest.game.add.text(player.x, player.y + 20, 'Armor acquired, 2X Health! ', { font: '22px Times New Roman', fill: '#ffffff' })
        // for now, double's the player's internal HP stat
        playerObject.stats.hp *= 2
        setTimeout(() => { armorNotice.destroy() }, 3000)
      }
      itemGraveyard.push(item)
      delete GameItems[itemKey]
      socket.emit('updatePlayer', { playerPos: playerObject.position, lootCount: playerObject.lootCount })
    })
  })
}

export default itemCollision
<commit_msg>fix item collision<commit_after>import { socket, GameItems } from 'APP/app/sockets'

/* global StackQuest */

const itemCollision = (playerObject, itemGraveyard) => {
  Object.keys(GameItems).forEach(itemKey => {
    const item = GameItems[itemKey]
    StackQuest.game.physics.arcade.collide(playerObject, item, (player, item) => {
      if (item.type === 'loot') {
        playerObject.lootCount++
        const lootCount = StackQuest.game.add.text(player.x, player.y + 20, 'Loot acquired ' + playerObject.lootCount, { font: '22px Times New Roman', fill: '#ffffff' })
        setTimeout(() => { lootCount.destroy() }, 3000)
      } else if (item.type === 'weapon') {
        const weaponNotice = StackQuest.game.add.text(player.x, player.y + 20, 'Weapon acquired, 2X Damage! ', { font: '22px Times New Roman', fill: '#ffffff' })
        // for now, doubling our projectile damage
        playerObject.weapon.damage *= 2
        setTimeout(() => { weaponNotice.destroy() }, 3000)
      } else {
        const armorNotice = StackQuest.game.add.text(player.x, player.y + 20, 'Armor acquired, 2X Health! ', { font: '22px Times New Roman', fill: '#ffffff' })
        // for now, double's the player's internal HP stat
        playerObject.stats.hp *= 2
        setTimeout(() => { armorNotice.destroy() }, 3000)
      }
      itemGraveyard.push(item)
      delete GameItems[itemKey]
      socket.emit('updatePlayer', { playerPos: playerObject.position, lootCount: playerObject.lootCount })
    })
  })
}

export default itemCollision
<|endoftext|>


<commit_before>///////////////////////////////////////////////////////////////////////////////
/////////////////////// ADMIN USER MANAGEMENT PART ////////////////////////////
///////////////////////////////////////////////////////////////////////////////

$usertable = $('#usertable').bootstrapTable({});

//flush the form add-user for new insertions//
$('#add-user').on("click", function () {
  $('.form-control').val('');
});

//action icons (update/delete) user//
function userOperateFormatter(value, row, index) {
  return [
    '',
    '',
    '',
    '',
    '',
    ''
  ].join('  ');
}

//action events (update/delete) user//
window.userOperateEvents = {
  'click .deleteuser': function (e, value, row, index) {
    $('#DeleteUserModal').modal('show');
    $('input#id').val(row['id']);
    $('input#deltrigger').val(true);
    $('input#name.form-control').val(row['name']);
    $('input#email.form-control').val(row['email']);
    $('input#affiliation.form-control').val(row['affiliation']);
  },
  'click .updateuser': function (e, value, row, index) {
    $('#UpdateUserModal').modal('show');
    $('input#id').val(row['id']);
    $('input#confirmed').prop('checked', row['confirmed']);
    $('select#role.form-control').val(row['role_id2']);
    $('input#name.form-control').val(row['name']);
    $('input#email.form-control').val(row['email']);
    $('input#affiliation.form-control').val(row['affiliation']);
    $('textarea#pgp.form-control').val(row['pgp']);
  }
};

///////////////////////////////////////////////////////////////////////////////
////////////////////////  NOTIFICATION MANAGEMENT /////////////////////////////
///////////////////////////////////////////////////////////////////////////////

$notiftable = $('#notiftable').bootstrapTable({});

function operateFormatter(value, row, index) {
  if (row['fulltxt'] == true) {
    return [
      '',
      '',
      ''
    ].join('  ');
  } else {
    return [
      '',
      '',
      '',
      '',
      '',
      ''
    ].join('  ');
  }
}

// coloring row if fulltxt notification or not //
function rowStyle(row, index) {
  if (row['fulltxt'] == true) {
    return {classes: "info"};

  } else {
    return {classes: "success"};
  }
}

function dateFormatter(value, row, index) {
  return new Date(value);
}

function refFormatter(value, row, index) {
  var tab = String(value).split(',');
  var ref = [];
  for (var j = 0; j < tab.length; j++) {
    ref.push(' ' + tab[j] + '');
  }
  return ref.join('
');
}

window.operateEvents = {
  'click .removenotif': function (e, value, row, index) {
    $.ajax({
      type: "POST",
      contentType: "application/json; charset=utf-8",
      url: "/notif/delnotif",
      dataType: "json",
      data: JSON.stringify(row['id']),
      success: function () {
        location.reload();
      }
    });

  },
  'click .checknotif': function (e, value, row, index) {
    $.ajax({
      type: "POST",
      contentType: "application/json; charset=utf-8",
      url: "/notif/checknotif",
      dataType: "json",
      data: JSON.stringify(row),
      success: function (data) {
        $('#CheckNotifModal').modal('show');
        $('#cvestab').bootstrapTable('destroy', {});
        $('#cvestab').bootstrapTable({
          method: 'post',
          data: data,
          search: true,
          showToggle: true,
          showColumns: true,
          height: 600,
          undefinedText: "---",
          minimumCountColumns: 2,
          searchAlign: 'left',
          striped: true,
          cache: false,
          pagination: true,
          columns: [
            {
              field: 'id',
              title: 'CVE ID',
              align: 'center',
              sortable: true
            },
            {
              field: 'Modified',
              title: 'Last Update',
              align: 'left',
              formatter: dateFormatter,
              sortable: true
            },
            {
              field: 'Published',
              title: 'Published',
              align: 'left',
              visible: false,
              formatter: dateFormatter,
              sortable: true
            },
            {
              field: 'cvss',
              title: 'CVSS',
              visible: false,
              align: 'left'
            },
            {
              field: 'cwe',
              title: 'CWE',
              align: 'left',
              visible: false,
              sortable: true
            },
            {
              field: 'summary',
              title: 'Summary',
              align: 'left'
            },
            {
              field: 'references',
              title: 'References',
              visible: true,
              formatter: refFormatter,
              align: 'left'
            },
            {
              field: 'vulnerable_configuration',
              title: 'Vulnerable Conf',
              visible: false,
              align: 'left'
            }
          ]
        });
      }
    });
  }
};

var delay = (function () {
  var timer = 0;
  return function (callback, ms) {
    clearTimeout(timer);
    timer = setTimeout(callback, ms)
  };
})();

$('#allproduct').on("click", function () {
  if ($(this).is(':checked')) {
    $('#product').val('');
    $('#version').val('');
    $('#product').parent().toggleClass('has-warning has-success', false);
    $('#version').parent().toggleClass('has-warning has-success', false);

    $('#product').prop('disabled', true);
    $('#version').prop('disabled', true);
    $('#allversion').prop('disabled', true);
    $('#allversion').prop('checked', true);
  } else {
    $('#product').removeAttr("disabled");
    $('#version').removeAttr("disabled");
    $('#allversion').prop('checked', false);
    $('#allversion').prop('disabled', false);
  }
});

$('#allversion').on("click", function () {
  if ($(this).is(':checked')) {
    $('#version').val('');
    $('#version').parent().toggleClass('has-warning has-success', false);
    $('#version').prop('disabled', true);
  } else {
    $('#version').removeAttr("disabled");
  }
});

$('#vendor-dropdown').on("click", "li.searchterm", function () {
  var value = $(this).text();
  $('#vendor').val(value);
});

$('#product-dropdown').on("click", "li.searchterm", function () {
  var value = $(this).text();
  $('#product').val(value);
  if ($('#vendor').val() == '' && $('#product').parent().hasClass('has-success')) {
    $('#vendor').val($('ul#vendor-dropdown.dropdown-menu').text());
  }
});

$('#version-dropdown').on("click", "li.searchterm", function () {
  var value = $(this).text();
  $('#version').val(value);
});

$('#vendor').on("keyup focusout", function () {
  delay(function () {
    $.ajax({
      type: "POST",
      contentType: "application/json; charset=utf-8",
      url: "/notif/notifjson",
      dataType: "json",
      data: JSON.stringify(
        {
          "queryvendor": $('#vendor').val(),
          "queryproduct": $('#product').val(),
          "queryversion": $('#version').val()
        }),
      success: function (data) {
        var vendors = data['vendors'];
        $('#vendor-dropdown').empty();
        for (var i = 0; i < vendors.length; i++) {
          $('#vendor-dropdown').append('
' + vendors[i] + '
');
        }
        if ($.inArray($('#vendor').val(), vendors) == -1) {
          $('#vendor').parent().toggleClass('has-warning', true);
          $('#vendor').parent().toggleClass('has-success', false);
        } else {
          $('#vendor').parent().toggleClass('has-success', true);
          $('#vendor').parent().toggleClass('has-warning', false);
        }
      }
    });
  }, 500);
});

$('#product').on("keyup click focusout", function () {
  delay(function () {
    $.ajax({
      type: "POST",
      contentType: "application/json; charset=utf-8",
      url: "/notif/notifjson",
      dataType: "json",
      data: JSON.stringify(
        {
          "queryvendor": $('#vendor').val(),
          "queryproduct": $('#product').val(),
          "queryversion": $('#version').val()
        }),
      success: function (data) {
        var products = data['products'];
        var vendors = data['vendors'];
        $('#product-dropdown').empty();
        $('#vendor-dropdown').empty();
        for (var j = 0; j < products.length; j++) {
          $('#product-dropdown').append('
' + products[j] + '
');
        }
        if ($.inArray($('#product').val(), products) == -1) {
          $('#product').parent().toggleClass('has-warning', true);
          $('#product').parent().toggleClass('has-success', false);
        } else {
          $('#product').parent().toggleClass('has-success', true);
          $('#product').parent().toggleClass('has-warning', false);
        }
        $('#vendor').val(vendors[0]);
        if ($('#vendor').val() != "") {
          $('#vendor').parent().toggleClass('has-success', true);
        }
      }
    });
  }, 500);
});

$('#version').on("keyup click focusout", function () {
  delay(function () {
    $.ajax({
      type: "POST",
      contentType: "application/json; charset=utf-8",
      url: "/notif/notifjson",
      dataType: "json",
      data: JSON.stringify(
        {
          "queryvendor": $('#vendor').val(),
          "queryproduct": $('#product').val(),
          "queryversion": $('#version').val()
        }),
      success: function (data) {
        var versions = data['versions'];
        $('#version-dropdown').empty();
        for (var j = 0; j < versions.length; j++) {
          $('#version-dropdown').append('
' + versions[j] + '
');
        }
        if ($.inArray($('#version').val(), versions) == -1) {
          $('#version').parent().toggleClass('has-warning', true);
          $('#version').parent().toggleClass('has-success', false);
        } else {
          $('#version').parent().toggleClass('has-success', true);
          $('#version').parent().toggleClass('has-warning', false);
        }
      }
    });
  }, 500);
});

// Reseting form for further add.
$('#add-notif').on("click", function () {
  $('#vendor').val('');
  $('#product').val('');
  $('#version').val('');
  $('#product').removeAttr("disabled");
  $('#version').removeAttr("disabled");
  $('#allversion').prop('checked', false);
  $('#allversion').attr('disabled', false);
  $('#allproduct').prop('checked', false);
  $('#vendor').parent().removeClass('has-warning has-success');
  $('#product').parent().removeClass('has-warning has-success');
  $('#version').parent().removeClass('has-warning has-success');
});

$('#delete-notif').on("click", function () {
  var selected_notif = [];
  for (var j = 0; j < $('#notiftable').bootstrapTable('getSelections').length; j++) {
    selected_notif.push($('#notiftable').bootstrapTable('getSelections')[j]['id'])
  }
  $.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: "/notif/delnotif",
    dataType: "json",
    data: JSON.stringify(selected_notif),
    success: function () {
      location.reload();
    }
  });
});

// Add notification in the database.
$('#btn-add-notif').on("click", function () {
  $.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: "/notif/addnotif",
    dataType: "json",
    data: JSON.stringify(
      {
        "queryvendor": $('#vendor').val(),
        "queryproduct": $('#product').val(),
        "queryversion": $('#version').val(),
        "allproduct": $('#allproduct').is(':checked'),
        "allversion": $('#allversion').is(':checked')
      }),
    success: function () {
      location.reload();
    }
  });
});

// Add full text notif in the database.
$('#fulltxtsearchadd').on("click", function () {
  $.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: "/notif/searchnotif",
    dataType: "json",
    data: JSON.stringify(
      {"searchquery": $('#fulltextsearch').val()}),
    success: function () {
      location.reload();
    }
  });
});

<commit_msg>make CVEs sortable by CVSS score<commit_after>///////////////////////////////////////////////////////////////////////////////
/////////////////////// ADMIN USER MANAGEMENT PART ////////////////////////////
///////////////////////////////////////////////////////////////////////////////

$usertable = $('#usertable').bootstrapTable({});

//flush the form add-user for new insertions//
$('#add-user').on("click", function () {
  $('.form-control').val('');
});

//action icons (update/delete) user//
function userOperateFormatter(value, row, index) {
  return [
    '',
    '',
    '',
    '',
    '',
    ''
  ].join('  ');
}

//action events (update/delete) user//
window.userOperateEvents = {
  'click .deleteuser': function (e, value, row, index) {
    $('#DeleteUserModal').modal('show');
    $('input#id').val(row['id']);
    $('input#deltrigger').val(true);
    $('input#name.form-control').val(row['name']);
    $('input#email.form-control').val(row['email']);
    $('input#affiliation.form-control').val(row['affiliation']);
  },
  'click .updateuser': function (e, value, row, index) {
    $('#UpdateUserModal').modal('show');
    $('input#id').val(row['id']);
    $('input#confirmed').prop('checked', row['confirmed']);
    $('select#role.form-control').val(row['role_id2']);
    $('input#name.form-control').val(row['name']);
    $('input#email.form-control').val(row['email']);
    $('input#affiliation.form-control').val(row['affiliation']);
    $('textarea#pgp.form-control').val(row['pgp']);
  }
};

///////////////////////////////////////////////////////////////////////////////
////////////////////////  NOTIFICATION MANAGEMENT /////////////////////////////
///////////////////////////////////////////////////////////////////////////////

$notiftable = $('#notiftable').bootstrapTable({});

function operateFormatter(value, row, index) {
  if (row['fulltxt'] == true) {
    return [
      '',
      '',
      ''
    ].join('  ');
  } else {
    return [
      '',
      '',
      '',
      '',
      '',
      ''
    ].join('  ');
  }
}

// coloring row if fulltxt notification or not //
function rowStyle(row, index) {
  if (row['fulltxt'] == true) {
    return {classes: "info"};

  } else {
    return {classes: "success"};
  }
}

function dateFormatter(value, row, index) {
  return new Date(value);
}

function refFormatter(value, row, index) {
  var tab = String(value).split(',');
  var ref = [];
  for (var j = 0; j < tab.length; j++) {
    ref.push(' ' + tab[j] + '');
  }
  return ref.join('
');
}

window.operateEvents = {
  'click .removenotif': function (e, value, row, index) {
    $.ajax({
      type: "POST",
      contentType: "application/json; charset=utf-8",
      url: "/notif/delnotif",
      dataType: "json",
      data: JSON.stringify(row['id']),
      success: function () {
        location.reload();
      }
    });

  },
  'click .checknotif': function (e, value, row, index) {
    $.ajax({
      type: "POST",
      contentType: "application/json; charset=utf-8",
      url: "/notif/checknotif",
      dataType: "json",
      data: JSON.stringify(row),
      success: function (data) {
        $('#CheckNotifModal').modal('show');
        $('#cvestab').bootstrapTable('destroy', {});
        $('#cvestab').bootstrapTable({
          method: 'post',
          data: data,
          search: true,
          showToggle: true,
          showColumns: true,
          height: 600,
          undefinedText: "---",
          minimumCountColumns: 2,
          searchAlign: 'left',
          striped: true,
          cache: false,
          pagination: true,
          columns: [
            {
              field: 'id',
              title: 'CVE ID',
              align: 'center',
              sortable: true
            },
            {
              field: 'Modified',
              title: 'Last Update',
              align: 'left',
              formatter: dateFormatter,
              sortable: true
            },
            {
              field: 'Published',
              title: 'Published',
              align: 'left',
              visible: false,
              formatter: dateFormatter,
              sortable: true
            },
            {
              field: 'cvss',
              title: 'CVSS',
              visible: false,
              align: 'left',
              sortable: true
            },
            {
              field: 'cwe',
              title: 'CWE',
              align: 'left',
              visible: false,
              sortable: true
            },
            {
              field: 'summary',
              title: 'Summary',
              align: 'left'
            },
            {
              field: 'references',
              title: 'References',
              visible: true,
              formatter: refFormatter,
              align: 'left'
            },
            {
              field: 'vulnerable_configuration',
              title: 'Vulnerable Conf',
              visible: false,
              align: 'left'
            }
          ]
        });
      }
    });
  }
};

var delay = (function () {
  var timer = 0;
  return function (callback, ms) {
    clearTimeout(timer);
    timer = setTimeout(callback, ms)
  };
})();

$('#allproduct').on("click", function () {
  if ($(this).is(':checked')) {
    $('#product').val('');
    $('#version').val('');
    $('#product').parent().toggleClass('has-warning has-success', false);
    $('#version').parent().toggleClass('has-warning has-success', false);

    $('#product').prop('disabled', true);
    $('#version').prop('disabled', true);
    $('#allversion').prop('disabled', true);
    $('#allversion').prop('checked', true);
  } else {
    $('#product').removeAttr("disabled");
    $('#version').removeAttr("disabled");
    $('#allversion').prop('checked', false);
    $('#allversion').prop('disabled', false);
  }
});

$('#allversion').on("click", function () {
  if ($(this).is(':checked')) {
    $('#version').val('');
    $('#version').parent().toggleClass('has-warning has-success', false);
    $('#version').prop('disabled', true);
  } else {
    $('#version').removeAttr("disabled");
  }
});

$('#vendor-dropdown').on("click", "li.searchterm", function () {
  var value = $(this).text();
  $('#vendor').val(value);
});

$('#product-dropdown').on("click", "li.searchterm", function () {
  var value = $(this).text();
  $('#product').val(value);
  if ($('#vendor').val() == '' && $('#product').parent().hasClass('has-success')) {
    $('#vendor').val($('ul#vendor-dropdown.dropdown-menu').text());
  }
});

$('#version-dropdown').on("click", "li.searchterm", function () {
  var value = $(this).text();
  $('#version').val(value);
});

$('#vendor').on("keyup focusout", function () {
  delay(function () {
    $.ajax({
      type: "POST",
      contentType: "application/json; charset=utf-8",
      url: "/notif/notifjson",
      dataType: "json",
      data: JSON.stringify(
        {
          "queryvendor": $('#vendor').val(),
          "queryproduct": $('#product').val(),
          "queryversion": $('#version').val()
        }),
      success: function (data) {
        var vendors = data['vendors'];
        $('#vendor-dropdown').empty();
        for (var i = 0; i < vendors.length; i++) {
          $('#vendor-dropdown').append('
' + vendors[i] + '
');
        }
        if ($.inArray($('#vendor').val(), vendors) == -1) {
          $('#vendor').parent().toggleClass('has-warning', true);
          $('#vendor').parent().toggleClass('has-success', false);
        } else {
          $('#vendor').parent().toggleClass('has-success', true);
          $('#vendor').parent().toggleClass('has-warning', false);
        }
      }
    });
  }, 500);
});

$('#product').on("keyup click focusout", function () {
  delay(function () {
    $.ajax({
      type: "POST",
      contentType: "application/json; charset=utf-8",
      url: "/notif/notifjson",
      dataType: "json",
      data: JSON.stringify(
        {
          "queryvendor": $('#vendor').val(),
          "queryproduct": $('#product').val(),
          "queryversion": $('#version').val()
        }),
      success: function (data) {
        var products = data['products'];
        var vendors = data['vendors'];
        $('#product-dropdown').empty();
        $('#vendor-dropdown').empty();
        for (var j = 0; j < products.length; j++) {
          $('#product-dropdown').append('
' + products[j] + '
');
        }
        if ($.inArray($('#product').val(), products) == -1) {
          $('#product').parent().toggleClass('has-warning', true);
          $('#product').parent().toggleClass('has-success', false);
        } else {
          $('#product').parent().toggleClass('has-success', true);
          $('#product').parent().toggleClass('has-warning', false);
        }
        $('#vendor').val(vendors[0]);
        if ($('#vendor').val() != "") {
          $('#vendor').parent().toggleClass('has-success', true);
        }
      }
    });
  }, 500);
});

$('#version').on("keyup click focusout", function () {
  delay(function () {
    $.ajax({
      type: "POST",
      contentType: "application/json; charset=utf-8",
      url: "/notif/notifjson",
      dataType: "json",
      data: JSON.stringify(
        {
          "queryvendor": $('#vendor').val(),
          "queryproduct": $('#product').val(),
          "queryversion": $('#version').val()
        }),
      success: function (data) {
        var versions = data['versions'];
        $('#version-dropdown').empty();
        for (var j = 0; j < versions.length; j++) {
          $('#version-dropdown').append('
' + versions[j] + '
');
        }
        if ($.inArray($('#version').val(), versions) == -1) {
          $('#version').parent().toggleClass('has-warning', true);
          $('#version').parent().toggleClass('has-success', false);
        } else {
          $('#version').parent().toggleClass('has-success', true);
          $('#version').parent().toggleClass('has-warning', false);
        }
      }
    });
  }, 500);
});

// Reseting form for further add.
$('#add-notif').on("click", function () {
  $('#vendor').val('');
  $('#product').val('');
  $('#version').val('');
  $('#product').removeAttr("disabled");
  $('#version').removeAttr("disabled");
  $('#allversion').prop('checked', false);
  $('#allversion').attr('disabled', false);
  $('#allproduct').prop('checked', false);
  $('#vendor').parent().removeClass('has-warning has-success');
  $('#product').parent().removeClass('has-warning has-success');
  $('#version').parent().removeClass('has-warning has-success');
});

$('#delete-notif').on("click", function () {
  var selected_notif = [];
  for (var j = 0; j < $('#notiftable').bootstrapTable('getSelections').length; j++) {
    selected_notif.push($('#notiftable').bootstrapTable('getSelections')[j]['id'])
  }
  $.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: "/notif/delnotif",
    dataType: "json",
    data: JSON.stringify(selected_notif),
    success: function () {
      location.reload();
    }
  });
});

// Add notification in the database.
$('#btn-add-notif').on("click", function () {
  $.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: "/notif/addnotif",
    dataType: "json",
    data: JSON.stringify(
      {
        "queryvendor": $('#vendor').val(),
        "queryproduct": $('#product').val(),
        "queryversion": $('#version').val(),
        "allproduct": $('#allproduct').is(':checked'),
        "allversion": $('#allversion').is(':checked')
      }),
    success: function () {
      location.reload();
    }
  });
});

// Add full text notif in the database.
$('#fulltxtsearchadd').on("click", function () {
  $.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: "/notif/searchnotif",
    dataType: "json",
    data: JSON.stringify(
      {"searchquery": $('#fulltextsearch').val()}),
    success: function () {
      location.reload();
    }
  });
});

<|endoftext|>


<commit_before><commit_msg>Deleting setup.js<commit_after><|endoftext|>


<commit_before>/* @flow */

import { Observable } from "rxjs/Observable";
import { of } from "rxjs/observable/of";
import { empty } from "rxjs/observable/empty";
import { merge } from "rxjs/observable/merge";
import { from } from "rxjs/observable/from";
import { createKernelRef } from "../state/refs";

import { createMessage, childOf, ofMessageType } from "@nteract/messaging";

import type { Notebook, ImmutableNotebook } from "@nteract/commutable";
import type { ContentRef, KernelRef } from "../state/refs";

const path = require("path");

import {
  filter,
  map,
  tap,
  mergeMap,
  concatMap,
  catchError,
  first,
  pluck,
  switchMap
} from "rxjs/operators";

import { ActionsObservable, ofType } from "redux-observable";

import * as uuid from "uuid";

import type {
  NewKernelAction,
  RestartKernel,
  SetNotebook
} from "../actionTypes";

import * as selectors from "../selectors";
import * as actions from "../actions";
import * as actionTypes from "../actionTypes";

/**
 * Sets the execution state after a kernel has been launched.
 *
 * @oaram  {ActionObservable}  action$ ActionObservable for LAUNCH_KERNEL_SUCCESSFUL action
 */
export const watchExecutionStateEpic = (action$: ActionsObservable<*>) =>
  action$.pipe(
    ofType(actionTypes.LAUNCH_KERNEL_SUCCESSFUL),
    switchMap((action: NewKernelAction) =>
      action.payload.kernel.channels.pipe(
        filter(msg => msg.header.msg_type === "status"),
        map(msg =>
          actions.setExecutionState({
            kernelStatus: msg.content.execution_state,
            kernelRef: action.payload.kernelRef,
            contentRef: action.payload.contentRef
          })
        )
      )
    )
  );

/**
 * Send a kernel_info_request to the kernel.
 *
 * @param  {Object}  channels  A object containing the kernel channels
 * @returns  {Observable}  The reply from the server
 */
export function acquireKernelInfo(
  channels: Channels,
  kernelRef: KernelRef,
  contentRef: ContentRef
) {
  const message = createMessage("kernel_info_request");

  const obs = channels.pipe(
    childOf(message),
    ofMessageType("kernel_info_reply"),
    first(),
    pluck("content", "language_info"),
    map(langInfo =>
      actions.setLanguageInfo({ langInfo, kernelRef, contentRef })
    )
  );

  return Observable.create(observer => {
    const subscription = obs.subscribe(observer);
    channels.next(message);
    return subscription;
  });
}

/**
 * Gets information about newly launched kernel.
 *
 * @param  {ActionObservable}  The action type
 */
export const acquireKernelInfoEpic = (action$: ActionsObservable<*>) =>
  action$.pipe(
    ofType(actionTypes.LAUNCH_KERNEL_SUCCESSFUL),
    switchMap((action: NewKernelAction) => {
      const {
        payload: { kernel: { channels }, kernelRef, contentRef }
      } = action;
      return acquireKernelInfo(channels, kernelRef, contentRef);
    })
  );

export const extractNewKernel = (
  filepath: ?string,
  notebook: ImmutableNotebook
) => {
  const cwd = (filepath && path.dirname(filepath)) || "/";

  const kernelSpecName = notebook.getIn(
    ["metadata", "kernelspec", "name"],
    notebook.getIn(["metadata", "language_info", "name"], "python3")
  );

  return {
    cwd,
    kernelSpecName
  };
};

export const launchKernelWhenNotebookSetEpic = (
  action$: ActionsObservable<*>
) =>
  action$.pipe(
    ofType(actionTypes.SET_NOTEBOOK),
    map((action: SetNotebook) => {
      const { cwd, kernelSpecName } = extractNewKernel(
        action.payload.filepath,
        action.payload.notebook
      );

      return actions.launchKernelByName({
        kernelSpecName,
        cwd,
        kernelRef: action.payload.kernelRef,
        selectNextKernel: true,
        contentRef: action.payload.contentRef
      });
    })
  );

export const restartKernelEpic = (action$: ActionsObservable<*>, store: *) =>
  action$.pipe(
    ofType(actionTypes.RESTART_KERNEL),
    concatMap((action: RestartKernel) => {
      const state = store.getState();

      const oldKernelRef = action.payload.kernelRef;
      const oldKernel = selectors.kernel(state, { kernelRef: oldKernelRef });

      const notificationSystem = selectors.notificationSystem(state);

      if (!oldKernelRef || !oldKernel) {
        notificationSystem.addNotification({
          title: "Failure to Restart",
          message: `Unable to restart kernel, please select a new kernel.`,
          dismissible: true,
          position: "tr",
          level: "error"
        });

        // TODO: Wow do we need to send notifications through our store for
        // consistency
        return empty();
      }

      // TODO: Incorporate this into each of the launchKernelByName
      //       actions...
      //       This only mirrors the old behavior of restart kernel (for now)
      notificationSystem.addNotification({
        title: "Kernel Restarted",
        message: `Kernel ${oldKernel.kernelSpecName ||
          "unknown"} has been restarted.`,
        dismissible: true,
        position: "tr",
        level: "success"
      });

      return of(
        actions.killKernel({
          restarting: true,
          kernelRef: oldKernelRef
        }),
        actions.launchKernelByName({
          kernelSpecName: oldKernel.kernelSpecName,
          cwd: oldKernel.cwd,
          kernelRef: createKernelRef(),
          selectNextKernel: true,
          contentRef: action.payload.contentRef
        })
      );
    })
  );
<commit_msg>start setting up new way to get kernel info<commit_after>/* @flow */

import { Observable } from "rxjs/Observable";
import { of } from "rxjs/observable/of";
import { empty } from "rxjs/observable/empty";
import { merge } from "rxjs/observable/merge";
import { from } from "rxjs/observable/from";
import { createKernelRef } from "../state/refs";

import { createMessage, childOf, ofMessageType } from "@nteract/messaging";

import type { Notebook, ImmutableNotebook } from "@nteract/commutable";
import type { ContentRef, KernelRef } from "../state/refs";

const path = require("path");

import {
  filter,
  map,
  tap,
  mergeMap,
  concatMap,
  catchError,
  first,
  pluck,
  switchMap
} from "rxjs/operators";

import { ActionsObservable, ofType } from "redux-observable";

import * as uuid from "uuid";

import type {
  NewKernelAction,
  RestartKernel,
  SetNotebook
} from "../actionTypes";

import * as selectors from "../selectors";
import * as actions from "../actions";
import * as actionTypes from "../actionTypes";

/**
 * Sets the execution state after a kernel has been launched.
 *
 * @oaram  {ActionObservable}  action$ ActionObservable for LAUNCH_KERNEL_SUCCESSFUL action
 */
export const watchExecutionStateEpic = (action$: ActionsObservable<*>) =>
  action$.pipe(
    ofType(actionTypes.LAUNCH_KERNEL_SUCCESSFUL),
    switchMap((action: NewKernelAction) =>
      action.payload.kernel.channels.pipe(
        filter(msg => msg.header.msg_type === "status"),
        map(msg =>
          actions.setExecutionState({
            kernelStatus: msg.content.execution_state,
            kernelRef: action.payload.kernelRef,
            contentRef: action.payload.contentRef
          })
        )
      )
    )
  );

/**
 * Send a kernel_info_request to the kernel.
 *
 * @param  {Object}  channels  A object containing the kernel channels
 * @returns  {Observable}  The reply from the server
 */
export function acquireKernelInfo(
  channels: Channels,
  kernelRef: KernelRef,
  contentRef: ContentRef
) {
  const message = createMessage("kernel_info_request");

  const obs = channels.pipe(
    childOf(message),
    ofMessageType("kernel_info_reply"),
    first(),
    mergeMap(msg => {
      return of(
        // The original action we were using
        actions.setLanguageInfo({
          langInfo: msg.content.language_info,
          kernelRef,
          contentRef
        })
        // The outer data for more uses
        /*
        TODO: switch the current actions.setKernelInfo to
              setKernelspecInfo
        actions.setKernelInfo({
          kernelInfo: msg.content,
          kernelRef,
          contentRef
        })*/
      );
    })
  );

  return Observable.create(observer => {
    const subscription = obs.subscribe(observer);
    channels.next(message);
    return subscription;
  });
}

/**
 * Gets information about newly launched kernel.
 *
 * @param  {ActionObservable}  The action type
 */
export const acquireKernelInfoEpic = (action$: ActionsObservable<*>) =>
  action$.pipe(
    ofType(actionTypes.LAUNCH_KERNEL_SUCCESSFUL),
    switchMap((action: NewKernelAction) => {
      const {
        payload: { kernel: { channels }, kernelRef, contentRef }
      } = action;
      return acquireKernelInfo(channels, kernelRef, contentRef);
    })
  );

export const extractNewKernel = (
  filepath: ?string,
  notebook: ImmutableNotebook
) => {
  const cwd = (filepath && path.dirname(filepath)) || "/";

  const kernelSpecName = notebook.getIn(
    ["metadata", "kernelspec", "name"],
    notebook.getIn(["metadata", "language_info", "name"], "python3")
  );

  return {
    cwd,
    kernelSpecName
  };
};

export const launchKernelWhenNotebookSetEpic = (
  action$: ActionsObservable<*>
) =>
  action$.pipe(
    ofType(actionTypes.SET_NOTEBOOK),
    map((action: SetNotebook) => {
      const { cwd, kernelSpecName } = extractNewKernel(
        action.payload.filepath,
        action.payload.notebook
      );

      return actions.launchKernelByName({
        kernelSpecName,
        cwd,
        kernelRef: action.payload.kernelRef,
        selectNextKernel: true,
        contentRef: action.payload.contentRef
      });
    })
  );

export const restartKernelEpic = (action$: ActionsObservable<*>, store: *) =>
  action$.pipe(
    ofType(actionTypes.RESTART_KERNEL),
    concatMap((action: RestartKernel) => {
      const state = store.getState();

      const oldKernelRef = action.payload.kernelRef;
      const oldKernel = selectors.kernel(state, { kernelRef: oldKernelRef });

      const notificationSystem = selectors.notificationSystem(state);

      if (!oldKernelRef || !oldKernel) {
        notificationSystem.addNotification({
          title: "Failure to Restart",
          message: `Unable to restart kernel, please select a new kernel.`,
          dismissible: true,
          position: "tr",
          level: "error"
        });

        // TODO: Wow do we need to send notifications through our store for
        // consistency
        return empty();
      }

      // TODO: Incorporate this into each of the launchKernelByName
      //       actions...
      //       This only mirrors the old behavior of restart kernel (for now)
      notificationSystem.addNotification({
        title: "Kernel Restarted",
        message: `Kernel ${oldKernel.kernelSpecName ||
          "unknown"} has been restarted.`,
        dismissible: true,
        position: "tr",
        level: "success"
      });

      return of(
        actions.killKernel({
          restarting: true,
          kernelRef: oldKernelRef
        }),
        actions.launchKernelByName({
          kernelSpecName: oldKernel.kernelSpecName,
          cwd: oldKernel.cwd,
          kernelRef: createKernelRef(),
          selectNextKernel: true,
          contentRef: action.payload.contentRef
        })
      );
    })
  );
<|endoftext|>


<commit_before>

export default ({ maxWidth }) => `

body {
  margin: 0;
}

.idyll-root {
  box-sizing: border-box;
  margin: 0 auto;
  padding: 60px 0;
  margin-bottom: 60px;
}

.section {
  padding: 0 10px;
  margin: 0 auto;
}

.article-header {
  width: 600px;
  max-width: 90vw;
  margin-bottom: 45px;
}

.inset {
  max-width: 400px;
  margin: 0 auto;
}

input {
  cursor: pointer;
}

.relative {
  position: relative;
}
.aside-container {
  position: relative;
}
.aside {
  position: absolute;
  width: 300px;
  right: calc((10vw + 600px + 150px) / -2);
}

.fixed {
  position: fixed;
  display: flex;
  align-self: center;
  flex-direction: column;
  align-items: center;
  right: 25px;
  top: 0;
  bottom: 0;
  width: calc((80vw - 600px) - 50px);
  justify-content: center;
}

.fixed div {
  width: 100%;
}

.idyll-scroll-graphic {
  position: -webkit-sticky;
  position: sticky;
}

.idyll-scroll-graphic img {
  max-height: 100vh;
}

.component-debug-view {
  position: relative;
  transition: background-color 0.3s ease-in;
}

.author-view-button {
  position: absolute;
  top: 0;
  right: 0;
  opacity: .38;
  background-color: #E7E3D0;
  background-image: url('https://idyll-lang.org/static/images/quill-icon.png');
  background-repeat: no-repeat;
  background-size: contain;
  width: 35px;
  height: 35px;
  margin-right: 10px;
  box-sizing: border-box;
  border-radius: 17px;
  cursor: pointer;
}

.author-view-button:focus {
  outline: none;
}

.component-debug-view:hover > .author-view-button {
  opacity: 0.87;
  transition: opacity 600ms linear;
}

.author-component-view {
  display: flex;
  flex-direction: column;
}

.author-component-view h2, .author-component-view h3 {
  margin-top: 5px;
  margin-bottom: 5px;
}

.props-table {
  width: 100%;
  display: table;
  border: 1px solid #A4A2A2;
  border-radius: 20px;
  margin: 0;
}

.debug-collapse {
  overflow: hidden;
  transition: height 0.3s ease-in;
  margin: 0;
  box-sizing: border-box;
}

.icon-links {
  display: flex;
  flex-direction: column-reverse;
}

.icon-link {
  width: 20px;
  height: 20px;
}

.icon-link-image {
  cursor: pointer;
}

.icon-tooltip {
  visibility: hidden;
  font-family: 'Courier New';
  font-size: 12px;
  margin-top: 3px;
}

.icon-link:hover ~ .icon-tooltip {
  visibility: visible;
}

.icon-link, .icon-tooltip {
  align-self: center;
}

.button-tooltip {
  background-color: black !important;
  padding: 0 5px;
}

@media all and (max-width: 1600px) {
  .fixed {
    width: calc((85vw - 600px) - 50px);
  }
}

@media all and (max-width: 1000px) {
  /* put your css styles in here */
  .desktop {
    display: none;
  }
  .relative {
    position: static;
  }
  .aside {
    position: static;
    width: 100%;
    right: 0;
  }

  .hed {
    width: 100%;
  }

  .idyll-root {
    padding: 15px 0;
  }

  .idyll-root {
    width: 90vw;
    max-width: 600px;
    margin: 0 auto;
    padding-bottom: 80vh;
  }
  .fixed {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    top: initial;
    background: white;
    padding: 20px 0;
    border-top: solid 2px black;
  }
}
`
<commit_msg>reduce line height for better readability<commit_after>

export default ({ maxWidth }) => `

body {
  margin: 0;
}

.idyll-root {
  box-sizing: border-box;
  margin: 0 auto;
  padding: 60px 0;
  margin-bottom: 60px;
}

.section {
  padding: 0 10px;
  margin: 0 auto;
}

.article-header {
  width: 600px;
  max-width: 90vw;
  margin-bottom: 45px;
}

.inset {
  max-width: 400px;
  margin: 0 auto;
}

input {
  cursor: pointer;
}

.relative {
  position: relative;
}
.aside-container {
  position: relative;
}
.aside {
  position: absolute;
  width: 300px;
  right: calc((10vw + 600px + 150px) / -2);
}

.fixed {
  position: fixed;
  display: flex;
  align-self: center;
  flex-direction: column;
  align-items: center;
  right: 25px;
  top: 0;
  bottom: 0;
  width: calc((80vw - 600px) - 50px);
  justify-content: center;
}

.fixed div {
  width: 100%;
}

.idyll-scroll-graphic {
  position: -webkit-sticky;
  position: sticky;
}

.idyll-scroll-graphic img {
  max-height: 100vh;
}

.component-debug-view {
  position: relative;
  transition: background-color 0.3s ease-in;
}

.author-view-button {
  position: absolute;
  top: 0;
  right: 0;
  opacity: .38;
  background-color: #E7E3D0;
  background-image: url('https://idyll-lang.org/static/images/quill-icon.png');
  background-repeat: no-repeat;
  background-size: contain;
  width: 35px;
  height: 35px;
  margin-right: 10px;
  box-sizing: border-box;
  border-radius: 17px;
  cursor: pointer;
}

.author-view-button:focus {
  outline: none;
}

.component-debug-view:hover > .author-view-button {
  opacity: 0.87;
  transition: opacity 600ms linear;
}

.author-component-view {
  display: flex;
  flex-direction: column;
}

.author-component-view h2, .author-component-view h3 {
  margin-top: 5px;
  margin-bottom: 5px;
}

.props-table {
  width: 100%;
  display: table;
  border: 1px solid #A4A2A2;
  border-radius: 20px;
  margin: 0;
}

.debug-collapse {
  overflow: hidden;
  transition: height 0.3s ease-in;
  margin: 0;
  box-sizing: border-box;
}

.icon-links {
  display: flex;
  flex-direction: column-reverse;
}

.icon-link {
  width: 20px;
  height: 20px;
}

.icon-link-image {
  cursor: pointer;
}

.icon-tooltip {
  visibility: hidden;
  font-family: 'Courier New';
  font-size: 12px;
  margin-top: 3px;
}

.icon-link:hover ~ .icon-tooltip {
  visibility: visible;
}

.icon-link, .icon-tooltip {
  align-self: center;
}

.button-tooltip {
  background-color: black !important;
  padding: 0 5px;
  line-height: 0.2;
}

@media all and (max-width: 1600px) {
  .fixed {
    width: calc((85vw - 600px) - 50px);
  }
}

@media all and (max-width: 1000px) {
  /* put your css styles in here */
  .desktop {
    display: none;
  }
  .relative {
    position: static;
  }
  .aside {
    position: static;
    width: 100%;
    right: 0;
  }

  .hed {
    width: 100%;
  }

  .idyll-root {
    padding: 15px 0;
  }

  .idyll-root {
    width: 90vw;
    max-width: 600px;
    margin: 0 auto;
    padding-bottom: 80vh;
  }
  .fixed {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    top: initial;
    background: white;
    padding: 20px 0;
    border-top: solid 2px black;
  }
}
`
<|endoftext|>