diff --git a/package.json b/package.json index ad6ae660c..5ba9101f2 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "build": "webpack --config webpack.production.js --progress --colors" }, "dependencies": { + "Idle.Js": "github:shawnmclean/Idle.js", "async": "^2.0.1", "blueimp-md5": "^2.4.0", "body-parser": "^1.15.2", @@ -88,6 +89,7 @@ "shortid": "2.2.6", "socket.io": "1.5.0", "socket.io-client": "^1.5.0", + "spin.js": "^2.3.2", "sqlite3": "^3.1.6", "store": "^1.3.20", "string": "^3.3.1", diff --git a/public/vendor/codemirror-spell-checker/spell-checker.min.js b/public/vendor/codemirror-spell-checker/spell-checker.min.js index 4e3921a67..d5dd34d7a 100644 --- a/public/vendor/codemirror-spell-checker/spell-checker.min.js +++ b/public/vendor/codemirror-spell-checker/spell-checker.min.js @@ -4,4 +4,4 @@ * @link https://github.com/NextStepWebs/codemirror-spell-checker * @license MIT */ -"use strict";var Typo=function(e,t,r,n){if(n=n||{},this.platform=n.platform||"chrome",this.dictionary=null,this.rules={},this.dictionaryTable={},this.compoundRules=[],this.compoundRuleCodes={},this.replacementTable=[],this.flags=n.flags||{},e){if(this.dictionary=e,"chrome"==this.platform)t||(t=this._readFile(chrome.extension.getURL("lib/typo/dictionaries/"+e+"/"+e+".aff"))),r||(r=this._readFile(chrome.extension.getURL("lib/typo/dictionaries/"+e+"/"+e+".dic")));else{var i=n.dictionaryPath||"";t||(t=this._readFile(i+"/"+e+"/"+e+".aff")),r||(r=this._readFile(i+"/"+e+"/"+e+".dic"))}this.rules=this._parseAFF(t),this.compoundRuleCodes={};for(var a=0,s=this.compoundRules.length;s>a;a++)for(var o=this.compoundRules[a],l=0,u=o.length;u>l;l++)this.compoundRuleCodes[o[l]]=[];"ONLYINCOMPOUND"in this.flags&&(this.compoundRuleCodes[this.flags.ONLYINCOMPOUND]=[]),this.dictionaryTable=this._parseDIC(r);for(var a in this.compoundRuleCodes)0==this.compoundRuleCodes[a].length&&delete this.compoundRuleCodes[a];for(var a=0,s=this.compoundRules.length;s>a;a++){for(var h=this.compoundRules[a],c="",l=0,u=h.length;u>l;l++){var p=h[l];c+=p in this.compoundRuleCodes?"("+this.compoundRuleCodes[p].join("|")+")":p}this.compoundRules[a]=RegExp(c,"i")}}return this};Typo.prototype={load:function(e){for(var t in e)this[t]=e[t];return this},_readFile:function(e,t){t||(t="ISO8859-1");var r=new XMLHttpRequest;return r.open("GET",e,!1),r.overrideMimeType&&r.overrideMimeType("text/plain; charset="+t),r.send(null),r.responseText},_parseAFF:function(e){var t={};e=this._removeAffixComments(e);for(var r=e.split("\n"),n=0,i=r.length;i>n;n++){var a=r[n],s=a.split(/\s+/),o=s[0];if("PFX"==o||"SFX"==o){for(var l=s[1],u=s[2],h=parseInt(s[3],10),c=[],p=n+1,f=n+1+h;f>p;p++){var a=r[p],d=a.split(/\s+/),v=d[2],g=d[3].split("/"),m=g[0];"0"===m&&(m="");var y=this.parseRuleCodes(g[1]),_=d[4],C={};C.add=m,y.length>0&&(C.continuationClasses=y),"."!==_&&(C.match=RegExp("SFX"===o?_+"$":"^"+_)),"0"!=v&&(C.remove="SFX"===o?RegExp(v+"$"):v),c.push(C)}t[l]={type:o,combineable:"Y"==u,entries:c},n+=h}else if("COMPOUNDRULE"===o){for(var h=parseInt(s[1],10),p=n+1,f=n+1+h;f>p;p++){var a=r[p],d=a.split(/\s+/);this.compoundRules.push(d[1])}n+=h}else if("REP"===o){var d=a.split(/\s+/);3===d.length&&this.replacementTable.push([d[1],d[2]])}else this.flags[o]=s[1]}return t},_removeAffixComments:function(e){return e=e.replace(/#.*$/gm,""),e=e.replace(/^\s\s*/m,"").replace(/\s\s*$/m,""),e=e.replace(/\n{2,}/g,"\n"),e=e.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},_parseDIC:function(e){function t(e,t){e in n&&"object"==typeof n[e]||(n[e]=[]),n[e].push(t)}e=this._removeDicComments(e);for(var r=e.split("\n"),n={},i=1,a=r.length;a>i;i++){var s=r[i],o=s.split("/",2),l=o[0];if(o.length>1){var u=this.parseRuleCodes(o[1]);"NEEDAFFIX"in this.flags&&-1!=u.indexOf(this.flags.NEEDAFFIX)||t(l,u);for(var h=0,c=u.length;c>h;h++){var p=u[h],f=this.rules[p];if(f)for(var d=this._applyRule(l,f),v=0,g=d.length;g>v;v++){var m=d[v];if(t(m,[]),f.combineable)for(var y=h+1;c>y;y++){var _=u[y],C=this.rules[_];if(C&&C.combineable&&f.type!=C.type)for(var R=this._applyRule(m,C),b=0,F=R.length;F>b;b++){var x=R[b];t(x,[])}}}p in this.compoundRuleCodes&&this.compoundRuleCodes[p].push(l)}}else t(l.trim(),[])}return n},_removeDicComments:function(e){return e=e.replace(/^\t.*$/gm,"")},parseRuleCodes:function(e){if(!e)return[];if(!("FLAG"in this.flags))return e.split("");if("long"===this.flags.FLAG){for(var t=[],r=0,n=e.length;n>r;r+=2)t.push(e.substr(r,2));return t}return"num"===this.flags.FLAG?textCode.split(","):void 0},_applyRule:function(e,t){for(var r=t.entries,n=[],i=0,a=r.length;a>i;i++){var s=r[i];if(!s.match||e.match(s.match)){var o=e;if(s.remove&&(o=o.replace(s.remove,"")),"SFX"===t.type?o+=s.add:o=s.add+o,n.push(o),"continuationClasses"in s)for(var l=0,u=s.continuationClasses.length;u>l;l++){var h=this.rules[s.continuationClasses[l]];h&&(n=n.concat(this._applyRule(o,h)))}}}return n},check:function(e){var t=e.replace(/^\s\s*/,"").replace(/\s\s*$/,"");if(this.checkExact(t))return!0;if(t.toUpperCase()===t){var r=t[0]+t.substring(1).toLowerCase();if(this.hasFlag(r,"KEEPCASE"))return!1;if(this.checkExact(r))return!0}var n=t.toLowerCase();if(n!==t){if(this.hasFlag(n,"KEEPCASE"))return!1;if(this.checkExact(n))return!0}return!1},checkExact:function(e){var t=this.dictionaryTable[e];if(void 0===t){if("COMPOUNDMIN"in this.flags&&e.length>=this.flags.COMPOUNDMIN)for(var r=0,n=this.compoundRules.length;n>r;r++)if(e.match(this.compoundRules[r]))return!0;return!1}for(var r=0,n=t.length;n>r;r++)if(!this.hasFlag(e,"ONLYINCOMPOUND",t[r]))return!0;return!1},hasFlag:function(e,t,r){if(t in this.flags){if(void 0===r)var r=Array.prototype.concat.apply([],this.dictionaryTable[e]);if(r&&-1!==r.indexOf(this.flags[t]))return!0}return!1},alphabet:"",suggest:function(e,t){function r(e){for(var t=[],r=0,n=e.length;n>r;r++){for(var i=e[r],a=[],s=0,o=i.length+1;o>s;s++)a.push([i.substring(0,s),i.substring(s,i.length)]);for(var l=[],s=0,o=a.length;o>s;s++){var h=a[s];h[1]&&l.push(h[0]+h[1].substring(1))}for(var c=[],s=0,o=a.length;o>s;s++){var h=a[s];h[1].length>1&&c.push(h[0]+h[1][1]+h[1][0]+h[1].substring(2))}for(var p=[],s=0,o=a.length;o>s;s++){var h=a[s];if(h[1])for(var f=0,d=u.alphabet.length;d>f;f++)p.push(h[0]+u.alphabet[f]+h[1].substring(1))}for(var v=[],s=0,o=a.length;o>s;s++){var h=a[s];if(h[1])for(var f=0,d=u.alphabet.length;d>f;f++)p.push(h[0]+u.alphabet[f]+h[1])}t=t.concat(l),t=t.concat(c),t=t.concat(p),t=t.concat(v)}return t}function n(e){for(var t=[],r=0;rh;h++)o[h]in l?l[o[h]]+=1:l[o[h]]=1;var p=[];for(var h in l)p.push([h,l[h]]);p.sort(i).reverse();for(var f=[],h=0,c=Math.min(t,p.length);c>h;h++)u.hasFlag(p[h][0],"NOSUGGEST")||f.push(p[h][0]);return f}if(t||(t=5),this.check(e))return[];for(var a=0,s=this.replacementTable.length;s>a;a++){var o=this.replacementTable[a];if(-1!==e.indexOf(o[0])){var l=e.replace(o[0],o[1]);if(this.check(l))return[l]}}var u=this;return u.alphabet="abcdefghijklmnopqrstuvwxyz",i(e)}};var num_loaded=0,aff_loading=!1,dic_loading=!1,aff_data="",dic_data="",typo;CodeMirror.defineMode("spell-checker",function(e){if(!aff_loading){aff_loading=!0;var t=new XMLHttpRequest;t.open("GET",serverurl+"/vendor/codemirror-spell-checker/en_US.aff",!0),t.onload=function(){4===t.readyState&&200===t.status&&(aff_data=t.responseText,num_loaded++,2==num_loaded&&(typo=new Typo("en_US",aff_data,dic_data,{platform:"any"})))},t.send(null)}if(!dic_loading){dic_loading=!0;var r=new XMLHttpRequest;r.open("GET",serverurl+"/vendor/codemirror-spell-checker/en_US.dic",!0),r.onload=function(){4===r.readyState&&200===r.status&&(dic_data=r.responseText,num_loaded++,2==num_loaded&&(typo=new Typo("en_US",aff_data,dic_data,{platform:"any"})))},r.send(null)}var n="!\"'#$%&()*+,-./:;<=>?@[\\]^_`{|}~ ",i=/^[A-Za-z][A-Za-z0-9]+$/,a={token:function(e){var t=e.peek(),r="";if(n.includes(t))return e.next(),null;for(;null!=(t=e.peek())&&!n.includes(t);)r+=t,e.next();return i.test(r)&&typo&&!typo.check(r)?"spell-error":null}},s=CodeMirror.getMode(e,e.backdrop||"text/plain");return CodeMirror.overlayMode(s,a,!0)}),String.prototype.includes||(String.prototype.includes=function(){return-1!==String.prototype.indexOf.apply(this,arguments)}); \ No newline at end of file +"use strict";var Typo=function(e,t,r,n){if(n=n||{},this.platform=n.platform||"chrome",this.dictionary=null,this.rules={},this.dictionaryTable={},this.compoundRules=[],this.compoundRuleCodes={},this.replacementTable=[],this.flags=n.flags||{},e){if(this.dictionary=e,"chrome"==this.platform)t||(t=this._readFile(chrome.extension.getURL("lib/typo/dictionaries/"+e+"/"+e+".aff"))),r||(r=this._readFile(chrome.extension.getURL("lib/typo/dictionaries/"+e+"/"+e+".dic")));else{var i=n.dictionaryPath||"";t||(t=this._readFile(i+"/"+e+"/"+e+".aff")),r||(r=this._readFile(i+"/"+e+"/"+e+".dic"))}this.rules=this._parseAFF(t),this.compoundRuleCodes={};for(var a=0,s=this.compoundRules.length;s>a;a++)for(var o=this.compoundRules[a],l=0,u=o.length;u>l;l++)this.compoundRuleCodes[o[l]]=[];"ONLYINCOMPOUND"in this.flags&&(this.compoundRuleCodes[this.flags.ONLYINCOMPOUND]=[]),this.dictionaryTable=this._parseDIC(r);for(var a in this.compoundRuleCodes)0==this.compoundRuleCodes[a].length&&delete this.compoundRuleCodes[a];for(var a=0,s=this.compoundRules.length;s>a;a++){for(var h=this.compoundRules[a],c="",l=0,u=h.length;u>l;l++){var p=h[l];c+=p in this.compoundRuleCodes?"("+this.compoundRuleCodes[p].join("|")+")":p}this.compoundRules[a]=RegExp(c,"i")}}return this};Typo.prototype={load:function(e){for(var t in e)this[t]=e[t];return this},_readFile:function(e,t){t||(t="ISO8859-1");var r=new XMLHttpRequest;return r.open("GET",e,!1),r.overrideMimeType&&r.overrideMimeType("text/plain; charset="+t),r.send(null),r.responseText},_parseAFF:function(e){var t={};e=this._removeAffixComments(e);for(var r=e.split("\n"),n=0,i=r.length;i>n;n++){var a=r[n],s=a.split(/\s+/),o=s[0];if("PFX"==o||"SFX"==o){for(var l=s[1],u=s[2],h=parseInt(s[3],10),c=[],p=n+1,f=n+1+h;f>p;p++){var a=r[p],d=a.split(/\s+/),v=d[2],g=d[3].split("/"),m=g[0];"0"===m&&(m="");var y=this.parseRuleCodes(g[1]),_=d[4],C={};C.add=m,y.length>0&&(C.continuationClasses=y),"."!==_&&(C.match=RegExp("SFX"===o?_+"$":"^"+_)),"0"!=v&&(C.remove="SFX"===o?RegExp(v+"$"):v),c.push(C)}t[l]={type:o,combineable:"Y"==u,entries:c},n+=h}else if("COMPOUNDRULE"===o){for(var h=parseInt(s[1],10),p=n+1,f=n+1+h;f>p;p++){var a=r[p],d=a.split(/\s+/);this.compoundRules.push(d[1])}n+=h}else if("REP"===o){var d=a.split(/\s+/);3===d.length&&this.replacementTable.push([d[1],d[2]])}else this.flags[o]=s[1]}return t},_removeAffixComments:function(e){return e=e.replace(/#.*$/gm,""),e=e.replace(/^\s\s*/m,"").replace(/\s\s*$/m,""),e=e.replace(/\n{2,}/g,"\n"),e=e.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},_parseDIC:function(e){function t(e,t){e in n&&"object"==typeof n[e]||(n[e]=[]),n[e].push(t)}e=this._removeDicComments(e);for(var r=e.split("\n"),n={},i=1,a=r.length;a>i;i++){var s=r[i],o=s.split("/",2),l=o[0];if(o.length>1){var u=this.parseRuleCodes(o[1]);"NEEDAFFIX"in this.flags&&-1!=u.indexOf(this.flags.NEEDAFFIX)||t(l,u);for(var h=0,c=u.length;c>h;h++){var p=u[h],f=this.rules[p];if(f)for(var d=this._applyRule(l,f),v=0,g=d.length;g>v;v++){var m=d[v];if(t(m,[]),f.combineable)for(var y=h+1;c>y;y++){var _=u[y],C=this.rules[_];if(C&&C.combineable&&f.type!=C.type)for(var R=this._applyRule(m,C),b=0,F=R.length;F>b;b++){var x=R[b];t(x,[])}}}p in this.compoundRuleCodes&&this.compoundRuleCodes[p].push(l)}}else t(l.trim(),[])}return n},_removeDicComments:function(e){return e=e.replace(/^\t.*$/gm,"")},parseRuleCodes:function(e){if(!e)return[];if(!("FLAG"in this.flags))return e.split("");if("long"===this.flags.FLAG){for(var t=[],r=0,n=e.length;n>r;r+=2)t.push(e.substr(r,2));return t}return"num"===this.flags.FLAG?textCode.split(","):void 0},_applyRule:function(e,t){for(var r=t.entries,n=[],i=0,a=r.length;a>i;i++){var s=r[i];if(!s.match||e.match(s.match)){var o=e;if(s.remove&&(o=o.replace(s.remove,"")),"SFX"===t.type?o+=s.add:o=s.add+o,n.push(o),"continuationClasses"in s)for(var l=0,u=s.continuationClasses.length;u>l;l++){var h=this.rules[s.continuationClasses[l]];h&&(n=n.concat(this._applyRule(o,h)))}}}return n},check:function(e){var t=e.replace(/^\s\s*/,"").replace(/\s\s*$/,"");if(this.checkExact(t))return!0;if(t.toUpperCase()===t){var r=t[0]+t.substring(1).toLowerCase();if(this.hasFlag(r,"KEEPCASE"))return!1;if(this.checkExact(r))return!0}var n=t.toLowerCase();if(n!==t){if(this.hasFlag(n,"KEEPCASE"))return!1;if(this.checkExact(n))return!0}return!1},checkExact:function(e){var t=this.dictionaryTable[e];if(void 0===t){if("COMPOUNDMIN"in this.flags&&e.length>=this.flags.COMPOUNDMIN)for(var r=0,n=this.compoundRules.length;n>r;r++)if(e.match(this.compoundRules[r]))return!0;return!1}for(var r=0,n=t.length;n>r;r++)if(!this.hasFlag(e,"ONLYINCOMPOUND",t[r]))return!0;return!1},hasFlag:function(e,t,r){if(t in this.flags){if(void 0===r)var r=Array.prototype.concat.apply([],this.dictionaryTable[e]);if(r&&-1!==r.indexOf(this.flags[t]))return!0}return!1},alphabet:"",suggest:function(e,t){function r(e){for(var t=[],r=0,n=e.length;n>r;r++){for(var i=e[r],a=[],s=0,o=i.length+1;o>s;s++)a.push([i.substring(0,s),i.substring(s,i.length)]);for(var l=[],s=0,o=a.length;o>s;s++){var h=a[s];h[1]&&l.push(h[0]+h[1].substring(1))}for(var c=[],s=0,o=a.length;o>s;s++){var h=a[s];h[1].length>1&&c.push(h[0]+h[1][1]+h[1][0]+h[1].substring(2))}for(var p=[],s=0,o=a.length;o>s;s++){var h=a[s];if(h[1])for(var f=0,d=u.alphabet.length;d>f;f++)p.push(h[0]+u.alphabet[f]+h[1].substring(1))}for(var v=[],s=0,o=a.length;o>s;s++){var h=a[s];if(h[1])for(var f=0,d=u.alphabet.length;d>f;f++)p.push(h[0]+u.alphabet[f]+h[1])}t=t.concat(l),t=t.concat(c),t=t.concat(p),t=t.concat(v)}return t}function n(e){for(var t=[],r=0;rh;h++)o[h]in l?l[o[h]]+=1:l[o[h]]=1;var p=[];for(var h in l)p.push([h,l[h]]);p.sort(i).reverse();for(var f=[],h=0,c=Math.min(t,p.length);c>h;h++)u.hasFlag(p[h][0],"NOSUGGEST")||f.push(p[h][0]);return f}if(t||(t=5),this.check(e))return[];for(var a=0,s=this.replacementTable.length;s>a;a++){var o=this.replacementTable[a];if(-1!==e.indexOf(o[0])){var l=e.replace(o[0],o[1]);if(this.check(l))return[l]}}var u=this;return u.alphabet="abcdefghijklmnopqrstuvwxyz",i(e)}};window.num_loaded=0;var aff_loading=!1,dic_loading=!1,aff_data="",dic_data="",typo;CodeMirror.defineMode("spell-checker",function(e){if(!aff_loading){aff_loading=!0;var t=new XMLHttpRequest;t.open("GET",serverurl+"/vendor/codemirror-spell-checker/en_US.aff",!0),t.onload=function(){4===t.readyState&&200===t.status&&(aff_data=t.responseText,num_loaded++,2==num_loaded&&(typo=new Typo("en_US",aff_data,dic_data,{platform:"any"})))},t.send(null)}if(!dic_loading){dic_loading=!0;var r=new XMLHttpRequest;r.open("GET",serverurl+"/vendor/codemirror-spell-checker/en_US.dic",!0),r.onload=function(){4===r.readyState&&200===r.status&&(dic_data=r.responseText,num_loaded++,2==num_loaded&&(typo=new Typo("en_US",aff_data,dic_data,{platform:"any"})))},r.send(null)}var n="!\"'#$%&()*+,-./:;<=>?@[\\]^_`{|}~ ",i=/^[A-Za-z][A-Za-z0-9]+$/,a={token:function(e){var t=e.peek(),r="";if(n.includes(t))return e.next(),null;for(;null!=(t=e.peek())&&!n.includes(t);)r+=t,e.next();return i.test(r)&&typo&&!typo.check(r)?"spell-error":null}},s=CodeMirror.getMode(e,e.backdrop||"text/plain");return CodeMirror.overlayMode(s,a,!0)}),String.prototype.includes||(String.prototype.includes=function(){return-1!==String.prototype.indexOf.apply(this,arguments)}); diff --git a/public/views/foot.ejs b/public/views/foot.ejs index 55be9e54b..0ce4b85b4 100644 --- a/public/views/foot.ejs +++ b/public/views/foot.ejs @@ -20,10 +20,8 @@ <% } %> - - diff --git a/public/views/index.ejs b/public/views/index.ejs index 939337712..f24a039e9 100644 --- a/public/views/index.ejs +++ b/public/views/index.ejs @@ -203,7 +203,6 @@ <% } else { %> - <% } %> diff --git a/webpackBaseConfig.js b/webpackBaseConfig.js index c0b24f8ff..df48e6583 100644 --- a/webpackBaseConfig.js +++ b/webpackBaseConfig.js @@ -39,10 +39,14 @@ module.exports = { "expose?filterXSS!xss", "js-url", "bootstrap", + "expose?Spinner!spin.js", + "script!Idle.Js", "expose?Viz!viz.js", "expose?ListPagination!list.pagination.js/dist/list.pagination.js", path.join(__dirname, 'public/vendor/codemirror/codemirror.min.js'), + path.join(__dirname, 'public/vendor/select2/select2.min.js'), path.join(__dirname, 'public/vendor/inlineAttachment/inline-attachment.js'), + path.join(__dirname, 'public/vendor/codemirror-spell-checker/spell-checker.min.js'), path.join(__dirname, 'public/vendor/inlineAttachment/codemirror.inline-attachment.js'), path.join(__dirname, 'public/vendor/ot/ot.min.js') ] @@ -96,7 +100,9 @@ module.exports = { include: [ path.join(__dirname, 'public/vendor/codemirror/codemirror.min.js'), path.join(__dirname, 'public/vendor/inlineAttachment/inline-attachment.js'), + path.join(__dirname, 'public/vendor/select2/select2.min.js'), path.join(__dirname, 'public/vendor/inlineAttachment/codemirror.inline-attachment.js'), + path.join(__dirname, 'public/vendor/codemirror-spell-checker/spell-checker.min.js'), path.join(__dirname, 'public/vendor/ot/ot.min.js') ] }]