Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- WikiaChat+ v1
- (c) spycrab0 - 2014
- Kann Spuren von Batman enthalten
- */
- var wind = document.createElement("div");
- var yt_soundfrm = document.createElement("iframe");
- var soundtype = "YT"; /* YT - Youtubevideo HTML5 - HTML5 Audio(Not supported yet) */
- var vid; /*Video id for YT*/
- var url; /*URL for HTML5 Audio*/
- var wcp_usesounds = true;
- var oldcontent = document.getElementById("ChatHeader").innerHTML;
- var lastmsg;
- /* Patching */
- 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,">");regexString=regexString.replace(/</g,"<");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,""");text=text.replace(regex,'$1'+emoticon+'$3');}while((origText!=text)&&(numIters++<5));}
- $().log("Done processing emoticons.");setTimeout("chkMsg(\""+text+"\")",1000);if (WikiaChatAPI.useEmoticons == false) {return oldtxt;} return text;}
- 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);}}
- /* API */
- var WikiaChatAPI={
- version: 1,
- useEmoticons: true
- };
- wind.id="wcp-window";
- wind.style.zIndex = "999";
- wind.style.position = "absolute";
- wind.style.top = "0px";
- wind.style.left = "0px";
- wind.innerHTML = "WikiaChat+ v"+WikiaChatAPI.version+"<br>";
- wind.innerHTML += "<a id='awayswitch' href='javascript:setAway(false)'>Away</a>|";
- wind.innerHTML += "<a id='soundswitch' href='javascript:setSound(false)'>Disable Sound</a>|";
- wind.innerHTML += "<a id='emoswitch' href='javascript:setEmoticons(false)'>Disable Emoticons</a>";
- document.body.appendChild(yt_soundfrm);
- document.getElementById("ChatHeader").innerHTML = oldcontent.replace("<img ","<meta ");
- document.getElementById("ChatHeader").appendChild(wind);
- /*Functions*/
- function chkMsg(msg) {
- if (msg != lastmsg && wcp_usesounds) {
- yt_soundfrm.src = "http://www.youtube.com/embed/_Sur-KDNcDA?autoplay=1";
- }
- };
- function setSound(bool) {
- wcp_usesounds = bool;
- if (bool == true) {
- document.getElementById("soundswitch").innerHTML = "Disable Sound";
- document.getElementById("soundswitch").href = "javascript:setSound(false)";
- } else {
- document.getElementById("soundswitch").innerHTML = "Enable Sound";
- document.getElementById("soundswitch").href = "javascript:setSound(true)";
- }
- }
- function setAway(bool) {
- document.getElementById("awayswitch").href = "javascript:setAway("+!bool+")";
- if (bool == true) {
- window.mainRoom.setAway();
- document.getElementById("awayswitch").innerHTML = "Back";
- } else {
- window.mainRoom.setBack();
- document.getElementById("awayswitch").innerHTML = "Away";
- }
- }
- function setEmoticons(bool) {
- WikiaChatAPI.useEmoticons = bool;
- if (bool == true) {
- document.getElementById("emoswitch").href = "javascript:setEmoticons(false)";
- document.getElementById("emoswitch").innerHTML = "Disable emoticons";
- } else {
- document.getElementById("emoswitch").href = "javascript:setEmoticons(true)";
- document.getElementById("emoswitch").innerHTML = "Enable emoticons";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement