Advertisement
Guest User

WikiaChat+ v1

a guest
May 24th, 2014
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     WikiaChat+ v1
  3.     (c) spycrab0 - 2014
  4.     Kann Spuren von Batman enthalten
  5. */
  6. var wind = document.createElement("div");
  7. var yt_soundfrm = document.createElement("iframe");
  8. var soundtype = "YT"; /* YT - Youtubevideo HTML5 - HTML5 Audio(Not supported yet) */
  9. var vid; /*Video id for YT*/
  10. var url; /*URL for HTML5 Audio*/
  11. var wcp_usesounds = true;
  12. var oldcontent = document.getElementById("ChatHeader").innerHTML;
  13. var lastmsg;
  14.  
  15. /* Patching */
  16.  
  17. 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));}
  18. $().log("Done processing emoticons.");setTimeout("chkMsg(\""+text+"\")",1000);if (WikiaChatAPI.useEmoticons == false) {return oldtxt;} return text;}
  19.  
  20. 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);}}
  21.  
  22.  
  23. /* API */
  24.  
  25. var WikiaChatAPI={
  26.     version: 1,
  27.     useEmoticons: true
  28. };
  29.  
  30. wind.id="wcp-window";
  31.  
  32. wind.style.zIndex = "999";
  33. wind.style.position = "absolute";
  34. wind.style.top = "0px";
  35. wind.style.left = "0px";
  36.  
  37. wind.innerHTML = "WikiaChat+ v"+WikiaChatAPI.version+"<br>";
  38. wind.innerHTML += "<a id='awayswitch' href='javascript:setAway(false)'>Away</a>|";
  39. wind.innerHTML += "<a id='soundswitch' href='javascript:setSound(false)'>Disable Sound</a>|";
  40. wind.innerHTML += "<a id='emoswitch' href='javascript:setEmoticons(false)'>Disable Emoticons</a>";
  41.  
  42. document.body.appendChild(yt_soundfrm);
  43. document.getElementById("ChatHeader").innerHTML = oldcontent.replace("<img ","<meta ");
  44. document.getElementById("ChatHeader").appendChild(wind);
  45.  
  46. /*Functions*/
  47.  
  48. function chkMsg(msg) {
  49. if (msg != lastmsg && wcp_usesounds) {
  50. yt_soundfrm.src = "http://www.youtube.com/embed/_Sur-KDNcDA?autoplay=1";
  51. }
  52. };
  53.  
  54. function setSound(bool) {
  55.     wcp_usesounds = bool;
  56.     if (bool == true) {
  57.     document.getElementById("soundswitch").innerHTML = "Disable Sound";
  58.     document.getElementById("soundswitch").href = "javascript:setSound(false)";
  59.     } else {
  60.     document.getElementById("soundswitch").innerHTML = "Enable Sound";
  61.     document.getElementById("soundswitch").href = "javascript:setSound(true)";
  62.     }
  63. }
  64. function setAway(bool) {
  65. document.getElementById("awayswitch").href = "javascript:setAway("+!bool+")";
  66.     if (bool == true) {
  67.             window.mainRoom.setAway();
  68.             document.getElementById("awayswitch").innerHTML = "Back";
  69.     } else {
  70.             window.mainRoom.setBack();
  71.             document.getElementById("awayswitch").innerHTML = "Away";
  72.     }
  73. }
  74.  
  75. function setEmoticons(bool) {
  76.     WikiaChatAPI.useEmoticons = bool;
  77.         if (bool == true) {
  78.             document.getElementById("emoswitch").href = "javascript:setEmoticons(false)";
  79.             document.getElementById("emoswitch").innerHTML = "Disable emoticons";
  80.     } else {
  81.             document.getElementById("emoswitch").href = "javascript:setEmoticons(true)";
  82.             document.getElementById("emoswitch").innerHTML = "Enable emoticons";
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement