123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616 |
-
- Namespace.register("U.UF.C");
- U.UF.C.fullScreen = function () {
- var _funcname = U.UF.C.getFullSreeenName("requestFullScreen");
- if (_funcname != null) {
- document[_funcname] ? document[_funcname]() : document.documentElement[_funcname]();
- }
- }
- U.UF.C.cancelfullScreen = function () {
- var _funcname = U.UF.C.getFullSreeenName("cancelFullScreen") || U.UF.C.getFullSreeenName("exitFullScreen");
- if (_funcname != null) {
- document[_funcname] ? document[_funcname]() : document.documentElement[_funcname]();
- }
- }
- U.UF.C.getFullSreeenName = function (funcname) {
- var i, _functionname;
-
-
-
- var _full = ["", "webkit", "moz", "ms", "o"];
- for (i = 0; i < _full.length; i++) {
- if (_full[i]) {
- _functionname = _full[i] + funcname.capitalizeFirstLetter();
- }
- else {
- _functionname = funcname;
- }
-
- if (_functionname in document.documentElement || _functionname in document) {
- return _functionname;
- }
- }
- return null;
- }
- U.UF.C.toArray = function (obj) {
- try {
- return Array.prototype.slice.call(obj);
- }
- catch (e) {
- var i = 0,
- _arr = [];
- for (; obj[i]; i++) {
- _arr.push(obj[i]);
- }
- return _arr;
- }
- }
- U.UF.C.apply = function (scope, fun) {
-
- return function () {
- fun.call(scope || this);
- }
- }
- U.UF.C.closure = function (fun, parms) {
-
- return function () {
- return fun.apply(this, parms)
- }
- }
- U.UF.C.getColorByRGB = function (style) {
- var i,
- _color = "#",
- _grbarr = style.match(U.UF.S.rgb);
-
- if (_grbarr) {
- for (i = 1; i < _grbarr.length; i++) {
- _color += ("0" + _grbarr[i].toInt().toString(16)).slice(-2);
- }
- return _color;
- }
- return style;
- }
- U.UF.C.queryString = function (key, search) {
- var _search = (search || window.document.location.search).substr(1);
- var i, j,
- _return = "",
- _valuearr,
- _arr = _search.split("&");
- for (i = 0; i < _arr.length; i++) {
- _valuearr = _arr[i].split("=");
- if (_valuearr[0].toUpperCase() == key.toUpperCase()) {
- for (j = 1; j < _valuearr.length; j++) {
- _return += _valuearr[j] + (j == _valuearr.length - 1 ? "" : "=");
- }
- break;
- }
- }
- return _return;
- }
- U.UF.C.getUrlHash = function () {
- var _hash = document.location.hash;
- return _hash.split("/");
- }
- U.UF.C.isUrl = function (str) {
-
- var _str = str;
-
- var _String = /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/;
-
- var _objExp = new RegExp(_String);
-
- if (_objExp.test(str) == true) {
- return true;
- } else {
- return false;
- }
- }
- U.UF.C.iframeSameDomain = function (iframe, htmlstr, cb) {
-
- U.UF.DL.iframeLoad(iframe, function () {
- if (htmlstr) {
- iframe.contentWindow.document.body.innerHTML = htmlstr;
- }
- if (cb) {
- cb();
- }
- });
-
- iframe.src = document.domain ? "javascript:void((function(){document.open();document.domain='" + document.domain + "';document.close()})())" : "about:blank";
- return iframe;
- }
- U.UF.C.urlEncode = function (arr) {
- var i;
- for (i = 0; i < arr.length; i++) {
- arr[i] = encodeURIComponent(encodeURIComponent(arr[i]));
- }
- return arr.join(",");
- }
- U.UF.C.copy = function () {
- if (window.clipboardData) {
- window.clipboardData.setData("text", copystr);
- }
- else if (event && event.clipboardData) {
- event.clipboardData.setData("text/HTML", copystr);
- }
- else if (event && event.originalEvent && event.originalEvent.clipboardData) {
- event.originalEvent.clipboardData("Text", copystr);
- }
- else if (document.execCommand) {
- document.execCommand("copy");
- return document.execCommand("copy");
- }
- else {
- U.alert("请手动选择复制");
- }
- }
- U.UF.C.pasteText = function () {
- if (window.clipboardData) {
- return window.clipboardData.getData("text");
- }
- else if (event.clipboardData) {
- var _str = event.clipboardData.getData("text/HTML");
- if (!_str) {
- _str = event.clipboardData.getData("text/plain").replaceAngleBrackets();
- }
- return _str;
- }
- else if (event && event.originalEvent && event.originalEvent.clipboardData) {
- return event.originalEvent.clipboardData("Text")
- }
- else if (document.execCommand) {
- if (document.execCommand("paste") == true) {
- document.execCommand("paste");
- return document.execCommand("paste");
- } else {
- U.alert && U.alert("无法粘贴");
- return false;
- }
- }
- else {
- U.alert && U.alert("无法粘贴");
- }
- }
- U.UF.C.rightClickMenuLocation = function (el) {
-
- var _e = event || window.event,
- _elementposition = U.UF.EL.getElementPosition(el),
- _getmousex = _e.clientX - _elementposition[1],
- _getmousey = _e.clientY - _elementposition[0],
- _eloffsetp = U.selectEl(el).Parent(),
- _ellocationw = el.offsetWidth,
- _ellocationh = el.offsetHeight,
- _eloffsetpw = _eloffsetp.offsetWidth,
- _eloffsetph = _eloffsetp.offsetHeight;
-
- if ((_ellocationw + _getmousex) > _eloffsetpw) {
- _getmousex = _getmousex;
- }
- else {
- _getmousex = _getmousex;
- }
-
- if ((_ellocationh + _getmousey) > _eloffsetph) {
- _getmousey = _getmousey;
- }
- else {
- _getmousey = _getmousey;
- }
- U.selectEl(el)[0].style.top = _getmousey + "px";
- U.selectEl(el)[0].style.left = _getmousex + "px";
- console.log('xzda');
- }
- U.UF.C.jsonToStr = function (o) {
- var r = [];
- if (typeof o == "string") {
- return "\"" + o.replace(/([\'\"\\])/g, "\\$1").replace(/(\n)/g, "\\n").replace(/(\r)/g, "\\r").replace(/(\t)/g, "\\t") + "\"";
- }
- if (typeof o == "object") {
- if (!o.sort) {
- for (var i in o) {
- r.push(i + ":" + U.UF.C.jsonToStr(o[i]));
- }
- if (!!document.all && !/^\n?function\s*toString\(\)\s*\{\n?\s*\[native code\]\n?\s*\}\n?\s*$/.test(o.toString)) {
- r.push("toString:" + o.toString.toString());
- }
- r = "{" + r.join() + "}";
- }
- else {
- for (var i = 0; i < o.length; i++) {
- r.push(U.UF.C.jsonToStr(o[i]));
- }
- r = "[" + r.join() + "]";
- }
- return r;
- }
- if (o == null) {
- return "null";
- }
- else { return o.toString(); }
- }
- U.UF.C.objectToString = function (obj) {
- return Object.prototype.toString.call(obj);
- }
- U.UF.C.console = function (err) {
- try {
-
- return;
- }
- catch (e) { }
- }
- U.UF.C.loadJs = function (el, htmlstr) {
- if (htmlstr != null) {
- el.innerHTML = htmlstr;
- }
- var i,
- _head = U.selectEl("head"),
- _scripts = U.selectEl("script", el);
-
- for (i = 0; i < _scripts.length; i++) {
-
- if (_scripts[i].src) {
- U.UF.DL.asynLoadJs({ "src": _scripts[i].src });
- } else {
-
- $$("script", { "type": _scripts[i].type || 'text/javascript' }, _head[0]).text = _scripts[i].text;
- }
- }
- return htmlstr;
- }
- U.UF.C.toJson = function (str) {
- var i,
- _json = str;
-
- if (U.UF.C.isString(str)) {
- _json = str.parseJSON();
- }
- if (Array.isArray(_json)) {
-
- for (i = 0; i < _json.length; i++) {
- if (U.UF.C.isString(_json[i])) {
- _json[i] = _json[i].parseJSON();
- }
- else if (Array.isArray(_json[i])) {
- U.UF.C.toJson(_json[i]);
- }
- }
- }
-
- return _json;
- }
- U.UF.C.getBriefText = function (el, length, str) {
- if (el.length > length) {
- var _el = U.UF.C.isString(el) ? $$("div", { "innerHTML": el }) : el;
- var _length = length || 200;
- var _str = str || "";
- var _biretext = _el.innerText.substring(0, _length) + (_el.innerText._length > 200 ? _str : "") + str;
- return _biretext;
- }
- return el;
- }
- U.UF.C.shieldedSelect = function () {
- var _editel = U.UF.EL.getAncestorEditElement(event.srcElement);
-
- if (_editel && (_editel.nodeType == 3 || _editel.contentEditable == "true" ||
- "textarea,input".indexOf(_editel.tagName.toLocaleLowerCase()))) {
- return true;
- }
- U.UF.EV.stopBubble();
- U.UF.EV.stopDefault();
- return false;
- }
- U.UF.C.shieldedBackspace = function () {
- if (event.keyCode == 8) {
-
- if (U.UF.EL.getAncestorEditElement((event.srcElement)) == document.body && !document.body.isContentEditable) {
- U.UF.EV.stopDefault();
- }
- }
- }
- U.UF.C.isObject = function (obj) {
- return (typeof obj == "object" && obj !== null);
- }
- U.UF.C.isNumber = function (obj) {
- return typeof obj == "number";
- }
- U.UF.C.isString = function (str) {
- return typeof str == "string"
- }
- U.UF.C.isFunction = function (fun) {
- var _isfun = typeof fun == "function";
- var _isobjfun = U.UF.C.objectToString(fun) == "[object Function]";
- return _isfun || _isobjfun;
- }
- U.UF.C.isElement = function (el) {
- return el != null && el.nodeType != null;
- }
- U.UF.C.AddObj = function (obj1, obj2) {
- for (var i in obj2) {
- if (obj2.hasOwnProperty(i)) {
- obj1[i] = obj2[i];
- }
- }
- return obj2;
- }
- U.UF.C.computeFileSize = function (size) {
- var _s;
- if (size > 1024) {
- if (size / 1024 > 1024) {
- if (size / (1024 * 1024) > 1024) {
- _s = (size / (1024 * 1024 * 1024)).toFixed(2) + 'GB';
- }
- else {
- _s = (size / (1024 * 1024)).toFixed(2) + 'MB';
- }
- }
- else {
- _s = (size / 1024).toFixed(2) + 'KB';
- }
- }
- else {
- _s = size.toFixed(2) + 'B';
- }
- return _s;
- }
- U.UF.C.filterTag = function () {
- }
|