// Class prototype // --------------- function vOS() { // Initialize properties // --------------------- this.arr_vApps = new Array(); this.arr_vAppsTemp = new Array(); this.arr_vWindows = new Array(); this.arr_vPrograms = new Array(); this.zOrder = 0; this.activeWindow = "a"; this.activeElement = ""; this.vWindow = vWindow; this.vApp = vApp; // Initialize classes // ------------------ this.taskbar = new vTaskbar(); this.vMenu = new vMenu(); this.vElement = new vElement(); this.iWindow = new iWindow(); this.vDialog = new vDialog(); this.vBase = new vBase(); this.vDesktop = new vDesktop(); // Initialize Time Functions // ------------------------- this.vTime = _vOS_vTime; this.vTime_change = _vOS_vTime_change; this.vTime_zone = _vOS_vTime_zone; this.vTime_format = _vOS_vTime_format; // Initialize functions // -------------------- this.run = _vOS_run; this.height = _vOS_height; this.width = _vOS_width; this.check_window = _vOS_check_window; this.event = _vOS_event; this.background = _vOS_background; this.themeSwitch = _vOS_themeSwitch; this.themeSwitched = _vOS_themeSwitched; this.preloadImages = _vOS_preloadImages; this.data = _vOS_data; this.vLogout = _vOS_logout; this.disable = _vOS_disable; this.enable = _vOS_enable; // Initialize event functions // -------------------------- this.resize = _vOS_resize; window.onresize = function() { if (vOS.onresizetimer) { window.clearTimeout(vOS.onresizetimer); } vOS.onresizetimer = window.setTimeout("vOS.resize()", 10); } window.onerror = _vOS_error; // Detect when the user tries to select text document.onmousedown = _vOS_mousedown; document.onselectstart = _vOS_mousedown; document.oncontextmenu = new Function("return false"); // Initialize inner variables (cannot be viewed by everything outside this script) var vTime_now = new Date(0); var vTime_zone = 0; //Create a screen container // ---------------- this.screen_container = document.createElement("DIV"); this.screen_container.style.overflow = "hidden"; this.screen_container.style.top = "0px"; this.screen_container.style.left = "0px"; this.screen_container.style.width = "100%"; this.screen_container.style.height = "100%"; this.screen_container.style.position = "absolute"; this.screen_container.onmouseup = _vOS_mouseup; this.screen_container.id = "_vOS_background"; document.body.appendChild(this.screen_container); // Functions prototype // ------------------- function _vOS_background(_vOS_color,_vOS_background,_vOS_repeat,_vOS_x,_vOS_y) { _vOS_repeat = _vOS_repeat == 1 ? "" : " no-repeat "; _vOS_x = _vOS_x ? _vOS_x : ""; _vOS_y = _vOS_y ? _vOS_y : ""; this.screen_container.style.background = _vOS_color + " url(" + _vOS_background + ") "+_vOS_repeat+" "+_vOS_x+" "+_vOS_y; } function _vOS_run(_vApp_file, _vApp_parameters) { new vOS.vApp(_vApp_file, _vApp_parameters); } function _vOS_height() { if (window.innerHeight) { _vOS_height = function() { return window.innerHeight; } } else if (document.documentElement && document.documentElement.clientHeight) { _vOS_height = function() { return document.documentElement.clientHeight; } } else { _vOS_height = function() { return document.body.clientHeight; } } return _vOS_height(); } function _vOS_width() { if (window.innerWidth) { _vOS_width = function() { return window.innerWidth; } } else if (document.documentElement && document.documentElement.clientWidth) { _vOS_width = function() { return document.documentElement.clientWidth; } } else { _vOS_width = function() { return document.body.clientWidth; } } return _vOS_width(); } function _vOS_check_window(x) { // Do not execute this function if the browserwindow is too small if (vOS.height() < 100 || vOS.width() < 100) { return; } // Check if it isn't a negative height if (parseInt(vOS.arr_vWindows[x].window_container.style.top + 0, 10) < _vTheme_padding_top) { vOS.arr_vWindows[x].setTop(_vTheme_padding_top); } // Check if it isn't to low if (parseInt(vOS.arr_vWindows[x].window_container.style.top + 0, 10) > (vOS.height() - (_vTheme_window_header + _vTheme_padding_bottom))) { vOS.arr_vWindows[x].setTop(vOS.height() - (_vTheme_window_header + _vTheme_padding_bottom)); } // Check right side of the browser if (parseInt(vOS.arr_vWindows[x].window_container.style.left + 0, 10) > (vOS.width() - 50 + _vTheme_padding_right)) { vOS.arr_vWindows[x].setLeft(vOS.width() - 50 + _vTheme_padding_right); } // Check left side of the browser if (vOS.arr_vWindows[x].window_container.clientWidth + parseInt(vOS.arr_vWindows[x].window_container.style.left + 0, 10) < (50 + _vTheme_padding_left)) { vOS.arr_vWindows[x].setLeft(-1 * (vOS.arr_vWindows[x].window_container.clientWidth - 50 + _vTheme_padding_left)); } } function _vOS_resize(e) { for(x=0; x < vOS.arr_vWindows.length; x++) { // Check if its still in place _vOS_check_window(x); if(vOS.arr_vWindows[x].state == "maximize") { vOS.arr_vWindows[x].maximize(); } } if(vOS.activeWindow != "a") { // Keep the taskbar putton in place if (vOS.arr_vWindows[vOS.activeWindow].taskbar == true) { vOS.arr_vWindows[vOS.activeWindow].taskbar_button.scrollView(); } } //Close the menu vOS.vMenu.closeMenu(); vOS.vDesktop.refresh(); } function _vOS_error(_error_message, _error_url, _error_line) { if (window.confirm("Critical error:\t" + _error_message + "\nURL:\t\t" + _error_url + "\nLine:\t\t" + _error_line + "\n\nClick OK to continue or press Cancel to start debugging.") == false) { // Code to debug the script, will only load when the Cancel button // is pressed at the window.confirm(). ret = window.prompt("Enter the object name to inspect", "vOS"); if (ret) { obj = eval(ret); var temp = ""; for (x in obj) { temp += x + ": " + obj[x] + "\n"; } window.alert("Results, press Ctrl+C to copy to clipboard:\n\n" + temp); } } } function _vOS_mousedown(e) { if (!e) { var e = window.event; } if (e.target) { targ = e.target; } else if (e.srcElement) { targ = e.srcElement; } // Check if a menu needs to be closed if (vOS.vMenu.openMenus.length > 0 && e.type == "mousedown") { // Check if the user clicks on the menu, if so, do not close it if (vOS.vMenu.menu_click != true) { vOS.vMenu.closeMenu(true); } else { vOS.vMenu.menu_click = false; } } // Check to see if the user is allowed to select text if (targ.tagName == "INPUT" || targ.tagName == "TEXTAREA" || targ.tagName == "SELECT" || targ.tagName == "OPTION") { if (targ.tagName != "OPTION") { vOS.activeElement = targ; } return true; } else { // Remove focus if (vOS.activeElement) { vOS.activeElement.blur(); } } mousebutton = e.which ? e.which : e.button; if (mousebutton == 2 || mousebutton == 3) { // User clicked the right or middle button if (window["mousemove"] == true) { // If the user is resizing a window, cancel it window["mousemove"] = false; // Remove the two global events used for resizing // the windows document.onmouseup = null; document.onmousemove = null; } } // Set the desktop item to inactive vOS.vDesktop.setInactive(e); return false; } function _vOS_mouseup(e) { e = e ? e : window.event; // Check if it's the background targ = vOS.event(e); if(targ.id != "_vOS_background") return false; var mousebutton = e.which ? e.which : e.button; // If it is a right click if(mousebutton == 2 || mousebutton == 3) { var popupMenu = [ ["Schikken op","", [ ["Naam","","vOS.vDesktop.order.name()"], ["Raster","","vOS.vDesktop.order.grid()"] ] ], ["-"], ["Opslaan","","alert(1)"], ["Vernieuwen","","alert(1)"], ["-"], ["Nieuwe...","", [ ["Map","","alert(1)"], ["Snelkoppeling","","alert(1)"] ] ], ["-"], ["Eigenschappen","","alert(1)"] ]; vOS.vMenu.system(e.clientY, e.clientX, popupMenu); } } function _vOS_event(e) { var targ; if (e.target) { targ = e.target; } else if (e.srcElement) { targ = e.srcElement; } if (targ.nodeType == 3) { targ = targ.parentNode; } return targ; } function _vOS_vTime() { window.setTimeout("vOS.vTime()", 10000); vTime_now.setSeconds(vTime_now.getSeconds() + 10); this.taskbar.setTime(vTime_now); } function _vOS_vTime_change(time) { temp = new Date(time); vTime_now = new Date(temp); temp = (vTime_now.getTime() + (vTime_now.getTimezoneOffset() * 60000) + vTime_zone); vTime_now.setTime(temp); } function _vOS_vTime_zone(zone, saving) { var zomertijd = 1; // ! daylightsaving if (zomertijd) { zone = parseInt(zone,10) + 1; } vTime_zone = zone * 3600000; } function _vOS_vTime_format(type, timestamp) { if (!timestamp) { timestamp = vTime_now; } // Load how the string should be formatted from the settings array. // "Type" can be a value as defined in the login script. var output = Settings[type]; // Hours output = output.replace(/%H/, timestamp.getHours()); output = output.replace(/%h/, (timestamp.getHours() > 12 ? timestamp.getHours() - 12 : timestamp.getHours())); output = output.replace(/%ampm/, (timestamp.getHours() > 12 ? "PM" : "AM")); // Minutes output = output.replace(/%N/, (timestamp.getMinutes() <= 9 ? "0" : "") + timestamp.getMinutes()); // Seconds output = output.replace(/%S/, (timestamp.getSeconds() <= 9 ? "0" : "") + timestamp.getSeconds()); // Days output = output.replace(/%T/, (timestamp.getDate() <= 9 ? "0" : "") + timestamp.getDate()); output = output.replace(/%d/, timestamp.getDate()); output = output.replace(/%D/, _LANG_["day" + timestamp.getDay()]); // Months output = output.replace(/%m/, (timestamp.getMonth() <= 9 ? "0" : "") + timestamp.getMonth()); output = output.replace(/%M/, _LANG_["month" + timestamp.getMonth()]); // Years output = output.replace(/%Y/, timestamp.getFullYear()); return output; } function _vOS_themeSwitch(theme) { // Save the current theme into a global variable this.theme = theme; // Load the new theme. document.getElementById("link_vTheme").href = "themes\/" + theme + "\/theme.css"; // Load the config.def file into memory. var _vOS_theme_definition = new XMLHttpRequest(); _vOS_theme_definition.open("GET", "themes\/" + theme + "\/config.def", false); _vOS_theme_definition.send(""); eval(_vOS_theme_definition.responseText); // Check if the theme has changed this.themeSwitched(); } function _vOS_themeSwitched() { var x = 0; if(document.getElementById("_vOS_stylechange").offsetWidth == 0) { x = 0; // Let all windows adjust their sizes depending on the new // window size configuration file. _vOS_resize(); // Now preload the images. // vOS.preloadImages(); } else { x++; if(x == 10) { alert("Style didn't changed!"); } else { window.setTimeout("vOS.themeSwitched()",50 * x); } } } function _vOS_preloadImages() { // Preload the images from the CSS file, not compatible with Opera 8.0 > if (document.styleSheets) { for (j=0; j < document.styleSheets.length; j++) { if (document.styleSheets[j].rules) { styleSheetArray = document.styleSheets[j].rules; } else { styleSheetArray = document.styleSheets[j].cssRules; } styleSheetPath = document.styleSheets[j].href.substr(0, document.styleSheets[j].href.lastIndexOf("/") + 1); // Loop through all CSS properties to see if url() is used for (i=0; i < styleSheetArray.length; i++) { styleSheetText = styleSheetArray[i].style.background + styleSheetArray[i].style.backgroundImage; if (styleSheetText.indexOf("url(") > -1) { styleSheetImage = styleSheetPath + styleSheetText.substr(styleSheetText.indexOf("url(") + 4, styleSheetText.indexOf(")") - styleSheetText.indexOf("url(") - 4); if (document.images) { // Preload images vOS.screen_container.innerHTML += "
"; } } } } } } function _vOS_data(_vOS_caller_type, _vOS_callback, _vOS_file, _vOS_parameters_array, _vOS_callbackparameters, _vOS_vApp_pid) { // How to use: // - vOS.data("vApp", , , , , ) // - vOS.data("vOS", , , , ) // Callbackfunction examples: // - this.ondata = function(data, parameters) // - ondatareceive(data, parameters) var _vOS_data_request = new Array(); _vOS_data_request["xml"] = new XMLHttpRequest(); _vOS_data_request["id"] = _vOS_vApp_pid; if (_vOS_data_request["xml"]) { _vOS_data_request["xml"].onreadystatechange = function() { if (_vOS_data_request["xml"].readyState == 4 && _vOS_data_request["xml"].status == 200) { _vOS_data = _vOS_data_request["xml"].responseText; // Decode the received data vOS.vBase.header(_vOS_data_request["xml"].getResponseHeader("Content-Identifier")); _vOS_data = vOS.vBase.decode(_vOS_data); // Create an object of the callback function if (_vOS_callback.substr(_vOS_callback.length - 2) == "()") { // Remove the brackets (if included) from the functionname _vOS_callback = _vOS_callback.substr(0, _vOS_callback.length - 2); } if (_vOS_callback.substr(0, 5) == "this.") { // If the function name is preceded by "this.", remove the "this." part _vOS_callback = _vOS_callback.substr(5); } // Prepare the function which will receive the data if (_vOS_caller_type == "vApp") { _vOS_temp = eval("vOS.arr_vApps[" + _vOS_data_request["id"] + "]." + _vOS_callback + ";"); } else if (_vOS_caller_type == "vOS") { _vOS_temp = eval(_vOS_callback); } // Execute the function _vOS_temp(_vOS_data, _vOS_callbackparameters); // Synchronize the vOS time vOS.vTime_change(_vOS_data_request["xml"].getResponseHeader("Date")); return; } } _vOS_data_request["xml"].open("POST", "php/data.php", true); _vOS_data_request["xml"].setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); // Get parameters from the _vApp_parameters_array array var _vOS_parameters = ""; // Check if parameters are given if (_vOS_parameters_array) { for (var i = 0; i < _vOS_parameters_array.length; i = i + 2) { // Replace | by || to make sure the server can decode the data properly _vOS_parameters_array[i] = _vOS_parameters_array[i]; _vOS_parameters_array[i + 1] = _vOS_parameters_array[i + 1].replace(new RegExp(/\|/g), "||"); _vOS_parameters += "|" + _vOS_parameters_array[i] + "|" + _vOS_parameters_array[i + 1]; } _vOS_parameters = _vOS_parameters.substr(1); } // Create a key and send it to the server var tempsendkey = vOS.vBase.generate_key(); _vOS_data_request["xml"].setRequestHeader("Content-Identifier", tempsendkey); // Encode the parameters which are to be send to the server vOS.vBase.header(tempsendkey); _vOS_parameters = vOS.vBase.encode(_vOS_parameters); // Request the data from the server with the specified parameters _vOS_data_request["xml"].send("f=" + _vOS_file + "&d=" + _vOS_parameters); } } function _vOS_logout() { //var _vLogout = new XMLHttpRequest(); //_vLogout.open("POST", "php\/logout.php", false); //_vLogout.send(""); } function _vOS_disable() { // Disables user input completely if (!this.screen_container_disabled) { this.screen_container_disabled = document.createElement("DIV"); this.screen_container_disabled.style.position = "absolute"; this.screen_container_disabled.style.background = "url(images/disable.png)"; this.screen_container_disabled.style.left = "0px"; this.screen_container_disabled.style.top = "0px"; this.screen_container_disabled.style.width = "10000px"; this.screen_container_disabled.style.height = "10000px"; this.screen_container_disabled.style.zIndex = "9999998"; this.screen_container.appendChild(this.screen_container_disabled); } } function _vOS_enable() { // If the screen is disabled, enable it if (this.screen_container_disabled) { this.screen_container_disabled.parentNode.removeChild(this.screen_container_disabled); this.screen_container_disabled = null; } } } add_counter(10);