Advertisement
Guest User

Untitled

a guest
Jun 13th, 2014
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     WikiaChat+ v2
  3.     (c) spycrab0 - 2014
  4.     Kann Spuren von Batman enthalten
  5. */
  6. var wind = document.createElement("div");
  7. var oldcontent = document.getElementById("ChatHeader").innerHTML;
  8. var lastmsg;
  9.  
  10. /* Patching */
  11.  
  12. WikiaEmoticons.doReplacements = function (text,emoticonMapping){var oldtxt=text;$().log("Processing any emoticons... ");var imgUrlsByRegexString=emoticonMapping.getImgUrlsByRegexString();for(var regexString in imgUrlsByRegexString){if(regexString=='')continue;imgSrc=imgUrlsByRegexString[regexString];imgSrc=imgSrc.replace(/"/g,"%22");regexString=regexString.replace(/>/g,"&gt;");regexString=regexString.replace(/</g,"&lt;");var numIters=0;var origText=text;do{var regex=new RegExp("(^| )("+regexString+")([^/]|$)","gi");var emoticon=" <img src=\""+imgSrc+"\" width='"+WikiaEmoticons.EMOTICON_WIDTH+"' height='"+WikiaEmoticons.EMOTICON_HEIGHT+"' alt=\"$2\" title=\"$2\"/> ";var glyphUsed=text.replace(regex,'$2');glyphUsed=glyphUsed.replace(/"/g,"&quot;");text=text.replace(regex,'$1'+emoticon+'$3');}while((origText!=text)&&(numIters++<5));}
  13. $().log("Done processing emoticons.");setTimeout("chkMsg(\""+text+"\")",1000);if (WikiaChatAPI.useEmoticons == false) {return oldtxt;} return text;}
  14.  
  15. window.mainRoom.socket.send = function ($msg){if ($msg.indexOf("text:") != -1) {lastmsg=$msg.split("text\":\"")[1].split("\"")[0];}$().log($msg,'message');if(this.socket){this.socket.emit('message',$msg);}}
  16.  
  17.  
  18. /* API */
  19.  
  20. var WikiaChatAPI={
  21.     version: 1,
  22.     useEmoticons: true
  23. };
  24.  
  25. wind.id="wcp-window";
  26.  
  27. wind.style.zIndex = "999";
  28. wind.style.position = "absolute";
  29. wind.style.top = "0px";
  30. wind.style.left = "0px";
  31.  
  32. wind.innerHTML = "WikiaChat+ v"+WikiaChatAPI.version+"<br>";
  33. wind.innerHTML += "<a id='awayswitch' href='javascript:setAway(false)'>Away</a>|";
  34. wind.innerHTML += "<a id='emoswitch' href='javascript:setEmoticons(false)'>Disable Emoticons</a>";
  35. wind.innerHTML += "<audio id='nots' controls style='width:150px;'><source src='http://spycrab.bplaced.de/nots1.mp3' type='audio/mp3'></audio>";
  36.  
  37. document.getElementById("ChatHeader").innerHTML = oldcontent.replace("<img ","<meta ");
  38. document.getElementById("ChatHeader").appendChild(wind);
  39.  
  40. /*Functions*/
  41.  
  42. function chkMsg(msg) {
  43. if (msg != lastmsg) {
  44.     $("#nots")[0].play();
  45. }
  46. };
  47.  
  48. function setAway(bool) {
  49. document.getElementById("awayswitch").href = "javascript:setAway("+!bool+")";
  50.     if (bool == true) {
  51.             window.mainRoom.setAway();
  52.             document.getElementById("awayswitch").innerHTML = "Back";
  53.     } else {
  54.             window.mainRoom.setBack();
  55.             document.getElementById("awayswitch").innerHTML = "Away";
  56.     }
  57. }
  58.  
  59. function setEmoticons(bool) {
  60.     WikiaChatAPI.useEmoticons = bool;
  61.         if (bool == true) {
  62.             document.getElementById("emoswitch").href = "javascript:setEmoticons(false)";
  63.             document.getElementById("emoswitch").innerHTML = "Disable emoticons";
  64.     } else {
  65.             document.getElementById("emoswitch").href = "javascript:setEmoticons(true)";
  66.             document.getElementById("emoswitch").innerHTML = "Enable emoticons";
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement