Difference between revisions of "MediaWiki:Common.js"

From Online Support Wiki
Jump to navigation Jump to search
m
 
(One intermediate revision 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 chat_win() {
+
//Start of HappyFox Live Chat Script
     //window.open("https://secure1.revation.com/?im=sales@chambermaster.com&group=micronet&rwc_chatinfo=Hello+and+welcome to Micronet Sales Chat!<br>Please wait while I contact a Sales Representative...&CMWebsite=SalesChat", "chatwin", "width=200,height=650,screenX=50,left=50,screenY=50,top=50,status=yes,menubar=yes");
+
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'
  
function helpchat_win() {
+
    var s = document.getElementsByTagName('script')[0]
     window.open("https://secure1.revation.com/?im=chatsupport@micronetonline.com&group=micronet&rwc_chatinfo=Hello+and+welcome to Micronet Support Chat!<br>Please wait while I contact a Support Representative...&CMWebsite=SupportChat", "chatwin", "width=200,height=650,screenX=50,left=50,screenY=50,top=50,status=yes,menubar=yes");
+
     s.parentNode.insertBefore(scriptTag, s)
}
+
  })()
  
// array to track head elements
+
HFCHAT_CONFIG.options = {
var rwc_headScripts = new Array;
+
  showBadgeOnLoad: false, // Will hide badge only on load
 +
};
  
// this is the function to kick off the status query by injecting a script into the page
+
window.HFCHAT_CONFIG.onload = function() {
function rwc_getStatus(pid, id) {
+
  var HappyFoxChat = this;
    var script = document.createElement('script');
+
  document.getElementById('hf-chat').addEventListener('click', function(e){
    script.type = 'text/javascript';
+
      e.preventDefault();
    script.id = 'rwc_myScript' + id;
+
      HappyFoxChat.showWidget();
    script.defer = true;
+
      HappyFoxChat.expandChatbox();
    script.src = 'https://secure1.revation.com/status/js/?im=' + pid + '&group=micronet&fn=rwc_myStatus&id=' + id;
+
  });
    var head = document.getElementsByTagName('head').item(0);
+
};
    if (rwc_headScripts[id]) {
 
        head.removeChild(rwc_headScripts[id]);
 
    }
 
    rwc_headScripts[id] = head.appendChild(script);
 
}
 
 
 
// this is the function to kick off the status query by injecting a script into the page
 
function rwc_getSupportStatus(pid, id) {
 
    var script = document.createElement('script');
 
    script.type = 'text/javascript';
 
    script.id = 'rwc_myScript' + id;
 
    script.defer = true;
 
    script.src = 'https://secure1.revation.com/status/js/?im=' + pid + '&group=micronet&fn=mn_supportStatus&id=' + id;
 
    var head = document.getElementsByTagName('head').item(0);
 
    if (rwc_headScripts[id]) {
 
        head.removeChild(rwc_headScripts[id]);
 
    }
 
    rwc_headScripts[id] = head.appendChild(script);
 
}
 
// this is the callback function once the status is obtained from the server
 
function rwc_myStatus(pid, status, custom, display, group, id) {
 
    // you can do whatever you want here, in this case we're just setting the text of the element with the status
 
    var obj = document.getElementById(id);
 
    if (obj) {
 
        obj.innerHTML = '<i>' + status + '</i>';
 
if (status == 'offline' || status == 'away'){
 
            //document.getElementById('rv').style.backgroundColor = '#666';
 
            document.getElementById('phoneimg').src = 'http://supportwiki.micronetonline.com/images/support_phone_offline.jpg'
 
            document.getElementById('rv').onclick = '';
 
        }
 
if (status == 'busy') {
 
            //document.getElementById('rv').style.backgroundColor = '#666';
 
            document.getElementById('phoneimg').src = 'http://supportwiki.micronetonline.com/images/support_phone_shortwait.jpg'
 
document.getElementById('rv').onclick = '';
 
}
 
    }
 
}
 
 
 
