*insert witty banner here*
Chat2.js: Difference between revisions
Jump to navigation
Jump to search
CODE DUMP FOR HPW'S CHATANGO, WHICH IS BEING TAKEN DOWN PERMANENTLY #JohnGate #GangerGate |
wrapped in pre tags |
||
Line 1: | Line 1: | ||
THE FOLLOWING IS A CODE DUMP FOR HPW'S CHATANGO, WHICH IS BEING TAKEN DOWN PERMANENTLY #JohnGate #GangerGate | |||
<pre> | |||
// Chatango in the wiki | // Chatango in the wiki | ||
// New code by mfaizsyahmi to replace the one adapted from Dead Island Wiki | // New code by mfaizsyahmi to replace the one adapted from Dead Island Wiki | ||
Line 122: | Line 122: | ||
// one last check at all chats just to make sure | // one last check at all chats just to make sure | ||
loadChatangoEnhance(); | loadChatangoEnhance(); | ||
</pre> |
Latest revision as of 22:21, 6 October 2014
THE FOLLOWING IS A CODE DUMP FOR HPW'S CHATANGO, WHICH IS BEING TAKEN DOWN PERMANENTLY #JohnGate #GangerGate
// Chatango in the wiki // New code by mfaizsyahmi to replace the one adapted from Dead Island Wiki // -- Chucked all the positioning rules present in Dead Island's code // since the HPW chat sits at the right edge of viewport // 19 FEB 2013 MAJOR CHANGES // - Chatango module now only load when visitors specifically // choose to, dropping a cookie. This is to reduce possible // privacy issues. // - Ability to pin the module // - Ability to turn on the module through a new 'On This Wiki' menu item // - Ability to turn off active module by both buttons and the 'On This Wiki' menu item // 21 Feb 13 - Added a mock module. It is placed in the same place as the docked module & functions similar to the menu item // 07 Aug 13 - Placed modules OUTSIDE the siderail to get around the ToU violation (Staff don't like their siderail being touched) // 07 Aug 13 - Made sure mock module would not appear on pages without wikiarail // ====================================================== // trying to reduce duplication of HTML // GLOBAL VARIABLES. MAKE SURE VAR NAME IS UNIQUE! ChatCoreHtml = '<div class="ChatangoContainer"><object width="280" height="400" id="obj_1334317971346"><param name="movie" value="http://dealantics.chatango.com/group"/><param name="AllowScriptAccess" VALUE="always"/><param name="AllowNetworking" VALUE="all"/><param name="AllowFullScreen" VALUE="true"/><param name="flashvars" value="cid=1334317971346&a=323232&b=100&c=D5D4B9&d=70B8FF&e=666666&g=D5D4B9&k=FFFFFF&l=012E59&m=012E59&n=FFFFFF&q=323232&r=100"/><embed id="emb_1334317971346" src="http://dealantics.chatango.com/group" width="280" height="400" allowScriptAccess="always" allowNetworking="all" type="application/x-shockwave-flash" allowFullScreen="true" flashvars="cid=1334317971346&a=323232&b=100&c=D5D4B9&d=70B8FF&e=666666&g=D5D4B9&k=FFFFFF&l=012E59&m=012E59&n=FFFFFF&q=323232&r=100"></embed></object><br><div class="chatStdLinks"><span style="float:left">[ <a href="http://dealantics.chatango.com/clonegroup?ts=1334317971346">Copy this</a> | <a href="http://chatango.com/creategroup?ts=1334317971346">Start New</a> | <a href="http://chat.untergangers.org">Full Size</a> ]</span></div><br/><div class="chatangoQuickLinks"></div></div>' ChatAgreement = 'By enabling and using the chat, you agree to Chatango\'s Terms of service, plus the rules set by the owner of the chat (John). There\'s a copy of the rules in the chat\'s wiki article, and we suggest that you check them out before chatting.\n\nChatango is not affiliated with the wiki. Both use separate accounts, and Chatango bans do not extend to the wiki and vice versa.\nNote that the chat would not be available on certain pages.\n\nEnable the chat?' ChatUrl = 'http://chat.untergangers.org' // $('.WikiaRail').append('<section class="module ChatangoModule">'+ChatCoreHtml+'</section>'); // Oh yeah, please disable Wikia's chat if there's any $('.ChatModule').remove(); //$('.subnav-2a["data-canonical"="chat"]').remove(); // Adds a toggle to the chat in the wiki-navigation. // This might fire before the other wiki-nav additions in the global js though. // events will be bound programmatically $("header nav > ul> li:first-child > ul.subnav-2").append('<li><a id="navChatToggle" class="subnav-2a" data-canonical="chatango" >Chat</a></li>'); // Mandatory. Places the chat in articles that needs them $('#PageChat, .PageChat').append(ChatCoreHtml); // ========= FUNCTIONS =========== // common jobs. // this should never be called by an event as there's no checking whatsoever function addChatango(){ if ( $('.WikiaRail').length ) { // wikiarail exists $('.module.ChatMockModule').remove(); $('body').append('<section class="module ChatangoModule">'+ChatCoreHtml+'</section>'); $(".module.ChatangoModule .chatStdLinks").append('<span style="float:right">[ <a id="chatangoPinButton" onclick="togglePinChatango()" title="Pin the chat so that it stays open">Pin</a> | <a id="chatangoCloseButton" onclick="setChatangoWithCookie(0)" title="Close chat">Close</a> ]</span>'); loadChatangoEnhance(); $('#navChatToggle').text('Chat [×]').attr('title','Close chat').addClass('navChatClose').unbind('click').click( function(e){ e.preventDefault(); setChatangoWithCookie(0); }); } else if ( $.cookie("HPW_Chatango")=="1" ) { // wikiarail doesn't exist, plus the cookie was set $('#navChatToggle').attr({'href':ChatUrl,'target':'_blank','onclick':''}).addClass('navChatExternal'); } } function removeChatango(){ $('.module.ChatangoModule').remove(); if ( $('.WikiaRail').length ) { // wikiarail exists // Should not have mock module if we can't have the chat module afterwards $("body").append('<section class="ChatMockModule module" title="Click to open chat"></section>'); } $('#navChatToggle').text('Chat').attr('title','Open chat').unbind('click') $('#navChatToggle, .module.ChatMockModule').click( function(e){ e.preventDefault(); setChatangoWithCookie(1); }); } // enhancements // this could be called several times during a page's lifetime, hence the "if" statements function loadChatangoEnhance(){ // enumerate each instance of $(".ChatangoContainer").each(function(){ if ( $('.chatangoQuickLinks',this).length == 0 ) { $(".ChatangoContainer").append('<div class="chatangoQuickLinks"></div>'); } if ( $('.chatangoQuickLinks',this).html().length == 0 ) { $(".chatangoQuickLinks").load('/wiki/Special:MyPage/chatango?action=render ul:first-child'); } }); } function togglePinChatango(){ $(".module.ChatangoModule").toggleClass('pinned'); if ( $(".module.ChatangoModule").hasClass('pinned') ) { $("#chatangoPinButton").text("Pinned").attr('title','Unpin this chat'); } else { $("#chatangoPinButton").text("Pin").attr('title','Pin this chat so that it stays open'); } } // Sets cookie and handles the addition/removal of chat module // val is either "0" or "1" function setChatangoWithCookie(c){ if (c>=1) { var result = confirm(ChatAgreement) if (result==true) { $.cookie("HPW_Chatango", "1", { path:"/", expires:365 }); addChatango(); } } else if (c==0) { var result = confirm("Disable chat?") if (result==true) { $.cookie("HPW_Chatango","0", { path:"/", expires:1 } ); removeChatango(); } } } // ========= END OF FUNCTIONS =========== // parse cookie if ( $.cookie("HPW_Chatango")=="1" ) { // Chat cookie set to on addChatango(); } else { // cookie is either off or nonexistent removeChatango(); } // applying some stylings $('#navChatToggle, .module.ChatMockModule').css('cursor','pointer'); // one last check at all chats just to make sure loadChatangoEnhance();