/////////////////////////////////////////////////////////////////////////////// /* build.js COPYRIGHT --------- Copyright (C) 2017-2025 Mark G.Daniel Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. VERSION ------- 20-JAN-2025 MGD integrate GeoLocation 30-JAN-2017 MGD initial */ /////////////////////////////////////////////////////////////////////////////// var intrsp_AlertsDisplay = false, intrsp_CollectDisplay = false, intrsp_InsightDisplay = false, intrsp_PurgeDisplay = false, intrsp_SynopsisDisplay = false, intrsp_UpdateDisplay = false; var intrsp_ThisFrame; /////////////////////////////////////////////////////////////////////////////// /* The stand-alone flag is set from a query string element. */ function intrspBuildPage () { // damned Microsoft // https://msdn.microsoft.com/en-us/library/dn265018%28v=vs.85%29.aspx document.body.setAttribute('x-ms-format-detection','none'); if (intrspFromQuery().frame) { /* an iframe (contained by the parent page) */ configINTRUspect(); if (acme_StandAlone) { intrspCSS ('#configAnchor','color','#000000'); intrspCSS ('#configControl','color','#000000'); intrspCSS ('body','background','transparent'); intrspCSS ('#monitor','background','transparent'); intrspCSS ('#monitor','border','none'); intrspCSS ('#monitor','box-shadow','none'); intrspCSS ('#monitor','padding','5px 15px 0 10px'); } else { intrspCSS ('#configAnchor','color','#ffffff'); intrspCSS ('#configControl','color','#ffffff'); intrspCSS ('body','background','transparent'); intrspCSS ('#configAnchor','color','#ffffff'); intrspCSS ('#configControl','color','#ffffff'); intrspCSS ('#monitor','border','1px outset white'); intrspCSS ('#monitor','box-shadow','1px 3px 5px 1px #505050'); intrspCSS ('#monitor','padding','10px'); } } else { /* the fundamental parent page (contains the iframes) */ if (acme_StandAlone) { intrspCSS ('#configTitle','color','#ffffff'); intrspCSS ('#configTitle','text-shadow', '0 1px 0 #ccc,\ 0 2px 0 #c9c9c9,\ 0 3px 0 #bbb,\ 0 4px 0 #b9b9b9,\ 0 5px 0 #aaa,\ 0 6px 1px rgba(0,0,0,.1),\ 0 0 5px rgba(0,0,0,.1),\ 0 1px 3px rgba(0,0,0,.3),\ 0 3px 5px rgba(0,0,0,.2),\ 0 5px 10px rgba(0,0,0,.25),\ 0 10px 10px rgba(0,0,0,.2),\ 0 20px 20px rgba(0,0,0,.15)'); intrspCSS ('#configTitle','background-clip','text'); /** http://www.colorzilla.com/gradient-editor/ **/ intrspCSS ('body','background','#eeeeee'); intrspCSS ('body','background', 'linear-gradient(135deg, #ffffff 0%,#e5e5e5 100%);'); } else { intrspCSS ('#configTitle','background-clip','text'); intrspCSS ('#configTitle','text-shadow', '0px 1px 2px rgba(255,255,255,.4), -1px -2px 0px rgba(0,0,0,.7)'); /** http://www.colorzilla.com/gradient-editor/ **/ intrspCSS ('body','background','#b5bdc8;'); intrspCSS ('body','background', 'linear-gradient(135deg, #b5bdc8 0%,#929ca5 50%,#48545b 100%);'); } intrspCSS ('body','background-attachment','fixed'); } window.addEventListener('message', acmePostedMessage, false); if (intrspFromQuery().frame) acmeLoadFile('monitor.html',intrspBuildMonitor); else intrspBuildIntruSpect(); } /////////////////////////////////////////////////////////////////////////////// /* Building the top-level main page. Generate an iframe for each server to be monitored. When the iframe loads it calls acmeBuildIframeLoad() to check the load success (or otherwise). */ function intrspBuildIntruSpect () { // Opera (only?) wait for the document to materialise if (!document.body) { setTimeout('intrspBuildIntruSpect()',250); return; } var nodes; if (!(nodes = intrspFromQuery().nodes)) nodes = location.protocol + '//' + location.host + location.pathname; nodes = nodes.replace(/\n|\r\n|\r/g,'+'); nodes = nodes.replace(/\+{2,}/g,'+'); nodes = nodes.replace(/^\+/, ''); nodes = nodes.replace(/^\+$/, ''); var these = nodes.split('+'); var html = '
\ \
\ \
\ \ \
'; for (var idx = 0; idx < these.length; idx++) { if (!these[idx].length) continue; var parts = these[idx].split('?'); these[idx] = parts[0] + '?frame=' + (idx+1); if (acme_StandAlone) these[idx] += '&salone=1'; if (parts.length > 1) these[idx] += '&' + parts[1]; acmeIframeCheck(idx+1,these[idx]); html += ''; } html += '
'; document.body.innerHTML = html; } /////////////////////////////////////////////////////////////////////////////// /* Send a message to each frame to open/close their WebSocket connection. Can be done semi-directly because the configuration panel resides in the top-level page. */ function intrspConfigCollectClick () { checked = $byId('checkboxConfigCollect').checked; for (var cnt = 0; true; cnt++) { if (!(obj = $byId('FRAME'+(cnt+1)))) break; var json = '{"$ConfigCollect":true,"checked":' + checked + '}'; obj.contentWindow.postMessage(json,'*'); } } /////////////////////////////////////////////////////////////////////////////// /* Build the monitor page in an iframe. */ function intrspBuildMonitor (html) { // tell the parent the frame has loaded successfully acmeIframeCheck(true); intrsp_ThisFrame = 'FRAME' + acmeFrameNumber(); var body = document.getElementsByTagName('body')[0]; body.innerHTML = html; intrspBuildControl(); intrspCollectClick(true); intrspPurgeClick(true); intrspUpdateClick(true); acmeAdjustSize(); // (no tips have been demed necessary as of v1.0.0) // acmeLoadFile('tips.js','intrspToolTipInit()'); } /////////////////////////////////////////////////////////////////////////////// /* */ function intrspConfigClick () { var ticked = $byId('SECTION1'); if (ticked.style.display == 'none') ticked.style.display = 'block' else ticked.style.display = 'none' if (acme_StandAlone) acmeFitWindow(); } /////////////////////////////////////////////////////////////////////////////// /* */ function intrspMonitorClick (obj) { var closed = $byId('monitorClosed'); var open = $byId('monitorOpen'); if (obj.checked) { closed.style.display = 'none'; open.style.display = 'block'; intrsp_SynopsisDisplay = false; } else { closed.style.display = 'block'; open.style.display = 'none'; intrsp_SynopsisDisplay = true; $byId('closedAlert').innerHTML = ''; intrspDisplaySynopsis(); } acmeAdjustSize(); } /////////////////////////////////////////////////////////////////////////////// /* Generate the URL, including the query string, used to open the top-level monitor page. */ function intrspConfigUrl () { var action = location.protocol + '//' + location.host + $ScriptName; var nodes = $byId('configNodes').value; nodes = nodes.replace(/\n|\r\n|\r/g,'+'); nodes = nodes.replace(/\+{2,}/g,'+'); nodes = nodes.replace(/^\+/, ''); nodes = nodes.replace(/^\+$/, ''); var url = action + '?nodes=' + encodeURIComponent(nodes); return url; } /////////////////////////////////////////////////////////////////////////////// /* Open a standalone monitor. */ function intrspOpenIntruSpect (url) { if (url) window.onerror = function (msg,url,lnum) { alert (msg+' '+url+' '+lnum) }; else { if (!document.getElementById('configForm')) { alert(mdsLangBookmarklet); return false; } } var name = new Date(); name = 'intruspect_' + name.getTime(); var specs = 'toolbar=0,location=0,directories=0,status=0,' + 'menubar=0,scrollbars=1,resizable=0,copyhistory=0,' + 'width=100,height=100'; window.open((url?url:intrspConfigUrl()),name,specs); return false; } /////////////////////////////////////////////////////////////////////////////// /* Display a link capable of being put into a bookmark and used to directly open a standalone monitor. */ function intrspLinkClick (change) { var cl = document.getElementById('configLink'); if (!change) { if (cl.style.display == 'inline-block') { cl.style.display = 'none'; return false; } cl.style.display = 'inline-block'; } if (cl.style.display != 'inline-block') return false; var params = 'status=0,toolbar=0,location=0,menubar=0,resizable=0,' + 'scrollbars=1,height=100,width=100'; var href = 'javascript:void(window.open("' + intrspConfigUrl() + '&salone=1' + '","_blank","' + params + '"))'; var title = 'IntruSpect ' + $ExeVersion; var nodes = $byId('configNodes').value; if (nodes.length < 10) cl.style.display = 'none'; else { var ca = $byId('configAnchor'); ca.href = ca.innerHTML = href; cl.style.display = 'inline-block'; } return false; } /////////////////////////////////////////////////////////////////////////////// //////////////////////// // control checkboxes // //////////////////////// /////////////////////////////////////////////////////////////////////////////// /* Generate the monitor control check boxes. */ function intrspBuildControl () { var html = ''; html += ''; html += ''; html += ''; if (true) html += '' else html += ''; html += ''; html += '
\ \ \ \  \ \
'; $byId('control').innerHTML = html; } /////////////////////////////////////////////////////////////////////////////// /* Collect checkbox has been clicked. The dollar prefixed version is called from acmePostedMessage(). */ function $CollectClick (state) { intrspCollectClick(state) }; function intrspCollectClick (state) { var cbx = $byId('checkboxCollect'); if (typeof state != 'undefined') intrsp_CollectDisplay = !state; if (intrsp_CollectDisplay) { intrsp_CollectDisplay = false; cbx.checked = false; intrspStreamData(false); } else { intrsp_CollectDisplay = true; cbx.checked = true; intrspStreamData(true); intrsp_CollectStartTime = new Date(); } } /////////////////////////////////////////////////////////////////////////////// /* Update checkbox has been clicked. */ function intrspUpdateClick (state) { var cbx = $byId('checkboxUpdate'); if (!cbx) return; if (typeof state != 'undefined') intrsp_UpdateDisplay = !state; if (intrsp_UpdateDisplay) { intrsp_UpdateDisplay = false; cbx.checked = false; } else { intrsp_UpdateDisplay = true; cbx.checked = true; } } /////////////////////////////////////////////////////////////////////////////// /* Purge checkbox has been clicked. */ function intrspPurgeClick (state) { var cbx = $byId('checkboxPurge'); if (!cbx) return; if (typeof state != 'undefined') intrsp_PurgeDisplay = !state; if (intrsp_PurgeDisplay) { intrsp_PurgeDisplay = false; cbx.checked = false; } else { intrsp_PurgeDisplay = true; cbx.checked = true; } intrspDisplayRecords () } /////////////////////////////////////////////////////////////////////////////// /* Reset button has been clicked. */ function intrspResetClick (state) { intrspRecordsReset(); intrspDisplayReset(); intrspDisplayRecords () } /////////////////////////////////////////////////////////////////////////////// /* Generate a parameter string of current interests. This parameter string is used to convey interests to the executable via WebSocket IPC and as query string parameters in the case of XHR requests. */ function intrspTheseData () { var these = ''; if ($WebSocket) { } return(these); } ///////////////////////////////////////////////////////////////////////////////