Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
(Replaced content with "→Any JavaScript here will be loaded for all users on every page load.: ") |
|||
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() { | ||
+ | //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"); | ||
+ | //} | ||
+ | |||
+ | function helpchat_win() { | ||
+ | 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"); | ||
+ | } | ||
+ | |||
+ | // array to track head elements | ||
+ | var rwc_headScripts = new Array; | ||
+ | |||
+ | // this is the function to kick off the status query by injecting a script into the page | ||
+ | function rwc_getStatus(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=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); | ||
+ | } | ||
+ | }); |
Revision as of 14:57, 14 July 2017
/* Any JavaScript here will be loaded for all users on every page load. */ //function chat_win() { //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"); //} function helpchat_win() { 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"); } // array to track head elements var rwc_headScripts = new Array; // this is the function to kick off the status query by injecting a script into the page function rwc_getStatus(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=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); } });