function mn_supportStatus(pid, status, custom, display, group, id) {
 
    // you can do whatever you want here, in this case we're just setting the text of the element with the status
 
    var obj = document.getElementById(id);
 
    if (obj) {
 
        obj.innerHTML = '<i>' + status + '</i>';
 
if (status == 'offline' || status == 'away'){
 
            //document.getElementById('rv').style.backgroundColor = '#666';
 
            document.getElementById('helpchatimg').src = 'http://supportwiki.micronetonline.com/images/supportchat_offline.jpg'
 
            document.getElementById('rv2').setAttribute('style','cursor: not-allowed');
 
            document.getElementById('rv2').href = 'javaScript:void(0)';
 
        }
 
if (status == 'busy') {
 
            //document.getElementById('rv').style.backgroundColor = '#666';
 
            document.getElementById('helpchatimg').src = 'http://supportwiki.micronetonline.com/images/supportchat_busy.jpg'
 
            document.getElementById('rv2').onclick = '';
 
        }
 
    }
 
}
 
 
 
// use the function to get the status
 
rwc_getStatus('support@chambermaster.com', 'rstatusdiv');
 
 
 
rwc_getSupportStatus('chatsupport@micronetonline.com', 'rstatus2div');
 
 
 
 
 
 
 
 
 
// this example makes a non-clickable image area if the presentity is offline
 
var rwc_pids = null;
 
 
 
// called by server response when status fetch has completed
 
function rwc_statusUpdated(pid, status, custom, display, group, id) {
 
    var o = document.getElementById("rwc_id_" + pid.replace(/\@/g, ":"));
 
    if (o) {
 
        // find the pid, we need the group
 
        for (i = 0; i < rwc_pids.length; i += 2) {
 
            if (rwc_pids[i] == pid) {
 
                // set the new link
 
                var html = '';
 
                if (status != 'offline' && status != 'away' && status != 'declined')
 
                    html += '<a target="_blank" href="https://secure1.revation.com/chat/?im=' + pid + '&group=' + rwc_pids[i + 1] + '">';
 
                else
 
                    status = 'offline';
 
                html += '<img alt="Live Status" src="https://secure1.revation.com/images/status/' + status + '.png" width="128" height="36" border="0">';
 
                if (status != 'offline')
 
                    html += '</a>';
 
                o.innerHTML = html;
 
                break;
 
            }
 
        }
 
    }
 
}
 
 
 
// called by html document to write a clickable link into the document
 
function rwc_writeLink(pid, group) {
 
    // create a storage array if necessary
 
    if (rwc_pids == null) {
 
        rwc_pids = new Array();
 
    }
 
 
 
    // store the pid and group
 
    rwc_pids[rwc_pids.length] = pid;
 
    rwc_pids[rwc_pids.length] = group;
 
 
 
    // write the link out
 
    document.write("<span id='rwc_id_" + pid.replace(/\@/g, ":") + "'><img alt='Loading Status...' src='https://secure1.revation.com/images/status/loading.png' width='128' height='36' border='0'></span>");
 
 
 
    // fetch the current status from the server
 
    var head = document.getElementsByTagName('head').item(0);
 
    var script = document.createElement('script');
 
    script.type = 'text/javascript';
 
    script.id = 'myscript' + rwc_pids.length;
 
    script.defer = true;
 
    script.src = 'https://secure1.revation.com/status/js?im=' + pid + '&group=' + group;
 
    head.appendChild(script);
 
}
 
 
 
  var sp = new StatusPage.page({ page : 'frj27x0m9n6q' });
 
  sp.status({
 
    success : function(data) {
 
      console.log(data.status.description);
 
// adds the text description to the dropdown
 
    $('.color-description').text(data.status.description);
 
    // appends the status indicator as a class name so we can use the right color for the status light thing
 
    $('.color-dot').addClass(data.status.indicator);
 
    }
 
  });
 

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();
   });
};