📄 core.js
字号:
Object.extend(Function.prototype, {
getArguments: function() {
var args = [];
for(var i=0; i<this.arguments.length; i++) {
args.push(this.arguments[i]);
}
return args;
}
}, false);
var MS = {"Browser":{}};
Object.extend(MS.Browser, {
isIE: navigator.userAgent.indexOf('MSIE') != -1,
isFirefox: navigator.userAgent.indexOf('Firefox') != -1,
isOpera: window.opera != null
}, false);
var AjaxPro = {};
AjaxPro.IFrameXmlHttp = function() {};
AjaxPro.IFrameXmlHttp.prototype = {
onreadystatechange: null, headers: [], method: "POST", url: null, async: true, iframe: null,
status: 0, readyState: 0, responseText: null,
abort: function() {
},
readystatechanged: function() {
var doc = this.iframe.contentDocument || this.iframe.document;
if(doc != null && doc.readyState == "complete" && doc.body != null && doc.body.res != null) {
this.status = 200;
this.statusText = "OK";
this.readyState = 4;
this.responseText = doc.body.res;
this.onreadystatechange();
return;
}
setTimeout(this.readystatechanged.bind(this), 10);
},
open: function(method, url, async) {
if(async == false) {
alert("Synchronous call using IFrameXMLHttp is not supported.");
return;
}
if(this.iframe == null) {
var iframeID = "hans";
if (document.createElement && document.documentElement &&
(window.opera || navigator.userAgent.indexOf('MSIE 5.0') == -1))
{
var ifr = document.createElement('iframe');
ifr.setAttribute('id', iframeID);
ifr.style.visibility = 'hidden';
ifr.style.position = 'absolute';
ifr.style.width = ifr.style.height = ifr.borderWidth = '0px';
this.iframe = document.getElementsByTagName('body')[0].appendChild(ifr);
}
else if (document.body && document.body.insertAdjacentHTML)
{
document.body.insertAdjacentHTML('beforeEnd', '<iframe name="' + iframeID + '" id="' + iframeID + '" style="border:1px solid black;display:none"></iframe>');
}
if (window.frames && window.frames[iframeID]) {
this.iframe = window.frames[iframeID];
}
this.iframe.name = iframeID;
this.iframe.document.open();
this.iframe.document.write("<"+"html><"+"body></"+"body></"+"html>");
this.iframe.document.close();
}
this.method = method;
this.url = url;
this.async = async;
},
setRequestHeader: function(name, value) {
for(var i=0; i<this.headers.length; i++) {
if(this.headers[i].name == name) {
this.headers[i].value = value;
return;
}
}
this.headers.push({"name":name,"value":value});
},
getResponseHeader: function(name, value) {
return null;
},
addInput: function(doc, form, name, value) {
var ele;
var tag = "input";
if(value.indexOf("\n") >= 0) {
tag = "textarea";
}
if(doc.all) {
ele = doc.createElement("<" + tag + " name=\"" + name + "\" />");
}else{
ele = doc.createElement(tag);
ele.setAttribute("name", name);
}
ele.setAttribute("value", value);
form.appendChild(ele);
ele = null;
},
send: function(data) {
if(this.iframe == null) {
return;
}
var doc = this.iframe.contentDocument || this.iframe.document;
var form = doc.createElement("form");
doc.body.appendChild(form);
form.setAttribute("action", this.url);
form.setAttribute("method", this.method);
form.setAttribute("enctype", "application/x-www-form-urlencoded");
for(var i=0; i<this.headers.length; i++) {
switch(this.headers[i].name.toLowerCase()) {
case "content-length":
case "accept-encoding":
case "content-type":
break;
default:
this.addInput(doc, form, this.headers[i].name, this.headers[i].value);
}
}
this.addInput(doc, form, "data", data);
form.submit();
setTimeout(this.readystatechanged.bind(this), 0);
}
};
var progids = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
var progid = null;
if(typeof ActiveXObject != "undefined") {
var ie7xmlhttp = false;
if(typeof XMLHttpRequest == "object") {
try{ var o = new XMLHttpRequest(); ie7xmlhttp = true; }catch(e){}
}
if(typeof XMLHttpRequest == "undefined" || !ie7xmlhttp) {
XMLHttpRequest = function() {
var xmlHttp = null;
if(!AjaxPro.noActiveX) {
if(progid != null) {
return new ActiveXObject(progid);
}
for(var i=0; i<progids.length && xmlHttp == null; i++) {
try {
xmlHttp = new ActiveXObject(progids[i]);
progid = progids[i];
}catch(e){}
}
}
if(xmlHttp == null && MS.Browser.isIE) {
return new AjaxPro.IFrameXmlHttp();
}
return xmlHttp;
};
}
}
Object.extend(AjaxPro, {
noOperation: function() {},
onLoading: function() {},
onError: function() {},
onTimeout: function() { return true; },
onStateChanged: function() {},
cryptProvider: null,
queue: null,
token: "",
version: "9.2.17.1",
ID: "AjaxPro",
noActiveX: false,
timeoutPeriod: 15*1000,
queue: null,
noUtcTime: false,
regExDate: function(str,p1, p2,offset,s) {
str = str.substring(1).replace('"','');
var date = str;
if (str.substring(0,7) == "\\\/Date(") {
str = str.match(/Date\((.*?)\)/)[1];
date = "new Date(" + parseInt(str) + ")";
}
else { // ISO Date 2007-12-31T23:59:59Z
var matches = str.split( /[-,:,T,Z]/);
matches[1] = (parseInt(matches[1],0)-1).toString();
date = "new Date(Date.UTC(" + matches.join(",") + "))";
}
return date;
},
parse: function(text) {
// not yet possible as we still return new type() JSON
// if (!(!(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(
// text.replace(/"(\\.|[^"\\])*"/g, ''))) ))
// throw new Error("Invalid characters in JSON parse string.");
var regEx = /(\"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}.*?\")|(\"\\\/Date\(.*?\)\\\/")/g;
text = text.replace(regEx,this.regExDate);
return eval('(' + text + ')');
},
m : {
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
},
toJSON: function(o) {
if(o == null) {
return "null";
}
var v = [];
var i;
var c = o.constructor;
if(c == Number) {
return isFinite(o) ? o.toString() : AjaxPro.toJSON(null);
} else if(c == Boolean) {
return o.toString();
} else if(c == String) {
if (/["\\\x00-\x1f]/.test(o)) {
o = o.replace(/([\x00-\x1f\\"])/g, function(a, b) {
var c = AjaxPro.m[b];
if (c) {
return c;
}
c = b.charCodeAt();
return '\\u00' +
Math.floor(c / 16).toString(16) +
(c % 16).toString(16);
});
}
return '"' + o + '"';
} else if (c == Array) {
for(i=0; i<o.length; i++) {
v.push(AjaxPro.toJSON(o[i]));
}
return "[" + v.join(",") + "]";
} else if (c == Date) {
// var d = {};
// d.__type = "System.DateTime";
// if(AjaxPro.noUtcTime == true) {
// d.Year = o.getFullYear();
// d.Month = o.getMonth() +1;
// d.Day = o.getDate();
// d.Hour = o.getHours();
// d.Minute = o.getMinutes();
// d.Second = o.getSeconds();
// d.Millisecond = o.getMilliseconds();
// } else {
// d.Year = o.getUTCFullYear();
// d.Month = o.getUTCMonth() +1;
// d.Day = o.getUTCDate();
// d.Hour = o.getUTCHours();
// d.Minute = o.getUTCMinutes();
// d.Second = o.getUTCSeconds();
// d.Millisecond = o.getUTCMilliseconds();
// }
return AjaxPro.toJSON("/Date(" + new Date(Date.UTC(o.getUTCFullYear(), o.getUTCMonth(), o.getUTCDate(), o.getUTCHours(), o.getUTCMinutes(), o.getUTCSeconds(), o.getUTCMilliseconds())).getTime() + ")/");
}
if(typeof o.toJSON == "function") {
return o.toJSON();
}
if(typeof o == "object") {
for(var attr in o) {
if(typeof o[attr] != "function") {
v.push('"' + attr + '":' + AjaxPro.toJSON(o[attr]));
}
}
if(v.length>0) {
return "{" + v.join(",") + "}";
}
return "{}";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -