Difference between revisions of "MediaWiki:Common.js"

From Online Support Wiki
Jump to navigation Jump to search
(Created page with "→‎Any JavaScript here will be loaded for all users on every page load.: function ModifySidebar( action, section, name, link ) { try { switch ( section ) { case 'langu...")
 
m
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
/* Any JavaScript here will be loaded for all users on every page load. */
function ModifySidebar( action, section, name, link ) {
+
//Start of HappyFox Live Chat Script
try {
+
window.HFCHAT_CONFIG = {
switch ( section ) {
+
    EMBED_TOKEN: 'ea83d280-c091-11ea-a122-a18adb1b3bea',
case 'languages':
+
    ASSETS_URL: 'https://widget.happyfoxchat.com/v2/visitor'
var target = 'p-lang';
+
  };
break;
+
  (function () {
case 'toolbox':
+
    var scriptTag = document.createElement('script')
var target = 'p-tb';
+
    scriptTag.type = 'text/javascript'
break;
+
    scriptTag.async = true
case 'navigation':
+
    scriptTag.src = window.HFCHAT_CONFIG.ASSETS_URL + '/js/widget-loader.js'
var target = 'p-navigation';
 
break;
 
default:
 
var target = 'p-' + section;
 
break;
 
}
 
  
if ( action == 'add' ) {
+
    var s = document.getElementsByTagName('script')[0]
var node = document.getElementById( target )
+
    s.parentNode.insertBefore(scriptTag, s)
  .getElementsByTagName( 'div' )[0]
+
  })()
  .getElementsByTagName( 'ul' )[0];
 
  
var aNode = document.createElement( 'a' );
+
HFCHAT_CONFIG.options = {
var liNode = document.createElement( 'li' );
+
  showBadgeOnLoad: false, // Will hide badge only on load
 +
};
  
aNode.appendChild( document.createTextNode( name ) );
+
window.HFCHAT_CONFIG.onload = function() {
aNode.setAttribute( 'href', link );
+
  var HappyFoxChat = this;
liNode.appendChild( aNode );
+
  document.getElementById('hf-chat').addEventListener('click', function(e){
liNode.className = 'plainlinks';
+
      e.preventDefault();
node.appendChild( liNode );
+
      HappyFoxChat.showWidget();
}
+
      HappyFoxChat.expandChatbox();
 
+
  });
if ( action == 'remove' ) {
+
};
var list = document.getElementById( target )
 
  .getElementsByTagName( 'div' )[0]
 
  .getElementsByTagName( 'ul' )[0];
 
 
 
var listelements = list.getElementsByTagName( 'li' );
 
 
 
for ( var i = 0; i < listelements.length; i++ ) {
 
if (
 
listelements[i].getElementsByTagName( 'a' )[0].innerHTML == name ||
 
listelements[i].getElementsByTagName( 'a' )[0].href == link
 
)
 
{
 
list.removeChild( listelements[i] );
 
}
 
}
 
}
 
 
 
 
 
} catch( e ) {
 
// let's just ignore what's happened
 
return;
 
}
 
}
 
 
 
function CustomizeModificationsOfSidebar() {
 
// adds [[Special:CategoryTree|Special:CategoryTree]] to toolbox
 
ModifySidebar( 'remove', 'tools', 'Page information', 'http://supportwiki.memberzone.org/index.php?title=MediaWiki:Common.js&action=info' );
 
// removes [[Special:Upload|Special:Upload]] from toolbox
 
ModifySidebar( 'remove', 'toolbox', 'Upload file', 'http://en.wikipedia.org/wiki/Special:Upload' );
 
}
 
 
 
jQuery( CustomizeModificationsOfSidebar );
 

Latest revision as of 21:01, 8 December 2020

/* Any JavaScript here will be loaded for all users on every page load. */
//Start of HappyFox Live Chat Script
window.HFCHAT_CONFIG = {
    EMBED_TOKEN: 'ea83d280-c091-11ea-a122-a18adb1b3bea',
    ASSETS_URL: 'https://widget.happyfoxchat.com/v2/visitor'
  };
  (function () {
    var scriptTag = document.createElement('script')
    scriptTag.type = 'text/javascript'
    scriptTag.async = true
    scriptTag.src = window.HFCHAT_CONFIG.ASSETS_URL + '/js/widget-loader.js'

    var s = document.getElementsByTagName('script')[0]
    s.parentNode.insertBefore(scriptTag, s)
  })()

HFCHAT_CONFIG.options = {
   showBadgeOnLoad: false, // Will hide badge only on load
};

window.HFCHAT_CONFIG.onload = function() {
   var HappyFoxChat = this;
   document.getElementById('hf-chat').addEventListener('click', function(e){
      e.preventDefault();
      HappyFoxChat.showWidget();
      HappyFoxChat.expandChatbox();
   });
};