123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787 |
-
- Namespace.register("U.A");
- U.A.ASet = [];
- U.A.DataBase = {
- Reply: ["Mysql", "UseStudio_Reply"],
- Money: ["Mysql", "UseStudio_Pay"],
- Develop: ["Mysql", "UseStudio_Develop"]
- };
- U.A.backAddress = {
-
- UseStudioManage: "http://main.1473.cn/Uses.ashx",
- UseStudioDisk: "http://main.1473.cn/Uses.ashx",
- pb: "http://main.1473.cn/Uses.ashx",
- Blog: "http://main.1473.cn/Uses.ashx",
- Application: "http://main.1473.cn/Uses.ashx",
- ABlog: "http://main.1473.cn/admin.ashx",
- APB: "http://main.1473.cn/admin.ashx",
- AUser: "http://main.1473.cn/admin.ashx",
- ADisk: "http://main.1473.cn/admin.ashx",
- AApp: "http://main.1473.cn/admin.ashx",
- Verify: "http://admin.1473.cn/Verify",
- Upload: "http://main.1473.cn/USupfile.ashx",
-
- Admin: "http://admin.1473.cn/Admin/Admin.ashx",
- KF: "http://admin.1473.cn/Admin/Admin.ashx",
- office: "http://office.1473.cn/Officetohtml.ashx",
- UseStudioPay: "http://pay.1473.cn/UseStudioPay.ashx",
- Reply: "http://reply.1473.cn"
- }
- U.A.Request = $.ajax = function (str, db, cb) {
-
- if (U.M.IsNetwork()) {
- var _ajax,
- _preAjax = U.A.ASet[U.A.ASet.length - 1];
-
-
-
- var _ifTimeSpan;
- if (_preAjax) {
- _ifTimeSpan = new Date().getTime() - _preAjax.date > 50;
- }
-
- if (!_preAjax || _preAjax.timeSpan < 50 || _ifTimeSpan) {
- _ajax = new U.A.Request.init(arguments);
-
- if (_ajax.handleDomain() === true) {
-
- if (_ajax.header) {
- return _ajax.createHeader(_ajax.header);
- } else {
- return _ajax.create();
- }
-
- }
- }
- return { "error": "application has been breached" };
- } else { U.Alert("网络断开!"); }
- }
- U.A.Request.init = function (arg) {
-
-
-
-
- U.Ut.AddObj(this, {
- win: window,
- ajax: null,
- err: null,
- url: arg[0],
-
-
- db: arg[1] || [],
- cb: arg[2] || "",
- cbParams: arg[3],
-
- header: arg[4] || "",
- UTI: new Date()
- });
- }
- U.A.Request.init.prototype = {
- createHeader: function (header) {
- var i, _url, _isDomain, _db, _ajax, isAsync, r;
- var ajaxType = header.type;
- var _USE = this.toAjaxFormat();
- _url = _USE[0];
- _db = _USE[1];
-
- if (U.Ut.isFunction(this.cb)) {
- isAsync = true;
- }
-
- if (ajaxType.toUpperCase() == "GET") {
- _url += "?" + _db;
- }
- this.ajax = this.CA(_url);
- _ajax = this.ajax.systemAjax;
- _ajax.open(ajaxType, _url, isAsync);
- header["CONTENT-TYPE"] = header["CONTENT-TYPE"] || "application/x-www-form-urlencoded;charset=UTF-8"
-
- for (i in header) {
- if ("type,async".indexOf(i) == -1) {
- try {
- if (i in _ajax) {
- _ajax[i] = header[i];
- } else {
- _ajax.setRequestHeader(i, header[i]);
- }
- } catch (e) { }
- }
- }
-
- if (_ajax.overrideMimeType) {
- if (header["responseType"] == "blob") {
- _ajax.overrideMimeType("text/plain; charset=x-user-defined");
- } else {
- _ajax.overrideMimeType("text/html");
- }
- }
-
- _ajax.send(_db);
-
- if (isAsync) {
- r = this["async"]();
- } else {
- r = this["sync"]();
- }
-
- return _isDomain;
- },
-
- create: function () {
- var header = {};
- var i, _url, _isDomain, _db, _ajax, isAsync, r;
- var ajaxType = "POST";
- var _params = this.toAjaxFormat();
- _url = _params[0];
- _db = _params[1];
-
- if (U.Ut.isFunction(this.cb)) {
- isAsync = true;
- }
-
- if (ajaxType.toUpperCase() == "GET") {
- _url += "?" + _db;
- }
-
- if (isAsync) {
-
- header.timeout = 90000;
- header.ontimeout = function () { this.AE(); }
- }
-
-
- this.ajax = this.CA(_url);
- _ajax = this.ajax.systemAjax;
- _ajax.open(ajaxType, _url, isAsync);
-
- _ajax.setRequestHeader("CONTENT-TYPE", "application/x-www-form-urlencoded;charset=UTF-8");
-
- if (_ajax.overrideMimeType) {
- _ajax.overrideMimeType("text/html");
- }
-
- _ajax.send(_db);
-
- if (isAsync) {
- r = this["async"]();
- } else {
- r = this["sync"]();
- }
-
- return r;
- },
-
- handleDomain: function () {
-
-
-
- var _isDomain, _url, _frame;
- var _params = this.toAjaxFormat();
- _url = _params[0];
- _isDomain = this.isDomain(_url);
-
- if (_isDomain[0] && !_isDomain[1]) {
-
- _frame = window.frames;
- for (i = 0; i < _frame.length; i++) {
- try {
- if (!_url.indexOf(_frame[i].location.protocol + "//" + _frame[i].location.host)) {
- return _frame[i].U.A.Request(this.url, this.db, this.cb, this.cbParams, this.header);
- }
- } catch (e) { }
- }
- }
-
- else if (!_isDomain[1] && _url.indexOf("1473.cn") > -1 && $("#U_Domain")[0]) {
-
- this.goDomain();
- return false;
- }
- return true;
- },
-
-
-
-
- toAjaxFormat: function () {
- var _userInfo, _useUrl, _defaultUrl,
- _requestObj = U.A.backAddress,
- _url = this.url,
- _params = U.M.SplitArray(this.db.concat()),
- _source = _url.indexOf(":") > -1 && U.M.IsUrl(_url),
- _requestArr = _url.split("."),
- _reqConfig = U.A.DataBase[_requestArr[0]];
- if (_source || _reqConfig) {
- if (_reqConfig) {
- _url = _requestObj[_requestArr[0]];
- _params += "&DBTYPE=" + _reqConfig[0] + "&DBNAME=" + _reqConfig[1];
- }
- _useUrl = _url;
- _params = "mode=" + _params;
- }
- else if (_requestArr && _requestArr[0] && _requestObj[_requestArr[0]]) {
- _defaultUrl = _requestObj[US.Auth, "UseStudioManage"];
- _useUrl = _requestObj[_requestArr[0]];
- _params = "functionname=" + _url + "&" + _url + "=" + _params;
- }
- else {
- _useUrl = window.location;
- _useUrl = window.location ? _useUrl.protocol + "//" + _useUrl.host + "/" + _url : "./" + _url;
- _params = "mode=" + _params;
- }
-
- try {
-
- if (parent.US) {
-
- _userInfo = parent.US.userInfo;
- if (_userInfo && _userInfo.UserId) {
- _params += "&UserId=" + _userInfo.UserId + "&LoginId=" + _userInfo.LoginId;
- }
- }
- else {
- _userInfo = {};
- }
- }
- catch (e) { _userInfo = {}; }
-
- _params += "&PageId=" + US.PageId + "&LoginId=" + US.SystemId;
-
- return [_useUrl, _params, _defaultUrl];
- },
-
- goDomain: function () {
-
- var _loading = this.cbParams ? this.cbParams[0] : null;
-
- if (_loading) {
- U.MD.loading(_loading[0])
- } else {
- U.MD.loading(_loading, _loading[1])
- }
-
-
- U.MN.message({
- "obj": "#U_Domain",
- "Sender": true,
- "me": U.M.apply(this, function (_data) {
- var _USE = _data[2].split("=");
-
- if (_USE[1] == "") {
- U.M.Cookies.del(_USE[0]);
- } else {
- U.M.Cookies.set(_data[2]);
- }
- document.wincookie = _data[2];
- (this.AE) && (this.AE(true, _data[0]));
- })
- }).post([this.url, this.db], "domain");
- },
-
- isDomain: function (URL) {
- var _url;
-
- if (window.location) {
-
- _url = window.location.protocol + "//" + window.location.host;
- if (_url.indexOf("1473.cn") > -1 && URL.indexOf("1473.cn") > 0) {
- return [true, !URL.indexOf(_url)];
- } else {
- return [false, false];
- }
-
- }
-
- },
-
- CA: function (url) {
- var i, _ajax, _xhr, _url, _ajaxObj = U.A.ASet,
- _preAjax = _ajaxObj[_ajaxObj.length - 1],
- _xhr = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];
-
- if (window.location) {
- _thisUrl = window.location.protocol + "//" + window.location.host;
- } else {
- _thisUrl = "";
- }
-
- for (i = 0; i < _ajaxObj.length; i++) {
- if ((_ajax = _ajaxObj[i].systemAjax).readyState == 4) {
- _ajax.onreadystatechange = U.M.apply();
- _ajax.abort();
- return _ajaxObj[i];
- }
- }
-
- try { _ajax = new window.XMLHttpRequest(); }
- catch (e) {
- for (i = 0; i < _xhr.length; i++) {
- try {
- _ajax = new ActiveXObject(_xhr[i]);
- break;
- } catch (e) { }
- }
- }
-
- if (url.indexOf(_thisUrl) == -1 && window.XDomainRequest) {
- _ajax = new window.XDomainRequest();
- }
-
- var timeSpan;
-
- if (_preAjax && ((new Date().getTime() - _preAjax.date) < 50)) {
- timeSpan = _preAjax.timeSpan + 1;
- } else {
- if (_preAjax) {
- timeSpan = _preAjax.timeSpan;
- } else {
- timeSpan = 0;
- }
- }
-
-
- var ajax = {
- systemAjax: _ajax,
- date: this.UTI,
- fun: this.url,
- timeSpan: timeSpan
- };
- _ajaxObj.push(ajax);
-
- return ajax;
- },
-
- async: function () {
- var _ajax = this.ajax.systemAjax,
- _loading = this.cbParams,
- _isUndefined = U.Ut.isUndefined(_ajax.onload),
- _cb;
- if (_isUndefined) {
- _cb = U.M.apply(this, this.AE);
- }
- else {
- _cb = U.M.apply(this, this.TAC);
- }
-
-
- if (_loading && _loading[0]) {
- if (_loading[0][0]) {
- U.MD.loading(_loading[0][0], _loading[0][1]);
- } else {
- U.MD.loading(_loading[0], _loading[0][1]);
- }
- }
-
-
-
- if (_isUndefined) {
- _ajax.onreadystatechange = _cb;
- } else {
- _ajax.onload = _cb;
- }
-
- try {
- _ajax.onerror = U.M.apply(this, this.OER);
- } catch (e) { }
- },
-
- TAC: function () {
- this.ajax.systemAjax.status = 200;
- this.AE(true);
- },
-
- OER: function () {
- this.ajax.systemAjax.status = 500;
- this.AE(true);
- },
-
- AE: function (UTF, UST) {
- try {
- if (UTF === true || this.ajax.systemAjax.readyState == 4) {
- (this.ajax) && (this.ajax.timeSpan = 0);
- var _loading = this.cbParams,
- _data = this.sync(UST),
- _timeSpan = (new Date()).getTime() - this.UTI.getTime();
-
- if (_loading && _loading[0]) {
- if (_loading[0][0]) {
- U.MD.uploading(_loading[0][0]);
- } else {
- U.MD.uploading(_loading[0]);
- }
- }
-
-
- if (_timeSpan > 1000 || _data.error) {
- (U.M.Console({ "T": _timeSpan, "N": this.url, "V": _data.error }));
- }
-
-
- if (_data.httpRequest.abort) {
- _data.httpRequest.abort();
- }
-
-
- if (this.cb && _data.value !== null) {
- this.cb.call(this.win, _data)
- }
-
- }
- } catch (e) { U.M.Console(e); }
- },
-
- sync: function (data) {
- var _UTF, _ajax;
-
- if (this.ajax) {
- _ajax = this.ajax.systemAjax;
- }
- else {
- _ajax = {};
- }
-
- var _ajaxAttr = { httpRequest: _ajax, status: null, value: null, context: this.cbParams },
- _errorFun = U.A.Error();
-
-
-
-
-
- _ajaxAttr.value = data;
-
- if (_ajax.status == 200) {
- _ajaxAttr.value = this.getBackStrToJson();
- _UTF = _errorFun.isError(_ajaxAttr.value);
- if (_UTF) {
- _errorFun.set(_ajaxAttr.value);
- }
- }
-
- else {
- _ajaxAttr.status = {
- "status": _ajax.status,
- "statusText": _ajax.statusText
- };
- }
-
-
-
-
-
-
- return _ajaxAttr;
- },
-
- getBackStrToJson: function () {
- var _ajax = this.ajax.systemAjax,
- _resXml = _ajax.responseXML;
-
- if (_resXml) {
- _resXml = _resXml.xml
- }
-
- if (!_resXml) {
- _resXml = _ajax.responseText;
- _resXml = U.M.toList(_resXml);
- }
- return _resXml;
- }
- }
- U.A.Jsonp = $.Jsonp = function (UDE) {
- var _UTE = new U.A.Jsonp.init(UDE);
- _UTE.send();
- return _UTE;
- }
- U.A.Jsonp.init = function (UDE) {
- U.Ut.AddObj(this, UDE);
- }
- U.A.Jsonp.init.prototype = {
-
- send: function () {
- var _URL = this.url,
- _UCE = this.call,
- _UPE = this.parameter,
- UDID = U.M.getFun(U.M.apply(this, this.success)).id;
- this.UFE = U.MD.DynamicLoad(_URL + (_UCE ? "?callback=" + _UDID + "&" : "") + (_UPE ? "parameter=" + U.M.SplitArray(_UPE) : ""), "js", U.M.apply(this, this.Asyn), null, true);
- },
-
- Asyn: function () { },
-
- success: function (r) {
- (this.call) && (this.call(r));
- $(this.UFE).remove();
- }
- }
- U.A.Post = $.Post = function (UDE) {
- var _UTE = new U.A.Post.init(UDE);
- _UTE.send();
- return _UTE;
- }
- U.A.Post.init = function (UDE) {
- U.Ut.AddObj(this, UDE);
- }
- U.A.Post.init.prototype = {
-
- send: function () {
- var i, _UDE = [],
- _URL = this.url,
- _UPE = this.parameter,
- _UCE = this.context;
-
- if (_UPE) {
- for (i in _UPE) {
- if (_UPE.hasOwnProperty(i)) {
- _UDE.push($$("input", { "name": i, "value": _UPE[i] }));
- }
- }
- }
-
- U.UP.uploading(_UDE, U.M.apply(this, this.success), _UCE, _URL, null, "application/x-www-form-urlencoded");
- },
-
- success: function (UDE) {
- (this.cb) && (this.cb(UDE));
- }
- }
- U.A.Error = function () {
- return new U.A.Error.init();
- }
- U.A.Error.init = function () {
- this.State = this.LogID = this.Value = this.Dt = this.Type = null;
- }
- U.A.Error.init.prototype = {
-
- isError: function (UDE) {
- if (U.Ut.isObject(UDE)) {
- for (var i in this) { if (this.hasOwnProperty(i) && !(i in UDE)) { return false; } }
- return true;
- }
- return false;
- },
-
- set: function (UDE) {
- U.Ut.AddObj(this, UDE);
- return this;
- }
- }
|