var MODE = '', ACTION = '', DIR = '', PROJECT = '', HOST = '', PARAMS = '', QOM = 'xinhu_', apiurl = '', token = '', device = '', CFROM = 'pc', ISDEMO = false, NOWURL = '', nwjsgui = false, apicloud = false, isapp = false; var windows = null, ismobile = 0; function initbody() { } function bodyunload() { } function globalbody() { } function initApp() { } function apiready() { apicloud = true; initApp(); } $(document).ready(function () { try { if (typeof (nw) == 'object') { nwjsgui = nw; } else { nwjsgui = require('nw.gui'); } } catch (e) { nwjsgui = false; } $(window).scroll(js.scrolla); HOST = js.gethost(); adminid = js.request('adminid'); token = js.request('token'); js.getsplit(); device = js.cookie('deviceid'); if (device == '') device = js.now('time'); js.savecookie('deviceid', device, 365); try { var winobj = js.request('winobj'); if (nwjsgui) window.focus = function () { nw.Window.get().focus() } if (winobj != '') opener.js.openarr[winobj] = window; } catch (e) { } globalbody(); initbody(); $('body').click(function (e) { js.downbody(this, e); }); $(window).unload(function () { js.onunload(); bodyunload(); }); var openfrom = js.request('openfrom', js.getoption('openfrom', '', true)); js.setoption('openfrom', openfrom, true); document.addEventListener('plusready', function () { plus.navigator.setStatusBarBackground('#1890ff'); isapp = true; plus.key.addEventListener('backbutton', function () { js.back(); }, false); initApp(); }); if (HOST == '127.0.0.1') window.addEventListener('error', function (e) { var msg = '文件:' + e.filename + '\n行:' + e.lineno + '\n错误:' + e.message + ''; js.alert(msg, 'js错误'); }); }); var js = { path: 'index', url: '', bool: false, login: {}, initdata: {}, openarr: {}, scroll: function () { } }; var isIE = true; if (!document.all) isIE = false; var get = function (id) { return document.getElementById(id) }; var isempt = function (an) { var ob = false; if (an == '' || an == null || typeof (an) == 'undefined') { ob = true; } if (typeof (an) == 'number') { ob = false; } return ob; } var strreplace = function (str) { if (isempt(str)) return ''; return str.replace(/[ ]/gi, '').replace(/\s/gi, '') } var strhtml = function (str) { if (isempt(str)) return ''; return str.replace(/\/gi, '>') } var form = function (an, fna) { if (!fna) fna = 'myform'; return document[fna][an] } var xy10 = function (s) { var s1 = '' + s + ''; if (s1.length < 2) s1 = '0' + s + ''; return s1; }; js.getarr = function (caa, bo) { var s = ''; for (var a in caa) s += ' @@ ' + a + '=>' + caa[a] + ''; if (!bo) alert(s); return s; } js.getarropen = function (caa) { jsopenararass = caa; js.open('js/array.shtml'); } if (typeof (api) == 'undefined') { var api = {}; api.systemType = 'android'; api.deviceId = ''; } js.str = function (o) { o.value = strreplace(o.value); } js.getcan = function (i, dev) { var a = PARAMS.split('-'); var val = ''; if (!dev) dev = ''; if (a[i]) val = a[i]; if (!val) val = dev; return val; } js.gethost = function () { var url = location.href, sau = ''; try { sau = url.split('//')[1].split('/')[0]; } catch (e) { } if (sau.indexOf('demo.rockoa.com') >= 0 || sau.indexOf('demo1.rockoa.com') >= 0) ISDEMO = true; var lse = url.lastIndexOf('/'); NOWURL = url.substr(0, lse + 1); QOM = NOWURL.replace(/\./g, '').replace(/\//g, '').replace(/\:/g, '') + '_'; var cfrom = this.request('cfrom', '', url); if (!cfrom) cfrom = this.getoption('CFROM'); if (cfrom) { this.setoption('CFROM', cfrom); CFROM = cfrom; } this.opentype = this.getoption('opentype'); var otype = this.request('opentype', '', url); if (otype) { this.setoption('opentype', otype); this.opentype = otype; } return sau; } function winHb() { var winH = (!isIE) ? window.innerHeight : document.documentElement.offsetHeight; return winH; } function winWb() { var winH = (!isIE) ? window.innerWidth : document.documentElement.offsetWidth; return winH; } js.scrolla = function () { var top = $(document).scrollTop(); js.scroll(top); } js.request = function (name, dev, url) { this.requestarr = {}; if (!dev) dev = ''; if (!name) return dev; if (!url) url = location.href; if (url.indexOf('\?') < 0) return dev; if (url.indexOf('#') > 0) url = url.split('#')[0]; var neurl = url.split('\?')[1]; neurl = neurl.split('&'); var value = dev, i, val; for (i = 0; i < neurl.length; i++) { val = neurl[i].split('='); this.requestarr[val[0]] = val[1]; if (val[0].toLowerCase() == name.toLowerCase()) { value = val[1]; break; } } if (!value) value = ''; return value; } js.now = function (type, sj) { if (!type) type = 'Y-m-d'; if (type == 'now') type = 'Y-m-d H:i:s'; var dt, ymd, his, weekArr, Y, m, d, w, H = 0, i = 0, s = 0, W; if (typeof (sj) == 'string') sj = sj.replace(/\//gi, '-'); if (/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}/.test(sj)) { sj = sj.split(' '); ymd = sj[0]; his = sj[1]; if (!his) his = '00:00:00'; ymd = ymd.split('-'); his = his.split(':'); H = his[0]; if (his.length > 1) i = his[1]; if (his.length > 2) s = his[2]; dt = new Date(ymd[0], ymd[1] - 1, ymd[2], H, i, s); } else { dt = (typeof (sj) == 'number') ? new Date(sj) : new Date(); } weekArr = new Array('日', '一', '二', '三', '四', '五', '六'); Y = dt.getFullYear(); m = xy10(dt.getMonth() + 1); d = xy10(dt.getDate()); w = dt.getDay(); H = xy10(dt.getHours()); i = xy10(dt.getMinutes()); s = xy10(dt.getSeconds()); W = weekArr[w]; if (type == 'time') { return dt.getTime(); } else { return type.replace('Y', Y).replace('m', m).replace('d', d).replace('H', H).replace('i', i).replace('s', s).replace('w', w).replace('W', W); } } js.float = function (num, w) { if (isNaN(num) || num == '' || !num || num == null) num = '0'; num = parseFloat(num); if (!w && w != 0) w = 2; var m = num.toFixed(w); return m; } js.splittime = 0; js.getsplit = function () { if (!js.servernow) return false; var dt = js.now('Y-m-d H:i:s'); var d1 = js.now('time', dt); var d2 = js.now('time', js.servernow); js.splittime = d1 - d2; } js.serverdt = function (atype) { if (!atype) atype = 'Y-m-d H:i:s'; var d1 = js.now('time') - js.splittime; var dt = js.now(atype, d1); return dt; } js.open = function (url, w, h, wina, can, wjcan) { if (wina) { try { var owina = this.openarr[wina]; owina.document.body; owina.focus(); return owina; } catch (e) { } } if (!w) w = 600; if (!h) h = 500; var l = (screen.width - w) * 0.5, t = (screen.height - h) * 0.5 - 50, rnd = parseInt(Math.random() * 50); if (rnd % 2 == 0) { l = l + rnd; t = t - rnd; } else { l = l - rnd; t = t + rnd; } if (!can) can = {}; var s = 'resizable=yes,scrollbars=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no'; var a1 = { 'left': '' + l + 'px', 'top': '' + t + 'px', 'width': '' + w + 'px', 'height': '' + h + 'px' }; a1 = js.apply(a1, can); for (var o1 in a1) s += ',' + o1 + '=' + a1[o1] + ''; var ja = (url.indexOf('?') >= 0) ? '&' : '?'; if (wina) url += '' + ja + 'winobj=' + wina + ''; if (typeof (nw) == 'undefined') { var opar = window.open(url, '', s); } else { var ocsn = js.apply({ 'frame': true, width: w, height: h, x: l, y: t, icon: 'assets/chat/images/logo.png' }, wjcan); if (url.substr(0, 4) != 'http') url = NOWURL + url; var opar = nw.Window.open(url, ocsn); } if (wina) this.openarr[wina] = opar; return false; } js.openrun = function (wina, act, ps1, ps2) { var owina = this.openarr[wina]; try { if (owina) owina[act](ps1, ps2); } catch (e) { owina = false; } return owina; } js.onunload = function () { var a = js.openarr; for (var b in a) { try { a[b].close() } catch (e) { } } try { var winobj = js.request('winobj'); if (winobj != '') opener.js.openarr[winobj] = false; } catch (e) { } } js.decode = function (str) { var arr = { length: -1 }; try { arr = new Function('return ' + str + '')(); } catch (e) { } return arr; } js.email = function (str) { if (isempt(str) || str.indexOf(' ') > -1) return false; if (str.indexOf('.') == -1 || str.indexOf('@') == -1) return false; var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g"); if (reg.test(str)) return false; return true; } js.reload = function () { location.reload(); } js.move = function (id, rl) { var _left = 0, _top = 0, _x = 0, _right = 0, _y = 0; var obj = id; if (!rl) rl = 'left'; if (typeof (id) == 'string') obj = get(id); var _Down = function (e) { try { var s = '
'; $('body').prepend(s); _x = e.clientX; _y = e.clientY; _left = parseInt(obj.style.left); _top = parseInt(obj.style.top); _right = parseInt(obj.style.right); document.onselectstart = function () { return false } } catch (e1) { } } var _Move = function (e) { try { var c = get('divmovetemp').innerHTML; var x = e.clientX - _x, y = e.clientY - _y; if (rl == 'left') obj.style.left = _left + x + 'px'; if (rl == 'right') obj.style.right = _right - x + 'px'; obj.style.top = _top + y + 'px'; } catch (e1) { _Down(e) } } var _Up = function () { document.onmousemove = ''; document.onselectstart = ''; $('#divmovetemp').remove(); } document.onmousemove = _Move; document.onmouseup = _Up; } js.setdev = function (val, dev) { var cv = val; if (isempt(cv)) cv = dev; return cv; } js.upload = function (call, can, glx) { if (!call) call = ''; if (!can) can = {}; js.uploadrand = js.now('YmdHis') + parseInt(Math.random() * 999999); var url = 'index.php?m=upload&d=public&callback=' + call + '&upkey=' + js.uploadrand + ''; for (var i in can) if (i != 'title') url += '&' + i + '=' + can[i] + ''; if (glx == 'url') return url; var s = '', tit = can.title; if (!tit) tit = '上传文件'; js.tanbody('uploadwin', tit, 500, 300, { html: '', bbar: 'none' }); winiframe.location.href = url; return false; } js.locationshow = function (sid) { var url = 'index.php?m=kaoqin&d=main&a=location&id=' + sid + ''; if (ismobile == 1) { js.location(url); return; } js.winiframe('地图位置查看', url); return false; } js.winiframemax = 45; js.winiframewidth = '900x800'; //默认的宽x高 js.winiframe = function (tit, url) { var mxw = 900, mxh = 800, tar = this.winiframewidth.split('x'); if (tar[0]) mxw = parseFloat(tar[0]); if (tar[1]) mxh = parseFloat(tar[1]); var hm = winHb() - 150; if (hm > mxh) hm = mxh; if (hm < 400) hm = 400; if (url.indexOf('wintype=max') > 0) { if (mxw < 1000) mxw = 1000; hm = winHb() - js.winiframemax; } var wi = winWb() - 150; if (wi > mxw) wi = mxw; if (wi < 700) wi = 700; js.tanbody('winiframe', tit, wi, 410, { html: '', bbar: 'none' }); openinputiframe.location.href = url; return false; } // 下载 js.downshow = function (id, fnun, cans) { if (this.fileoptWin(id)) return; if (appobj1('openfile', id)) return; if (!isempt(fnun)) { this.fileopt(id, 1); return false; } var url = 'api.php?m=upload&id=' + id + '&a=down'; if (cans) for (var i in cans) url += '&' + i + '=' + cans[i] + ''; this.location(url); return false; } js.downupdels = function (sid, said, o1) { js.confirm('确定要删除此文件吗?', function (lx) { if (lx == 'yes') { js.downupdel(sid, said, o1); } }); } js.downupdel = function (sid, said, o1) { if (sid > 0) { $.get(js.getajaxurl('delfile', 'upload', 'public', { id: sid })); } if (o1) $(o1).parent().remove(); var o = $('#view_' + said + ''); var to = $('#count_' + said + ''); var o1 = o.find('span'), s1 = ''; for (i = 0; i < o1.length; i++)$(o1[i]).html('' + (i + 1)); to.html(''); if (i > 0) to.html('文件:' + i + ''); o1 = o.find('font'); for (i = 0; i < o1.length; i++)s1 += ',' + $(o1[i]).html(); if (s1 != '') s1 = s1.substr(1); $('#' + said + '-inputEl').val(s1); $('#fileid_' + said + '').val(s1); } js.downupshow = function (a, showid, nbj) { var s = '', i = 0, s1 = '', fis; var o = $('#view_' + showid + ''); for (i = 0; i < a.length; i++) { fis = 'assets/chat/images/fileicons/' + js.filelxext(a[i].fileext) + '.gif'; if (js.isimg(a[i].fileext) && !isempt(a[i].thumbpath)) fis = a[i].thumbpath; s = '' + title + ' | '; s += ''; s += ' |