创建版本
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,191 @@
|
||||
/**
|
||||
* 桌面通知插件(支持IE啊)
|
||||
* var notify = notifyClass({
|
||||
* 'sound':'声音文件地址','soundbo':true,'icon':'通知图标'
|
||||
* });
|
||||
* notify.showpopup('这是个通知?');
|
||||
* soundbo 声音提示
|
||||
* sound 声音文件地址
|
||||
*/
|
||||
|
||||
function notifyClass(opts){
|
||||
var me = this;
|
||||
this.title = '系统提醒';
|
||||
this.icon = 'images/logo.png';
|
||||
this.notbool =true;
|
||||
this.lastmsg = '';
|
||||
this.sound = '';
|
||||
this.sounderr= '';
|
||||
this.soundbo = true;
|
||||
this.showbool= false;
|
||||
this._init=function() {
|
||||
if (opts) for(var o1 in opts)this[o1]=opts[o1];
|
||||
var strsr = '';
|
||||
if (typeof(Notification)=='undefined') {
|
||||
this.notbool = false;
|
||||
strsr = '<bgsound id="notify_sound_audio" src="" hidden="true" autostart="false" loop="false">';
|
||||
} else {
|
||||
strsr = '<audio id="notify_sound_audio" hidden="true" src="'+this.sound+'"></audio>';
|
||||
}
|
||||
if(this.sound)$('body').append(strsr);
|
||||
};
|
||||
this.setsound = function(bo){
|
||||
this.soundbo=bo;
|
||||
};
|
||||
this.opennotify = function(clsfun){
|
||||
if(!this.notbool)return false;
|
||||
if(!clsfun)clsfun=function(){};
|
||||
if(Notification.permission === 'granted')return false;
|
||||
if(Notification.permission !== 'denied') {
|
||||
Notification.requestPermission(function (permission) {
|
||||
clsfun();
|
||||
if(!('permission' in Notification)) {
|
||||
Notification.permission = permission;
|
||||
}
|
||||
if(permission==='granted') {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
this.showpopup = function(msg,cans){
|
||||
this.lastmsg = msg;
|
||||
var can = {body:msg,icon:this.icon,soundbo:this.soundbo,sound:this.sound,tag:'rockwebkitMeteoric',title:this.title,click:function(){}};
|
||||
if(cans)for(var oi in cans)can[oi]=cans[oi];
|
||||
var clsfun=can.click,title=can.title;
|
||||
if(this.showbool)this.show(can);
|
||||
if(!this.notbool){
|
||||
this._showpopupie(msg,clsfun,can);
|
||||
return;
|
||||
}else{
|
||||
var lx = this.getaccess();
|
||||
if(lx!='ok'){
|
||||
this.opennotify();
|
||||
}
|
||||
}
|
||||
var notification = new Notification(title, can);
|
||||
notification.onclick = function(){
|
||||
var salx=clsfun(can);
|
||||
if(!salx)nwjs.winshow();
|
||||
this.close();
|
||||
};
|
||||
this.notification = notification;
|
||||
if(can.soundbo)this.playsound(can.sound);
|
||||
};
|
||||
this.close = function(){
|
||||
try{
|
||||
if(this.notification)this.notification.close();
|
||||
}catch(e){}
|
||||
this.notification = false;
|
||||
};
|
||||
this.playsound=function(src){
|
||||
if(!src)src=this.sound;
|
||||
var boa=document.getElementById('notify_sound_audio');
|
||||
if(boa){
|
||||
boa.src=src;
|
||||
if(boa.play)boa.play();
|
||||
}
|
||||
};
|
||||
this.playerrsound=function(src){
|
||||
if(!src)src=this.sounderr;
|
||||
if(src)this.playsound(src);
|
||||
};
|
||||
this.getaccess=function(){
|
||||
var lx = 'none';
|
||||
if(typeof(Notification)=='undefined'){
|
||||
lx='ok';
|
||||
return lx;
|
||||
}
|
||||
lx = Notification.permission;
|
||||
if(lx=='granted'){lx='ok';}else if(lx=='denied'){lx='jz';}else{lx='mr';}
|
||||
return lx;
|
||||
};
|
||||
this._showpopupie=function(msg, clsfun, can){
|
||||
if(typeof(createPopup)=='undefined')return;
|
||||
var x = window.screenLeft?window.screenLeft: window.screenX,
|
||||
y = window.screenTop?window.screenTop: window.screenY;
|
||||
var w = 310,h=80;
|
||||
var l = screen.width-x-w-10,
|
||||
t = screen.height-y-h-60;
|
||||
var p=window.createPopup();
|
||||
var pbody=p.document.body;
|
||||
pbody.style.backgroundColor='#f5f5f5';
|
||||
pbody.style.border= 'solid #cccccc 1px';
|
||||
msg = msg.replace(/\n/gi,'<br>');
|
||||
var s = '<div style="cursor:pointer">';
|
||||
s+='<span id="createPopup_close" style="position:absolute;right:0px;top:0px;cursor:pointer;">×</span>';
|
||||
s+='<table id="createPopup_body"><tr valign="top">';
|
||||
s+='<td style="padding:5px"><img width="60px" src="'+can.icon+'" height="60px"><td>';
|
||||
s+='<td style="padding:0px 5px"><div style="font-size:14px;line-height:20px;padding-top:3px" align="left"><b>'+can.title+'</b></div><div style="font-size:12px;padding-top:3px;height:50px;overflow:hidden;">'+msg+'</div><td>';
|
||||
s+='</tr></table>';
|
||||
s+='</div>';
|
||||
pbody.innerHTML=s;
|
||||
p.show(l,t,w,h,document.body);
|
||||
p.document.getElementById('createPopup_close').onclick=function(){p.hide();};
|
||||
p.document.getElementById('createPopup_body').onclick=function(){
|
||||
var salx = clsfun(can);
|
||||
if(!salx) nwjs.winshow();
|
||||
p.hide();
|
||||
};
|
||||
if(can.soundbo)this.playsound(can.sound);
|
||||
};
|
||||
this.getnotifystr=function(ostr){
|
||||
var slx = '<font color="green">[已开启]</font>';
|
||||
var olx = this.getaccess();
|
||||
if(olx=='jz'){
|
||||
slx = '<font color="red">[已禁止]</font>,<a href="http://www.gdoo.net/view_notify.html" target="_blank">(去设置)</a>';
|
||||
}
|
||||
if(olx=='mr'){
|
||||
slx = '<font color="#ff6600">[未开启]</font>,<a onclick="'+ostr+'" href="javascript:;">[开启]</a>';
|
||||
}
|
||||
return slx;
|
||||
};
|
||||
|
||||
// 右边提示的
|
||||
this.show = function(cans) {
|
||||
if(!cans)cans={};
|
||||
var can = {body:'',icon:'/assets/chat/images/web/todo.png',type:'info',right:'30px',top:'80px',closetime:0,soundbo:this.soundbo,sound:this.sound,title:this.title,click:false,rand:js.getrand()};
|
||||
if(cans)for(var oi in cans)can[oi]=cans[oi];
|
||||
var coarr = {
|
||||
'info':['#31708f', '#d9edf7','#bce8f1'],
|
||||
'success':['#3c763d', '#dff0d8','#d6e9c6'],
|
||||
'error':['#a94442', '#f2dede','#ebccd1'],
|
||||
'wait':['#8a6d3b', '#fcf8e3','#faebcc']
|
||||
};
|
||||
var cos = coarr[can.type],id = 'notify_show_'+can.rand+'';
|
||||
$('#'+id+'').remove();
|
||||
var wz = this.showwei(can.right,can.top),mess=can.body
|
||||
mess = mess.replace(/\n/gi, '<br>');
|
||||
var s = '<div id="'+id+'" temp="notifyshow" class="boxs" style="position:absolute;z-index:70;right:'+wz[0]+';top:'+wz[1]+';border:1px '+cos[2]+' solid; background:'+cos[1]+';color:'+cos[0]+';border-radius:5px">';
|
||||
if(can.closetime==0)s+='<div onclick="$(this).parent().fadeOut(function(){$(this).remove()})" style="position:absolute;right:3px;top:0px;cursor:pointer">×</div>';
|
||||
s+='<table style="margin:15px"><tr valign="top">';
|
||||
s+=' <td width="53px" align="left"><img style="width:40px;height:40px" src="'+can.icon+'"></td>';
|
||||
s+=' <td id="'+id+'_td" align="left"><div style="padding-bottom:3px;font-size:14px"><b>'+can.title+'</b></div><div>'+mess+'</div></td>';
|
||||
s+='</tr></table>';
|
||||
s+='</div>';
|
||||
$('body').append(s);
|
||||
if(can.closetime>0)setTimeout(function(){me.showclose(id)}, can.closetime*1000);
|
||||
if(typeof(can.click)=='function'){
|
||||
var clsfun=can.click;
|
||||
$('#'+id+'_td').click(function(){
|
||||
var salx=clsfun(can);
|
||||
me.showclose(id);
|
||||
});
|
||||
}
|
||||
};
|
||||
this.showwei=function(r,t){
|
||||
var cas = $("div[temp='notifyshow']");
|
||||
if(cas.length>0){
|
||||
var o = cas[cas.length-1];
|
||||
var t1 = parseInt(o.style.top)+$(o).height()+20;
|
||||
t = ''+t1+'px';
|
||||
}
|
||||
return [r,t];
|
||||
};
|
||||
|
||||
this.showclose=function(id){
|
||||
$('#'+id+'').fadeOut(function(){$(this).remove();})
|
||||
}
|
||||
|
||||
this._init();
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
var nwjs = {
|
||||
init:function() {
|
||||
this.nw = nwjsgui;
|
||||
if(!this.nw)return;
|
||||
this.fs = require('fs');
|
||||
this.win = nwjsgui.Window.get();
|
||||
},
|
||||
serverdata:function(str) {
|
||||
},
|
||||
createtray:function(tls, lx) {
|
||||
if(!this.nw) return;
|
||||
var icon = 'images/logo.png';
|
||||
var tray = new nwjsgui.Tray({ title:tls, icon: icon});
|
||||
tray.tooltip = tls;
|
||||
var menu = new nwjsgui.Menu();
|
||||
menu.append(new nwjsgui.MenuItem({label: '打开窗口',click:function(){
|
||||
nwjs.winshow();
|
||||
}}));
|
||||
this.closebool = false;
|
||||
menu.append(new nwjsgui.MenuItem({label: '退出',click:function(){
|
||||
nwjs.closebool = true;
|
||||
try{bodyunload();js.onunload();}catch(e){}
|
||||
nw.App.quit();
|
||||
}}));
|
||||
|
||||
tray.menu = menu;
|
||||
|
||||
tray.on('click',function(){
|
||||
nwjs.winshow();
|
||||
});
|
||||
|
||||
this.tray = tray;
|
||||
|
||||
this.win.removeAllListeners('close');
|
||||
this.win.on('close',function(){
|
||||
if(nwjs.closebool){
|
||||
try{bodyunload();js.onunload();}catch(e){}
|
||||
nw.App.quit();
|
||||
//nw.Window.get().close(true);
|
||||
}else{
|
||||
nwjs.win.hide();
|
||||
}
|
||||
});
|
||||
|
||||
if(lx==0)return;
|
||||
var kjj=js.getoption('kuaijj','Q');
|
||||
this.addShortcut(kjj);
|
||||
this.addfile();
|
||||
var llq = navigator.userAgent.toLowerCase();
|
||||
try{if(llq.indexOf('windows nt 5')<0)this.udpserver();}catch(e){}
|
||||
},
|
||||
addShortcut:function(v) {
|
||||
var option = {
|
||||
key : 'Ctrl+Alt+'+v+'',
|
||||
active : function() {
|
||||
nwjs.changewinhide();
|
||||
}
|
||||
};
|
||||
this.shortcut = new nwjsgui.Shortcut(option);
|
||||
nwjsgui.App.unregisterGlobalHotKey(this.shortcut);
|
||||
nwjsgui.App.registerGlobalHotKey(this.shortcut);
|
||||
},
|
||||
changekuai:function(o1) {
|
||||
var val=o1.value;
|
||||
this.addShortcut(val);
|
||||
js.setoption('kuaijj', val);
|
||||
},
|
||||
removetray:function() {
|
||||
if(!this.nw) return;
|
||||
if(this.tray) this.tray.remove();
|
||||
this.win.removeAllListeners('close');
|
||||
if(this.shortcut) nwjsgui.App.unregisterGlobalHotKey(this.shortcut);
|
||||
this.closeserver();
|
||||
this.tray = false;
|
||||
this.shortcut = false;
|
||||
},
|
||||
changewinhide:function() {
|
||||
if (windowfocus) {
|
||||
this.win.hide();
|
||||
} else {
|
||||
this.winshow();
|
||||
}
|
||||
},
|
||||
runcmd:function(cmd) {
|
||||
if (!this.nw) return;
|
||||
if (!this.execcmd) this.execcmd= require('child_process').exec;
|
||||
this.execcmd(cmd);
|
||||
},
|
||||
openurl:function(url) {
|
||||
this.runcmd(''+this.getpath()+'/images/start.bat '+url+'');
|
||||
},
|
||||
editoffice:function(cstr) {
|
||||
this.runcmd(''+this.getpath()+'/images/rockoffice.exe '+cstr+'');
|
||||
},
|
||||
winshow:function() {
|
||||
if (!this.nw) {
|
||||
window.focus();
|
||||
return;
|
||||
}
|
||||
this.win.show();
|
||||
this.win.focus();
|
||||
},
|
||||
changeicon:function(oi) {
|
||||
if (!this.tray) return;
|
||||
var s = 'images/logo.png';
|
||||
if (oi > 0) {
|
||||
s = 'images/logo.png';
|
||||
}
|
||||
this.tray.icon = s;
|
||||
},
|
||||
writeFile:function(path, str) {
|
||||
if (!this.nw) return;
|
||||
if (!this.fs) this.fs = require('fs');
|
||||
var oatg = this.getpath();
|
||||
this.fs.writeFile(oatg + '/' + path, str, function(err) {
|
||||
if (err) {
|
||||
js.msg('msg', 'error:' + err);
|
||||
}
|
||||
});
|
||||
},
|
||||
getpath:function() {
|
||||
if (!this.pathobj) this.pathobj = require('path');
|
||||
var oatg = this.pathobj.dirname(process.execPath);
|
||||
oatg = oatg.replace(/\\/g, '/');
|
||||
return oatg;
|
||||
var peiz= nwjsgui.App.manifest;
|
||||
if(peiz.localpath)return peiz.localpath;
|
||||
var url = peiz.main;
|
||||
var las = url.lastIndexOf('\\');
|
||||
var oatg = url.substr(0, las);
|
||||
if(oatg.substr(0,5)=='file:')oatg=oatg.substr(7)
|
||||
return oatg;
|
||||
},
|
||||
addfile:function() {
|
||||
return;
|
||||
js.ajaxss('down','file',function(ret){
|
||||
var fs = require("fs");
|
||||
fs.writeFile('rock.php', ret.filecont, function(err) {
|
||||
alert(err);
|
||||
});
|
||||
});
|
||||
},
|
||||
banben:function(o1) {
|
||||
o1.innerHTML = '已是最新';
|
||||
},
|
||||
getipmac:function() {
|
||||
var json = {ip:'','mac':''};
|
||||
if (!this.nw) return json;
|
||||
var os = require('os');
|
||||
var network = os.networkInterfaces();
|
||||
for (var a in network) {
|
||||
for (var i = 0; i < network[a].length; i++) {
|
||||
var json = network[a][i];
|
||||
if (json.family == 'IPv4') {
|
||||
json.ip = json.address
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return json;
|
||||
},
|
||||
closeserver:function() {
|
||||
if (!this.server) return;
|
||||
if (this.socketobj) this.socketobj.destroy();
|
||||
this.server.close();
|
||||
this.server = false;
|
||||
},
|
||||
socketobj:false,
|
||||
udpserver:function(funarr) {
|
||||
if (!this.nw) return;
|
||||
var http = require('http');
|
||||
this.server = http.createServer(function(req, res) {
|
||||
var url = req.url.toString(),bstr='ok';
|
||||
if (url.indexOf('?') > -1) {
|
||||
try {
|
||||
var urla= url.split('?'),batr= urla[urla.length-1],i,bas1,bst='',bas={},k,v;
|
||||
var batra = batr.split('&');
|
||||
for(i = 0; i < batra.length; i++) {
|
||||
bas1 = batra[i].split('=');
|
||||
k = bas1[0]; v = bas1[1]; if (!v) v='';
|
||||
if (v.indexOf('base64') == 0) v = v.substr(6);
|
||||
bas[k]= v;
|
||||
}
|
||||
var barr = nwjs.serverdata(bas);
|
||||
if (typeof(barr)=='object') bas = js.apply(bas, barr);
|
||||
for (k in bas) bst+=',"'+k+'":"'+bas[k]+'"';
|
||||
if (bst!='') bst=bst.substr(1);
|
||||
bstr= '{'+bst+'}';
|
||||
if (typeof(barr) == 'string') bstr = barr;
|
||||
if (bas.callback) bstr = bas.callback + '({'+bst+'})';
|
||||
} catch(e) {}
|
||||
}
|
||||
res.writeHead(200,{'Content-Type':'text/html;charset=utf-8'});
|
||||
res.write(bstr);
|
||||
res.end();
|
||||
nwjs.socketobj.destroy();
|
||||
nwjs.socketobj = false;
|
||||
});
|
||||
this.server.on('connection',function(socket) {
|
||||
nwjs.socketobj = socket;
|
||||
});
|
||||
this.server.listen(2829,'127.0.0.1',function() {
|
||||
|
||||
});
|
||||
},
|
||||
downfile:function(params) {
|
||||
var cans = js.apply({url:'',savefile:'',onsuccess:function(){},onjindu:function(){},onerror:function(){}},params);
|
||||
var http = require('http');
|
||||
http.get(cans.url, function(res) {
|
||||
if(res.statusCode != 200){
|
||||
cans.onerror('not found');
|
||||
return;
|
||||
}
|
||||
var filesize = res.headers['content-length'];
|
||||
if(!filesize)filesize = res.headers['accept-length'];
|
||||
filesize = parseFloat(filesize);
|
||||
res.setEncoding('binary');
|
||||
var str = '';
|
||||
res.on('data',function(s) {
|
||||
str += s;
|
||||
var jd = Math.round(100 * str.length / filesize);
|
||||
cans.onjindu(jd, filesize * jd * 0.01);
|
||||
}).on('end', function() {
|
||||
nwjs.fs.writeFile(cans.savefile, str, 'binary', function(err) {
|
||||
cans.onsuccess();
|
||||
});
|
||||
});
|
||||
}).on('error', function(e) {
|
||||
cans.onerror('error');
|
||||
});
|
||||
},
|
||||
createdir:function(path) {
|
||||
var a1 = path.split('/') ,spth='';
|
||||
for(var i = 0;i < a1.length-1; i++) {
|
||||
spth += a1[i] + '/';
|
||||
if(!this.fs.existsSync(spth))this.fs.mkdirSync(spth);
|
||||
}
|
||||
},
|
||||
filetobase64:function(path) {
|
||||
var data = this.fs.readFileSync(path);
|
||||
data = new Buffer(data).toString('base64');
|
||||
//this.fs.writeFileSync(path, data);
|
||||
return data;
|
||||
}
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,275 @@
|
||||
var touchobj=false;
|
||||
var strformat = {
|
||||
sendcodearr:{},
|
||||
sendcuxo:0,
|
||||
emotsstr:',[微笑],[撇嘴],[色],[发呆],[得意],[流泪],[害羞],[闭嘴],[睡],[大哭],[尴尬],[发怒],[调皮],[呲牙],[惊讶],[难过],[酷],[冷汗],[抓狂],[吐],[偷笑],[愉快],[白眼],[傲慢],[饥饿],[困],[恐惧],[流汗],[憨笑],[悠闲],[奋斗],[咒骂],[疑问],[嘘],[晕],[疯了],[衰],[骷髅],[敲打],[再见],[擦汗],[抠鼻],[鼓掌],[糗大了],[坏笑],[左哼哼],[右哼哼],[哈欠],[鄙视],[委屈],[快哭了],[阴险],[亲亲],[吓],[可怜],[菜刀],[西瓜],[啤酒],[篮球],[乒乓],[咖啡],[饭],[猪头],[玫瑰],[凋谢],[嘴唇],[爱心],[心碎],[蛋糕],[闪电],[炸弹],[刀],[足球],[瓢虫],[便便],[月亮],[太阳],[礼物],[拥抱],[强],[弱],[握手],[胜利],[抱拳],[勾引],[拳头],[差劲],[爱你],[NO],[OK],[爱情],[飞吻],[跳跳],[发抖],[怄火],[转圈],[磕头],[回头],[跳绳],[投降],[激动],[街舞],[献吻],[左太极],[右太极]',
|
||||
addcode:function(key, val){
|
||||
this.sendcuxo++;
|
||||
key = key+','+this.sendcuxo;
|
||||
this.sendcodearr[key] = val;
|
||||
return '[C]'+key+'[/C]'
|
||||
},
|
||||
geturl:function(d){
|
||||
if(!d)d={'url':''};
|
||||
var url = d.url;
|
||||
if(!url&&d.table&&d.mid)url='?m=flow&a=view&d=taskrun&table='+d.table+'&mid='+d.mid+'&uid='+adminid+'';
|
||||
return url;
|
||||
},
|
||||
emotspath:'',
|
||||
strcont:function(nr){
|
||||
var str = unescape(nr),patt1,emu,i,st1,oi;
|
||||
|
||||
if(str.indexOf('<img')==-1){
|
||||
var strRegex = "((https|http)?://){1}"
|
||||
+ "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" //ftp的user@
|
||||
+ "(([0-9]{1,3}\.){3}[0-9]{1,3}" // IP形式的URL- 199.194.52.184
|
||||
+ "|" // 允许IP和DOMAIN(域名)
|
||||
+ "([0-9a-z_!~*'()-]+\.)*" // 域名- www.
|
||||
+ "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." // 二级域名
|
||||
+ "[a-z]{2,6})" // first level domain- .com or .museum
|
||||
+ "(:[0-9]{1,4})?" // 端口- :80
|
||||
+ "((/?)|" // a slash isn't required if there is no file name
|
||||
+ "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)";
|
||||
patt1 = new RegExp(strRegex, 'gi');
|
||||
emu = str.match(patt1);
|
||||
if(emu!=null){
|
||||
for(i=0;i<emu.length; i++){
|
||||
st1 = emu[i];
|
||||
if(st1.indexOf('http')==0){
|
||||
str = str.replace(st1, '{URL'+i+'}');
|
||||
}
|
||||
}
|
||||
for(i=0;i<emu.length; i++){
|
||||
st1 = emu[i];
|
||||
if(st1.indexOf('http')==0){
|
||||
str = str.replace('{URL'+i+'}', '<a onclick="return strformat.openurl(\''+st1+'\')" href="javascript:;">'+st1+'</a>');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
patt1 = new RegExp("\\[(.*?)\\](.*?)", 'gi');
|
||||
emu = str.match(patt1);
|
||||
if(emu!=null){
|
||||
for(i=0;i<emu.length; i++){
|
||||
st1=emu[i];
|
||||
oi=this.emotsarrss[st1];
|
||||
if(oi)str = str.replace(st1, '<img height="24" width="24" src="'+this.emotspath+'images/im/emots/qq/'+(oi-1)+'.gif">');
|
||||
}
|
||||
}
|
||||
str = str.replace(/\n/gi, '<br>');
|
||||
return str;
|
||||
},
|
||||
downshow:function(sid){
|
||||
var url = 'mode/upload/uploadshow.php?id='+sid+'';
|
||||
openurlla(url, 400, 300);
|
||||
return false;
|
||||
},
|
||||
strcontss:function(str,bq,rstr){
|
||||
var patt1 = new RegExp("\\["+bq+"\\](.*?)\\[\\/"+bq+"\\]", "gi");
|
||||
var emu = str.match(patt1);
|
||||
if(emu != null){
|
||||
bq1 = bq.toLowerCase();
|
||||
for(var i=0;i<emu.length; i++){
|
||||
var s0 = emu[i].replace('['+bq+']','').replace('[/'+bq+']','');
|
||||
s0 = s0.replace('['+bq1+']','').replace('[/'+bq1+']','');
|
||||
var s1 = s0,s2 = s0,s3='',sa;
|
||||
if(s0.indexOf('|')>0){
|
||||
sa = s0.split('|');
|
||||
s1 = sa[1];
|
||||
s2 = sa[0];
|
||||
s3 = sa[2];
|
||||
}
|
||||
var s4 = rstr.replace('{s1}',s1).replace('{s2}',s2).replace('{s3}',s3);
|
||||
str = str.replace(emu[i], s4);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
},
|
||||
sendinstr:function(str, tuas){
|
||||
var bq = 'C';
|
||||
var patt1 = new RegExp("\\["+bq+"\\](.*?)\\[\\/"+bq+"\\]", "gi");
|
||||
var emu = str.match(patt1);
|
||||
|
||||
if(emu != null){
|
||||
for(var i=0;i<emu.length; i++){
|
||||
var s0 = emu[i].replace('['+bq+']','').replace('[/'+bq+']','');
|
||||
str = str.replace(emu[i], this.sendcodearr[s0]);
|
||||
}
|
||||
}
|
||||
var nowa = js.serverdt('Y-m-d H:i:s 星期W'),
|
||||
nowas = nowa.split(' ');
|
||||
var ztstr = [['now',nowa],['date',nowas[0]],['time',nowas[1]],['week',nowas[2]]];
|
||||
var patt1,a,thnr,ths='';
|
||||
for(var i=0; i<ztstr.length; i++){
|
||||
a = ztstr[i];
|
||||
if(a[2] == 1){
|
||||
patt1 = new RegExp(""+a[0]+"", "gi");
|
||||
thnr = '[A]'+a[0]+'|'+a[1]+'[/A]';
|
||||
}else{
|
||||
thnr = a[1];
|
||||
patt1 = new RegExp("\\["+a[0]+"\\]", "gi");
|
||||
}
|
||||
str = str.replace(patt1, thnr);
|
||||
}
|
||||
return str;
|
||||
},
|
||||
picshow:function(str, wj){
|
||||
var s=str,sa;
|
||||
if(s.indexOf('[图片.')==0){
|
||||
s=s.substr(1,s.length-1);
|
||||
sa=s.split('.');
|
||||
if(wj)s='<img src="'+apiurl+''+wj+'">';
|
||||
}
|
||||
return s;
|
||||
},
|
||||
showdt:function(sj){
|
||||
if(!sj)sj='';
|
||||
var s='';
|
||||
sja=sj.split(' ');
|
||||
if(sj.indexOf(this.dt)==0){
|
||||
s=sja[1];
|
||||
}else{
|
||||
s=sj.substr(5,11);
|
||||
}
|
||||
return s;
|
||||
},
|
||||
showqp:function(type, name, dt, cont, nuid, fase, rnd) {
|
||||
var str = this.strcont(cont);
|
||||
if(!rnd)rnd=js.getrand();
|
||||
var nr = '';
|
||||
this.showqpid = 'ltcont_'+rnd+'';
|
||||
nr+='<div id="'+this.showqpid+'" class="ltcont">';
|
||||
nr+=' <div class="qipao" align="'+type+'">';
|
||||
nr+=' <div class="dt" style="padding-'+type+':65px"><font id="ltname_'+rnd+'">'+name+'</font>('+this.showdt(dt)+')</div>';
|
||||
|
||||
nr+=' <table border="0" cellspacing="0" cellpadding="0">';
|
||||
|
||||
nr+=' <tr valign="top">';
|
||||
if(type == 'left'){
|
||||
nr+=' <td width="50" align="center"><img src="'+fase+'" class="qipaoface" width="40" height="40"></td>';
|
||||
nr+=' <td><div class="qipao'+type+'"></div></td>';
|
||||
}else{
|
||||
nr+=' <td width="30" align="right">';
|
||||
if(nuid)nr+='<img src="/assets/chat/images/loadings.gif" title="发送中..." id="'+nuid+'" style="margin-top:5px" align="absmiddle"> ';
|
||||
nr+=' </td>';
|
||||
}
|
||||
|
||||
nr+=' <td>';
|
||||
nr+=' <div ontouchstart="touchobj=this" id="qipaocont_'+rnd+'" rand="'+rnd+'" class="qipaocont qipaocont'+type+'">'+str+'</div>';
|
||||
nr+=' </td>';
|
||||
|
||||
if(type == 'right'){
|
||||
nr+=' <td><div class="qipao'+type+'"></div></td>';
|
||||
nr+=' <td width="50" align="center"><img src="'+fase+'" class="qipaoface" width="40" height="40"></td>';
|
||||
}else{
|
||||
nr+=' <td width="30"></td>';
|
||||
}
|
||||
|
||||
nr+=' </tr></table>';
|
||||
nr+=' </div>';
|
||||
nr+='</div>';
|
||||
return nr;
|
||||
},
|
||||
showupfile:function(f, snr){
|
||||
var nuid= js.now('time'),optdt = js.serverdt(),nr='';
|
||||
nr = '<div id="showve_'+nuid+'">';
|
||||
if(f && f.filename){
|
||||
if(f.isimg){
|
||||
var src = ''+this.emotspath+'assets/chat/images/noimg.jpg';
|
||||
if(f.thumbpath)src = ''+apiurl+''+f.thumbpath+'';
|
||||
if(f.imgviewurl)src = f.imgviewurl;
|
||||
nr+='<div><img width="150" id="imgview_'+nuid+'" src="'+src+'"><br>'+f.filesizecn+'</div>';
|
||||
}else{
|
||||
nr+= '<div><img src="'+this.emotspath+'images/fileicons/'+js.filelxext(f.fileext)+'.gif" align="absmiddle"> '+f.filename+'('+f.filesizecn+')</div>';
|
||||
}
|
||||
}
|
||||
if(snr){
|
||||
nr+= '<div><img src="'+snr+'" id="jietuimg_'+nuid+'" width="150"></div>';
|
||||
nr+= '<div><a onclick="im.upbase64(\''+nuid+'\')" href="javascript:;">[发送截图]</a>';
|
||||
}
|
||||
nr+= '<div class="progresscls"><div id="progresscls_'+nuid+'" class="progressclssse"></div><div class="progressclstext" id="progresstext_'+nuid+'">0%</div></div>';
|
||||
nr+= '<div id="progcanter_'+nuid+'"><a href="javascript:;" onclick="strformat.cancelup(\''+nuid+'\')">取消</a></div>';
|
||||
nr+= '</div>';
|
||||
this.nuidup_tep = nuid;
|
||||
var cont= this.showqp('right','我',optdt, nr, nuid, f.face, nuid);
|
||||
return {'cont':cont,optdt:optdt,nuid:nuid};
|
||||
},
|
||||
upprogresss:function(per, nuid){
|
||||
if(!nuid)nuid=this.nuidup_tep;
|
||||
$('#progresscls_'+nuid+'').css('width',''+per+'%');
|
||||
$('#progresstext_'+nuid+'').html(''+per+'%');
|
||||
if(per==100)$('#progcanter_'+nuid+'').remove();
|
||||
},
|
||||
upsuccess:function(f,nuid){
|
||||
if(!nuid)nuid=this.nuidup_tep;
|
||||
this.upprogresss(100, nuid);
|
||||
$('#progresstext_'+nuid+'').html('上传成功');
|
||||
var contss;
|
||||
if(js.isimg(f.fileext)){
|
||||
contss = '[图片 '+f.filesizecn+']';
|
||||
}else{
|
||||
contss = '['+f.filename+' '+f.filesizecn+']';
|
||||
}
|
||||
var s = this.contshozt(f);
|
||||
$('#showve_'+nuid+'').html(s);
|
||||
return contss;
|
||||
},
|
||||
uperror:function(nuid){
|
||||
if(!nuid)nuid=this.nuidup_tep;
|
||||
$('#progresstext_'+nuid+'').html('<font color=red>上传失败</font>');
|
||||
$('#progcanter_'+nuid+'').remove();
|
||||
},
|
||||
cancelup:function(nuid){
|
||||
if(!nuid)nuid=this.nuidup_tep;
|
||||
try{if(this.upobj)this.upobj.abort();}catch(e){}
|
||||
$('#ltcont_'+nuid+'').remove();
|
||||
},
|
||||
openimg:function(src){
|
||||
var img = src;
|
||||
if(src.indexOf('thumb')>0){
|
||||
var ext = src.substr(src.lastIndexOf('.')+1);
|
||||
img = src.substr(0,src.lastIndexOf('_'))+'.'+ext;
|
||||
}
|
||||
js.open(img);
|
||||
},
|
||||
emotsarrss:{},
|
||||
init:function(){
|
||||
var a = this.emotsstr.split(',');
|
||||
this.emotsarr=a;
|
||||
var len = a.length,i;
|
||||
for(i=1;i<len;i++){
|
||||
this.emotsarrss[a[i]]=i;
|
||||
}
|
||||
this.dt=js.now();
|
||||
},
|
||||
contshozt:function(d, lj){
|
||||
var s='',slx,sttr;
|
||||
if(!d)return s;
|
||||
if(!d.fileid)d.fileid=d.id;
|
||||
if(js.isimg(d.fileext)){
|
||||
sttr='';
|
||||
if(d.thumbpath){
|
||||
s='<img src="'+d.thumbpath+'" fid="'+d.fileid+'">';
|
||||
}else{
|
||||
if(d.width){
|
||||
if(d.width>150)sttr='width="150"';
|
||||
}else{
|
||||
sttr='width="150"';
|
||||
}
|
||||
s='<img src="'+d.filepath+'" '+sttr+' fid="'+d.fileid+'">';
|
||||
}
|
||||
}else if(d.fileext=='amr'){
|
||||
s+='<i class="fa fa-volume-up"></i> '+(parseInt(d.filesize/1000))+'"';
|
||||
s+=' <a href="javascript:;" style="font-size:12px" onclick="js.fileopt('+d.fileid+',1)">下载</a>';
|
||||
}else{
|
||||
slx = d.fileext;if(!lj)lj='';
|
||||
if(js.fileall.indexOf(','+slx+',')<0)slx='wz';
|
||||
s=''+d.filename+'<br><a href="javascript:;" onclick="js.fileopt('+d.fileid+',1)">下载</a> <a href="javascript:;" onclick="js.fileopt('+d.fileid+',0)">预览</a> '+d.filesizecn+'';
|
||||
s='<table><tr><td><div class="qipaofile">'+d.fileext.toUpperCase()+'</div></td><td>'+s+'</td></tr></table>';
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
strformat.init();
|
||||
@@ -0,0 +1,73 @@
|
||||
function websocketClass(a) {
|
||||
var b = this;
|
||||
this.wsobj = !1,
|
||||
this.wshost = "",
|
||||
this.onopen = function() {},
|
||||
this.onmessage = function() {},
|
||||
this.onclose = function() {},
|
||||
this.onerror = function() {},
|
||||
this.reimfrom = "rockdemo",
|
||||
this.adminid = "1",
|
||||
this.sendname = "1",
|
||||
this._init = function() {
|
||||
if (a) for (var c in a) this[c] = a[c];
|
||||
"undefined" == typeof WebSocket ? (WEB_SOCKET_SWF_LOCATION = "res/swf/WebSocketMain.swf", WEB_SOCKET_DEBUG = !0, $.getScript("res/js/swfobject.js",
|
||||
function() {
|
||||
b._contect()
|
||||
})) : this._contect()
|
||||
},
|
||||
this._contect = function() {
|
||||
this.wsobj = new WebSocket(this.wshost),
|
||||
this.wsobj.onopen = function(a) {
|
||||
b._onopen(a)
|
||||
},
|
||||
this.wsobj.onmessage = function(a) {
|
||||
b._onmessage(a)
|
||||
},
|
||||
this.wsobj.onclose = function(a) {
|
||||
b._onclose(a)
|
||||
},
|
||||
this.wsobj.onerror = function(a) {
|
||||
b._onerror(a)
|
||||
}
|
||||
},
|
||||
this.connect = function() {
|
||||
this._contect()
|
||||
},
|
||||
this._onopen = function(a) {
|
||||
this.onopen(this, a);
|
||||
},
|
||||
this._onmessage = function(a) {
|
||||
var b = a.data;
|
||||
this.onmessage(b, this)
|
||||
},
|
||||
this._onclose = function(a) {
|
||||
this.onclose(this, a)
|
||||
},
|
||||
this._onerror = function(a) {
|
||||
this.onerror(this, a)
|
||||
},
|
||||
this.send = function(a) {
|
||||
// var b = this.objecttostr(a);
|
||||
a.from = this.reimfrom;
|
||||
a.adminid = this.adminid;
|
||||
a.sendname = this.sendname;
|
||||
a.atype = 'send';
|
||||
return this.wsobj.send(JSON.stringify(a))
|
||||
},
|
||||
this.objecttostr = function(a) {
|
||||
var b, d, c = "",
|
||||
e = js.apply({
|
||||
from: this.reimfrom,
|
||||
adminid: this.adminid,
|
||||
atype: "send",
|
||||
sendname: this.sendname
|
||||
},
|
||||
a);
|
||||
for (b in e) d = e[b],
|
||||
c += ',"' + b + '":"' + d + '"';
|
||||
return "" != c && (c = c.substr(1)),
|
||||
"{" + c + "}"
|
||||
},
|
||||
this._init()
|
||||
}
|
||||
Reference in New Issue
Block a user