3131 lines
105 KiB
JavaScript
3131 lines
105 KiB
JavaScript
|
||
|
||
var MODULES = {
|
||
FIC: '1C6DFE25-347D-4889-AB75-73ADE9190D27',
|
||
FRS: 'EFFD07E9-6800-419A-8066-9BEE81C48CCD'
|
||
};
|
||
|
||
var MAX_SAFE_INTEGER = 9007199254740991;
|
||
|
||
var PRESETS = {
|
||
colorPresets: function () {
|
||
if (this._colorPresets == null) {
|
||
this._colorPresets = [
|
||
{ color: '#000000', text: GetLanguageByKey('LHBIS_FIC_Client_FICControls_ShapeAndColorSetting_A007', 'Black') },
|
||
{ color: '#0000FF', text: GetLanguageByKey('LHBIS_FIC_Client_FICControls_ShapeAndColorSetting_A008', 'Blue') },
|
||
{ color: '#A52A2A', text: GetLanguageByKey('LHBIS_FIC_Client_FICControls_ShapeAndColorSetting_A009', 'Brown') },
|
||
{ color: '#00FFFF', text: GetLanguageByKey('LHBIS_FIC_Client_FICControls_ShapeAndColorSetting_A010', 'Cyan') },
|
||
{ color: '#A9A9A9', text: GetLanguageByKey('LHBIS_FIC_Client_FICControls_ShapeAndColorSetting_A011', 'DarkGray') },
|
||
{ color: '#808080', text: GetLanguageByKey('LHBIS_FIC_Client_FICControls_ShapeAndColorSetting_A012', 'Gray') },
|
||
{ color: '#008000', text: GetLanguageByKey('LHBIS_FIC_Client_FICControls_ShapeAndColorSetting_A013', 'Green') },
|
||
{ color: '#D3D3D3', text: GetLanguageByKey('LHBIS_FIC_Client_FICControls_ShapeAndColorSetting_A014', 'LightGray') },
|
||
{ color: '#FF00FF', text: GetLanguageByKey('LHBIS_FIC_Client_FICControls_ShapeAndColorSetting_A015', 'Magenta') },
|
||
{ color: '#FFA500', text: GetLanguageByKey('LHBIS_FIC_Client_FICControls_ShapeAndColorSetting_A016', 'Orange') },
|
||
{ color: '#800080', text: GetLanguageByKey('LHBIS_FIC_Client_FICControls_ShapeAndColorSetting_A017', 'Purple') },
|
||
{ color: '#FF0000', text: GetLanguageByKey('LHBIS_FIC_Client_FICControls_ShapeAndColorSetting_A018', 'Red') },
|
||
{ color: '#FFFFFF', text: GetLanguageByKey('LHBIS_FIC_Client_FICControls_ShapeAndColorSetting_A019', 'White') },
|
||
{ color: '#FFFF00', text: GetLanguageByKey('LHBIS_FIC_Client_FICControls_ShapeAndColorSetting_A020', 'Yellow') }
|
||
];
|
||
}
|
||
return this._colorPresets;
|
||
}
|
||
};
|
||
|
||
// window open
|
||
function onsubclick(href) {
|
||
return function () {
|
||
openSubPage(href);
|
||
return false;
|
||
};
|
||
}
|
||
function replaceLink(container) {
|
||
if (typeof container === 'string') {
|
||
container = $(container);
|
||
}
|
||
var a = container.find('a');
|
||
for (var i = 0; i < a.length; i++) {
|
||
var href = a[i].href;
|
||
a[i].onclick = onsubclick(href);
|
||
}
|
||
}
|
||
|
||
if (typeof Operators !== 'object') {
|
||
var Operators = {
|
||
Equal: '=',
|
||
Greater: '>',
|
||
GreaterEqual: '>=',
|
||
Less: '<',
|
||
LessEqual: '<=',
|
||
NotEqual: '<>',
|
||
Null: 'Is Null',
|
||
NotNull: 'Is Not Null',
|
||
In: 'In',
|
||
Between: 'Between'
|
||
};
|
||
}
|
||
|
||
if (typeof Booleans !== 'object') {
|
||
var Booleans = {
|
||
True: 'TRUE',
|
||
False: 'FALSE'
|
||
};
|
||
}
|
||
|
||
//获取Chart颜色方案
|
||
function getChartColorSchemes() {
|
||
return new Promise(function (resolve, reject) {
|
||
_network.query('GetChartColorSchemes', [], function (data) {
|
||
for (var i in data.Result) {
|
||
addColorSet(data.Result[i]);
|
||
_utility.chartColorSchemes.push(data.Result[i]);
|
||
}
|
||
|
||
resolve();
|
||
});
|
||
});
|
||
}
|
||
|
||
$.wrapDate = function (dt) {
|
||
if ($.nullOrEmpty(dt)) {
|
||
return null;
|
||
}
|
||
if (dt.length === 19 && dt.indexOf(' ') === 10) {
|
||
return new Date(dt.substring(0, 10).replace(/-/g, '/'));
|
||
}
|
||
return new Date(dt);
|
||
};
|
||
|
||
$.toLowerCase = function (s) {
|
||
if (s == null) {
|
||
return null;
|
||
}
|
||
return String(s).toLowerCase();
|
||
};
|
||
|
||
$.convertChartIndex = function (number) {
|
||
var baseChar = 65; // 'A'.charCodeAt(0);
|
||
var letter = '';
|
||
|
||
do {
|
||
number--;
|
||
letter = String.fromCharCode(baseChar + (number % 26)) + letter;
|
||
number = (number / 26) >> 0;
|
||
} while (number > 0);
|
||
|
||
return letter;
|
||
};
|
||
$.convertCharNumber = function (s) {
|
||
var baseChar = 65;
|
||
var num = 0;
|
||
|
||
for (var i = 0; i < s.length; i++) {
|
||
num *= 26;
|
||
var n = s.charCodeAt(i) - baseChar + 1;
|
||
num += n;
|
||
}
|
||
|
||
return num;
|
||
};
|
||
|
||
$.getOwnerDocument = function (obj) {
|
||
obj = obj || this;
|
||
if (obj.parentDom != null) {
|
||
return (obj.parentDom instanceof $) ? obj.parentDom[0].ownerDocument : obj.parentDom.ownerDocument;
|
||
}
|
||
return window.document;
|
||
|
||
};
|
||
|
||
$.ignoreEquals = function (s1, s2) {
|
||
if (s1 == null && s2 == null) {
|
||
return true;
|
||
}
|
||
if (typeof s1 !== 'string' || typeof s2 !== 'string') {
|
||
return false;
|
||
}
|
||
return s1.toLowerCase() == s2.toLowerCase();
|
||
};
|
||
$.ignoreIndexOf = function (s, key) {
|
||
if (typeof s === 'string') {
|
||
return s.ignoreIndexOf(key);
|
||
}
|
||
return -1;
|
||
};
|
||
$.ignoreVal = function (o, key) {
|
||
if (typeof o !== 'object') {
|
||
return null;
|
||
}
|
||
var keys = Object.keys(o);
|
||
for (var i = 0; i < keys.length; i++) {
|
||
var k = keys[i];
|
||
if ($.ignoreEquals(k, key)) {
|
||
return o[k];
|
||
}
|
||
}
|
||
return null;
|
||
};
|
||
$.parseIntStrict = function (s) {
|
||
var i = Number(s);
|
||
if (i % 1 !== 0) { // i !== parseInt(s)
|
||
return NaN;
|
||
}
|
||
return i;
|
||
};
|
||
$.parseFloatStrict = function (s) {
|
||
var f = Number(s);
|
||
if (parseFloat(s) !== f) {
|
||
return NaN;
|
||
}
|
||
return f;
|
||
};
|
||
$.base64Encode = function (str) {
|
||
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) {
|
||
return String.fromCharCode('0x' + p1);
|
||
}));
|
||
};
|
||
$.base64Decode = function (str) {
|
||
return decodeURIComponent(atob(str).split('').map(function (c) {
|
||
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
||
}).join(''));
|
||
};
|
||
// replaced by Number(s)
|
||
//$.parseFloatStrict = function (s) {
|
||
// var n1 = parseFloat(s);
|
||
// if (isNaN(n1)) {
|
||
// return n1;
|
||
// }
|
||
// var n2 = parseFloat(s + '1');
|
||
// if (n1 === n2) {
|
||
// return NaN;
|
||
// }
|
||
// return n1;
|
||
//};
|
||
$.isBool = function (s) {
|
||
return /(true|false)/i.test(s);
|
||
};
|
||
|
||
$.delay = function (action, d) {
|
||
if (typeof action !== 'function') {
|
||
return;
|
||
}
|
||
var delay = !isNaN(d) ? d : ((isNaN($.ieVersion()) && !$.isEdge()) ? 0 : 100);
|
||
setTimeout(action, delay);
|
||
};
|
||
|
||
String.prototype.padRight = function (num, char) {
|
||
var s = '';
|
||
for (var i = 0; i < num - this.length; i++) {
|
||
s += char;
|
||
}
|
||
return s + this;
|
||
};
|
||
|
||
String.prototype.endWith = function (str, ignore) {
|
||
if (typeof str !== 'string') {
|
||
return false;
|
||
}
|
||
if (String.prototype.hasOwnProperty('endsWith')) {
|
||
if (ignore) {
|
||
return this.toLowerCase().endsWith(str.toLowerCase());
|
||
}
|
||
return this.endsWith(str);
|
||
}
|
||
if (ignore) {
|
||
str = str.toLowerCase();
|
||
return this.toLowerCase().substr(-str.length, str.length) === str;
|
||
}
|
||
return this.substr(-str.length, str.length) === str;
|
||
};
|
||
|
||
String.prototype.startWith = function (str, ignore) {
|
||
if (typeof str !== 'string') {
|
||
return false;
|
||
}
|
||
if (String.prototype.hasOwnProperty('startsWith')) {
|
||
if (ignore) {
|
||
return this.toLowerCase().startsWith(str.toLowerCase());
|
||
}
|
||
return this.startsWith(str);
|
||
}
|
||
if (ignore) {
|
||
str = str.toLowerCase();
|
||
return this.toLowerCase().substr(0, str.length) === str;
|
||
}
|
||
return this.substr(0, str.length) === str;
|
||
};
|
||
|
||
String.prototype.trim = String.prototype.trim || function () {
|
||
return this.replace(/(^\s*)|(\s*$)/g, '');
|
||
};
|
||
|
||
String.prototype.IsDigit = function () {
|
||
var patrn = /^[0-9]{1,20}$/;
|
||
if (!patrn.exec(this)) return false
|
||
return true
|
||
};
|
||
|
||
String.prototype.IsLetter = function () {
|
||
if (/^[A-Za-z]+$/.test(this)) {
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
};
|
||
|
||
String.prototype.IsLetterOrDigit = function () {
|
||
if (/^[A-Za-z0-9]+$/.test(this)) {
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
};
|
||
|
||
String.prototype.isDateTime = function () {
|
||
return /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]+)?$/.test(this);
|
||
};
|
||
|
||
String.prototype.replaceAll = function (s1, s2) {
|
||
return this.replace(new RegExp(s1, "gm"), s2);
|
||
};
|
||
|
||
String.prototype.escapeHtml = function () {
|
||
return this.replace(/&/g, "&")
|
||
.replace(/</g, "<")
|
||
.replace(/>/g, ">")
|
||
//.replace(/ /g, " ")
|
||
.replace(/"/g, """)
|
||
.replace(/'/g, "'");
|
||
};
|
||
|
||
String.prototype.ignoreIndexOf = function (key) {
|
||
if (typeof key !== 'string') {
|
||
return -1;
|
||
}
|
||
return this.toLowerCase().indexOf(key.toLowerCase());
|
||
};
|
||
String.prototype.ignoreStars = function (key) {
|
||
if (typeof key !== 'string') {
|
||
return false;
|
||
}
|
||
if (key.length > this.length) {
|
||
return false;
|
||
}
|
||
var s = this.toLowerCase();
|
||
key = key.toLowerCase();
|
||
for (var i = 0; i < key.length; i++) {
|
||
if (key[i] !== s[i]) {
|
||
return false;
|
||
}
|
||
}
|
||
return true;
|
||
};
|
||
|
||
Date.prototype.GetFormatDate = function () {
|
||
var month = this.getMonth() + 1;
|
||
if (month < 10)
|
||
month = new Array(2).join('0').concat(month);
|
||
|
||
var day = this.getDate();
|
||
if (day < 10)
|
||
day = new Array(2).join('0').concat(day);
|
||
|
||
var hours = this.getHours();
|
||
if (hours < 10)
|
||
hours = new Array(2).join('0').concat(hours);
|
||
|
||
var minutes = this.getMinutes();
|
||
if (minutes < 10)
|
||
minutes = new Array(2).join('0').concat(minutes);
|
||
|
||
var seconds = this.getSeconds();
|
||
if (seconds < 10)
|
||
seconds = new Array(2).join('0').concat(seconds);
|
||
|
||
return this.getFullYear() + "" + month + "" + day
|
||
+ "" + hours + "" + minutes + "" + seconds;
|
||
};
|
||
|
||
Date.prototype.getDefaultFormat = function () {
|
||
var month = this.getMonth() + 1;
|
||
var day = this.getDate();
|
||
var hours = this.getHours();
|
||
var tt;
|
||
if (hours >= 12) {
|
||
if (hours > 12) {
|
||
hours -= 12;
|
||
}
|
||
tt = 'PM';
|
||
} else {
|
||
if (hours == 0) {
|
||
hours = 12;
|
||
}
|
||
tt = 'AM';
|
||
}
|
||
var minutes = this.getMinutes();
|
||
if (minutes < 10)
|
||
minutes = '0' + minutes;
|
||
var seconds = this.getSeconds();
|
||
if (seconds < 10)
|
||
seconds = '0' + seconds;
|
||
|
||
return month + "/" + day + "/" + this.getFullYear()
|
||
+ " " + hours + ":" + minutes + ":" + seconds + " " + tt;
|
||
};
|
||
|
||
(function () {
|
||
|
||
function find(key, value) {
|
||
for (var i = 0; i < this.length; i++) {
|
||
if (this[i][key] === value) {
|
||
return i;
|
||
}
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'findName')) {
|
||
Object.defineProperty(Array.prototype, 'findName', {
|
||
value: function (name) {
|
||
return find.call(this, 'name', name);
|
||
}
|
||
});
|
||
}
|
||
if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'findIt')) {
|
||
Object.defineProperty(Array.prototype, 'findIt', {
|
||
value: function (key, value) {
|
||
return find.call(this, key, value);
|
||
}
|
||
});
|
||
}
|
||
|
||
if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'FirstOrDefault')) {
|
||
Object.defineProperty(Array.prototype, 'FirstOrDefault', {
|
||
value: function (func) {
|
||
if (typeof func !== 'function') {
|
||
return null;
|
||
}
|
||
for (var i = 0; i < this.length; i++) {
|
||
if (func(this[i])) {
|
||
return this[i];
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
});
|
||
}
|
||
|
||
if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'distinct')) {
|
||
Object.defineProperty(Array.prototype, 'distinct', {
|
||
value: function (key) {
|
||
return this.reduce(function (array, value) {
|
||
if (key != null) {
|
||
var flag = false;
|
||
for (var i = 0; i < this.length; i++) {
|
||
if (this[i][key] == value[key]) {
|
||
flag = true;
|
||
break;
|
||
}
|
||
}
|
||
if (!flag) {
|
||
array.push(value);
|
||
}
|
||
} else if (array.indexOf(value) < 0) {
|
||
array.push(value);
|
||
}
|
||
return array;
|
||
}, []);
|
||
}
|
||
});
|
||
}
|
||
|
||
function _foreach(func) {
|
||
if (typeof func !== 'function') {
|
||
return;
|
||
}
|
||
for (var key in this) {
|
||
if (this.hasOwnProperty(key) && func(key)) {
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (!Object.prototype.hasOwnProperty.call(Object.prototype, 'Clear')) {
|
||
Object.defineProperty(Object.prototype, 'Clear', {
|
||
value: function () {
|
||
var _this = this;
|
||
_foreach.call(this, function (key) {
|
||
delete _this[key];
|
||
});
|
||
}
|
||
});
|
||
}
|
||
//Object.defineProperty(Object.prototype, 'Values', {
|
||
// value: function () {
|
||
// var values = [];
|
||
// var _this = this;
|
||
// _foreach.call(this, function (key) {
|
||
// values.push(_this[key]);
|
||
// });
|
||
// return values;
|
||
// }
|
||
//});
|
||
if (!Object.prototype.hasOwnProperty.call(Object.prototype, 'Keys')) {
|
||
Object.defineProperty(Object.prototype, 'Keys', {
|
||
value: function () {
|
||
var keys = [];
|
||
_foreach.call(this, function (key) {
|
||
keys.push(key);
|
||
});
|
||
return keys;
|
||
}
|
||
});
|
||
}
|
||
if (!Object.prototype.hasOwnProperty.call(Object.prototype, 'FirstOrDefault')) {
|
||
Object.defineProperty(Object.prototype, 'FirstOrDefault', {
|
||
value: function (func) {
|
||
if (typeof func !== 'function') {
|
||
return null;
|
||
}
|
||
for (var key in this) {
|
||
if (this.hasOwnProperty(key)) {
|
||
var kv = {
|
||
key: key,
|
||
value: this[key]
|
||
};
|
||
if (func(kv)) {
|
||
return kv;
|
||
}
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
});
|
||
}
|
||
|
||
}());
|
||
|
||
$.isEdge = function () { return /edge/i.test(navigator.userAgent); };
|
||
$.isIE = function () {
|
||
var ua = navigator.userAgent;
|
||
if (/trident/i.test(ua)) {
|
||
return true;
|
||
}
|
||
if (/compatible/i.test(ua) && /msie/i.test(ua)) {
|
||
return true;
|
||
}
|
||
return false;
|
||
};
|
||
$.ieVersion = function () {
|
||
var ua = navigator.userAgent;
|
||
if (/trident/i.test(ua)) {
|
||
return 11;
|
||
} else if (/msie 10\.0/i.test(ua)) {
|
||
return 10;
|
||
} else if (/msie 9\.0/i.test(ua)) {
|
||
return 9;
|
||
}
|
||
return NaN;
|
||
}
|
||
$.cloneObject = function (obj, ignoreFields, allIgnore) {
|
||
if (obj == null) {
|
||
return null;
|
||
}
|
||
if ($.isArray(obj)) {
|
||
var a = [];
|
||
for (var i = 0; i < obj.length; i++) {
|
||
a.push($.cloneObject(obj[i], ignoreFields, allIgnore));
|
||
}
|
||
return a;
|
||
} else if (typeof obj === 'object') {
|
||
var o = {};
|
||
for (var key in obj) {
|
||
if ($.isArray(ignoreFields) && $.inArray(key, ignoreFields) >= 0) {
|
||
continue;
|
||
}
|
||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||
if (allIgnore) {
|
||
o[key] = $.cloneObject(obj[key], ignoreFields, allIgnore);
|
||
} else {
|
||
o[key] = $.cloneObject(obj[key]);
|
||
}
|
||
}
|
||
}
|
||
return o;
|
||
}
|
||
return obj;
|
||
};
|
||
$.assignObject = function (obj, target) {
|
||
if (obj == null) {
|
||
return target;
|
||
}
|
||
for (var key in obj) {
|
||
target[key] = $.cloneObject(obj[key]);
|
||
}
|
||
return target;
|
||
};
|
||
$.assignArray = function (array, ctor) {
|
||
var list = [];
|
||
if (array != null) {
|
||
for (var i = 0; i < array.length; i++) {
|
||
list.push($.assignObject(array[i], new ctor()));
|
||
}
|
||
}
|
||
return list;
|
||
};
|
||
$.debounce = function throttle(method, delay, context) {
|
||
delay = void 0 !== delay ? delay : 100;
|
||
context = void 0 !== context ? context : window;
|
||
for (var count = arguments.length, args = Array(count > 3 ? count - 3 : 0), i = 3; i < count; i++) {
|
||
args[i - 3] = arguments[i];
|
||
}
|
||
clearTimeout(method.tiid);
|
||
method.tiid = setTimeout(function () { method.apply(context, args) }, delay);
|
||
};
|
||
$.throttle = function throttle(method, delay, context) {
|
||
delay = void 0 !== delay ? delay : 100;
|
||
context = void 0 !== context ? context : window;
|
||
for (var count = arguments.length, args = Array(count > 3 ? count - 3 : 0), i = 3; i < count; i++) {
|
||
args[i - 3] = arguments[i];
|
||
}
|
||
clearTimeout(method.tiid);
|
||
var current = new Date();
|
||
if (method.tdate === void 0 || current - method.tdate > delay) {
|
||
method.apply(context, args);
|
||
method.tdate = current;
|
||
} else {
|
||
method.tiid = setTimeout(function () { method.apply(context, args) }, delay);
|
||
}
|
||
};
|
||
$.measureWidth = function (str) {
|
||
var span = document.getElementById('span_measure_holder');
|
||
if (span == null) {
|
||
span = document.createElement('span');
|
||
span.setAttribute('id', 'span_measure_holder');
|
||
document.body.appendChild(span);
|
||
}
|
||
span.innerText = str;
|
||
return span.offsetWidth;
|
||
};
|
||
$.start = function (fun) {
|
||
return new Promise(fun);
|
||
};
|
||
$.isChrome = /chrom(e|ium)/.test(navigator.userAgent.toLowerCase());
|
||
$.notEmptyGuid = function (v) {
|
||
// v.length > 0
|
||
return (typeof v === 'string') && _utility.isGuid(v) && v !== _utility.GuidEmpty;
|
||
};
|
||
$.notEmpty = function (v) {
|
||
return (typeof v === 'string') && v.length > 0 && v !== _utility.GuidEmpty;
|
||
}
|
||
$.selectionStart = function (input, v) {
|
||
if (!input) {
|
||
return -1;
|
||
}
|
||
if (isNaN(v)) {
|
||
v = null;
|
||
} else {
|
||
v = parseInt(v);
|
||
}
|
||
if (input.selectionStart != null) {
|
||
if (v != null) {
|
||
input.selectionStart = v;
|
||
}
|
||
return input.selectionStart;
|
||
}
|
||
// IE
|
||
try {
|
||
var range = document.selection.createRange();
|
||
range.moveStart("character", -input.value.length);
|
||
return range.text.length;
|
||
} catch (e) {
|
||
return 0;
|
||
}
|
||
};
|
||
$.privSet = function (key, val) {
|
||
if (Object.prototype.hasOwnProperty.call(this, key)) {
|
||
this[key] = val;
|
||
} else {
|
||
Object.defineProperty(this, key, {
|
||
value: val,
|
||
writable: true
|
||
});
|
||
}
|
||
};
|
||
|
||
function Guid() {
|
||
'use strict';
|
||
|
||
this.date = new Date();
|
||
|
||
if (typeof this.create != 'function') {
|
||
|
||
Guid.prototype.create = function () {
|
||
this.date = new Date();
|
||
var guidStr = '';
|
||
var sexadecimalDate = this.hexadecimal(this.getGUIDDate(), 16);
|
||
var sexadecimalTime = this.hexadecimal(this.getGUIDTime(), 16);
|
||
for (var i = 0; i < 9; i++) {
|
||
guidStr += Math.floor(Math.random() * 16).toString(16);
|
||
}
|
||
guidStr += sexadecimalDate;
|
||
guidStr += sexadecimalTime;
|
||
while (guidStr.length < 32) {
|
||
guidStr += Math.floor(Math.random() * 16).toString(16);
|
||
}
|
||
return this.formatGUID(guidStr);
|
||
}
|
||
|
||
Guid.prototype.getGUIDDate = function () {
|
||
return this.date.getFullYear() + this.addZero(this.date.getMonth() + 1) + this.addZero(this.date.getDay());
|
||
}
|
||
|
||
Guid.prototype.getGUIDTime = function () {
|
||
return this.addZero(this.date.getHours()) + this.addZero(this.date.getMinutes()) + this.addZero(this.date.getSeconds()) + this.addZero(parseInt(this.date.getMilliseconds() / 10));
|
||
}
|
||
|
||
Guid.prototype.addZero = function (num) {
|
||
if (!isNaN(Number(num)) && num >= 0 && num < 10) { // .toString() != 'NaN'
|
||
return '0' + Math.floor(num);
|
||
} else {
|
||
return num.toString();
|
||
}
|
||
}
|
||
|
||
Guid.prototype.hexadecimal = function (num, x, y) {
|
||
if (y != undefined) {
|
||
return parseInt(num.toString(), y).toString(x);
|
||
} else {
|
||
return parseInt(num.toString()).toString(x);
|
||
}
|
||
}
|
||
|
||
Guid.prototype.formatGUID = function (guidStr) {
|
||
var str1 = guidStr.slice(0, 8) + '-',
|
||
str2 = guidStr.slice(8, 12) + '-',
|
||
str3 = guidStr.slice(12, 16) + '-',
|
||
str4 = guidStr.slice(16, 20) + '-',
|
||
str5 = guidStr.slice(20);
|
||
return str1 + str2 + str3 + str4 + str5;
|
||
}
|
||
}
|
||
}
|
||
$.G5Version = function () {
|
||
var v = $().jquery;
|
||
return v == "1.12.4";
|
||
}
|
||
|
||
$.newGuid = function () {
|
||
return new Guid().create();
|
||
}
|
||
$.nullOrEmpty = function (v) {
|
||
if (typeof v !== 'string') {
|
||
return v == null;
|
||
}
|
||
return v.length === 0;
|
||
};
|
||
$.nullOrWhite = function (v) {
|
||
if (typeof v !== 'string') {
|
||
return v == null;
|
||
}
|
||
return v.replace(/\s/g, '').length === 0;
|
||
}
|
||
$.jsonToXml = function (json) {
|
||
|
||
};
|
||
$.clientEvent = function (e, preventDefault, button, offsetFlag) {
|
||
var touch = e.originalEvent.targetTouches && e.originalEvent.targetTouches[0];
|
||
if (touch !== undefined) {
|
||
if (preventDefault) {
|
||
e.preventDefault();
|
||
}
|
||
if (offsetFlag === true) {
|
||
touch.offsetX = touch.clientX - $(e.target).offset().left;
|
||
}
|
||
return touch;
|
||
}
|
||
if (button !== undefined && e.button !== button) {
|
||
return undefined;
|
||
}
|
||
return e;
|
||
};
|
||
$.fn.touchdown = function (data, fn, cls) {
|
||
if (typeof data === 'function') {
|
||
cls = fn;
|
||
fn = data;
|
||
data = undefined;
|
||
}
|
||
if (typeof cls === 'string') {
|
||
return this.on('mousedown.' + cls, null, data, fn).on('touchstart.' + cls, null, data, fn);
|
||
}
|
||
return this.mousedown(data, fn).on('touchstart', null, data, fn);
|
||
};
|
||
$.fn.touchmove = function (data, fn, cls) {
|
||
if (typeof data === 'function') {
|
||
cls = fn;
|
||
fn = data;
|
||
data = undefined;
|
||
}
|
||
fn = $.throttle.bind(this, fn, 8, null);
|
||
if (typeof cls === 'string') {
|
||
return this.on('mousemove.' + cls, null, data, fn).on('touchmove.' + cls, null, data, fn);
|
||
}
|
||
return this.mousemove(data, fn).on('touchmove', null, data, fn);
|
||
};
|
||
$.fn.touchup = function (data, fn, cls) {
|
||
if (typeof data === 'function') {
|
||
cls = fn;
|
||
fn = data;
|
||
data = undefined;
|
||
}
|
||
if (typeof cls === 'string') {
|
||
return this.on('mouseup.' + cls, null, data, fn).on('touchend.' + cls, null, data, fn);
|
||
}
|
||
return this.mouseup(data, fn).on('touchend', null, data, fn);
|
||
};
|
||
$.fn.touchdrilldown = function (data, fn, cls) {
|
||
if (typeof data === 'function') {
|
||
cls = fn;
|
||
fn = data;
|
||
data = undefined;
|
||
}
|
||
var cfn = function (_this) {
|
||
return function (e) {
|
||
var time = _this.data('taptime');
|
||
var now = new Date().getTime();
|
||
if (time == null || now - time > 400) {
|
||
_this.data('taptime', now);
|
||
} else {
|
||
fn.call(_this, e);
|
||
}
|
||
};
|
||
};
|
||
if (typeof cls === 'string') {
|
||
return this.on('touchend.' + cls, null, data, cfn(this));
|
||
}
|
||
return this.on('touchend', null, data, cfn(this));
|
||
};
|
||
$.fn.appendClear = function () {
|
||
return this.each(function () {
|
||
$(this).append('<div style="clear: both;"></div>');
|
||
});
|
||
}
|
||
|
||
_chartType = {
|
||
Gauge: 'Gauge',
|
||
Grid: 'Grid',
|
||
Grid3D: 'Grid3D',
|
||
List: 'List',
|
||
Line2D: 'Line',
|
||
Line3D: 'Line3D',
|
||
Column2D: 'Column',
|
||
Column3D: 'Column3D',
|
||
Bar2D: 'Bar',
|
||
Bar3D: 'Bar3D',
|
||
ColumnLine: 'ColumnLine',
|
||
Scatter: 'ScatterPlot',
|
||
Pie: 'Pie',
|
||
Doughnut: 'Doughnut',
|
||
Scorecard: 'FreeChart',
|
||
Rss: 'RSS',
|
||
Video: 'Video',
|
||
Stock: 'Stock',
|
||
Alert: 'Alert',
|
||
Favorites: 'Favorites',
|
||
FRPT: 'FRPT',
|
||
WebForm: 'WebForm',
|
||
MapView: 'MapView'
|
||
};
|
||
|
||
if (typeof ChartTypeEnum !== 'object') {
|
||
var ChartTypeEnum = {
|
||
Line: -4,
|
||
Bar: -3,
|
||
Column: -2,
|
||
Grid: -1,
|
||
Alert: 'dd84f196-0028-4e38-a36d-27c214f65c53',
|
||
Bar2D: '2ef390cc-ab7a-402b-8624-6b38eccc1440',
|
||
Bar3D: 'f7233ba2-b13c-4062-9e68-f2ae102b2ed2',
|
||
Column2D: '2f9f6c14-fa70-4f31-8bab-01a32933efce',
|
||
Column3D: '228d7392-9be7-4d22-87a0-61444b48f7d2',
|
||
ColumnAndLine: '2254a334-3c12-4f1c-a12c-82fada556ba4',
|
||
Favorite: 'fba92b54-e4a1-4ced-8c71-72ba307909c5',
|
||
FRPT: 'dfeb1c9a-10a3-4ba3-bad1-da5108c703ea',
|
||
FreeReport: '7f8c5164-5960-4a65-9501-3df88f90f4e5',
|
||
Gauge: 'fd555bde-8bac-4f89-99cc-09c5d9c11f58',
|
||
Grid2D: 'a570f4bd-79a9-488b-8d26-7d3871061718',
|
||
Grid3D: '10fdc141-4f5e-4ea8-ad69-1d1040cd3a5f',
|
||
Line2D: '04941378-d5b2-462a-8a5f-c92bc344f1f1',
|
||
Line3D: '9a6cbbea-9108-4fc1-9a2e-1411139f41cf',
|
||
ListChart: '0c0d543e-c659-4e9f-b408-ce9392a495ad',
|
||
Pie: '18923b34-9288-4079-b16a-c04ed1e09a63',
|
||
Rss: 'a43a7dc9-f8f3-4202-84f8-34b3239960cc',
|
||
ScatterPlot: '3e47d021-f7e6-42ec-96e3-c4626c7e176b',
|
||
Stock: '2ca6e0d1-d675-4a2c-8bef-325cfcd674bb',
|
||
Video: '1a810091-a69b-4fd0-9a4c-5d57af7ebe7f',
|
||
WebForm: '6f35db66-32a8-43ae-8b4e-fb74fc8ba971',
|
||
MapView: '0c71443c-49b5-474d-b1cd-1a53030dec53',
|
||
|
||
getName: function (iid) {
|
||
switch (iid.toLowerCase()) {
|
||
case 'dd84f196-0028-4e38-a36d-27c214f65c53':
|
||
return _chartType.Alert;
|
||
case '2ef390cc-ab7a-402b-8624-6b38eccc1440':
|
||
return _chartType.Bar2D;
|
||
case 'f7233ba2-b13c-4062-9e68-f2ae102b2ed2':
|
||
return _chartType.Bar3D;
|
||
case '2f9f6c14-fa70-4f31-8bab-01a32933efce':
|
||
return _chartType.Column2D;
|
||
case '228d7392-9be7-4d22-87a0-61444b48f7d2':
|
||
return _chartType.Column3D;
|
||
case '2254a334-3c12-4f1c-a12c-82fada556ba4':
|
||
return _chartType.ColumnLine;
|
||
case 'fba92b54-e4a1-4ced-8c71-72ba307909c5':
|
||
return _chartType.Favorites;
|
||
case 'dfeb1c9a-10a3-4ba3-bad1-da5108c703ea':
|
||
return _chartType.FRPT;
|
||
case '7f8c5164-5960-4a65-9501-3df88f90f4e5':
|
||
return _chartType.Scorecard;
|
||
case 'fd555bde-8bac-4f89-99cc-09c5d9c11f58':
|
||
return _chartType.Gauge;
|
||
case 'a570f4bd-79a9-488b-8d26-7d3871061718':
|
||
return _chartType.Grid;
|
||
case '10fdc141-4f5e-4ea8-ad69-1d1040cd3a5f':
|
||
return _chartType.Grid3D;
|
||
case '04941378-d5b2-462a-8a5f-c92bc344f1f1':
|
||
return _chartType.Line2D;
|
||
case '9a6cbbea-9108-4fc1-9a2e-1411139f41cf':
|
||
return _chartType.Line3D;
|
||
case '0c0d543e-c659-4e9f-b408-ce9392a495ad':
|
||
return _chartType.List;
|
||
case '18923b34-9288-4079-b16a-c04ed1e09a63':
|
||
return _chartType.Pie;
|
||
case 'a43a7dc9-f8f3-4202-84f8-34b3239960cc':
|
||
return _chartType.Rss;
|
||
case '3e47d021-f7e6-42ec-96e3-c4626c7e176b':
|
||
return _chartType.Scatter;
|
||
case '2ca6e0d1-d675-4a2c-8bef-325cfcd674bb':
|
||
return _chartType.Stock;
|
||
case '1a810091-a69b-4fd0-9a4c-5d57af7ebe7f':
|
||
return _chartType.Video;
|
||
case '6f35db66-32a8-43ae-8b4e-fb74fc8ba971':
|
||
return _chartType.WebForm;
|
||
case '0c71443c-49b5-474d-b1cd-1a53030dec53':
|
||
return _chartType.MapView;
|
||
}
|
||
},
|
||
|
||
IsChartType: function (chart, target) {
|
||
if (chart == null) {
|
||
return false;
|
||
}
|
||
var type = typeof chart === 'string' ? chart : chart.ChartClassIID;
|
||
return type === target;
|
||
},
|
||
IsD3Chart: function (chart) {
|
||
var type = typeof chart === 'string' ? chart : chart.ChartClassIID;
|
||
switch (type) {
|
||
case ChartTypeEnum.Bar3D:
|
||
case ChartTypeEnum.Column3D:
|
||
case ChartTypeEnum.Grid3D:
|
||
case ChartTypeEnum.Line3D:
|
||
return true;
|
||
}
|
||
return false;
|
||
},
|
||
IsD2Chart: function (chart) {
|
||
var type = typeof chart === 'string' ? chart : chart.ChartClassIID;
|
||
switch (type) {
|
||
case ChartTypeEnum.Bar2D:
|
||
case ChartTypeEnum.Column2D:
|
||
case ChartTypeEnum.Grid2D:
|
||
case ChartTypeEnum.Line2D:
|
||
case ChartTypeEnum.Pie:
|
||
case ChartTypeEnum.ColumnAndLine:
|
||
return true;
|
||
}
|
||
return false;
|
||
},
|
||
IsDimChart: function (chart) {
|
||
var type = typeof chart === 'string' ? chart : chart.ChartClassIID;
|
||
switch (type) {
|
||
// TODO:
|
||
case ChartTypeEnum.Bar2D:
|
||
case ChartTypeEnum.Column2D:
|
||
case ChartTypeEnum.Grid2D:
|
||
case ChartTypeEnum.Line2D:
|
||
case ChartTypeEnum.Pie:
|
||
case ChartTypeEnum.ColumnAndLine:
|
||
case ChartTypeEnum.Bar3D:
|
||
case ChartTypeEnum.Column3D:
|
||
case ChartTypeEnum.Grid3D:
|
||
case ChartTypeEnum.Line3D:
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
};
|
||
}
|
||
|
||
var DBDataType = {
|
||
dtString: 1,
|
||
dtInteger: 2,
|
||
dtFloat: 3,
|
||
dtDate: 4,
|
||
dtBoolean: 5,
|
||
dtGuid: 6,
|
||
getName: function (dbType) {
|
||
switch (dbType) {
|
||
case 1:
|
||
return "String";
|
||
case 2:
|
||
return "Integer";
|
||
case 3:
|
||
return "Float";
|
||
case 4:
|
||
return "Date";
|
||
case 5:
|
||
return "Boolean";
|
||
case 6:
|
||
return "Guid";
|
||
}
|
||
},
|
||
isDefined: function (v) {
|
||
switch (v) {
|
||
case 1:
|
||
case 2:
|
||
case 3:
|
||
case 4:
|
||
case 5:
|
||
case 6:
|
||
return true;
|
||
}
|
||
return false;
|
||
},
|
||
canConvertTo: function (current, target) {
|
||
if (current === target) {
|
||
return true;
|
||
}
|
||
if (target === DBDataType.dtString) {
|
||
return true;
|
||
}
|
||
if (target === DBDataType.dtFloat && current === DBDataType.dtInteger) {
|
||
return true;
|
||
}
|
||
if (current === DBDataType.dtFloat && target === DBDataType.dtInteger) {
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
};
|
||
|
||
// 0-weak, 1-medium, 2-strong
|
||
function getStrength(val) {
|
||
if (typeof val !== 'string') {
|
||
return 0;
|
||
}
|
||
if (val.length < 8) {
|
||
return 0;
|
||
}
|
||
var lowers = 0;
|
||
var uppers = 0;
|
||
var nums = 0;
|
||
var others = 0;
|
||
for (var i = 0; i < val.length; i++) {
|
||
var c = val[i];
|
||
if (c >= 'A' && c <= 'Z') {
|
||
uppers++;
|
||
} else if (c >= 'a' && c <= 'z') {
|
||
lowers++;
|
||
} else if (c >= '0' && c <= '9') {
|
||
nums++;
|
||
} else {
|
||
others++;
|
||
}
|
||
}
|
||
if (lowers == val.length || uppers == val.length || nums == val.length || others == val.length) {
|
||
return 0;
|
||
} else if (lowers + uppers == val.length || lowers + nums == val.length || lowers + others == val.length ||
|
||
uppers + nums == val.length || uppers + others == val.length ||
|
||
nums + others == val.length || uppers == 0 || lowers == 0 || nums == 0) {
|
||
return 1;
|
||
}
|
||
return 2;
|
||
}
|
||
|
||
function isEmail(val) {
|
||
var r = /^\w[-\w.+]*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
|
||
return r.test(val);
|
||
}
|
||
|
||
function isUserID(val) {
|
||
var r = /^[a-zA-Z0-9\\_-]+$/;
|
||
return r.test(val);
|
||
}
|
||
|
||
function isURL(val) {
|
||
var r = /^(https?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?$/;
|
||
return r.test(val);
|
||
}
|
||
|
||
function htmlencode(str, ele) {
|
||
if (ele) {
|
||
return ele.text(str).html();
|
||
}
|
||
return $('<span></span>').text(str).html();
|
||
}
|
||
|
||
function htmldecode(str, ele) {
|
||
if (ele) {
|
||
return ele.html(str).text();
|
||
}
|
||
return $('<span></span>').html(str).text();
|
||
}
|
||
|
||
function prevent(e) {
|
||
if (e.preventDefault != null) {
|
||
e.preventDefault();
|
||
} else {
|
||
e.returnValue = false;
|
||
}
|
||
}
|
||
|
||
$.fn.number = function (flag) {
|
||
return this.each(function () {
|
||
this.addEventListener('keydown', function (e) {
|
||
if (e.keyCode === 8 || e.keyCode === 9) {
|
||
// Backspace
|
||
// Tab
|
||
} else if (e.keyCode === 46) {
|
||
// Delete
|
||
} else if (e.keyCode >= 35 && e.keyCode <= 40) {
|
||
// End, Home
|
||
// Arrow Left, Up, Right, Down
|
||
} else if (e.keyCode === 65 && e.ctrlKey) {
|
||
// Ctrl+A
|
||
} else if ((flag === 'float') && (e.keyCode === 110 || e.keyCode === 190)) {
|
||
// . || Decimal
|
||
if (this.value.indexOf('.') >= 0) {
|
||
prevent(e);
|
||
}
|
||
} else if (e.keyCode === 173 || e.keyCode === 189 || e.keyCode === 109) {
|
||
// - || NumpadSubtract
|
||
if (flag === 'noneg') {
|
||
prevent(e);
|
||
} else if (this.value.indexOf('-') >= 0) {
|
||
prevent(e);
|
||
} else if (selectionStart(e.target) !== 0) {
|
||
prevent(e);
|
||
}
|
||
} else if ((e.keyCode < 48 || e.keyCode > 57) &&
|
||
(e.keyCode < 96 || e.keyCode > 105)) {
|
||
prevent(e);
|
||
} else if (e.shiftKey) {
|
||
prevent(e);
|
||
}
|
||
});
|
||
});
|
||
};
|
||
|
||
// multi-language
|
||
(function () {
|
||
'use strict';
|
||
|
||
function getKey(ele, attr) {
|
||
var key = ele.attr(attr).replace(/[.]/g, '_');
|
||
if (!key.startWith('LHBIS_') && !key.startWith('Extend_LHBIS_') && !key.startWith('FI_HOST_') && !key.startWith('FI_FRS_')) {
|
||
key = 'LHBIS_FIC_CLIENT_MODULES_' + key;
|
||
}
|
||
return key;
|
||
}
|
||
|
||
$.fn.applyLanguageText = function (includeTitle) {
|
||
return this.each(function () {
|
||
var es = $(this).find('[data-lgid]');
|
||
var ele, key;
|
||
for (var i = 0; i < es.length; i++) {
|
||
ele = $(es[i]);
|
||
key = getKey(ele, 'data-lgid');
|
||
if (ele.is('input')) {
|
||
ele.val(GetLanguageByKey(key, ele.val()));
|
||
} else {
|
||
ele.text(GetLanguageByKey(key, ele.text()));
|
||
}
|
||
}
|
||
if (includeTitle) {
|
||
es = $(this).find('[data-title-lgid]');
|
||
for (var j = 0; j < es.length; j++) {
|
||
ele = $(es[j]);
|
||
key = getKey(ele, 'data-title-lgid');
|
||
ele.attr('title', GetLanguageByKey(key, key));
|
||
}
|
||
}
|
||
});
|
||
};
|
||
|
||
})();
|
||
|
||
|
||
// 测试使用
|
||
//const DEBUG_BREAK = 1;
|
||
var COMMON_USER = 1;
|
||
var ADMIN_USER = 2;
|
||
var READONLY_USER = 0;
|
||
var SUPERADMIN_USER = 3;
|
||
|
||
function AdminOrSuperAdmin() {
|
||
var userType = loginedUser("UserType");
|
||
return userType == ADMIN_USER || userType == SUPERADMIN_USER;
|
||
}
|
||
|
||
var LEVEL_PRIVATE = 0;
|
||
var LEVEL_PUBLIC = 1;
|
||
var LEVEL_SYSTEM = 2;
|
||
var LEVEL_3RD_BORDER = 11;
|
||
|
||
var BOARD_PIVOT = true;
|
||
|
||
var YPIVOT = 1;
|
||
var XLEVELPIVOT = 2;
|
||
var ZLEVELPIVOT = 3;
|
||
|
||
var DROPDOWN_PIVOT = 0;
|
||
var INPUT_PIVOT = 1;
|
||
|
||
var DATE_TYPE = 4;
|
||
|
||
var ANIMATE_SPEED = 'fast';
|
||
var ANIMATE_FAST_SPEED = 90;
|
||
|
||
var BORDER_PADDING = 2;
|
||
var POS_PADDING = 6;
|
||
|
||
var PIVOTVAL = {
|
||
ALL: { v: '@all' },
|
||
NULL: { v: '@null', text: '( Null )' },
|
||
EMPTY: { v: '', text: '( Blank )' }
|
||
};
|
||
Object.defineProperty(PIVOTVAL.ALL, 'text', {
|
||
get: function () {
|
||
if (this._text == null) {
|
||
this._text = GetLanguageByKey('LHBIS_FIC_CHARTS_COMMONCHART_A007', '( All )');
|
||
}
|
||
return this._text;
|
||
},
|
||
set: function () {
|
||
// ignore
|
||
}
|
||
});
|
||
|
||
|
||
function replaceText(val) {
|
||
switch (val) {
|
||
case PIVOTVAL.ALL.v:
|
||
return PIVOTVAL.ALL.text;
|
||
case PIVOTVAL.NULL.v:
|
||
return PIVOTVAL.NULL.text;
|
||
case PIVOTVAL.EMPTY.v:
|
||
return PIVOTVAL.EMPTY.text;
|
||
}
|
||
return val;
|
||
}
|
||
|
||
function SetColWidthSort(columns, gridwidth) {
|
||
for (var i = 0; i < columns.length; i++) {
|
||
if (columns[i].name == gridwidth.ColumnKey) {
|
||
columns[i].width = gridwidth.Width;
|
||
columns[i].Sort = gridwidth.Sort;
|
||
columns[i].displayIndex = gridwidth.DisplayIndex;
|
||
return columns[i];
|
||
}
|
||
}
|
||
return undefined;
|
||
}
|
||
|
||
var DEFAULT_LANG = {
|
||
not_signed: 'Not signed.',
|
||
unknown_error: 'There was an error while the chart was loading. Please try again later.',
|
||
cannot_be_public: 'This Board has at least one Private Chart and can not be saved as Public.',
|
||
level: 'Level',
|
||
multi: 'Multi',
|
||
newboard: 'Untitled Board',
|
||
filter: 'Filter',
|
||
FIC: 'Foresight Intelligence Center',
|
||
FICManagement: 'FIC Management',
|
||
must_select_one: 'You must select at least one item.',
|
||
popup_blocked: 'Pop-up window was blocked on this page.',
|
||
save: 'Save'
|
||
};
|
||
Object.defineProperty(DEFAULT_LANG, 'all', {
|
||
get: function () {
|
||
return PIVOTVAL.ALL.text;
|
||
}
|
||
});
|
||
(function () {
|
||
'use strict';
|
||
|
||
function getText(obj, key, lgid, text) {
|
||
if (!obj.__res) {
|
||
obj.__res = {};
|
||
}
|
||
var s = obj.__res[key];
|
||
if (typeof s === 'string') {
|
||
return s;
|
||
}
|
||
s = obj.__res[key] = GetLanguageByKey(lgid, text);
|
||
return s;
|
||
}
|
||
|
||
Object.defineProperty(DEFAULT_LANG, 'yes', {
|
||
get: function () { return getText(this, 'yes', 'LHBIS_MULTILANGUAGE_LHBISMESSAGEBOX_A006', 'Yes'); }
|
||
});
|
||
Object.defineProperty(DEFAULT_LANG, 'no', {
|
||
get: function () { return getText(this, 'no', 'LHBIS_MULTILANGUAGE_LHBISMESSAGEBOX_A007', 'No'); }
|
||
});
|
||
Object.defineProperty(DEFAULT_LANG, 'ok', {
|
||
get: function () { return getText(this, 'ok', 'LHBIS_MULTILANGUAGE_LHBISMESSAGEBOX_A004', 'OK'); }
|
||
});
|
||
Object.defineProperty(DEFAULT_LANG, 'cancel', {
|
||
get: function () { return getText(this, 'cancel', 'LHBIS_MULTILANGUAGE_LHBISMESSAGEBOX_A005', 'Cancel'); }
|
||
});
|
||
Object.defineProperty(DEFAULT_LANG, 'save', {
|
||
get: function () { return getText(this, 'save', 'LHBIS_FIC_CLIENT_MODULES_UserOptionsCtrl_A006', 'Save'); }
|
||
});
|
||
Object.defineProperty(DEFAULT_LANG, 'next', {
|
||
get: function () { return getText(this, 'next', 'LHBIS_MULTILANGUAGE_COMMON_A005', 'Next'); }
|
||
});
|
||
})();
|
||
|
||
// 默认参数
|
||
if (typeof _defs !== 'object') {
|
||
_defs = {
|
||
select: function (id) {
|
||
return '#' + id;
|
||
},
|
||
selectbd: function (iid) {
|
||
return '#board' + iid;
|
||
},
|
||
getboardiid: function (id) {
|
||
return String(id).substring(5);
|
||
},
|
||
R: {
|
||
'personal_checkbox': 'wsp_personal',
|
||
'board_header': 'header',
|
||
'workspace_info': 'workspace_info',
|
||
'theme_selector': 'seltheme'
|
||
}
|
||
};
|
||
}
|
||
|
||
// ui工具类
|
||
if (typeof _utility !== 'object') {
|
||
_utility = {
|
||
menuHolder: 'chartMenu',
|
||
pinOff: '../image/pin0.png',
|
||
pinOn: '../image/pin1.png',
|
||
drilldowns: [],
|
||
increment: 0,
|
||
// 主题样式
|
||
themes: [],
|
||
chartColorSchemes: [],
|
||
// TODO: all workspaces
|
||
workspaces: [],
|
||
loginedUser: undefined,
|
||
currentLang: 'en-us',
|
||
version: "5.1.623",
|
||
dateTimeFormat: 'm/dd/yyyy',
|
||
//GuidEmpty: "00000000-0000-0000-0000-000000000000",
|
||
isGuid: function (v) {
|
||
return /^[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}$/.test(v);
|
||
},
|
||
//isReadOnly: true,
|
||
|
||
eq: function (s1, s2) {
|
||
if (typeof s1 === 'string' && typeof s2 === 'string') {
|
||
return s1.toLowerCase() == s2.toLowerCase();
|
||
}
|
||
return s1 == s2;
|
||
}
|
||
};
|
||
Object.defineProperty(_utility, 'GuidEmpty', { get: function () { return '00000000-0000-0000-0000-000000000000'; } });
|
||
Object.defineProperty(_utility, 'GuidOne', { get: function () { return '00000000-0000-0000-0000-000000000001'; } });
|
||
var modal = window['g5-modal'];
|
||
if (modal != null) {
|
||
_utility.showMessage = modal.showMessage;
|
||
}
|
||
|
||
function writelog(source, message, detail) {
|
||
_network.query('WriteLog', [source, message, detail], undefined, undefined, true);
|
||
}
|
||
|
||
function writeexlog(source, err) {
|
||
var message, detail = "";
|
||
if (err) {
|
||
message = err.message;
|
||
detail = err.stack;
|
||
}
|
||
_network.query('WriteLog', [source, message, detail], undefined, undefined, true);
|
||
}
|
||
|
||
var languageDoc = undefined;
|
||
function loadXmlFile(xmlFile)//xmlFile 是xml文件的地址
|
||
{
|
||
var xmlDom = null;
|
||
//if (window.ActiveXObject)//IE浏览器中读取xml文件
|
||
//if ('ActiveXObject' in window) // IE11下typeof window.ActiveXObject === 'undefined'
|
||
//{
|
||
// xmlDom = new ActiveXObject("Microsoft.XMLDOM");
|
||
// xmlDom.async = "false";
|
||
// xmlDom.load(xmlFile);
|
||
//}
|
||
//else
|
||
if (document.implementation && document.implementation.createDocument) {
|
||
//Firefox,Chrome 浏览器中读取xml文件 ,Chrome 需要开服务器才能访问
|
||
//var xmlhttp = new window.XMLHttpRequest();
|
||
//xmlhttp.open("GET", xmlFile, false);
|
||
//xmlhttp.send(null);
|
||
//xmlDom = xmlhttp.responseXML;
|
||
$.ajax({
|
||
url: xmlFile,
|
||
dataType: 'xml',
|
||
type: 'GET',
|
||
async: false,
|
||
success: function (xml) {
|
||
xmlDom = xml;
|
||
},
|
||
error: function () {
|
||
xmlDom = null;
|
||
}
|
||
});
|
||
}
|
||
else {
|
||
xmlDom = null;
|
||
}
|
||
return xmlDom;
|
||
};
|
||
|
||
function GetFRPTLanguageByKey(key, defaultValue) {
|
||
return GetLanguageByKey('FI_FRS_' + key, defaultValue);
|
||
}
|
||
|
||
function GetLanguageByKey(key, defaultValue) {
|
||
var languageDir = _utility.currentLang;
|
||
if (languageDir === "zh-cn") {
|
||
languageDir = "zh-chs";
|
||
}
|
||
if (languageDoc == undefined) {
|
||
var sp;
|
||
if (typeof _utility.rootPath === 'string') {
|
||
sp = _utility.rootPath;
|
||
} else if (typeof sitePath === 'string') {
|
||
sp = sitePath;
|
||
} else {
|
||
sp = '';
|
||
}
|
||
languageDoc = loadXmlFile(sp + "Languages\\" + languageDir + "\\textres.xml");
|
||
if (languageDoc == null) {
|
||
if (_utility.currentLang.indexOf('en') >= 0) {
|
||
languageDir = "en-us";
|
||
} else if (_utility.currentLang.indexOf('fr') >= 0) {
|
||
languageDir = "fr-fr";
|
||
} else {
|
||
languageDir = "en-us";
|
||
}
|
||
languageDoc = loadXmlFile(sp + "Languages\\" + languageDir + "\\textres.xml");
|
||
}
|
||
}
|
||
try {
|
||
if (languageDoc) {
|
||
key = key.toUpperCase();
|
||
// IE下找不到tag会抛出Error,2017/6/21
|
||
var val = languageDoc.getElementsByTagName(key);
|
||
if (val && val.length > 0) {
|
||
// IE下取tag为''的元素时会返回所有element
|
||
if (val.length > 10) {
|
||
return defaultValue;
|
||
}
|
||
return val[0].textContent || val[0].text;
|
||
}
|
||
}
|
||
} catch (e) { }
|
||
return defaultValue;
|
||
}
|
||
|
||
function loginedUser(key) {
|
||
if (key === undefined || !_utility.loginedUser)
|
||
return _utility.loginedUser;
|
||
|
||
if (key == 'UserType' && _utility.loginedUser.UserType === undefined)
|
||
return READONLY_USER;
|
||
return _utility.loginedUser[key];
|
||
}
|
||
|
||
function UserIsAdmin() {
|
||
//var user = loginedParameter("UserID");
|
||
//return $.ignoreEquals(user, "admin");
|
||
return loginedParameter("UserType") === 3;
|
||
}
|
||
|
||
function loginedParameter(key) {
|
||
var user = _utility.loginedUser;
|
||
if (user == null) {
|
||
return null;
|
||
}
|
||
if (key == null || !user.UserParameters) {
|
||
return user.UserParameters;
|
||
}
|
||
return user.UserParameters[key];
|
||
}
|
||
|
||
var PMS = {
|
||
change_board_name: 0,
|
||
add_board: 1,
|
||
close_board: 2,
|
||
could_personal: 3,
|
||
close_chart: 4
|
||
};
|
||
|
||
// 判断是否拥有某项权限
|
||
function hasPermission(key, obj) {
|
||
var userType = loginedUser('UserType');
|
||
var userIId = loginedUser('userIId');
|
||
switch (key) {
|
||
// 修改board名称
|
||
case PMS.change_board_name:
|
||
if (obj.IsNew || _utility.eq(obj.Creater, userIId)) {
|
||
// 该board的创建者,可以修改其名称
|
||
return true;
|
||
}
|
||
if (AdminOrSuperAdmin() && obj.Level === LEVEL_PUBLIC) {
|
||
// admin类型用户可以修改公共board名称
|
||
return true;
|
||
}
|
||
if (userType === COMMON_USER && obj.Level === LEVEL_PUBLIC && loginedUser('CanAccessPublic')) {
|
||
//普通类型用户 公有board 需要有权限
|
||
return true;
|
||
}
|
||
break;
|
||
|
||
// 添加/关闭board
|
||
case PMS.add_board:
|
||
if (userType != READONLY_USER) {
|
||
if (obj || _workspace.isPersonal) {
|
||
// 新建工作区或personal状态
|
||
return true;
|
||
}
|
||
if (_workspace.IsMyCreate && _workspace.level === LEVEL_PRIVATE) {
|
||
// 该私有workspace的创建者
|
||
return true;
|
||
}
|
||
if (AdminOrSuperAdmin() && _workspace.level === LEVEL_PUBLIC) {
|
||
// admin类型的用户
|
||
return true;
|
||
}
|
||
if (userType === COMMON_USER && _workspace.level === LEVEL_PUBLIC && loginedUser('CanAccessPublic')) {
|
||
//普通类型用户 公有wsp 需要有权限
|
||
return true;
|
||
}
|
||
}
|
||
break;
|
||
case PMS.close_board:
|
||
if (obj || _workspace.isPersonal || _workspace.isNew) {
|
||
// 新建工作区或personal状态
|
||
return true;
|
||
}
|
||
if (_utility.eq(_workspace.creater, userIId)) {
|
||
// 该workspace的创建者
|
||
if (userType <= COMMON_USER && !loginedUser('CanAccessPublic')) { }
|
||
else {
|
||
return true;
|
||
}
|
||
}
|
||
if (_workspace.level === LEVEL_PUBLIC) {
|
||
if (AdminOrSuperAdmin()) {
|
||
// admin类型的用户
|
||
return true;
|
||
} else if (userType >= COMMON_USER && loginedUser('CanAccessPublic')) {
|
||
return true;
|
||
}
|
||
}
|
||
|
||
if (_workspace.level === LEVEL_PRIVATE) {
|
||
return true;
|
||
}
|
||
|
||
break;
|
||
|
||
// 可以进行personal操作
|
||
case PMS.could_personal:
|
||
// readonly
|
||
if (userType !== READONLY_USER && obj) {
|
||
return couldPersonal(obj.l);
|
||
}
|
||
break;
|
||
|
||
// 可以关闭chart
|
||
case PMS.close_chart:
|
||
// ((chartobj.board.level > 10 || (loginUserType === COMMON_USER && !loginedUser('CanAccessPublic') && chartobj.board.level != 0)) &&
|
||
// (chartobj.Level > 10 || (loginUserType === COMMON_USER && chartobj.Level != 0)))
|
||
if ((obj.b >= LEVEL_3RD_BORDER || (userType === COMMON_USER && !loginedUser('CanAccessPublic') && obj.b != LEVEL_PRIVATE)) &&
|
||
(obj.c >= LEVEL_3RD_BORDER || (userType === COMMON_USER && obj.c != LEVEL_PRIVATE))) {
|
||
return true;
|
||
}
|
||
break;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
function couldPersonal(level) {
|
||
return level == LEVEL_PUBLIC || level >= LEVEL_3RD_BORDER;
|
||
}
|
||
|
||
function getUtcDateString(str) {
|
||
if ($.nullOrEmpty(str)) {
|
||
return str;
|
||
}
|
||
if (/[+Z]/.test(str)) {
|
||
return str;
|
||
}
|
||
return str + 'Z';
|
||
}
|
||
|
||
function getFormatDate(date, notime, utc) {
|
||
var dt;
|
||
if (typeof date === 'string') {
|
||
if (notime) {
|
||
if (utc) {
|
||
dt = new Date(getUtcDateString(date));
|
||
} else {
|
||
dt = new Date(date);
|
||
}
|
||
} else {
|
||
dt = new Date(parseInt(date));
|
||
}
|
||
} else if (typeof date === 'number') {
|
||
dt = new Date(date);
|
||
} else if (date instanceof Date) {
|
||
dt = date;
|
||
} else {
|
||
throw new Error('Wrong type: [' + (typeof date) + '] ' + date);
|
||
}
|
||
|
||
var d;
|
||
if (utc) {
|
||
d = (dt.getUTCMonth() + 1) + '/' + dt.getUTCDate() + '/' + dt.getUTCFullYear();
|
||
} else {
|
||
d = (dt.getMonth() + 1) + '/' + dt.getDate() + '/' + dt.getFullYear();
|
||
}
|
||
if (notime) {
|
||
return d;
|
||
}
|
||
var minutes = dt.getMinutes();
|
||
var hours = dt.getHours();
|
||
return d + ' '
|
||
+ (hours < 10 ? '0' + hours : hours) + ':'
|
||
+ (minutes < 10 ? '0' + minutes : minutes);
|
||
}
|
||
|
||
function getColorFromString(color, defaultColor) {
|
||
if (typeof color !== 'string')
|
||
return defaultColor;
|
||
if (color.toLowerCase().indexOf("rgba") < 0) {
|
||
if (color.length === 0 || color[0] !== '#')
|
||
return defaultColor;
|
||
color = color.substring(1);
|
||
var r, g, b;
|
||
if (color.length === 8) {
|
||
a = parseInt(color.substring(0, 2), 16);
|
||
r = parseInt(color.substring(2, 4), 16);
|
||
g = parseInt(color.substring(4, 6), 16);
|
||
b = parseInt(color.substring(6, 8), 16);
|
||
return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
|
||
} else if (color.length === 6) {
|
||
r = parseInt(color.substring(0, 2), 16);
|
||
g = parseInt(color.substring(2, 4), 16);
|
||
b = parseInt(color.substring(4, 6), 16);
|
||
return r + ',' + g + ',' + b;
|
||
}
|
||
|
||
return '#' + color;
|
||
}
|
||
else {
|
||
return color;
|
||
}
|
||
}
|
||
|
||
function getColorFromRGBA(rgba, raw) {
|
||
var r = rgba.Red + ',' + rgba.Green + ',' + rgba.Blue;
|
||
if (raw)
|
||
return r;
|
||
return 'rgba(' + r + ',' + rgba.Alpha + ')';
|
||
}
|
||
|
||
function getColorFromRGBARatio(rgba, ratio) {
|
||
return 'rgba(' + (rgba.Red * ratio) + ',' + (rgba.Green * ratio) + ',' + (rgba.Blue * ratio) + ',' + rgba.Alpha + ')';
|
||
}
|
||
|
||
function getRgbFromString(color, defaultColor, ratio) {
|
||
if (typeof color !== 'string')
|
||
return defaultColor;
|
||
if (color.length === 0 || color[0] !== '#')
|
||
return defaultColor;
|
||
color = color.substring(1);
|
||
var r, g, b;
|
||
if (color.length === 8) {
|
||
a = parseInt(color.substring(0, 2), 16);
|
||
r = parseInt(color.substring(2, 4), 16);
|
||
g = parseInt(color.substring(4, 6), 16);
|
||
b = parseInt(color.substring(6, 8), 16);
|
||
return getLighterColor(r, g, b, isNaN(ratio) ? 1 : ratio); // + ',' + a;
|
||
} else if (color.length === 3) {
|
||
r = parseInt(color.substring(0, 1), 16);
|
||
g = parseInt(color.substring(1, 2), 16);
|
||
b = parseInt(color.substring(2, 3), 16);
|
||
return getLighterColor((r * 16 + r), (g * 16 + g), (b * 16 + b), isNaN(ratio) ? 1 : ratio);
|
||
}
|
||
|
||
r = parseInt(color.substring(0, 2), 16);
|
||
g = parseInt(color.substring(2, 4), 16);
|
||
b = parseInt(color.substring(4, 6), 16);
|
||
return getLighterColor(r, g, b, isNaN(ratio) ? 1 : ratio);
|
||
}
|
||
|
||
function getLighterColor(r, g, b, ratio) {
|
||
r = Math.min(round(r * ratio), 255);
|
||
g = Math.min(round(g * ratio), 255);
|
||
b = Math.min(round(b * ratio), 255);
|
||
return r + ',' + g + ',' + b;
|
||
}
|
||
|
||
function round(num) {
|
||
return (num + 0.5) << 0;
|
||
}
|
||
|
||
function endsWith(str, suffix) {
|
||
if (typeof suffix !== 'string') {
|
||
return str === suffix;
|
||
}
|
||
if (typeof str !== 'string')
|
||
return false;
|
||
var i = str.indexOf('?');
|
||
if (i > 0) {
|
||
str = str.substring(0, i);
|
||
}
|
||
return str.indexOf(suffix, str.length - suffix.length) !== -1;
|
||
}
|
||
|
||
//空字符串校验
|
||
function strIsNullorEmpty(str) {
|
||
//if (str == undefined || str == null || str.length == 0 || str.trim() == "") {
|
||
// return true;
|
||
//}
|
||
//return false;
|
||
return $.nullOrWhite(str);
|
||
}
|
||
|
||
//GUID校验
|
||
function isGUID(val) {
|
||
if (val) {
|
||
var reg = /^[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}$/;
|
||
return reg.test(val);
|
||
}
|
||
return false;
|
||
}
|
||
|
||
function stopEventPrevent(e) {
|
||
if (e && e.preventDefault)
|
||
e.preventDefault();
|
||
else
|
||
window.event.returnValue = false;
|
||
return false;
|
||
}
|
||
|
||
function IngeterTextKeyUp(obj, maxnumber) {
|
||
if ((obj.value + "").startWith("0")) {
|
||
obj.value = "0"
|
||
} else {
|
||
obj.value = obj.value.replace(/[^0-9-]+/, '');
|
||
if (maxnumber && $.parseIntStrict(obj.value) > maxnumber) {
|
||
obj.value = maxnumber;
|
||
}
|
||
}
|
||
}
|
||
|
||
function FloatTextKeyUp(obj) {
|
||
|
||
//得到第一个字符是否为负号
|
||
var t = obj.value.charAt(0);
|
||
//先把非数字的都替换掉,除了数字和.
|
||
obj.value = obj.value.replace(/[^\d\.]/g, '');
|
||
//必须保证第一个为数字而不是.
|
||
obj.value = obj.value.replace(/^\./g, '');
|
||
//保证只有出现一个.而没有多个.
|
||
obj.value = obj.value.replace(/\.{2,}/g, '.');
|
||
//保证.只出现一次,而不能出现两次以上
|
||
obj.value = obj.value.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.');
|
||
//保证不会出现0+数字
|
||
if ((obj.value + "").startWith("0") && !(obj.value + "").startWith("0.")) {
|
||
obj.value = "0"
|
||
}
|
||
//如果第一位是负号,则允许添加
|
||
if (t == '-') {
|
||
obj.value = '-' + obj.value;
|
||
}
|
||
}
|
||
|
||
function copyTextToClipboard(text) {
|
||
var textArea = document.createElement("textarea");
|
||
|
||
//
|
||
// *** This styling is an extra step which is likely not required. ***
|
||
//
|
||
// Why is it here? To ensure:
|
||
// 1. the element is able to have focus and selection.
|
||
// 2. if element was to flash render it has minimal visual impact.
|
||
// 3. less flakyness with selection and copying which **might** occur if
|
||
// the textarea element is not visible.
|
||
//
|
||
// The likelihood is the element won't even render, not even a flash,
|
||
// so some of these are just precautions. However in IE the element
|
||
// is visible whilst the popup box asking the user for permission for
|
||
// the web page to copy to the clipboard.
|
||
//
|
||
|
||
// Place in top-left corner of screen regardless of scroll position.
|
||
textArea.style.position = 'fixed';
|
||
textArea.style.top = 0;
|
||
textArea.style.left = 0;
|
||
|
||
// Ensure it has a small width and height. Setting to 1px / 1em
|
||
// doesn't work as this gives a negative w/h on some browsers.
|
||
textArea.style.width = '2em';
|
||
textArea.style.height = '2em';
|
||
|
||
// We don't need padding, reducing the size if it does flash render.
|
||
textArea.style.padding = 0;
|
||
|
||
// Clean up any borders.
|
||
textArea.style.border = 'none';
|
||
textArea.style.outline = 'none';
|
||
textArea.style.boxShadow = 'none';
|
||
|
||
// Avoid flash of white box if rendered for any reason.
|
||
textArea.style.background = 'transparent';
|
||
|
||
|
||
textArea.value = text;
|
||
|
||
document.body.appendChild(textArea);
|
||
|
||
textArea.select();
|
||
|
||
try {
|
||
var successful = document.execCommand('copy');
|
||
var msg = successful ? 'successful' : 'unsuccessful';
|
||
//console.log('Copying text command was ' + msg);
|
||
} catch (err) {
|
||
writeexlog("copyTextToClipboard", err);
|
||
}
|
||
|
||
document.body.removeChild(textArea);
|
||
}
|
||
|
||
(function () {
|
||
'use strict';
|
||
|
||
// jQuery UI扩展
|
||
$.fn.label = function (txt) {
|
||
return this.each(function () {
|
||
$(this).children('span').text(txt);
|
||
});
|
||
};
|
||
//*/
|
||
|
||
|
||
// resizer 扩展
|
||
//var CURSORS = ['ew-resize', 'ns-resize', 'nwse-resize', 'ew-resize', null, 'nesw-resize', null, 'ns-resize', 'nesw-resize', null, null, 'nwse-resize'];
|
||
|
||
var resizingMod = 0;
|
||
var iX, iY;
|
||
var cX, cY;
|
||
var iWidth, iHeight;
|
||
|
||
// border-resize, →↓←↑, 1,2,4,8
|
||
function resizeChart(e) {
|
||
|
||
var ev = $.clientEvent(e, true, 0);
|
||
if (!ev) { return; }
|
||
|
||
var p = e.data[0];
|
||
resizingMod = e.data[1];
|
||
var div = e.data[2];
|
||
|
||
if (typeof p.start === 'function')
|
||
p.start(p);
|
||
//$('body').css('cursor', CURSORS[resizingMod]);
|
||
iWidth = div.width();
|
||
iHeight = div.height();
|
||
iX = ev.clientX;
|
||
iY = ev.clientY;
|
||
var o = _utility.getInnerOffset(div);
|
||
cX = o.left;
|
||
cY = o.top;
|
||
//Management里的Form可能要出现在IFRAME外的Body 所以得这样单独处理
|
||
if (p._this && p._this.parentDom) {
|
||
$(p._this.parentDom).touchmove(resizemove, 'chart_resize');
|
||
$(p._this.parentDom).touchup(resizeup, 'chart_resize');
|
||
}
|
||
else {
|
||
$(document).touchmove(resizemove, 'chart_resize');
|
||
$(document).touchup(resizeup, 'chart_resize');
|
||
}
|
||
|
||
function resizemove(e) {
|
||
var e = e || window.event;
|
||
var ev = $.clientEvent(e);
|
||
var wid = iWidth, hei = iHeight;
|
||
var offX = ev.clientX - iX;
|
||
var offY = ev.clientY - iY;
|
||
var x = cX, y = cY;
|
||
if ((resizingMod & 1) === 1) { wid += offX; }
|
||
if ((resizingMod & 2) === 2) { hei += offY; }
|
||
if ((resizingMod & 4) === 4) {
|
||
x += offX;
|
||
wid -= offX;
|
||
if (!isNaN(p.min_width) && wid < p.min_width) {
|
||
wid = p.min_width;
|
||
x = cX + iWidth - p.min_width;
|
||
}
|
||
}
|
||
if ((resizingMod & 8) === 8) {
|
||
y += offY;
|
||
hei -= offY;
|
||
if (!isNaN(p.min_height) && hei < p.min_height) {
|
||
hei = p.min_height;
|
||
y = cY + iHeight - p.min_height;
|
||
}
|
||
}
|
||
//alert(x + ',' + y + ',' + wid + ',' + hei);
|
||
if (typeof p.move === 'function')
|
||
p.move(x, y, wid, hei, div);
|
||
else {
|
||
div.css({
|
||
left: x,
|
||
top: y,
|
||
width: wid,
|
||
height: hei
|
||
});
|
||
}
|
||
}
|
||
function resizeup(e) {
|
||
if (p._this && p._this.parentDom) {
|
||
$(p._this.parentDom).off('.chart_resize');
|
||
}
|
||
else {
|
||
$(document).off('.chart_resize');
|
||
}
|
||
//$('body').css('cursor', '');
|
||
if (typeof p.end === 'function')
|
||
p.end(p);
|
||
}
|
||
}
|
||
|
||
$.fn.makeResizable = function (p) {
|
||
return this.each(function () {
|
||
var _this = $(this);
|
||
if (!p) p = {};
|
||
// right, bottom, left, top
|
||
$('<div class="chart_border right"></div>').css('display', p.display ? 'block' : 'none')
|
||
.touchdown([p, 1, _this], resizeChart)
|
||
.appendTo(_this);
|
||
$('<div class="chart_border bottom"></div>').css('display', p.display ? 'block' : 'none')
|
||
.touchdown([p, 2, _this], resizeChart)
|
||
.appendTo(_this);
|
||
$('<div class="chart_border left"></div>').css('display', p.display ? 'block' : 'none')
|
||
.touchdown([p, 4, _this], resizeChart)
|
||
.appendTo(_this);
|
||
$('<div class="chart_border top"></div>').css('display', p.display ? 'block' : 'none')
|
||
.touchdown([p, 8, _this], resizeChart)
|
||
.appendTo(_this);
|
||
// bottom-right, bottom-left, top-left, top-right
|
||
$('<div class="chart_border bottomright"></div>').css('display', p.display ? 'block' : 'none')
|
||
.touchdown([p, 3, _this], resizeChart)
|
||
.appendTo(_this);
|
||
$('<div class="chart_border bottomleft"></div>').css('display', p.display ? 'block' : 'none')
|
||
.touchdown([p, 6, _this], resizeChart)
|
||
.appendTo(_this);
|
||
$('<div class="chart_border topleft"></div>').css('display', p.display ? 'block' : 'none')
|
||
.touchdown([p, 12, _this], resizeChart)
|
||
.appendTo(_this);
|
||
$('<div class="chart_border topright"></div>').css('display', p.display ? 'block' : 'none')
|
||
.touchdown([p, 9, _this], resizeChart)
|
||
.appendTo(_this);
|
||
|
||
// max button
|
||
if (p.maxButton) {
|
||
var lastButton = _this.children('.form-head').children('.fa:last');
|
||
var maxButton = $('<div class="form-max fa"></div>');
|
||
maxButton.insertAfter(lastButton).click(function () {
|
||
var max = _this.data('maxFlag');
|
||
if (!max) {
|
||
max = _this.offset();
|
||
max.width = _this.width();
|
||
max.height = _this.height();
|
||
p.move(5, 5, window.innerWidth - 10, window.innerHeight - 15, _this);
|
||
_this.data('maxFlag', max);
|
||
} else {
|
||
_this.removeData('maxFlag');
|
||
p.move(max.left, max.top, max.width, max.height, _this);
|
||
}
|
||
});
|
||
}
|
||
});
|
||
};
|
||
//*/
|
||
|
||
|
||
$(document).bind('contextmenu', function (e) {
|
||
if (e.target && typeof e.target.tagName === 'string')
|
||
if ($.inArray(e.target.tagName.toUpperCase(), []) >= 0)
|
||
return true;
|
||
return false;
|
||
});
|
||
|
||
|
||
function padNumber(s) {
|
||
return s < 10 ? '0' + s : s;
|
||
}
|
||
_utility.titleBackgroud = '170,170,170';
|
||
// 默认边框颜色
|
||
_utility.borderColor = '170,170,170';
|
||
_utility.borderGrayColor = '170,170,170';
|
||
|
||
// 获取css样式表配置
|
||
_utility.getCss = function (key) {
|
||
for (var i = 0; i < document.styleSheets.length; i++) {
|
||
var css = document.styleSheets[i];
|
||
if (css.href === key || endsWith(css.href, key))
|
||
return css;
|
||
}
|
||
};
|
||
|
||
// 获取事件相对目标元素的y偏移量
|
||
_utility.getTargetOffsetY = function (e, target) {
|
||
var y = e.offsetY || (e.clientY - $(e.target).offset().top);
|
||
var obj = e.target;
|
||
while (obj && obj !== target) {
|
||
y += obj.offsetTop;
|
||
obj = obj.offsetParent;
|
||
}
|
||
return y;
|
||
};
|
||
|
||
// 获取目标元素的内部偏移量
|
||
_utility.getInnerOffset = function (ele) {
|
||
// _this.chartDiv.offset().left - (_this.container ? _this.getContainer().offset().left : 0) + _this.getContainer().scrollLeft();
|
||
//var offset = ele.offset();
|
||
//var obj = ele[0];
|
||
//while (obj && obj.offsetParent) {
|
||
// var j = ele.offsetParent();
|
||
// var o = j.offset();
|
||
// offset.left -= o.left - j.scrollLeft();
|
||
// offset.top -= o.top - j.scrollTop();
|
||
// obj = obj.offsetParent;
|
||
//}
|
||
//return offset;
|
||
return {
|
||
left: ele[0].offsetLeft,
|
||
top: ele[0].offsetTop
|
||
};
|
||
};
|
||
|
||
$.fn.offsetInParent = function (parent) {
|
||
var othis = this.offset();
|
||
var oparent = parent.offset();
|
||
return { left: (othis.left - oparent.left + parent.scrollLeft()), top: (othis.top - oparent.top + parent.scrollTop()) };
|
||
};
|
||
|
||
// 从Ticks获取时间
|
||
_utility.getDateFromTicks = function (ticks, offset) {
|
||
return new Date((ticks - 621355968000000000) / 10000 + (isNaN(offset) ? 0 : offset * 1000));
|
||
};
|
||
_utility.getTicksFromDate = function (date) {
|
||
return (date.getTime() * 10000) + 621355968000000000;
|
||
};
|
||
|
||
// 格式化日期
|
||
_utility.formatDate = function (date) {
|
||
return date.toLocaleString();
|
||
//return date.getFullYear() + '/'
|
||
// + padNumber(date.getMonth() + 1) + '/'
|
||
// + padNumber(date.getDate()) + ' '
|
||
// + padNumber(date.getHours()) + ':'
|
||
// + padNumber(date.getMinutes()) + ':'
|
||
// + padNumber(date.getSeconds());
|
||
};
|
||
_utility.formatEnglishDate = function (date) {
|
||
return (date.getMonth() + 1) + '/' +
|
||
padNumber(date.getDate()) + '/' +
|
||
date.getFullYear();
|
||
};
|
||
|
||
// 删除指定元素
|
||
_utility.deleteArrayValue = function (arr, e) {
|
||
var rtn = -1;
|
||
for (var i = 0; i < arr.length; i++) {
|
||
if (arr[i] === e) {
|
||
delete arr.splice(i, 1);
|
||
rtn = i;
|
||
break;
|
||
}
|
||
}
|
||
return rtn;
|
||
};
|
||
|
||
function removeMember(e) {
|
||
if (_utility.increment++ > 10)
|
||
return;
|
||
for (var p in e) {
|
||
if (e.hasOwnProperty(p)) {
|
||
if (typeof e[p] !== 'string')
|
||
removeMember(e[p]);
|
||
delete e[p];
|
||
}
|
||
}
|
||
}
|
||
|
||
// 移除所有成员
|
||
_utility.removeAllMembers = function (e) {
|
||
removeMember(e);
|
||
_utility.increment = 0;
|
||
};
|
||
|
||
// 返回随机字符串后缀
|
||
_utility.randomString = function (str) { return str + '_' + Math.random().toString(16).substring(2); };
|
||
|
||
// 在parent中追加clear:both的div元素
|
||
_utility.appendClear = function (parent) { return $('<span></span>').css({ 'display': 'block', 'clear': 'both', 'height': '0', 'line-height': '0', 'font-size': '0' }).appendTo(parent); };
|
||
|
||
// 添加关闭按钮
|
||
_utility.addCloseButton = function (parent) { return $('<i class="chart_close fa"></i>').appendTo(parent); };
|
||
|
||
// 添加菜单按钮
|
||
_utility.addMenuButton = function (parent) { return $('<i class="chart_menu fa"></i>').appendTo(parent); };
|
||
|
||
// 添加chart note按钮
|
||
_utility.addNoteButton = function (parent) {
|
||
var title = GetLanguageByKey("LHBIS_FIC_CHARTS_CHARTTITLE_A006");
|
||
return $('<i class="chart_note fa" style="display: none" title="' + title + '"></i>').appendTo(parent);
|
||
};
|
||
|
||
// 添加chart note按钮
|
||
_utility.addInternalNoteButton = function (parent) {
|
||
var title = GetLanguageByKey("LHBIS_FIC_CLIENT_FICCONTROLS_CHARTNOTECTRL_A003");
|
||
return $('<i class="chart_internal_note fa" style="display: none" title="' + title + '"></i>').appendTo(parent);
|
||
};
|
||
|
||
_utility.addStarButton = function (parent, v) {
|
||
if (v) {
|
||
return $('<i class="chart_star fa"></i>').appendTo(parent);
|
||
}
|
||
else {
|
||
return $('<i class="chart_nostar fa"></i>').appendTo(parent);
|
||
}
|
||
|
||
};
|
||
|
||
// 添加chart comments按钮
|
||
_utility.addCommentsButton = function (parent) { return $('<i class="chart_comments fa"></i>').appendTo(parent); };
|
||
|
||
_utility.addAutoRefreshButton = function (parent, v) {
|
||
return $('<i class="chart_refresh fa"></i>').appendTo(parent);
|
||
};
|
||
|
||
// 添加loading图标
|
||
_utility.addLoading = function (parent) { return $('<i class="chart_loading fa fa-spin"></i>').appendTo(parent); };
|
||
|
||
_utility.getLevelPng = function (level) {
|
||
level = parseInt(level);
|
||
if (level === LEVEL_PUBLIC) {
|
||
return 'GradeIcon2.png';
|
||
} else if (level === LEVEL_PRIVATE) {
|
||
return 'GradeIcon3.png';
|
||
} else if (level >= LEVEL_3RD_BORDER) {
|
||
return 'GradeIcon1.png';
|
||
}
|
||
// TODO: System?
|
||
return 'GradeIcon0.png';
|
||
};
|
||
_utility.getGradeLevel = function (level) {
|
||
var src;
|
||
if (typeof sitePath !== 'string') {
|
||
src = '../image/';
|
||
} else {
|
||
src = sitePath + 'image/';
|
||
}
|
||
src += _utility.getLevelPng(level);
|
||
return $('<img/>')
|
||
.attr('src', src)
|
||
.css({ 'width': '15px', 'height': '11px' });
|
||
};
|
||
_utility.getPersonalLevel = function () { return $('<img/>').attr('src', '../image/Personal.png').css({ 'width': '15px', 'height': '11px' }) };
|
||
// 添加级别图标
|
||
_utility.addGradeLevel = function (parent, level) { return _utility.getGradeLevel(level).appendTo(parent); };
|
||
|
||
// 添加固定按钮
|
||
//_utility.addPinButton = function (parent) { return $('<img/>').attr('src', _utility.pinOff).css({ 'width': '13px' }).appendTo(parent); };
|
||
_utility.addPinButton = function (parent) { return $('<em class="pinner fa"></em>').css({ 'width': '13px' }).appendTo(parent); };
|
||
|
||
// 清除pivot
|
||
_utility.clearPivot = function (wnd, iid) {
|
||
wnd = wnd || window;
|
||
var ps = $(wnd.document).find('.pivot_selector').filter(function () {
|
||
return !$(this).hasClass('filter-fixed');
|
||
});
|
||
if (iid != null) {
|
||
ps = ps.filter(function () {
|
||
return $(this).attr('refiid') !== iid;
|
||
});
|
||
}
|
||
ps.css({ 'display': 'none' });
|
||
};
|
||
|
||
// 绘制搜索按钮
|
||
_utility.appendSearch = function (width, func) {
|
||
var search = $('<span class="search-bar fa"></span>')
|
||
.css('width', 30).mousemove(function (e) {
|
||
if (e.target && !e.target.isAnimate && ((' ' + e.target.className + ' ').indexOf(' search-bar ') >= 0)) {
|
||
e.target.isAnimate = true;
|
||
var t = $(e.target);
|
||
t.stop().animate({ 'width': 150 }, ANIMATE_SPEED, function () {
|
||
t.children('.search-text').css('display', 'block').focus();
|
||
delete t[0].isAnimate;
|
||
});
|
||
return false;
|
||
}
|
||
});
|
||
var txt = $('<input type="text" class="search-text"/>').blur(function (e) {
|
||
$(this).css('display', 'none');
|
||
var p = $(e.target).parent();
|
||
p.length && p.stop().animate({ 'width': 30 }, ANIMATE_SPEED, function () {
|
||
delete p[0].isAnimate;
|
||
});
|
||
}).appendTo(search);
|
||
if (txt[0].onpropertychange)
|
||
txt[0].onpropertychange = func;
|
||
else
|
||
txt[0].oninput = func;
|
||
|
||
return search;
|
||
};
|
||
|
||
// dilldown 功能实现
|
||
_utility.drilldown = function (c, x, y, series, t, parameters) {
|
||
if (!c)
|
||
return;
|
||
|
||
if (t.DestUrl) {
|
||
// drilldown to URL
|
||
var query = [
|
||
c.chartData.IID,
|
||
{
|
||
$type: 'FI.FIC.Contracts.DataObjects.Chart.ChartQueryParam, FICIntf',
|
||
ChartIID: c.chartData.IID + '',
|
||
Pivots: c.getPivots(true),
|
||
Params: parameters,
|
||
DrilldownParameter: {
|
||
$type: 'FI.FIC.Contracts.DataObjects.Chart.DrilldownParameter, FICIntf',
|
||
XValues: x,
|
||
YSValues: y,
|
||
ZValues: series,
|
||
DrilldownCellIID: t.DrilldownCellIID,//DrilldownCell的列IID,有值则说明是DrilldownCell
|
||
IsAlert: t.isAlert === 1 ? 1 : 0,//是否是Alert Drilldown
|
||
MessageID: t.MessageID,//Alert Drilldown的MessageID
|
||
MessagePoolIID: t.MessagePoolIID,//Alert Drilldown的MessagePoolIID
|
||
}
|
||
}
|
||
];
|
||
if (c.isPreview) {
|
||
query.push(c.chartobj.Structure);
|
||
}
|
||
_network.query(c.isPreview ? 'GetGeneratorUrlsForPreview' : 'GetGeneratorUrls', query, function (e) {
|
||
|
||
if (e.Result && e.Result.length > 0) {
|
||
var url = e.Result[0].URL;
|
||
if (!/^(http:\/\/|https:\/\/|\/)/.test(url)) {
|
||
var prefix = _utility.rootPath || sitePath;
|
||
url = prefix + url;
|
||
}
|
||
var wnd = window.open(url);
|
||
if (!wnd)
|
||
alert(DEFAULT_LANG.popup_blocked);
|
||
}
|
||
});
|
||
|
||
} else {
|
||
var wnd = c.getWindow();
|
||
var obj = {
|
||
ID: t.DestChartIID,
|
||
//ChartType: t.DestChartClassName
|
||
};
|
||
if (!obj.ID /*|| !obj.ChartType*/)
|
||
return;
|
||
|
||
var mask = $('<div class="maskbg"></div>')
|
||
.attr('id', 'maskbg')
|
||
.css('z-index', _utility.getMaxZIndex(wnd) - 1)
|
||
.appendTo($(wnd.document.body));
|
||
|
||
var chart = new $chart();
|
||
chart.wnd = wnd;
|
||
chart.parentDom = wnd.document;
|
||
chart.isPreview = c.isPreview;
|
||
if (c.board) {
|
||
chart.ispivotpinned = c.board.pivotpinned;
|
||
chart.displayRefreshTime = c.board.displayRefreshTime;
|
||
}
|
||
else {
|
||
chart.ispivotpinned = c.ispivotpinned;
|
||
chart.displayRefreshTime = c.displayRefreshTime;
|
||
}
|
||
chart.isdrilldown = true;
|
||
//chart.isborderpinned = c.isborderpinned;
|
||
chart.drilldownSource = c.chartData.IID;
|
||
chart.drilldownPivots = c.getPivots(true);
|
||
chart.drilldownParameters = parameters;
|
||
chart.drilldownParams = {
|
||
x: x,
|
||
y: y,
|
||
series: series,
|
||
SelectedY: t.SelectedY,
|
||
PreviewStructure: c.chartobj.Structure,
|
||
DrilldownCellIID: t.DrilldownCellIID,//DrilldownCell的列IID,有值则说明是DrilldownCell
|
||
IsAlert: t.isAlert === 1 ? 1 : 0,//是否是Alert Drilldown
|
||
MessageID: t.MessageID,//Alert Drilldown的MessageID
|
||
MessagePoolIID: t.MessagePoolIID,//Alert Drilldown的MessagePoolIID
|
||
};
|
||
chart.load(obj);
|
||
var width = $(wnd).width();
|
||
var height = $(wnd).height();
|
||
var cwidth = width < 200 ? 200 : (width > 980 ? 960 : width - 20);
|
||
var cheight = height - 90;
|
||
|
||
var x = (width - cwidth);
|
||
var y = 90;
|
||
chart.move(x, y);
|
||
chart.showborder(c.isborderpinned);
|
||
chart.resize(cwidth, cheight);
|
||
chart.chartDiv.css('z-index', _utility.getMaxZIndex(wnd));
|
||
if (c.isfullscreen)
|
||
chart.toggleFullscreen(true, true);
|
||
_utility.drilldowns.push(chart);
|
||
|
||
chart.onClickClose = function () {
|
||
_utility.drilldowns.pop(chart);
|
||
mask.remove();
|
||
};
|
||
}
|
||
};
|
||
|
||
_utility.exportToExcel = function (chartdt, pivots, obj, orderColumnNames, customColumnNames, callback) {
|
||
|
||
// _network.management('ExportChart2Excel', [JSON.stringify(chartdt), JSON.stringify(pivots), chartdt.ClassName, { '$type': 'System.String[], mscorlib', '$values': orderColumnNames }, obj ? (obj.displayRefreshTime === true) : false],
|
||
// callback,
|
||
// function (err) {
|
||
// console.warn(err);
|
||
// if (obj && obj.loading)
|
||
// obj.loading(false);
|
||
// var msg = new $msgdialog();
|
||
// msg.parentDom = $(window.parent.document.body);
|
||
// msg.title = DEFAULT_LANG.FIC;
|
||
// msg.message = GetLanguageByKey('LHBIS_EXCEPTION_E0X65024014', 'Cannot connect to the network at this time. Please try again later.');
|
||
// msg.showMessage(500, 175);
|
||
// });
|
||
|
||
try {
|
||
var formData = new FormData();
|
||
/*
|
||
if (typeof btoa === 'function') {
|
||
formData.append("chartdata", $.base64Encode(JSON.stringify(chartdt)));
|
||
formData.append('base64', true);
|
||
} else
|
||
//*/
|
||
formData.append("chartdata", encodeURIComponent(JSON.stringify(chartdt)));
|
||
formData.append("chartPivots", encodeURIComponent(JSON.stringify(pivots)));
|
||
formData.append("chattype", chartdt.ClassName);
|
||
formData.append("OrderColumnNames", encodeURIComponent(JSON.stringify({ '$type': 'System.String[], mscorlib', '$values': orderColumnNames })));
|
||
formData.append("CustomColumnNames", encodeURIComponent(JSON.stringify({ '$type': 'System.String[], mscorlib', '$values': customColumnNames })));
|
||
formData.append("showRefreshTime", obj ? (obj.displayRefreshTime === true) : false);
|
||
formData.append("MethodName", "ExportChart2Excel");
|
||
formData.append("LanguageCode", _utility.currentLang);
|
||
} catch (e) {
|
||
if (obj && obj.loading)
|
||
obj.loading(false);
|
||
console.error(e);
|
||
}
|
||
_network.fileRequest('', formData, callback, function (err) {
|
||
console.warn(err);
|
||
if (obj && obj.loading)
|
||
obj.loading(false);
|
||
var msg = new $msgdialog();
|
||
msg.parentDom = $(window.parent.document.body);
|
||
msg.title = DEFAULT_LANG.FIC;
|
||
msg.message = GetLanguageByKey('LHBIS_EXCEPTION_E0X65024014', 'Cannot connect to the network at this time. Please try again later.');
|
||
msg.showMessage(500, 175);
|
||
});
|
||
|
||
};
|
||
|
||
_utility.IsExportToFileComplete = function (tid, title, chart, uesParent) {
|
||
_network.management('IsExportToFileComplete', [tid], function (data) {
|
||
|
||
if (data.ErrorCode !== 0) {
|
||
if (chart && chart.loading)
|
||
chart.loading(false);
|
||
var msg = new $msgdialog();
|
||
msg.parentDom = $(window.parent.document.body);
|
||
msg.title = DEFAULT_LANG.FIC;
|
||
msg.message = data.ErrorMessage;
|
||
msg.showMessage(500, 175);
|
||
return;
|
||
}
|
||
|
||
if (data.Result == "true") {
|
||
if (chart && chart.loading)
|
||
chart.loading(false);
|
||
|
||
var url = window.sitePath + 'fic/ExportToFile.aspx';
|
||
window.location.href = url + "?dataid=" + encodeURIComponent(tid) + "&Title=" + encodeURIComponent(title) + "&fileTyp=xlsx";
|
||
}
|
||
else if (data.Result != "false") {
|
||
if (chart && chart.loading)
|
||
chart.loading(false);
|
||
var msg = new $msgdialog();
|
||
msg.parentDom = $(window.parent.document.body);
|
||
msg.title = DEFAULT_LANG.FIC;
|
||
msg.message = data.Result;
|
||
msg.showMessage(500, 175);
|
||
}
|
||
else {
|
||
setTimeout(_utility.IsExportToFileComplete, 1 * 1000, tid, title, chart);
|
||
}
|
||
}, function (err) {
|
||
setTimeout(_utility.IsExportToFileComplete, 10 * 1000, tid, title, chart);
|
||
});
|
||
};
|
||
|
||
// 获取最大z-index
|
||
_utility.getMaxZIndex = function (wnd) {
|
||
var charts = $((wnd || window).document.body).children('.chart_container');
|
||
var maxz = 0;
|
||
for (var i = 0; i < charts.length; i++) {
|
||
var z = parseInt($(charts[i]).css('z-index'));
|
||
if (z > maxz)
|
||
maxz = z;
|
||
}
|
||
maxz++;
|
||
if (maxz < 601)
|
||
maxz = 601;
|
||
return maxz;
|
||
}
|
||
|
||
// 克隆对象
|
||
_utility.clone = function (obj) {
|
||
if (!obj)
|
||
return undefined;
|
||
if (obj instanceof Array) {
|
||
var vs = [];
|
||
for (var i = 0; i < obj.length; i++) {
|
||
vs.push(_utility.clone(obj[i]));
|
||
}
|
||
return vs;
|
||
}
|
||
var o = {};
|
||
for (var k in obj) {
|
||
if (obj.hasOwnProperty(k)) {
|
||
var v = obj[k];
|
||
if (v instanceof $board || v instanceof $chart || v instanceof $pivot)
|
||
continue;
|
||
|
||
o[k] = v;
|
||
}
|
||
}
|
||
return o;
|
||
};
|
||
}());
|
||
}
|
||
|
||
// 网络操作类
|
||
if (typeof _network !== 'object') {
|
||
_network = {};
|
||
|
||
(function () {
|
||
'use strict';
|
||
|
||
function getBaseURL() {
|
||
// 不是所有页面都有 sitePath
|
||
if (typeof sitePath !== 'string')
|
||
return 'fic/FICSvc.ashx?fmt=json&SN=' + Math.random();
|
||
|
||
return sitePath + 'fic/FICSvc.ashx?fmt=json&SN=' + Math.random();
|
||
}
|
||
|
||
function getFilterHandlerURL() {
|
||
if (typeof sitePath !== 'string')
|
||
return 'fic/SelectAutoFilterHandler.ashx?SN=' + Math.random();
|
||
|
||
return sitePath + 'fic/SelectAutoFilterHandler.ashx?SN=' + Math.random();
|
||
}
|
||
|
||
function getHostURL() {
|
||
if (typeof sitePath !== 'string')
|
||
return 'fic/Host.ashx?SN=' + Math.random();
|
||
|
||
return sitePath + 'fic/Host.ashx?SN=' + Math.random();
|
||
}
|
||
|
||
function getFileURL() {
|
||
if (typeof sitePath !== 'string')
|
||
return 'fic/UploadFile.ashx?SN=' + Math.random();
|
||
|
||
return sitePath + 'fic/UploadFile.ashx?SN=' + Math.random();
|
||
}
|
||
function getHostFileURL() {
|
||
if (typeof sitePath !== 'string')
|
||
return 'UploadHostFile.ashx?SN=' + Math.random();
|
||
|
||
return sitePath + 'UploadHostFile.ashx?SN=' + Math.random();
|
||
}
|
||
|
||
function getExtendHostURL() {
|
||
if (typeof sitePath !== 'string')
|
||
return 'ExtendHost.ashx?SN=' + Math.random();
|
||
|
||
return sitePath + 'ExtendHost.ashx?SN=' + Math.random();
|
||
}
|
||
|
||
_network.get = function (url, data, callback, error) {
|
||
url = (typeof sitePath === 'string') ? sitePath + url : url;
|
||
$.ajax({
|
||
url: url,
|
||
type: data == null ? 'GET' : 'POST',
|
||
cache: false,
|
||
data: data,
|
||
success: callback,
|
||
error: error ||
|
||
function (request, textStatus, errorThrown) {
|
||
console.log("_network.get", request, textStatus, errorThrown);
|
||
}
|
||
});
|
||
};
|
||
|
||
// 请求服务器
|
||
_network.request = function (service, method, param, callback, error, nolog, isSync) {
|
||
$.ajax({
|
||
url: getBaseURL(),
|
||
type: 'POST',
|
||
dataType: 'json',
|
||
//contentType: 'application/xml;charset=utf-8',
|
||
cache: false,
|
||
data: encodeURIComponent(JSON.stringify({
|
||
'LoginIID': '',
|
||
'SessionID': '',
|
||
'LanguageID': _utility.currentLang,
|
||
'UtcOffset': new Date().getTimezoneOffset(),
|
||
'Flag': 0,
|
||
'AppName': '',
|
||
'ServiceType': service,
|
||
'MethodName': method,
|
||
'Parameters': param,
|
||
'RequestTime': _utility.getTicksFromDate(new Date())
|
||
})),
|
||
async: !isSync,
|
||
success: callback,
|
||
error: function (request, textStatus, errorThrown) {
|
||
if (error)
|
||
error(request, textStatus, errorThrown);
|
||
if (!nolog) {
|
||
writelog("_network.request", textStatus, errorThrown + "");
|
||
}
|
||
//console.log(request);
|
||
//console.log(textStatus);
|
||
}
|
||
});
|
||
};
|
||
|
||
// 请求服务器
|
||
_network.pivotRequest = function (method, param, callback, error, nolog, isSync) {
|
||
$.ajax({
|
||
url: getFilterHandlerURL(),
|
||
type: 'POST',
|
||
dataType: 'json',
|
||
//contentType: 'application/xml;charset=utf-8',
|
||
cache: false,
|
||
data: encodeURIComponent(JSON.stringify({
|
||
'LoginIID': loginedUser('userIId'),
|
||
'SessionID': '',
|
||
'LanguageID': _utility.currentLang,
|
||
'UtcOffset': new Date().getTimezoneOffset(),
|
||
'Flag': 0,
|
||
'AppName': '',
|
||
'MethodName': method,
|
||
'Parameters': param,
|
||
'RequestTime': _utility.getTicksFromDate(new Date())
|
||
})),
|
||
async: !isSync,
|
||
success: callback,
|
||
error: function (request, textStatus, errorThrown) {
|
||
if (error)
|
||
error(request, textStatus, errorThrown);
|
||
if (!nolog) {
|
||
writelog("_network.pivotRequest", textStatus, errorThrown + "");
|
||
}
|
||
//console.log(request);
|
||
//console.log(textStatus);
|
||
}
|
||
});
|
||
};
|
||
|
||
// 请求服务器
|
||
_network.fileRequest = function (method, param, callback, error, nolog, isSync) {
|
||
$.ajax({
|
||
url: getFileURL(),
|
||
type: 'POST',
|
||
dataType: 'json',
|
||
processData: false,
|
||
contentType: false,
|
||
data: param,
|
||
async: !isSync,
|
||
success: callback,
|
||
error: function (request, textStatus, errorThrown) {
|
||
if (error)
|
||
error(request, textStatus, errorThrown);
|
||
if (!nolog) {
|
||
writelog("_network.request", textStatus, errorThrown + "");
|
||
}
|
||
//console.log(request);
|
||
//console.log(textStatus);
|
||
}
|
||
});
|
||
};
|
||
|
||
_network.hostFileRequest = function (method, param, callback, error, nolog, isSync) {
|
||
$.ajax({
|
||
url: getHostFileURL(),
|
||
type: 'POST',
|
||
dataType: 'json',
|
||
processData: false,
|
||
contentType: false,
|
||
data: param,
|
||
async: !isSync,
|
||
success: callback,
|
||
error: function (request, textStatus, errorThrown) {
|
||
if (error)
|
||
error(request, textStatus, errorThrown);
|
||
if (!nolog) {
|
||
writelog("_network.request", textStatus, errorThrown + "");
|
||
}
|
||
//console.log(request);
|
||
//console.log(textStatus);
|
||
}
|
||
});
|
||
};
|
||
|
||
// 查询方法
|
||
_network.query = function (method, param, callback, error, nolog, isSync) {
|
||
_network.request('FI.FIC.IFICQuery', method, param, callback, error, nolog, isSync);
|
||
}
|
||
|
||
_network.management = function (method, param, callback, error, nolog, isSync) {
|
||
_network.request('FI.FIC.IFICManagement', method, param, callback, error, nolog, isSync);
|
||
}
|
||
|
||
_network.frsquery = function (method, param, callback, error, isSync) {
|
||
_network.request('FI.FIC.IFRSQuery', method, param, callback, error, true, isSync);
|
||
}
|
||
|
||
_network.extendHostquery = function (method, param, callback, error, isSync) {
|
||
$.ajax({
|
||
url: getExtendHostURL(),
|
||
type: 'POST',
|
||
dataType: 'json',
|
||
//contentType: 'application/xml;charset=utf-8',
|
||
cache: false,
|
||
data: encodeURIComponent(JSON.stringify({
|
||
'LoginIID': _utility.loginedUser.userIId,
|
||
'SessionID': _utility.loginedUser.SessionID,
|
||
'LanguageID': _utility.currentLang,
|
||
'UtcOffset': new Date().getTimezoneOffset(),
|
||
'Flag': 0,
|
||
'AppName': '',
|
||
'ServiceType': '',
|
||
'MethodName': method,
|
||
'Parameters': param,
|
||
'RequestTime': _utility.getTicksFromDate(new Date())
|
||
})),
|
||
async: !isSync,
|
||
success: callback,
|
||
error: function (request, textStatus, errorThrown) {
|
||
if (error)
|
||
error(request, textStatus, errorThrown);
|
||
//if (!nolog) {
|
||
writelog("_network.request", textStatus, errorThrown);
|
||
//}
|
||
//console.log(request);
|
||
//console.log(textStatus);
|
||
}
|
||
});
|
||
}
|
||
|
||
_network.hostquery = function (method, param, callback, error, isSync) {
|
||
$.ajax({
|
||
url: getHostURL(),
|
||
type: 'POST',
|
||
dataType: 'json',
|
||
//contentType: 'application/xml;charset=utf-8',
|
||
cache: false,
|
||
data: encodeURIComponent(JSON.stringify({
|
||
'LoginIID': _utility.loginedUser.userIId,
|
||
'SessionID': _utility.loginedUser.SessionID,
|
||
'LanguageID': _utility.currentLang,
|
||
'UtcOffset': new Date().getTimezoneOffset(),
|
||
'Flag': 0,
|
||
'AppName': '',
|
||
'ServiceType': '',
|
||
'MethodName': method,
|
||
'Parameters': param,
|
||
'RequestTime': _utility.getTicksFromDate(new Date())
|
||
})),
|
||
async: !isSync,
|
||
success: callback,
|
||
error: function (request, textStatus, errorThrown) {
|
||
if (error)
|
||
error(request, textStatus, errorThrown);
|
||
//if (!nolog) {
|
||
writelog("_network.request", textStatus, errorThrown);
|
||
//}
|
||
//console.log(request);
|
||
//console.log(textStatus);
|
||
}
|
||
});
|
||
}
|
||
|
||
}());
|
||
}
|
||
|
||
|
||
// 数学操作工具
|
||
if (typeof _math !== 'object') {
|
||
_math = {};
|
||
|
||
(function () {
|
||
'use strict';
|
||
|
||
// 偏移量相减
|
||
_math.subOffset = function (o1, o2) {
|
||
return {
|
||
left: o1.left - o2.left,
|
||
top: o1.top - o2.top
|
||
};
|
||
};
|
||
|
||
// 角度转弧度
|
||
_math.radians = function (degress) { return degress * Math.PI / 180; };
|
||
}());
|
||
}
|
||
|
||
|
||
// userData 存储
|
||
if (typeof _userdata !== 'object') {
|
||
_userdata = {
|
||
prefix: null,
|
||
prefixTable: [],
|
||
// 用户登录信息
|
||
userinfo: {
|
||
useriid: undefined,
|
||
sessioniid: undefined,
|
||
lang: _utility.currentLang
|
||
}
|
||
};
|
||
|
||
(function () {
|
||
'use strict';
|
||
|
||
var REMOVABLE = [
|
||
'Rcdata', // chart数据
|
||
'Rcstru' // chart结构
|
||
];
|
||
|
||
function initPrefix() {
|
||
if (!window.localStorage) {
|
||
return false;
|
||
}
|
||
var table = localStorage.getItem('prefixTable');
|
||
if (table)
|
||
_userdata.prefixTable = JSON.parse(table);
|
||
|
||
var p = location.pathname;
|
||
if (p && p[0] == '/')
|
||
p = p.substring(1);
|
||
if (endsWith(p, 'FIC.aspx'))
|
||
p = p.substring(0, p.length - 14);
|
||
p += '_' + _userdata.userinfo.useriid;
|
||
|
||
for (var pid in _userdata.prefixTable) {
|
||
var pre = _userdata.prefixTable[pid];
|
||
if (pre === p) {
|
||
_userdata.prefix = pid;
|
||
return;
|
||
}
|
||
}
|
||
|
||
// add new
|
||
_userdata.prefix = (_userdata.prefixTable.push(p) - 1) + '';
|
||
try {
|
||
localStorage.setItem('prefixTable', JSON.stringify(_userdata.prefixTable));
|
||
} catch (e) {
|
||
alert('The browser doesn\'t support to write the local storage in the private browsing mode.');
|
||
console.log(e);
|
||
}
|
||
}
|
||
|
||
function dealloc(size, level) {
|
||
var max = { length: 0, key: null };
|
||
for (var i = 0; i < localStorage.length; i++) {
|
||
var key = localStorage.key(i);
|
||
if (key.indexOf('_' + REMOVABLE[level]) >= 0) {
|
||
var c = key.length + localStorage.getItem(key).length;
|
||
if (c >= size && (max.length === 0 || c < max.length)) {
|
||
max.length = c;
|
||
max.key = key;
|
||
} else if (c > max.length) {
|
||
max.length = c;
|
||
max.key = key;
|
||
}
|
||
}
|
||
}
|
||
if (max.length > 0) {
|
||
localStorage.removeItem(max.key);
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
function trySetItem(key, value) {
|
||
try {
|
||
localStorage.setItem(key, value);
|
||
} catch (e) {
|
||
if (dealloc(value.length, 0))
|
||
trySetItem(key, value);
|
||
else
|
||
console.log('cannot set item "' + key + '": "' + value + '"');
|
||
}
|
||
}
|
||
|
||
// 设置项
|
||
_userdata.setItem = function (key, value) {
|
||
if (window.localStorage) {
|
||
if (!_userdata.prefix)
|
||
initPrefix();
|
||
trySetItem(_userdata.prefix + key, value);
|
||
} else {
|
||
console.log('unable to set localStorage value: "' + _userdata.prefix + key + '": "' + value + '"');
|
||
}
|
||
};
|
||
|
||
// 获取项
|
||
_userdata.getItem = function (key) {
|
||
if (window.localStorage) {
|
||
if (!_userdata.prefix)
|
||
initPrefix();
|
||
return localStorage.getItem(_userdata.prefix + key);
|
||
}
|
||
console.log('unable to get userdata "' + _userdata.prefix + key + '"');
|
||
};
|
||
|
||
// 删除
|
||
_userdata.remove = function (key) {
|
||
if (window.localStorage) {
|
||
if (!_userdata.prefix)
|
||
initPrefix();
|
||
localStorage.removeItem(_userdata.prefix + key);
|
||
} else {
|
||
console.log('unable to remove userdata "' + _userdata.prefix + key + '"');
|
||
}
|
||
};
|
||
}());
|
||
}
|
||
|
||
|
||
if (typeof Class !== 'function') {
|
||
|
||
// 基类实现 (空实现)
|
||
Class = function () { };
|
||
|
||
/* Simple JavaScript Inheritance
|
||
* By John Resig http://ejohn.org/
|
||
* MIT Licensed.
|
||
*/
|
||
// Inspired by base2 and Prototype
|
||
(function () {
|
||
'use strict';
|
||
|
||
var initializing = false, fnTest = /xyz/.test(function () { xyz; }) ? /\b_super\b/ : /.*/;
|
||
|
||
// 创建一个继承当前调用类的子类
|
||
Class.extend = function ext(prop) {
|
||
var _super = this.prototype;
|
||
|
||
// 实例化,此时不执行构造方法 (x.prototype.constructor)
|
||
initializing = true;
|
||
var prototype = new this();
|
||
initializing = false;
|
||
|
||
// 复制属性到新的prototype中
|
||
for (var name in prop) {
|
||
// 判断属性或重载方法
|
||
prototype[name] = typeof prop[name] == "function" &&
|
||
typeof _super[name] == "function" && fnTest.test(prop[name]) ?
|
||
(function (name, fn) {
|
||
return function () {
|
||
var tmp = this._super;
|
||
|
||
this._super = _super[name];
|
||
var ret = fn.apply(this, arguments);
|
||
this._super = tmp;
|
||
|
||
return ret;
|
||
};
|
||
})(name, prop[name]) :
|
||
prop[name];
|
||
}
|
||
|
||
// 临时构造方法
|
||
function Class() {
|
||
if (!initializing && this.init)
|
||
this.init.apply(this, arguments);
|
||
}
|
||
|
||
Class.prototype = prototype;
|
||
// 修正构造方法的指向
|
||
Class.prototype.constructor = Class;
|
||
// 添加扩展
|
||
Class.extend = ext; // arguments.callee;
|
||
|
||
return Class;
|
||
};
|
||
}());
|
||
}
|
||
|
||
if (typeof $basechart !== 'function') {
|
||
// 抽象图形chart
|
||
$basechart = Class.extend({
|
||
|
||
// 构造方法
|
||
init: function (chart) {
|
||
this.chart = chart;
|
||
},
|
||
|
||
// chart容器对象
|
||
chart: undefined,
|
||
|
||
// 容器id
|
||
containerid: undefined,
|
||
|
||
// 画布
|
||
canvas: undefined,
|
||
|
||
// 加载chart
|
||
load: function (parent) {
|
||
},
|
||
|
||
// 获取自定义title
|
||
getTitle: function () {
|
||
var chartData = this.chartData;
|
||
if (chartData == null) {
|
||
if (this.chart == null) {
|
||
return;
|
||
}
|
||
chartData = this.chart.chartData;
|
||
if (chartData == null) {
|
||
return;
|
||
}
|
||
}
|
||
var lg = this.personalData && this.personalData.ClientLanguage;
|
||
if (lg != null && chartData.UseChartPersonal) {
|
||
return lg.ChartTitle;
|
||
}
|
||
return chartData.Title;
|
||
},
|
||
|
||
// drilldown反馈
|
||
dodrilldown: undefined,
|
||
|
||
// 大小改变时触发的事件
|
||
onresize: undefined,
|
||
|
||
// 移动时触发的事件
|
||
onmove: undefined,
|
||
|
||
// 开始触发动画
|
||
startAnimate: undefined,
|
||
|
||
});
|
||
}
|
||
|
||
$.fn.tap = function (data, action) {
|
||
var pt;
|
||
if (action == null && typeof data === 'function') {
|
||
action = data;
|
||
data = undefined;
|
||
}
|
||
return this.each(function () {
|
||
$(this).on('touchstart', function (e) {
|
||
pt = e.originalEvent.touches[0];
|
||
}).on('touchend', data, function (e) {
|
||
var oe = e.originalEvent;
|
||
if (pt != null && oe.changedTouches[0]) {
|
||
var p = oe.changedTouches[0];
|
||
if (Math.abs(p.clientX - pt.clientX) > 2 || Math.abs(p.clientY - pt.clientY) > 2) {
|
||
return;
|
||
}
|
||
}
|
||
return action.call(this, e);
|
||
});
|
||
});
|
||
};
|
||
|
||
/*Help Document*/
|
||
$(function () {
|
||
var iframewindow;
|
||
var isSubPageEvent = false;
|
||
$(document.body).mousedown(function (e) {
|
||
var t = $(e.target);
|
||
var hm = $(".helpmenu");
|
||
if (hm.length > 0 && !t.is(".helpmenu") && !t.parent().is(".helpmenu"))
|
||
$(".helpmenu").remove();
|
||
|
||
if (isSubPageEvent)
|
||
isSubPageEvent = false;
|
||
else if (iframewindow && iframewindow.triggerMousedownEvent) {
|
||
//$(iframewindow.document.body).mousedown();
|
||
iframewindow.triggerMousedownEvent();//触发iframe下的事件
|
||
}
|
||
});
|
||
|
||
var mainframe = $('#MainContent');
|
||
if (mainframe.length > 0) {
|
||
mainframe.load(function () {
|
||
getiframedoc();
|
||
});
|
||
|
||
function getiframedoc() {
|
||
iframewindow = mainframe.prop('contentWindow');
|
||
$(iframewindow.document.body).mousedown(function () {//触发主页面的事件
|
||
isSubPageEvent = true;
|
||
$(document.body).mousedown();
|
||
});
|
||
}
|
||
|
||
getiframedoc();
|
||
}
|
||
|
||
$(".helpicon").click(helpButtonClick);
|
||
//$(".helpicon").parent().click(function (e) {//点击helpicon的Parent也打开Help Menu
|
||
// var t = $(e.target);
|
||
// if (t.children().length == 1) {
|
||
// $(".helpicon").click();
|
||
// }
|
||
//});
|
||
|
||
window.triggerMousedownEvent = function () {
|
||
$(document.body).mousedown();
|
||
}
|
||
});
|
||
|
||
function helpButtonClick(e) {
|
||
var t = $(e.target);
|
||
var pageName = t.attr("PageName");
|
||
if (!pageName) pageName = "";
|
||
var about = t.attr("About") === "1";
|
||
var supportSite = "http://support.foresightintelligence.com";
|
||
var path = loginedParameter("HelpSiteAddress");
|
||
if (!path) {
|
||
path = "https://doc.foresightintelligence.com/FIC";
|
||
}
|
||
if (!path.endWith("/"))
|
||
path = path + "/";
|
||
|
||
var text = GetLanguageByKey('LHBIS_FIC_Client_Help_A001', 'Online Help');
|
||
var helpmenu = $("<div></div>").addClass("helpmenu");
|
||
|
||
var menuitem = $("<div>" + text + "</div>").addClass("helpmenuitem");
|
||
menuitem.click(function () {
|
||
var url = path + "en/Help.html?tag=" + pageName;
|
||
window.open(url, "helpwindow");
|
||
helpmenu.remove();
|
||
});
|
||
helpmenu.append(menuitem);
|
||
|
||
text = GetLanguageByKey('LHBIS_FIC_Client_Help_A002', 'Support');
|
||
menuitem = $("<div>" + text + "</div>").addClass("helpmenuitem");
|
||
menuitem.click(function () {
|
||
window.open(supportSite, "supportwindow");
|
||
helpmenu.remove();
|
||
});
|
||
helpmenu.append(menuitem);
|
||
|
||
if (about) {
|
||
var sp = $("<div></div>").addClass("helpmenusp");
|
||
helpmenu.append(sp);
|
||
text = GetLanguageByKey('LHBIS_FIC_Silverlight_WSP_RMenuCtrl_A022', 'About');
|
||
menuitem = $("<div>" + text + "</div>").addClass("helpmenuitem");
|
||
menuitem.click(function () {
|
||
var about = new $about().showAbout(500, 321);
|
||
helpmenu.remove();
|
||
});
|
||
helpmenu.append(menuitem);
|
||
}
|
||
|
||
t.parents("body").append(helpmenu);
|
||
helpmenu.css("left", t.offset().left + t.outerWidth(true) - helpmenu.width());
|
||
helpmenu.css("top", t.offset().top + t.outerHeight(true));
|
||
helpmenu.show();
|
||
}
|
||
|
||
|
||
if (!Object.prototype.hasOwnProperty.call(Array.prototype, 'orderBy')) {
|
||
Object.defineProperty(Array.prototype, 'orderBy', {
|
||
value: function (func) {
|
||
var list = this.slice();
|
||
list.sort(function (a, b) {
|
||
var ra = func(a);
|
||
var rb = func(b);
|
||
return ra > rb ? 1 : ra === rb ? 0 : -1;
|
||
});
|
||
return list;
|
||
}
|
||
});
|
||
}
|
||
|
||
Date.prototype.format = function (format) {
|
||
var o = {
|
||
"M+": this.getMonth() + 1, //month
|
||
"d+": this.getDate(), //day
|
||
"h+": this.getHours(), //hour
|
||
"m+": this.getMinutes(), //minute
|
||
"s+": this.getSeconds(), //second
|
||
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
|
||
"S": this.getMilliseconds() //millisecond
|
||
}
|
||
if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
|
||
(this.getFullYear() + "").substr(4 - RegExp.$1.length));
|
||
for (var k in o)
|
||
if (new RegExp("(" + k + ")").test(format))
|
||
format = format.replace(RegExp.$1,
|
||
RegExp.$1.length == 1 ? o[k] :
|
||
("00" + o[k]).substr(("" + o[k]).length));
|
||
return format;
|
||
}
|
||
|
||
|