updated console and server repo name
This commit is contained in:
25
private-console/web/public_js/bower.json
Normal file
25
private-console/web/public_js/bower.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "irext",
|
||||
"version": "0.0.1",
|
||||
"description": "console of irext",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/irext/irext-cli"
|
||||
},
|
||||
"keywords": [
|
||||
"IRDA"
|
||||
],
|
||||
"author": "strawmanbobi",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bootstrap": "^3.3.7",
|
||||
"bootstrap-multiselect": "^0.9.13",
|
||||
"bootstrap-spinner": "^1.1.1",
|
||||
"bootstrap-table": "^1.11.0",
|
||||
"bootstrap-progressbar": "^0.9.0",
|
||||
"highcharts": "^5.0.6",
|
||||
"jquery": "^2.2.4",
|
||||
"select2": "^4.0.3",
|
||||
"toastr": "^2.1.3"
|
||||
}
|
||||
}
|
||||
528
private-console/web/public_js/chinese/await.js
Normal file
528
private-console/web/public_js/chinese/await.js
Normal file
@@ -0,0 +1,528 @@
|
||||
// ########################################################################
|
||||
// PROLOGUE - LICENSE
|
||||
|
||||
/*
|
||||
Copyright (c) 2013 by Greg Reimer
|
||||
https://github.com/greim
|
||||
http://obadger.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
(function(){
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// CLOSURE SCOPE VARS
|
||||
|
||||
var slice = Array.prototype.slice;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// PROGRESS CLASS
|
||||
|
||||
function Progress(){}
|
||||
Progress.prototype = {
|
||||
getAverage: function(){
|
||||
var names = Object.keys(this);
|
||||
var total = 0;
|
||||
for (var i=0; i<names.length; i++) {
|
||||
total += this[names[i]];
|
||||
}
|
||||
var average = total / names.length;
|
||||
return average;
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// GOTTEN CLASS
|
||||
|
||||
function Gotten(){}
|
||||
Gotten.prototype = {
|
||||
forEach: Array.prototype.forEach,
|
||||
map: Array.prototype.map,
|
||||
some: Array.prototype.some,
|
||||
every: Array.prototype.every,
|
||||
reduce: Array.prototype.reduce,
|
||||
slice: Array.prototype.slice,
|
||||
join: Array.prototype.join,
|
||||
keys: function(){
|
||||
return Object.keys(this);
|
||||
},
|
||||
values: function(){
|
||||
return Object.keys(this).map(function(name){
|
||||
return this[name];
|
||||
}, this)
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// PROMISE CLASS
|
||||
|
||||
function Promise() {
|
||||
this._progress = new Progress();
|
||||
this._built = false;
|
||||
this._slots = {};
|
||||
this._got = new Gotten();
|
||||
this._allbacks = [];
|
||||
this._failure = false;
|
||||
this._success = false;
|
||||
}
|
||||
|
||||
Promise.prototype = {
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Runs the given callback, passing it an instance of the promise,
|
||||
and then returning that same instance.
|
||||
*/
|
||||
run: function(cb, ctx){
|
||||
cb.call(ctx, this);
|
||||
return this;
|
||||
},
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
_on: function(event, cb, ctx){
|
||||
if (typeof cb !== 'function') {
|
||||
throw new Error('No callback provided.');
|
||||
}
|
||||
|
||||
// NOTE: It's possible for both this._success and this._failure
|
||||
// to be true at the same time. In such cases this._success
|
||||
// pre-empts this._failure.
|
||||
|
||||
if (this._success || this._failure) {
|
||||
// timeout guarantees cb gets
|
||||
// executed after return
|
||||
var thisProm = this;
|
||||
setTimeout(function(){
|
||||
if (event === 'resolve') {
|
||||
cb.call(ctx);
|
||||
}
|
||||
if (thisProm._success) {
|
||||
if (event === 'keep') {
|
||||
cb.call(ctx, thisProm._got);
|
||||
}
|
||||
} else {
|
||||
if (event === 'fail') {
|
||||
cb.apply(ctx, thisProm._failure);
|
||||
}
|
||||
}
|
||||
},0);
|
||||
} else {
|
||||
this._allbacks.push({
|
||||
callback:cb,
|
||||
context:ctx,
|
||||
type:event
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
onfail: function(cb, ctx){
|
||||
return this._on('fail', cb, ctx);
|
||||
},
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
onkeep: function(cb, ctx){
|
||||
return this._on('keep', cb, ctx);
|
||||
},
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
onresolve: function(cb, ctx){
|
||||
return this._on('resolve', cb, ctx);
|
||||
},
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
onprogress: function(cb, ctx){
|
||||
return this._on('progress', cb, ctx);
|
||||
},
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
failer: function(){
|
||||
var thisProm = this;
|
||||
return function(){
|
||||
return Promise.prototype.fail.apply(thisProm, arguments);
|
||||
};
|
||||
},
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
progress: function(){
|
||||
if (!this._allbacks) {
|
||||
return this;
|
||||
}
|
||||
var amounts = arguments[0];
|
||||
if (typeof arguments[0] === 'string' && typeof arguments[1] === 'number') {
|
||||
amounts = {};
|
||||
amounts[arguments[0]] = arguments[1];
|
||||
}
|
||||
Object.keys(amounts).forEach(function(name){
|
||||
var amount = amounts[name];
|
||||
if (this._slots[name] === undefined) {
|
||||
return;
|
||||
}
|
||||
amount = parseFloat(amount) || 0;
|
||||
amount = Math.max(Math.min(amount, 1), 0);
|
||||
this._progress[name] = amount;
|
||||
}, this);
|
||||
this._allbacks.forEach(function(allback){
|
||||
if (allback.type === 'progress') {
|
||||
allback.callback.call(allback.context, this._progress);
|
||||
}
|
||||
}, this);
|
||||
return this;
|
||||
},
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
Keep part of the promise.
|
||||
*/
|
||||
keep: function(name, data){
|
||||
if (data === undefined) {
|
||||
data = null;
|
||||
}
|
||||
if (this._got[name] !== undefined){
|
||||
return this;
|
||||
}
|
||||
if (this._slots[name] === undefined) {
|
||||
this._got[name] = data;
|
||||
return this;
|
||||
}
|
||||
if (!this._failure && !this._success){
|
||||
this._progress[name] = 1;
|
||||
this._slots[name] = true;
|
||||
this._got[name] = data;
|
||||
var kept = Object.keys(this._slots).every(function(item){
|
||||
return this._slots[item];
|
||||
}, this);
|
||||
if (kept) {
|
||||
this._success = true;
|
||||
this._allbacks.filter(function(obj){
|
||||
return obj.type === 'keep' || obj.type === 'resolve';
|
||||
}).forEach(function(obj){
|
||||
if (obj.type === 'keep') {
|
||||
obj.callback.call(obj.context, this._got);
|
||||
} else { // it's resolve
|
||||
obj.callback.call(obj.context);
|
||||
}
|
||||
}, this);
|
||||
// these are no longer needed, allow GC
|
||||
this._allbacks = undefined;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
Fail the promise for some reason.
|
||||
*/
|
||||
fail: function(){
|
||||
if (!this._failure && !this._success){
|
||||
this._failure = slice.call(arguments);
|
||||
this._allbacks.filter(function(obj){
|
||||
return obj.type === 'fail' || obj.type === 'resolve';
|
||||
}).forEach(function(obj){
|
||||
if (obj.type === 'fail') {
|
||||
obj.callback.apply(obj.context, this._failure);
|
||||
} else { // resolve
|
||||
obj.callback.call(obj.context);
|
||||
}
|
||||
}, this);
|
||||
// these are no longer needed, allow GC
|
||||
this._allbacks = undefined;
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Convenience function for error-first Node JS callback convention.
|
||||
*/
|
||||
nodify: function(){
|
||||
var items = slice.call(arguments);
|
||||
var thisProm = this;
|
||||
return function(err){
|
||||
if (err) {
|
||||
thisProm.fail(err);
|
||||
} else {
|
||||
var args = slice.call(arguments);
|
||||
if (typeof items[0] === 'function') {
|
||||
var cb = items[0];
|
||||
var ctx = items[1];
|
||||
cb.apply(ctx, args);
|
||||
} else {
|
||||
args.shift(); // lose the error
|
||||
items.forEach(function(thing, idx){
|
||||
if (thing !== null && thing !== undefined) {
|
||||
thisProm.keep(thing, args[idx]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
take: function(p2, map){
|
||||
if (this._success || this._failure) {
|
||||
// do nothing
|
||||
} else if (p2 instanceof Promise) {
|
||||
p2.onfail(this.failer());
|
||||
p2.onkeep(function(got){
|
||||
var taken = {}, gotItems = Object.keys(got);
|
||||
|
||||
// take any direct matches first
|
||||
gotItems.forEach(function(item){
|
||||
if (this._slots.hasOwnProperty(item)) {
|
||||
taken[item] = got[item];
|
||||
}
|
||||
}, this);
|
||||
|
||||
// take matches via mapping, overwrites any direct matches
|
||||
if (map) {
|
||||
gotItems.forEach(function(item){
|
||||
if (map.hasOwnProperty(item) && this._slots.hasOwnProperty(map[item])){
|
||||
taken[map[item]] = got[item];
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
Object.keys(taken).forEach(function(item){
|
||||
this.keep(item, taken[item]);
|
||||
}, this);
|
||||
}, this);
|
||||
} else if (p2 && typeof p2.then === 'function' && typeof map === 'string') {
|
||||
var name = map;
|
||||
var thisProm = this;
|
||||
p2.then(function(val){
|
||||
thisProm.keep(name, val);
|
||||
},function(err){
|
||||
thisProm.fail(err);
|
||||
},function(amount){
|
||||
thisProm.progress(name, amount);
|
||||
});
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
map: function(map){
|
||||
map || (map = {});
|
||||
var items = [];
|
||||
Object.keys(this._slots).forEach(function(item){
|
||||
if (map.hasOwnProperty(item)) {
|
||||
items.push(map[item]);
|
||||
} else {
|
||||
items.push(item);
|
||||
}
|
||||
});
|
||||
return await.apply(this, items).take(this, map);
|
||||
},
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
then: (function(){
|
||||
// private helper
|
||||
function defaultFulfilled(){ return this; }
|
||||
function defaultRejected(err){ throw err; }
|
||||
function fulfillWithResult(thenProm, returned, got) {
|
||||
if (returned instanceof await) {
|
||||
thenProm._buildState(returned);
|
||||
} else {
|
||||
var valueProm = await('value').run(function(prom){
|
||||
if (returned && typeof returned.then === 'function') {
|
||||
returned.then(function(val) {
|
||||
prom.keep('value', val);
|
||||
},function(reason) {
|
||||
prom.fail(reason);
|
||||
});
|
||||
} else {
|
||||
// 'returned' is some value other than a promise
|
||||
prom.keep('value', returned);
|
||||
}
|
||||
});
|
||||
thenProm._buildState(valueProm);
|
||||
}
|
||||
// accumulate values, as long as the old
|
||||
// values don't clobber the new ones
|
||||
if (got) {
|
||||
got.keys().forEach(function(name){
|
||||
if (!thenProm._slots.hasOwnProperty(name)) {
|
||||
thenProm.keep(name, got[name]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return function(onFulfilled, onRejected, onProgress) {
|
||||
if (typeof onFulfilled !== 'function') {
|
||||
onFulfilled = defaultFulfilled;
|
||||
}
|
||||
if (typeof onRejected !== 'function') {
|
||||
onRejected = defaultRejected;
|
||||
}
|
||||
var thisProm = this;
|
||||
// empty promise so it can build state from a future promise
|
||||
return await().run(function(thenProm) {
|
||||
thisProm
|
||||
.onkeep(function(got) {
|
||||
try {
|
||||
var returnedValue = onFulfilled.call(thisProm, got);
|
||||
fulfillWithResult(thenProm, returnedValue, got);
|
||||
} catch(ex) {
|
||||
thenProm.fail(ex);
|
||||
}
|
||||
})
|
||||
.onfail(function(reason) {
|
||||
try {
|
||||
var returnedValue = onRejected.call(thisProm, reason);
|
||||
fulfillWithResult(thenProm, returnedValue);
|
||||
} catch(ex) {
|
||||
thenProm.fail(ex);
|
||||
}
|
||||
});
|
||||
if (typeof onProgress === 'function') {
|
||||
thisProm.onprogress(function(progress) {
|
||||
try {
|
||||
// make sure to call the prototype getAverage() in case there's a slot named "getAverage"
|
||||
onProgress.call(thisProm, Progress.prototype.getAverage.call(thisProm._progress));
|
||||
} catch(ex) {}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
})(),
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
catch: function(onRejected){
|
||||
return this.then(null, onRejected);
|
||||
},
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
_buildState: function() {
|
||||
var items = slice.call(arguments);
|
||||
|
||||
// Check if already built.
|
||||
if (this._built) {
|
||||
throw new Error('cannot build state twice');
|
||||
} else {
|
||||
this._built = items.length > 0;
|
||||
}
|
||||
|
||||
// Populate slots.
|
||||
items.forEach(function(item) {
|
||||
if (item instanceof Promise) {
|
||||
Object.keys(item._slots).forEach(function(item) {
|
||||
this._slots[item] = false;
|
||||
}, this);
|
||||
} else {
|
||||
this._slots[item] = false;
|
||||
}
|
||||
}, this);
|
||||
|
||||
// Having populated slots, take promises.
|
||||
items.forEach(function(item) {
|
||||
if (item instanceof Promise) {
|
||||
this.take(item);
|
||||
}
|
||||
}, this);
|
||||
|
||||
Object.keys(this._slots).forEach(function(slot){
|
||||
this._progress[slot] = 0;
|
||||
}, this);
|
||||
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// FACTORY FUNCTION
|
||||
|
||||
// this is the function exported
|
||||
var await = function(){
|
||||
var prom = new Promise();
|
||||
prom._buildState.apply(prom, arguments);
|
||||
return prom;
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// AWAITING LISTS
|
||||
|
||||
await.all = function(list) {
|
||||
if (!list || list.length === 0) {
|
||||
return await('length').keep('length',0);
|
||||
}
|
||||
var keys = list.map(function(prom, idx){
|
||||
return idx;
|
||||
});
|
||||
keys.push('length');
|
||||
return await.apply(this, keys).run(function(allProm){
|
||||
allProm.keep('length', list.length);
|
||||
list.forEach(function(prom, idx){
|
||||
prom.onfail(allProm.failer());
|
||||
prom.onkeep(function(got){
|
||||
allProm.keep(idx, got);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// INSTANCEOF SUPPORT
|
||||
|
||||
// so that "foo instanceof await" works
|
||||
await.prototype = Promise.prototype;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// EXPORT
|
||||
|
||||
// for browsers
|
||||
try {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('await', [], function(){ return await; });
|
||||
} else {
|
||||
window.await = await;
|
||||
}
|
||||
} catch(err) {}
|
||||
|
||||
// for node
|
||||
try {
|
||||
module.exports = await;
|
||||
// back compat, for people calling this lib
|
||||
// like var await = require('await').await
|
||||
module.exports.await = await;
|
||||
} catch(err) {}
|
||||
|
||||
})();
|
||||
|
||||
104925
private-console/web/public_js/chinese/cedict_ts.u8
Normal file
104925
private-console/web/public_js/chinese/cedict_ts.u8
Normal file
File diff suppressed because it is too large
Load Diff
188
private-console/web/public_js/chinese/chinese.js
Normal file
188
private-console/web/public_js/chinese/chinese.js
Normal file
@@ -0,0 +1,188 @@
|
||||
function Trie(key) {
|
||||
this.key = key;
|
||||
this.value;
|
||||
}
|
||||
|
||||
Trie.prototype.put = function (name, value) {
|
||||
|
||||
var node = this,
|
||||
nameLength = name.length,
|
||||
i = 0,
|
||||
currentLetter;
|
||||
|
||||
for (i = 0; i < nameLength; i++) {
|
||||
currentLetter = name[i];
|
||||
node = node[currentLetter] || (node[currentLetter] = new Trie(currentLetter));
|
||||
}
|
||||
|
||||
node.value = value;
|
||||
node.name = name;
|
||||
|
||||
};
|
||||
|
||||
Trie.prototype.get = function (name) {
|
||||
var node = this,
|
||||
nameLength = name.length,
|
||||
i, node;
|
||||
|
||||
for (i = 0; i < nameLength; i++) {
|
||||
if (!(node = node[name[i]])) break;
|
||||
}
|
||||
|
||||
return (i === nameLength) ? node.value : null;
|
||||
};
|
||||
|
||||
function Chinese() {
|
||||
}
|
||||
|
||||
Chinese.prototype.loaded = await("dict-loaded");
|
||||
Chinese.prototype.dictionary = new Trie();
|
||||
|
||||
Chinese.prototype.toEnglish = function(value) {
|
||||
var entry = this.getFirstMatchingEntry(value);
|
||||
|
||||
if(entry) {
|
||||
return entry["en"];
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
Chinese.prototype.toPinyin = function(value) {
|
||||
var result = "";
|
||||
var pos = 0;
|
||||
|
||||
while(true) {
|
||||
var currentChar = value[pos];
|
||||
if(!currentChar) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(!(currentChar.charCodeAt(0) >= 19968 && currentChar.charCodeAt(0) <= 64041)) {
|
||||
// It's not a chinese character
|
||||
result += currentChar;
|
||||
pos += 1;
|
||||
}
|
||||
else {
|
||||
// It's a chinese character. start by trying to find a long word match,
|
||||
// and if it fails, all the way down to a single hanzi.
|
||||
var match = null;
|
||||
var match_length = 0;
|
||||
|
||||
for(var j = 4; j > 0; j--) {
|
||||
match = this.getFirstMatchingEntry(value.substring(pos, pos + j));
|
||||
match_length = j;
|
||||
if(match) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(match && match["pin"]) {
|
||||
result += match["pin"].replace(/\s/g, '');
|
||||
pos += match_length;
|
||||
}
|
||||
else {
|
||||
result += currentChar;
|
||||
pos += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Chinese.prototype.toTraditional = function(value) {
|
||||
var entry = this.getFirstMatchingEntry(value);
|
||||
|
||||
if(!entry) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return entry["trad"];
|
||||
}
|
||||
|
||||
Chinese.prototype.toSimplified = function(value) {
|
||||
var entry = this.getFirstMatchingEntry(value);
|
||||
|
||||
if(!entry) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return entry["simp"];
|
||||
}
|
||||
|
||||
Chinese.prototype.determineBeginningWord = function(value) {
|
||||
for(var i = value.length; i > 0; i--) {
|
||||
var entry = this.getFirstMatchingEntry(value.substring(0, i));
|
||||
if(entry) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Chinese.prototype.getFirstMatchingEntry = function(value) {
|
||||
return this.dictionary.get(value + "0");
|
||||
}
|
||||
|
||||
Chinese.prototype.getMatchingEntries = function(value) {
|
||||
var results = new Array();
|
||||
var index = 0;
|
||||
while(true) {
|
||||
var entry = this.dictionary.get(value + index.toString());
|
||||
if(!entry) {
|
||||
break;
|
||||
}
|
||||
|
||||
results.push(entry);
|
||||
index += 1;
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
$.get('src/cedict_ts.u8', function(myContentFile) {
|
||||
var lines = myContentFile.split("\r\n");
|
||||
|
||||
// Build a simple Trie structure
|
||||
for(var i = 0; i < lines.length; i++) {
|
||||
// Skip empty lines and comments
|
||||
if(!lines[i] || lines[i] === "" || lines[i].substring(0, 1) === "#") {
|
||||
continue;
|
||||
}
|
||||
|
||||
// CC-CEDICT format:
|
||||
// Traditional Simplified [pin1 yin1] /English equivalent 1/equivalent 2/
|
||||
var line_data = {};
|
||||
|
||||
// Parse the dictionary entry into its respective parts
|
||||
var results = [];
|
||||
results = lines[i].split(" ", 2);
|
||||
line_data["trad"] = results[0] ;
|
||||
line_data["simp"] = results[1];
|
||||
|
||||
lines[i] = lines[i].substring(lines[i].indexOf("[") + 1, lines[i].length);
|
||||
|
||||
line_data["pin"] = lines[i].substring(0, lines[i].indexOf("]"));
|
||||
line_data["en"] = lines[i].substring(lines[i].indexOf("/") + 1, lines[i].lastIndexOf("/"));
|
||||
|
||||
var existingCountSimplified = 0;
|
||||
if(Chinese.prototype.dictionary.get(line_data["simp"] + "0")) {
|
||||
existingCountSimplified = Chinese.prototype.getMatchingEntries(line_data["simp"]).length;
|
||||
}
|
||||
Chinese.prototype.dictionary.put(line_data["simp"] + existingCountSimplified.toString(), line_data);
|
||||
|
||||
if(line_data["simp"] !== line_data["trad"] + "0") {
|
||||
// also add lookup for this entry via trad word
|
||||
var existingCountTraditional = 0;
|
||||
if(Chinese.prototype.dictionary.get(line_data["trad"])) {
|
||||
existingCountTraditional = Chinese.prototype.getMatchingEntries(line_data["trad"]).length;
|
||||
}
|
||||
|
||||
Chinese.prototype.dictionary.put(line_data["trad"] + existingCountTraditional.toString(), line_data);
|
||||
}
|
||||
}
|
||||
|
||||
Chinese.prototype.loaded.keep("dict-loaded");
|
||||
}, 'text');
|
||||
7
private-console/web/public_js/i18n/i18next-1.11.2.min.js
vendored
Normal file
7
private-console/web/public_js/i18n/i18next-1.11.2.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
149
private-console/web/public_js/utils/ciphering.js
Normal file
149
private-console/web/public_js/utils/ciphering.js
Normal file
@@ -0,0 +1,149 @@
|
||||
function MD5(sMessage) {
|
||||
function RotateLeft(lValue, iShiftBits) { return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits)); }
|
||||
function AddUnsigned(lX,lY) {
|
||||
var lX4,lY4,lX8,lY8,lResult;
|
||||
lX8 = (lX & 0x80000000);
|
||||
lY8 = (lY & 0x80000000);
|
||||
lX4 = (lX & 0x40000000);
|
||||
lY4 = (lY & 0x40000000);
|
||||
lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
|
||||
if (lX4 & lY4) return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
|
||||
if (lX4 | lY4) {
|
||||
if (lResult & 0x40000000) return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
|
||||
else return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
|
||||
} else return (lResult ^ lX8 ^ lY8);
|
||||
}
|
||||
function F(x,y,z) { return (x & y) | ((~x) & z); }
|
||||
function G(x,y,z) { return (x & z) | (y & (~z)); }
|
||||
function H(x,y,z) { return (x ^ y ^ z); }
|
||||
function I(x,y,z) { return (y ^ (x | (~z))); }
|
||||
function FF(a,b,c,d,x,s,ac) {
|
||||
a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
|
||||
return AddUnsigned(RotateLeft(a, s), b);
|
||||
}
|
||||
function GG(a,b,c,d,x,s,ac) {
|
||||
a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
|
||||
return AddUnsigned(RotateLeft(a, s), b);
|
||||
}
|
||||
function HH(a,b,c,d,x,s,ac) {
|
||||
a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
|
||||
return AddUnsigned(RotateLeft(a, s), b);
|
||||
}
|
||||
function II(a,b,c,d,x,s,ac) {
|
||||
a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
|
||||
return AddUnsigned(RotateLeft(a, s), b);
|
||||
}
|
||||
function ConvertToWordArray(sMessage) {
|
||||
var lWordCount;
|
||||
var lMessageLength = sMessage.length;
|
||||
var lNumberOfWords_temp1=lMessageLength + 8;
|
||||
var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64;
|
||||
var lNumberOfWords = (lNumberOfWords_temp2+1)*16;
|
||||
var lWordArray=Array(lNumberOfWords-1);
|
||||
var lBytePosition = 0;
|
||||
var lByteCount = 0;
|
||||
while ( lByteCount < lMessageLength ) {
|
||||
lWordCount = (lByteCount-(lByteCount % 4))/4;
|
||||
lBytePosition = (lByteCount % 4)*8;
|
||||
lWordArray[lWordCount] = (lWordArray[lWordCount] | (sMessage.charCodeAt(lByteCount)<<lBytePosition));
|
||||
lByteCount++;
|
||||
}
|
||||
lWordCount = (lByteCount-(lByteCount % 4))/4;
|
||||
lBytePosition = (lByteCount % 4)*8;
|
||||
lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition);
|
||||
lWordArray[lNumberOfWords-2] = lMessageLength<<3;
|
||||
lWordArray[lNumberOfWords-1] = lMessageLength>>>29;
|
||||
return lWordArray;
|
||||
}
|
||||
function WordToHex(lValue) {
|
||||
var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;
|
||||
for (lCount = 0;lCount<=3;lCount++) {
|
||||
lByte = (lValue>>>(lCount*8)) & 255;
|
||||
WordToHexValue_temp = "0" + lByte.toString(16);
|
||||
WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);
|
||||
}
|
||||
return WordToHexValue;
|
||||
}
|
||||
var x=Array();
|
||||
var k,AA,BB,CC,DD,a,b,c,d
|
||||
var S11=7, S12=12, S13=17, S14=22;
|
||||
var S21=5, S22=9 , S23=14, S24=20;
|
||||
var S31=4, S32=11, S33=16, S34=23;
|
||||
var S41=6, S42=10, S43=15, S44=21;
|
||||
// Steps 1 and 2. Append padding bits and length and convert to words
|
||||
x = ConvertToWordArray(sMessage);
|
||||
// Step 3. Initialise
|
||||
a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
|
||||
// Step 4. Process the message in 16-word blocks
|
||||
for (k=0;k<x.length;k+=16) {
|
||||
AA=a; BB=b; CC=c; DD=d;
|
||||
a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
|
||||
d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
|
||||
c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
|
||||
b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
|
||||
a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
|
||||
d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
|
||||
c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
|
||||
b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
|
||||
a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
|
||||
d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
|
||||
c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
|
||||
b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
|
||||
a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
|
||||
d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
|
||||
c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
|
||||
b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
|
||||
a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
|
||||
d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
|
||||
c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
|
||||
b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
|
||||
a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
|
||||
d=GG(d,a,b,c,x[k+10],S22,0x2441453);
|
||||
c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
|
||||
b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
|
||||
a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
|
||||
d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
|
||||
c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
|
||||
b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
|
||||
a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
|
||||
d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
|
||||
c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
|
||||
b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
|
||||
a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
|
||||
d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
|
||||
c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
|
||||
b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
|
||||
a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
|
||||
d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
|
||||
c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
|
||||
b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
|
||||
a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
|
||||
d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
|
||||
c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
|
||||
b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
|
||||
a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
|
||||
d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
|
||||
c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
|
||||
b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
|
||||
a=II(a,b,c,d,x[k+0], S41,0xF4292244);
|
||||
d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
|
||||
c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
|
||||
b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
|
||||
a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
|
||||
d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
|
||||
c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
|
||||
b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
|
||||
a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
|
||||
d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
|
||||
c=II(c,d,a,b,x[k+6], S43,0xA3014314);
|
||||
b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
|
||||
a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
|
||||
d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
|
||||
c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
|
||||
b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
|
||||
a=AddUnsigned(a,AA); b=AddUnsigned(b,BB); c=AddUnsigned(c,CC); d=AddUnsigned(d,DD);
|
||||
}
|
||||
// Step 5. Output the 128 bit digest
|
||||
var temp= WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);
|
||||
return temp.toUpperCase();
|
||||
}
|
||||
65
private-console/web/public_js/utils/date_utils.js
Normal file
65
private-console/web/public_js/utils/date_utils.js
Normal file
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Created by strawmanbobi on 15-06-26
|
||||
*/
|
||||
|
||||
function formatDate(date, fmt) {
|
||||
var o = {
|
||||
"M+" : date.getMonth() + 1,
|
||||
"d+" : date.getDate(),
|
||||
"h+" : date.getHours(),
|
||||
"m+" : date.getMinutes(),
|
||||
"s+" : date.getSeconds(),
|
||||
"q+" : Math.floor((date.getMonth() + 3) / 3),
|
||||
"S" : date.getMilliseconds()
|
||||
};
|
||||
if(/(y+)/.test(fmt))
|
||||
fmt=fmt.replace(RegExp.$1, (date.getFullYear()+"").substr(4 - RegExp.$1.length));
|
||||
for(var k in o)
|
||||
if(new RegExp("("+ k +")").test(fmt))
|
||||
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
|
||||
return fmt;
|
||||
}
|
||||
|
||||
function getNextDay(dateString) {
|
||||
var nextDayStr;
|
||||
var nextMonthStr;
|
||||
var nextYearStr;
|
||||
var currentDate = new Date(dateString);
|
||||
var nextDate = new Date(currentDate.getTime() + 24 * 60 * 60 * 1000);
|
||||
var nextDay = nextDate.getDate();
|
||||
if(nextDay < 10) {
|
||||
nextDayStr = "0" + nextDay;
|
||||
} else {
|
||||
nextDayStr = nextDay;
|
||||
}
|
||||
var nextMonth = nextDate.getMonth() + 1;
|
||||
if(nextMonth < 10) {
|
||||
nextMonthStr = "0" + nextMonth;
|
||||
} else {
|
||||
nextMonthStr = nextMonth;
|
||||
}
|
||||
nextYearStr = nextDate.getFullYear();
|
||||
return nextYearStr + "-" + nextMonthStr + "-" + nextDayStr;
|
||||
}
|
||||
|
||||
function getPreviousDay(dateString) {
|
||||
var lastDayStr;
|
||||
var lastMonthStr;
|
||||
var lastYearStr;
|
||||
var currentDate = new Date(dateString);
|
||||
var lastDate = new Date(currentDate.getTime() - 24 * 60 * 60 * 1000);
|
||||
var lastDay = lastDate.getDate();
|
||||
if(lastDay < 10) {
|
||||
lastDayStr = "0" + lastDay;
|
||||
} else {
|
||||
lastDayStr = lastDay;
|
||||
}
|
||||
var lastMonth = lastDate.getMonth() + 1;
|
||||
if(lastMonth < 10) {
|
||||
lastMonthStr = "0" + lastMonth;
|
||||
} else {
|
||||
lastMonthStr = lastMonth;
|
||||
}
|
||||
lastYearStr = lastDate.getFullYear();
|
||||
return lastYearStr + "-" + lastMonthStr + "-" + lastDayStr;
|
||||
}
|
||||
25
private-console/web/public_js/utils/url_parser.js
Normal file
25
private-console/web/public_js/utils/url_parser.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Created by strawmanbobi on 15-06-26
|
||||
*/
|
||||
|
||||
function truncate(str, len) {
|
||||
if(str.length > len)
|
||||
return str.substring(0, len) + "...";
|
||||
else
|
||||
return str;
|
||||
}
|
||||
|
||||
function getQueryStringRegExp(name) {
|
||||
var reg = new RegExp("(^|\\?|&|)"+ name +"=([^&]*)(\\s|&|$|)", "i");
|
||||
if (reg.test(decodeURI(location.href))) return unescape(RegExp.$2.replace(/\+/g, " ")); return "";
|
||||
}
|
||||
|
||||
function getParameter(name) {
|
||||
var rawParam = getQueryStringRegExp(name);
|
||||
var sharpPos = rawParam.indexOf('#');
|
||||
var p = rawParam;
|
||||
if (sharpPos >= 0) {
|
||||
p = p.substring(0, sharpPos);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
5
private-console/web/public_js/utils/view_utils.js
Normal file
5
private-console/web/public_js/utils/view_utils.js
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
function getViewPortHeight() {
|
||||
var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
|
||||
return h;
|
||||
}
|
||||
Reference in New Issue
Block a user