📄 pfcclient.js.tpl.php
字号:
li.setAttribute('class', '<?php echo $prefix; ?>nickmarker <?php echo $prefix; ?>nick_'+ hex_md5(nicks[i])); // nobr is not xhtml valid but it's a workeround // for IE which doesn't support 'white-space: pre' css rule var nobr = document.createElement('nobr'); nobr.appendChild(document.createTextNode(nicks[i])); li.appendChild(nobr); ul.appendChild(li); } var fc = nickdiv.firstChild; if (fc) nickdiv.replaceChild(ul,fc); else nickdiv.appendChild(ul,fc); this.colorizeNicks(nickdiv); }, /** * clear the nickname list */ clearNickList: function() { var nickdiv = this.el_online; var fc = nickdiv.firstChild; if (fc) nickdiv.removeChild(fc); }, /** * clear the message list history */ clearMessages: function() { var msgdiv = $('<?php echo $prefix; ?>chat'); msgdiv.innerHTML = ''; }, /** * parse the message */ parseMessage: function(msg) { var rx = null; // parse urls var rx_url = new RegExp('(^|[^\\"])([a-z]+\:\/\/[a-z0-9.\\/\\?\\=\\&\\-\\_\\#]*)([^\\"]|$)','ig'); var ttt = msg.split(rx_url); if (ttt.length > 1 && !navigator.appName.match("Explorer|Konqueror") && !navigator.appVersion.match("KHTML")) { msg = ''; for( var i = 0; i<ttt.length; i++) { var offset = (ttt[i].length - 7) / 2; var delta = (ttt[i].length - 7 - 60); var range1 = 7+offset-delta; var range2 = 7+offset+delta; if (ttt[i].match(rx_url)) msg = msg + '<a href="' + ttt[i] + '"<?php if($openlinknewwindow) echo ' target="_blank"'; ?>>' + (delta>0 ? ttt[i].substring(7,range1)+ ' ... '+ ttt[i].substring(range2,ttt[i].length) : ttt[i]) + '</a>'; else { msg = msg + ttt[i]; } } } else // fallback for IE6/Konqueror which do not support split with regexp msg = msg.replace(rx_url, '$1<a href="$2"<?php if($openlinknewwindow) echo ' target="_blank"'; ?>>$2</a>$3'); // replace double spaces by entity rx = new RegExp(' ','g'); msg = msg.replace(rx, ' '); // try to parse bbcode rx = new RegExp('\\[b\\](.+?)\\[\/b\\]','ig'); msg = msg.replace(rx, '<span style="font-weight: bold">$1</span>'); rx = new RegExp('\\[i\\](.+?)\\[\/i\\]','ig'); msg = msg.replace(rx, '<span style="font-style: italic">$1</span>'); rx = new RegExp('\\[u\\](.+?)\\[\/u\\]','ig'); msg = msg.replace(rx, '<span style="text-decoration: underline">$1</span>'); rx = new RegExp('\\[s\\](.+?)\\[\/s\\]','ig'); msg = msg.replace(rx, '<span style="text-decoration: line-through">$1</span>'); // rx = new RegExp('\\[pre\\](.+?)\\[\/pre\\]','ig'); // msg = msg.replace(rx, '<pre>$1</pre>'); rx = new RegExp('\\[email\\]([A-z0-9][\\w.-]*@[A-z0-9][\\w\\-\\.]+\\.[A-z0-9]{2,6})\\[\/email\\]','ig'); msg = msg.replace(rx, '<a href="mailto: $1">$1</a>'); rx = new RegExp('\\[email=([A-z0-9][\\w.-]*@[A-z0-9][\\w\\-\\.]+\\.[A-z0-9]{2,6})\\](.+?)\\[\/email\\]','ig'); msg = msg.replace(rx, '<a href="mailto: $1">$2</a>'); rx = new RegExp('\\[color=([a-zA-Z]+|\\#?[0-9a-fA-F]{6}|\\#?[0-9a-fA-F]{3})](.+?)\\[\/color\\]','ig'); msg = msg.replace(rx, '<span style="color: $1">$2</span>'); // parse bbcode colors twice because the current_text_color is a bbcolor // so it's possible to have a bbcode color imbrication rx = new RegExp('\\[color=([a-zA-Z]+|\\#?[0-9a-fA-F]{6}|\\#?[0-9a-fA-F]{3})](.+?)\\[\/color\\]','ig'); msg = msg.replace(rx, '<span style="color: $1">$2</span>'); // try to parse smileys var sl = this.smileys.keys(); for(var i = 0; i < sl.length; i++) { rx = new RegExp(RegExp.escape(sl[i]),'g'); msg = msg.replace(rx, '<img src="'+ this.smileys[sl[i]] +'" alt="' + sl[i] + '" title="' + sl[i] + '" />'); } // try to parse nickname for highlighting rx = new RegExp('(^|[ :,;])'+RegExp.escape(this.nickname)+'([ :,;]|$)','gi'); msg = msg.replace(rx, '$1<strong>'+ this.nickname +'</strong>$2'); // don't allow to post words bigger than 65 caracteres // doesn't work with crappy IE and Konqueror ! rx = new RegExp('([^ \\:\\<\\>\\/\\&\\;]{60})','ig'); var ttt = msg.split(rx); if (ttt.length > 1 && !navigator.appName.match("Explorer|Konqueror") && !navigator.appVersion.match("KHTML")) { msg = ''; for( var i = 0; i<ttt.length; i++) { msg = msg + ttt[i] + ' '; } } return msg; }, /** * parse messages and append it to the message list */ parseAndPost: function(msgs) { var msgdiv = $('<?php echo $prefix; ?>chat'); var msgids = Array(); var html = ''; for(var mid = 0; mid < msgs.length ; mid++) { var id = msgs[mid][0]; var date = msgs[mid][1]; var heure = msgs[mid][2]; var nick = msgs[mid][3]; var words = msgs[mid][4]; var cmd = msgs[mid][5]; var fromtoday = msgs[mid][6]; var oldmsg = msgs[mid][7]; msgids.push(id); /* check the nickname is in the list or not */ var nickfound = false; for(var i = 0; i < this.nicklist.length && !nickfound; i++) { if (this.nicklist[i] == nick) nickfound = true; } var nickcolor = ''; if (nickfound) nickcolor = this.getAndAssignNickColor(nick); /* format and post message */ var line = ''; line += '<div id="<?php echo $prefix; ?>msg'+ id +'" class="<?php echo $prefix; ?>'+ cmd +' <?php echo $prefix; ?>message'; if (oldmsg == 1) line += ' <?php echo $prefix; ?>oldmsg'; line += '">'; line += '<span class="<?php echo $prefix; ?>date'; if (fromtoday == 1) line += ' <?php echo $prefix; ?>invisible'; line += '">'+ date +'</span> '; line += '<span class="<?php echo $prefix; ?>heure">'+ heure +'</span> '; if (cmd == 'cmd_msg') { line += ' <span class="<?php echo $prefix; ?>nick">'; line += '‹'; line += '<span '; if (nickcolor != '') line += 'style="color: ' + nickcolor + '" '; line += 'class="<?php echo $prefix; ?>nickmarker <?php echo $prefix; ?>nick_'+ hex_md5(nick) +'">'; line += nick; line += '</span>'; line += '›'; line += '</span> '; } if (cmd == 'cmd_notice' || cmd == 'cmd_me') line += '<span class="<?php echo $prefix; ?>words">* '+ this.parseMessage(words) +'</span> '; else line += '<span class="<?php echo $prefix; ?>words">'+ this.parseMessage(words) +'</span> '; line += '</div>'; html += line; } /* create a dummy div to avoid konqueror bug when setting nickmarkers */ var m = document.createElement('div'); m.innerHTML = html; /* finaly append this to the message list */ msgdiv.appendChild(m); for(var i = 0; i < msgids.length ; i++) { this.scrolldown($('<?php echo $prefix; ?>msg'+ msgids[i])); /* colorize messages nicknames */ var root = $('<?php echo $prefix; ?>msg'+ msgids[i]); this.refresh_nickmarker(root); this.refresh_clock(root); } }, /** * scroll down from the posted message height */ scrolldown: function(elttoscroll) { $('<?php echo $prefix; ?>chat').scrollTop += elttoscroll.offsetHeight+2; }, /** * apply nicknames color to the root childs */ colorizeNicks: function(root) { for(var i = 0; i < this.nicklist.length; i++) { var cur_nick = this.nicklist[i]; var cur_color = this.getAndAssignNickColor(cur_nick); this.applyNickColor(root, cur_nick, cur_color); } }, /** * Initialize the color array used to colirize the nicknames */ reloadColorList: function() { this.colorlist = Array('#CCCCCC', '#000000', '#3636B2', '#2A8C2A', '#C33B3B', '#C73232', '#80267F', '#66361F', '#D9A641', '#3DCC3D', '#1A5555', '#2F8C74', '#4545E6', '#B037B0', '#4C4C4C', '#959595' ); }, /** * get the corresponding nickname color */ getAndAssignNickColor: function(nick) { /* check the nickname is colorized or not */ var allready_colorized = false; var nc = ''; for(var j = 0; j < this.nickcolor.length; j++) { if (this.nickcolor[j][0] == nick) { allready_colorized = true; nc = this.nickcolor[j][1]; } } if (!allready_colorized) { /* reload the color stack if it's empty */ if (this.colorlist.length == 0) this.reloadColorList(); /* take the next color from the list and colorize this nickname */ var cid = Math.round(Math.random()*(this.colorlist.length-1)); nc = this.colorlist[cid]; this.colorlist.splice(cid,1); this.nickcolor.push(new Array(nick, nc)); } return nc; }, /** * Colorize with 'color' all the nicknames found as a 'root' child */ applyNickColor: function(root, nick, color) { var nicktochange = this.getElementsByClassName(root, '<?php echo $prefix; ?>nick_'+ hex_md5(nick), '') for(var i = 0; nicktochange.length > i; i++) nicktochange[i].style.color = color; }, /** * Returns a list of elements which have a clsName class */ getElementsByClassName: function( root, clsName, clsIgnore ) { var i, matches = new Array(); var els = root.getElementsByTagName('*'); var rx1 = new RegExp('.*'+clsName+'.*'); var rx2 = new RegExp('.*'+clsIgnore+'.*'); for(i=0; i<els.length; i++) { if(els.item(i).className.match(rx1) && (clsIgnore == '' || !els.item(i).className.match(rx2)) ) { matches.push(els.item(i)); } } return matches; }, showClass: function(root, clsName, clsIgnore, show) { var elts = this.getElementsByClassName(root, clsName, clsIgnore); for(var i = 0; elts.length > i; i++) if (show) elts[i].style.display = 'inline'; else elts[i].style.display = 'none'; }, /** * Nickname marker show/hide */ nickmarker_swap: function() { if (this.nickmarker) { this.nickmarker = false; } else { this.nickmarker = true; } this.refresh_nickmarker() setCookie('<?php echo $prefix; ?>nickmarker', this.nickmarker); }, refresh_nickmarker: function(root) { var nickmarker_icon = $('<?php echo $prefix; ?>nickmarker'); if (!root) root = $('<?php echo $prefix; ?>chat'); if (this.nickmarker) { nickmarker_icon.src = "<?php echo $c->getFileUrlFromTheme('images/color-on.gif'); ?>"; nickmarker_icon.alt = this.i18n.hide_nickname_color; nickmarker_icon.title = nickmarker_icon.alt; this.colorizeNicks(root);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -