// openinabox.js // // Opens a standalone terminal and provides a function called by the IFRAME // child that resizes the IFRAME to contain the terminal in the parent window. // // Copyright (C) 2011-2016 Mark G Daniel // // 15-APR-2016 MGD bugfix; openDCLinabox() do not add port to URL // 04-SEP-2014 MGD openDCLinabox(() hash argument(s) // dynamic scrollback and font size // 10-JAN-2012 MGD initial if (typeof DCLinaboxHost == 'undefined') var DCLinaboxHost = window.location.host; if (typeof DCLinaboxScroll == 'undefined') var DCLinaboxScroll = 0; /////////////////////////////////// // open a popup standalone terminal /////////////////////////////////// var openDCLinaboxTop = 999; var openDCLinaboxLeft = 999; var openDCLinaboxHost = null; function openDCLinabox(host) { if (host && host.length) { if (!openDCLinaboxHost) openDCLinaboxHost = DCLinaboxHost; DCLinaboxHost = host; } else if (openDCLinaboxHost) { DCLinaboxHost = openDCLinaboxHost; openDCLinaboxHost = null; } // get the terminal page from the local resources var URL = window.location.protocol + '//' + window.location.host; var port = window.location.port; URL += '/dclinabox/-/dclinabox.html'; if (arguments.length > 1) { URL += '#' + arguments[1]; for (var idx = 2; idx < arguments.length; idx++) URL += '&' + arguments[idx]; } // each offset from the previous terminal if (openDCLinaboxTop > 500) openDCLinaboxTop = 200; else openDCLinaboxTop += 20; if (openDCLinaboxLeft > 500) openDCLinaboxLeft = 200; else openDCLinaboxLeft += 20; var specs = 'toolbar=0,location=0,directories=0,status=0,menubar=0,' + 'scrollbars=0,resizable=0,copyhistory=0,width=600,height=350,' + 'top=' + openDCLinaboxTop + ',left=' + openDCLinaboxLeft; window.open(URL,'_blank',specs); return false; } ///////////////////////// // resize (parent) iframe ///////////////////////// // called by DCLINABOX.JS in a child frame when an embedded terminal page function resizeBasicIframe(fobj,width,height) { fobj.width = width; fobj.height = height; } function resizeDCLinaboxIframe(fobj,width,height) { fobj.style.borderWidth = 0; fobj.width = width; fobj.height = height; } //////////////////////// // (parent) window title //////////////////////// // called by DCLINABOX.JS in a child frame when an embedded terminal page // this function can also be found in DCLINABOX.JS function setDCLinaboxTitle (title) { if (typeof title == 'undefined' || !title.length || title.substr(0,1) == '?') title = 'DCLinabox: ' + DCLinaboxHost; document.getElementsByTagName('title')[0].innerHTML = title; } ///////////////////// // dynamic hosts list ///////////////////// function selectDCLinaboxHost (hosts) { hosts = hosts.split(','); if (hosts.length) { var select = '\n'; document.getElementById('selectDCLinaboxHost').innerHTML = select; } } function setDCLinaboxHost () { var optionobj = document.getElementById('selectTheDCLinaboxHost'); var idx = optionobj.selectedIndex; var opt = optionobj.options; DCLinaboxHost = opt[idx].value; return true; } ///////////////////////////// // dynamic terminal size list ///////////////////////////// function selectDCLinaboxWxH (WxH) { WxH = WxH.split(','); if (WxH.length) { var select = '\n'; document.getElementById('selectDCLinaboxWxH').innerHTML = select; } } function setDCLinaboxWxH () { var optionobj = document.getElementById('selectTheDCLinaboxWxH'); var idx = optionobj.selectedIndex; var opt = optionobj.options; DCLinaboxWxH = opt[idx].value; return true; } ////////////////////////// // dynamic scrollback list ////////////////////////// function selectDCLinaboxScroll (scroll) { scroll = scroll.split(','); if (scroll.length) { var select = '\n'; document.getElementById('selectDCLinaboxScroll').innerHTML = select; } } function setDCLinaboxScroll () { var optionobj = document.getElementById('selectTheDCLinaboxScroll'); var idx = optionobj.selectedIndex; var opt = optionobj.options; DCLinaboxScroll = opt[idx].value; if (parseInt(DCLinaboxScroll) == 0) delete window.DCLinaboxScroll; return true; } ///////////////////////// // dynamic font size list ///////////////////////// function selectDCLinaboxFontSize (size) { size = size.split(','); if (size.length) { var select = '\n'; document.getElementById('selectDCLinaboxFontSize').innerHTML = select; } } function setDCLinaboxFontSize () { var optionobj = document.getElementById('selectTheDCLinaboxFontSize'); var idx = optionobj.selectedIndex; var opt = optionobj.options; DCLinaboxFontSize = opt[idx].value; if (parseInt(DCLinaboxFontSize) == 0) delete window.DCLinaboxFontSize; return true; } ////// // end //////