Stian_B
asked on
javascript safari problem(printing js code on page)
Hi,
i have currently made a webpage to organize shifts for workers at a store. i thought everything worked fine, until i discovered that sometimes when the page reload(only in safari), safari starts printing out the javascript code at random position in the code, and then shows the intended result below the code. I've also been notified that this is a problem on another website i've made as well, which has a totally different code. I'm out of ideas on this one, since i cant find any errors in my code, and the place where the printing of code changes every time, also the print starts in very odd places, like in this example in the middle of an array variable.
Here is an example of when safari prints code on the page:
tions[i] = new Option("20:30", "20:30"); i++; } if("21:00" == "12:00"){ sel4.options[i] = new Option("21:00", "21:00", true, true); i++; }else{ sel4.options[i] = new Option("21:00", "21:00"); i++; } if("21:30" == "12:00"){ sel4.options[i] = new Option("21:30", "21:30", true, true); i++; }else{ sel4.options[i] = new Option("21:30", "21:30"); i++; } if("22:00" == "12:00"){ sel4.options[i] = new Option("22:00", "22:00", true, true); i++; }else{ sel4.options[i] = new Option("22:00", "22:00"); i++; } if("22:30" == "12:00"){ sel4.options[i] = new Option("22:30", "22:30", true, true); i++; }else{ sel4.options[i] = new Option("22:30", "22:30"); i++; } if("23:00" == "12:00"){ sel4.options[i] = new Option("23:00", "23:00", true, true); i++; }else{ sel4.options[i] = new Option("23:00", "23:00"); i++; } if("23:30" == "12:00"){ sel4.options[i] = new Option("23:30", "23:30", true, true); i++; }else{ sel4.options[i] = new Option("23:30", "23:30"); i++; } sel4.onchange=function(){ var id = this.id; var lengde = id.length; if(lengde == 5) id = id.substr(2,3); if(lengde == 4) id = id.substr(2,2); if(lengde == 3) id = id.substr(2,1); lagDiv(id); } ut.appendChild(sel4); var tidslinje = rad.insertCell(4); var div = document.createElement("di v"); div.style.height = "20px"; div.style.width = "auto"; div.style.position = "relative"; div.id = "rad" + html("raderLaget") if(fargetRad == 0){ div.style.backgroundColor = "#F5FAFA"; //sel2.style.color = "#B4AA9D"; } tidslinje.appendChild(div) ; var lunch = rad.insertCell(5); var divLunch = document.createElement("di v"); divLunch.style.height = "20px"; divLunch.style.width = "62px"; divLunch.id = "lunchDiv" + html("raderLaget"); if(fargetRad == 0){ divLunch.style.backgroundC olor = "#F5FAFA"; //sel2.style.color = "#B4AA9D"; } divLunch.onmouseover = function(){ var id = this.id; musOverBakgrunn(id) } divLunch.onmouseout = function(){ var id = this.id; musUt(id) } divLunch.onclick = function(){ var id = this.id; id = id.split("lunchDiv"); toggleCheckbox("lunchbox"+ id[1]); } lunch.style.textAlign = "right"; var sel5 = document.createElement('in put'); sel5.type = "checkbox"; sel5.id = "lunchbox" + html("raderLaget"); sel5.name = "lunchbox" + html("raderLaget"); sel5.onclick = function(){ var id = this.id; id = id.split("lunchbox"); toggleCheckbox("lunchbox"+ id[1]); } divLunch.appendChild(sel5) ; lunch.appendChild(divLunch ); var syk = rad.insertCell(6); var divSyk = document.createElement("di v"); divSyk.style.height = "20px"; divSyk.style.width = "90px"; divSyk.id = "sykDiv" + html("raderLaget"); if(fargetRad == 0){ divSyk.style.backgroundCol or = "#F5FAFA"; //sel2.style.color = "#B4AA9D"; } divSyk.onmouseover = function(){ var id = this.id; musOverBakgrunn(id) } divSyk.onmouseout = function(){ var id = this.id; musUt(id) } divSyk.onclick = function(){ var id = this.id; id = id.split("sykDiv"); toggleCheckbox("sykbox"+id [1]); } syk.style.textAlign = "right"; var sel6 = document.createElement('in put'); sel6.type = "checkbox"; sel6.id = "sykbox" + html("raderLaget"); sel6.name = "sykbox" + html("raderLaget"); sel6.onclick = function(){ var id = this.id; id = id.split("sykbox"); toggleCheckbox("sykbox"+id [1]); } divSyk.appendChild(sel6); syk.appendChild(divSyk); var celle = rad.insertCell(7); celle.style.background = "#FFFFFF"; celle.style.border = "none"; var slett = document.createElement("im g"); slett.src = "gfx/slett.png"; slett.style.background = "#FFFFFF"; slett.style.width = "11px"; slett.style.height = "11px"; slett.style.border = "none"; slett.style.padding = "5px"; slett.id = "slett" + html("antRader"); slett.onclick = function(){ var id = this.id; id = id.split("slett"); slettRad(id[1]); } celle.appendChild(slett); } function slettRad(i){ document.getElementById('v aktlisteta bell').del eteRow(i); var antall = html("antRader"); antall++; for(j=i;j<=antall;j++){ if(document.getElementById ("slett"+j ) != null){ var div = document.getElementById("s lett"+j); id = "slett"+(j-1); div.id = id; } } minusId(); } function lastSide(){ var dato = document.getElementById("a ktuellDato ").value; var url = location.href; url = url.split("?"); location.href= url[0]+"?dato="+dato; } function forrigeDag(){ var dag = "04-09-2008" var url = location.href; url = url.split("?"); location.href= url[0]+"?dato="+dag; } function nesteDag(){ var dag = "06-09-2008" var url = location.href; url = url.split("?"); location.href= url[0]+"?dato="+dag; } function oppdaterId(){ oppdaterHiddenfelt(); var antall = html("antRader"); if(antall == "0"){ antall = 1; }else antall++; settHTML("antRader", antall); } function oppdaterTotalId(){ var totaltAnt = html("raderLaget"); if(totaltAnt == "0"){ totaltAnt = 1; }else totaltAnt++; settHTML("raderLaget", totaltAnt); } function minusId(){ var antall = html("antRader"); antall--; settHTML("antRader", antall); return antall; } function value(id){ return document.getElementById(id ).value; } function html(id){ return document.getElementById(id ).innerHTM L; } function settVerdi(id, verdi){ document.getElementById(id ).value = verdi; } function settHTML(id, verdi){ document.getElementById(id ).innerHTM L = verdi; } function oppdaterHiddenfelt(){ var antall = value("hiddenAntRader"); if(antall == "0" || antall == ""){ antall = 1; } else antall++; settVerdi("hiddenAntRader" , antall); return antall; } function sok(){ var sokeord = value("sokefelt"); var currentTime = new Date(); getFromServer("sokVaktlist e.php?ord= "+sokeord+ "&time="+c urrentTime .getTime() , visResultat); } function visResultat(XHR){ document.getElementById('l ight').sty le.display ='block'; document.getElementById('f ade').styl e.display= 'block'; var url = location.href; url = url.split("?"); var div = document.getElementById('l ight'); var html = ""; if(XHR.responseText != "-1"){ //location.href= url[0]+"?dato="+dag; var datoArray = XHR.responseText.split(":" ); if(datoArray.length >1){ for(i = 0;i
I don't know if it's the code that is the problem or the browser, but here is the entire code (i know it's a little long..):
i have currently made a webpage to organize shifts for workers at a store. i thought everything worked fine, until i discovered that sometimes when the page reload(only in safari), safari starts printing out the javascript code at random position in the code, and then shows the intended result below the code. I've also been notified that this is a problem on another website i've made as well, which has a totally different code. I'm out of ideas on this one, since i cant find any errors in my code, and the place where the printing of code changes every time, also the print starts in very odd places, like in this example in the middle of an array variable.
Here is an example of when safari prints code on the page:
tions[i] = new Option("20:30", "20:30"); i++; } if("21:00" == "12:00"){ sel4.options[i] = new Option("21:00", "21:00", true, true); i++; }else{ sel4.options[i] = new Option("21:00", "21:00"); i++; } if("21:30" == "12:00"){ sel4.options[i] = new Option("21:30", "21:30", true, true); i++; }else{ sel4.options[i] = new Option("21:30", "21:30"); i++; } if("22:00" == "12:00"){ sel4.options[i] = new Option("22:00", "22:00", true, true); i++; }else{ sel4.options[i] = new Option("22:00", "22:00"); i++; } if("22:30" == "12:00"){ sel4.options[i] = new Option("22:30", "22:30", true, true); i++; }else{ sel4.options[i] = new Option("22:30", "22:30"); i++; } if("23:00" == "12:00"){ sel4.options[i] = new Option("23:00", "23:00", true, true); i++; }else{ sel4.options[i] = new Option("23:00", "23:00"); i++; } if("23:30" == "12:00"){ sel4.options[i] = new Option("23:30", "23:30", true, true); i++; }else{ sel4.options[i] = new Option("23:30", "23:30"); i++; } sel4.onchange=function(){ var id = this.id; var lengde = id.length; if(lengde == 5) id = id.substr(2,3); if(lengde == 4) id = id.substr(2,2); if(lengde == 3) id = id.substr(2,1); lagDiv(id); } ut.appendChild(sel4); var tidslinje = rad.insertCell(4); var div = document.createElement("di
I don't know if it's the code that is the problem or the browser, but here is the entire code (i know it's a little long..):
<?php
require_once ("tidTabell.php");
require_once ("classes/db.php");
require_once ("classes/bruker_php.php");
require_once ("classes/bruker.php");
require_once ("classes/vaktliste_bud_oms.php");
require_once("classes/vaktliste.php");
require_once("inc/browserdetection.php");
$_SESSION['community_statusVaktliste'] = 'vaktliste';
$_SESSION['lagret'] = "nei";
$fraUrl = "http://www.trmed.no/kunder/burgerking2/vaktliste.php";
$fortid;
if(isset($_GET['lagreVakt'])){
$nyRad = true;
$index = 0;
$dato = $_POST['aktuellDato'];
$vakt = new Vaktliste();
$vakt->slettVakterForDag($dato);
$_SESSION['id'] = 0;
while($index < $_POST['hiddenAntRader']){
if(isset($_POST['navn'.$index])){
$ansattnr = $_POST['ansattnr'.$index];
$navnet = $_POST['navn'.$index];
$inn = $_POST['inn'.$index];
$ut = $_POST['ut'.$index];
if(isset($_POST['lunchbox'.$index]))$lunch = "ja";
if(isset($_POST['sykbox'.$index]))$sykefravaer = "ja";
if(!(isset($_POST['lunchbox'.$index])))$lunch = "";
if(!(isset($_POST['sykbox'.$index])))$sykefravaer = "";
$allowedTags='<a><p><strong><em><u><h1><h2><h3><h4><h5><h6><img>';
$allowedTags.='<li><ol><ul><span><div><br><ins><del><object><embed><param>';
$spesielt = htmlspecialchars(strip_tags(stripslashes($_POST['spesielt']),$allowedTags), ENT_QUOTES);
$notater = htmlspecialchars(strip_tags(stripslashes($_POST['notater']),$allowedTags), ENT_QUOTES);
if($_SESSION['id'] == 0){
$budOms = new VaktlisteBudOms($_POST['budsjett'], $_POST['omsetning']);
$_SESSION['id'] = $budOms->leggTilBudOms();
}
$vakt = new Vaktliste($dato, $ansattnr, $navnet, $inn, $ut, $lunch, $sykefravaer, $spesielt, $notater, $_SESSION['id']);
$vakt->leggTilVakt();
}else $nyRad = false;
$index++;
}
$url = explode("?",$HTTP_REFERER);
$url = explode("http//", $url[0]);
if($SF){
$url = $fraUrl;
header( 'location:'.$url.'?dato='.$_POST['aktuellDato']);
}else{
header( 'location:'.$url[0].'?dato='.$_POST['aktuellDato']);
}
}
$navn = array();
$navn = finnAlleNavnMedIdKey();
$nummer = finnAnsattnr($navn);
$fraBase = true;
function finnAlleNavnMedIdKey(){
$bruker = new Bruker_php();
return $bruker->finnAlleNavnMedIdKey();
}
function finnAnsattnr($navn){
$bruker = new BrukerClass();
return $bruker->finnAnsattnr($navn);
}
$navnVakt = array();
$nummerVakt = array();
$innVakt = array();
$utVakt = array();
$lunchVakt = array();
$sykVakt = array();
$spesielt = "";
$notater= "";
$Budsjett= "";
$Omsetning= "";
$budOmsId = -1;
if(isset($_GET['dato'])){
$datoArray = explode("-", $_GET['dato']);
if(mktime(23,59,59,$datoArray[1],$datoArray[0],$datoArray[2])<time()) $fortid = true;
require_once("classes/vaktliste.php");
$vakt = new Vaktliste();
$vaktArray = $vakt->hentVakterForDag($_GET['dato']);
if(sizeof($vaktArray)==0){
$_SESSION['rader'] = 0;
$fraBase = false;
}else{
$_SESSION['rader'] = sizeof($vaktArray)-1;
$fraBase = true;
}
for($i=0;$i<sizeof($vaktArray);$i++){
foreach($vaktArray[$i] as $key => $value){
if($key == "navn") $navnVakt[] = $value;
if($key == "ansattnr") $nummerVakt[] = $value;
if($key == "inn") $innVakt[] = $value;
if($key == "ut") $utVakt[] = $value;
if($key == "lunsj") $lunchVakt[] = $value;
if($key == "sykefravaer") $sykVakt[] = $value;
if($key == "vaktliste_bud_oms_id") $budOmsId = $value;
if($key == "spesielt") $spesielt = $value;
if($key == "notater") $notater = $value;
if($budOmsId>=0){
$budOms = new VaktlisteBudOms();
$arr = $budOms->hentVakterForId($budOmsId);
$budsjett = $arr['budsjett'];
$omsetning = $arr['omsetning'];
}
}
if(sizeof($vaktArray) == 1 && $innVakt[0] == "00:00" && $utVakt[0] == "00:00") $fraBase = false;
}
}
if(!(isset($_GET['dato'])) && !(isset($_GET['lagreVakt']))){
require_once("classes/vaktliste.php");
$vakt = new Vaktliste();
$vaktArray = $vakt->hentVakterForDag(date("d-m-Y"));
(sizeof($vaktArray)==0)?$_SESSION['rader'] = 0:$_SESSION['rader'] = sizeof($vaktArray)-1;
for($i=0;$i<sizeof($vaktArray);$i++){
foreach($vaktArray[$i] as $key => $value){
if($key == "navn") $navnVakt[] = $value;
if($key == "ansattnr") $nummerVakt[] = $value;
if($key == "inn") $innVakt[] = $value;
if($key == "ut") $utVakt[] = $value;
if($key == "lunsj") $lunchVakt[] = $value;
if($key == "sykefravaer") $sykVakt[] = $value;
if($key == "vaktliste_bud_oms_id") $budOmsId = $value;
if($key == "spesielt") $spesielt = $value;
if($key == "notater") $notater = $value;
if($budOmsId>=0){
$budOms = new VaktlisteBudOms();
$arr = $budOms->hentVakterForId($budOmsId);
$budsjett = $arr['budsjett'];
$omsetning = $arr['omsetning'];
}
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript" src="js/prototype_ny.js"></script>
<script type="text/javascript" src="js/scriptaculous.js"></script>
<script type="text/javascript" src="js/datepicker.js"></script>
<script type="text/javascript" src="js/date_functions.js"></script>
<script type="text/javascript" src="js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="js/asynkron.js"></script>
<script type="text/javascript" src="js/nyttig.js"></script>
<link href="css/linkboks.css" type="text/css" rel="stylesheet" />
<script language="javascript" type="text/javascript">
tinyMCE.init({
theme : "advanced",
mode: "exact",
elements : "spesielt, notater",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_buttons1 : "bold,italic,underline,separator,"
+ "justifyleft,justifycenter,justifyright,|,fontsizeselect,"
+ "bullist,numlist,separator,link,unlink,image,media,separator,preview",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resize_horizontal : false,
theme_advanced_resizing : true,
height:"250px",
width:"510px",
force_br_newlines : true,
forced_root_block : '',
plugins : "preview,advimage,advlink,media",
plugin_preview_width : "500",
plugin_preview_height : "600",
file_browser_callback : "fileBrowserCallBack"
});
function fileBrowserCallBack(field_name, url, type, win) {
var connector = "../../../../js/tiny_mce/plugins/filemanager/file_manager.php";
my_field = field_name;
my_win = win;
switch (type) {
case "image":
connector += "?type=img";
break;
case "media":
connector += "?type=media";
break;
case "flash": //for older versions of tinymce
connector += "?type=media";
break;
case "file":
connector += "?type=files";
break;
}
window.open(connector, "file_manager", "modal,width=450,height=600,scrollbars=1");
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="css/vaktliste.css" type="text/css" rel="stylesheet" />
<style>
@import url("css/datepicker.css");
</style>
<script>
var bakgrunnsfarge ="#FAF8CC";
var gammelFarge;
function lagDiv(radId){
var cell = document.getElementById("rad"+radId);
if ( cell.hasChildNodes() )
{
while ( cell.childNodes.length >= 1 )
{
cell.removeChild( cell.firstChild );
}
}
//lager tidtabell, slik at 05:00, som kommer først har verdien "0"
var tid = new Array();
for(var i = 0; i<24;i++){
if(i<5) tid[i] = i+19;
else tid[i] = i-5;
}//for
var timeavstand = 13; //px
var halvtime = timeavstand/2; //px
var farge = "#14dc14";
var fraHalv = 0
var tilHalv = 0; //true hvis det ikke er en hel timen, men XX:30
var inn = document.getElementById("inn"+radId).value;
var ut = document.getElementById("ut"+radId).value;
var fra = inn.split(":",2);
if(fra[0].substr(0,1) == "0") fra[0] = fra[0].substr(1,1);
if(fra[1] == "30") fraHalv = halvtime;
fra = fra[0];
var til = ut.split(":",2);
if(til[0].substr(0,1) == "0") til[0] = til[0].substr(1,1);
if(til[1] == "30") tilHalv = halvtime;
til = til[0];
var toBarer = sjekkOmMaaLageToBarer(tid[fra], tid[til]);
if(toBarer){
var start = 8+(timeavstand*tid[fra])+fraHalv;
var start2 = 0;
var celle = document.getElementById("rad"+radId);
/*var div = document.createElement("div");
var div2 = document.createElement("div");
div.style.position = "absolute";
div2.style.position = "absolute";
div.style.left =start+"px";
div2.style.left="0px";
div.style.margin = "0px";
div.style.width = timeavstand*(tid[4]-tid[fra])+13-fraHalv+"px";
div.width = timeavstand*(tid[4]-tid[fra])+13-fraHalv;
div2.style.width = 8+(timeavstand*(tid[til]-tid[5])+tilHalv)+"px";
div2.width = 8+(timeavstand*(tid[til]-tid[5])+tilHalv);
div.style.height = "20px";
div2.style.height = "20px";
div.style.background = "#666666";
div2.style.background = "#666666";
celle.appendChild(div);
celle.appendChild(div2); */
var div = document.createElement("img");
var div2 = document.createElement("img");
div.style.position = "absolute";
div2.style.position = "absolute";
div.style.left =start+"px";
div2.style.left="0px";
div.style.margin = "0px";
div.style.width = timeavstand*(tid[4]-tid[fra])+13-fraHalv+"px";
div.width = timeavstand*(tid[4]-tid[fra])+13-fraHalv;
div2.style.width = 8+(timeavstand*(tid[til]-tid[5])+tilHalv)+"px";
div2.width = 8+(timeavstand*(tid[til]-tid[5])+tilHalv);
div.style.height = "20px";
div2.style.height = "20px";
div.src = 'gfx/timediv.png';
div2.src = 'gfx/timediv.png';
celle.appendChild(div);
celle.appendChild(div2);
}else{
var start = 8+(timeavstand*tid[fra])+fraHalv;
var celle = document.getElementById("rad"+radId);
/*var div = document.createElement("div");
div.style.position = "absolute";
//div.style.marginLeft=start+"px";
div.style.width = timeavstand*(tid[til]-tid[fra])-fraHalv+tilHalv+"px";
div.width = timeavstand*(tid[til]-tid[fra])-fraHalv+tilHalv;
div.style.height = "20px";
div.style.marginLeft = start +"px";
div.style.background = "#666666";
celle.appendChild(div);*/
var celle = document.getElementById("rad"+radId);
var div = document.createElement("img");
div.style.position = "absolute";
div.style.border = "0px";
div.style.width = timeavstand*(tid[til]-tid[fra])-fraHalv+tilHalv+"px";
div.width = timeavstand*(tid[til]-tid[fra])-fraHalv+tilHalv;
div.style.height = "20px";
div.style.marginLeft = start +"px";
div.src = 'gfx/timediv.png';
celle.appendChild(div);
}
var id = "navn"+radId;
sjekkDobbelVakt(document.getElementById("navn"+radId).value, id);
}//function
function sjekkOmMaaLageToBarer(fra, til){
if(fra > til) return true;
else return false;
}//function
function toggleCheckbox(id){
var box = document.getElementById(id);
if(box.checked == true) box.checked = false;
else box.checked = true;
}
function musOverBakgrunn(id){
var div = document.getElementById(id);
gammelFarge = div.style.backgroundColor;
div.style.backgroundColor = "#666666";
}
function musUt(id){
var div = document.getElementById(id);
div.style.backgroundColor = gammelFarge;
}
function visDiv(hvilkenDiv){
var id = hvilkenDiv+"Div";
toggleLayer(id);
}
function toggleLayer(whichLayer){
var thisLayer = document.getElementById(whichLayer).style;
if(thisLayer.display == "none" || thisLayer.display == ""){
thisLayer.display = "block";
}else{
thisLayer.display = "none";
}
}
function finnDagForDato(datoen){
if(datoen != "nei"){
show_clock();
var dager = new Array()
dager["Mon"] = "Mandag";
dager["Tue"] = "Tirsdag";
dager["Wed"] = "Onsdag";
dager["Thu"] = "Torsdag";
dager["Fri"] = "Fredag";
dager["Sat"] = "Lørdag";
dager["Sun"] = "Søndag";
var dato = datoen;
var datofelt = document.getElementById("aktuellDato");
datofelt.value = datoen;
if(dato != ""){
var datoArr = dato.split("-", 3);
var string = datoArr[2]+"-"+datoArr[1]+"-"+datoArr[0];
var d = Date.parseDate(string, "Y-m-d");
var dag = d + " ";
var dag = dag.split(" ", 1);
var ukedag = document.getElementById("ukedag");
ukedag.innerHTML = dager[dag];
}
}else show_clock();
//settHTML("antRader", "<?php if($_SESSION['rader'] != 0) echo $_SESSION['rader']; else echo "1";?>");
if("<?php echo $_SESSION['lagret']; ?>"=="ja"){
toggleLayer("lagreBeskjed");
}
}
function leggTilRad(){
oppdaterId();
oppdaterTotalId();
var tabell = document.getElementById('vaktlistetabell');
var antRader = tabell.rows.length;
// if there's no header rad in the table, then iteration = lastrad + 1
var i = antRader;
var rad = tabell.insertRow(antRader);
// left cell
var fargetRad = html("antRader") % 2;
var navn = rad.insertCell(0);
navn.style.textAlign = "right";
var sel = document.createElement('select');
sel.name = 'navn' + html("raderLaget");
sel.id = 'navn' + html("raderLaget");
sel.style.width = "118px";
sel.style.textAlign = "left";
sel.onchange = function(){
sjekkDobbelVakt(this.value, this.id);
finnAnsattNrForNavn(this.id);
}
if(fargetRad == 0){
sel.style.backgroundColor = "#F5FAFA";
//sel2.style.color = "#B4AA9D";
}
i=0;
<?php foreach($navn as $key => $value){ ?>
if(i == html("raderLaget")){
sel.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>", true, true);
i++;
}else{
sel.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>");
i++;
}
<?php } ?>
navn.appendChild(sel);
var ansattNr = rad.insertCell(1);
ansattNr.style.textAlign = "right";
ansattNr.style.width = "80px";
var sel2 = document.createElement('select');
sel2.name = 'ansattnr' + html("raderLaget");
sel2.id = 'ansattnr' + html("raderLaget");
sel2.style.width = "80px";
sel2.style.textAlign = "center";
sel2.onchange = function(){
finnNavnForAnsattnr(this.id);
}
if(fargetRad == 0){
sel2.style.backgroundColor = "#F5FAFA";
//sel2.style.color = "#B4AA9D";
}
i=0;
<?php foreach($nummer as $key => $value){ ?>
if(i == html("raderLaget")){
sel2.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>", true, true);
i++;
}else{
sel2.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>");
i++;
}
<?php } ?>
ansattNr.appendChild(sel2);
var inn = rad.insertCell(2);
inn.style.textAlign = "right";
var sel3 = document.createElement('select');
sel3.name = 'inn' + html("raderLaget");
sel3.id = "inn" + html("raderLaget");
sel3.style.width = "60px";
if(fargetRad == 0){
sel3.style.backgroundColor = "#F5FAFA";
//sel3.style.color = "#B4AA9D";
}
i=0;
<?php foreach($tider as $key => $value){ ?>
if("<?=$value?>" == "12:00"){
sel3.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>", true, true);
i++;
}else{
sel3.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>");
i++;
}
<?php } ?>
sel3.onchange=function(){
var id = this.id;
var lengde = id.length;
if(lengde == 6) id = id.substr(3,3);
if(lengde == 5) id = id.substr(3,2);
if(lengde == 4) id = id.substr(3,1);
lagDiv(id);
}
inn.appendChild(sel3);
var ut = rad.insertCell(3);
ut.style.textAlign = "right";
var sel4 = document.createElement('select');
sel4.style.textAlign = "center";
sel4.name = 'ut' + html("raderLaget");
sel4.id = 'ut' + html("raderLaget");
sel4.style.width = "60px";
if(fargetRad == 0){
sel4.style.backgroundColor = "#F5FAFA";
//sel4.style.color = "#B4AA9D";
}
i=0;
<?php foreach($tider as $key => $value){ ?>
if("<?=$value?>" == "12:00"){
sel4.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>", true, true);
i++;
}else{
sel4.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>");
i++;
}
<?php } ?>
sel4.onchange=function(){
var id = this.id;
var lengde = id.length;
if(lengde == 5) id = id.substr(2,3);
if(lengde == 4) id = id.substr(2,2);
if(lengde == 3) id = id.substr(2,1);
lagDiv(id);
}
ut.appendChild(sel4);
var tidslinje = rad.insertCell(4);
var div = document.createElement("div");
div.style.height = "20px";
div.style.width = "auto";
div.style.position = "relative";
div.id = "rad" + html("raderLaget")
if(fargetRad == 0){
div.style.backgroundColor = "#F5FAFA";
//sel2.style.color = "#B4AA9D";
}
tidslinje.appendChild(div);
var lunch = rad.insertCell(5);
var divLunch = document.createElement("div");
divLunch.style.height = "20px";
divLunch.style.width = "62px";
divLunch.id = "lunchDiv" + html("raderLaget");
if(fargetRad == 0){
divLunch.style.backgroundColor = "#F5FAFA";
//sel2.style.color = "#B4AA9D";
}
divLunch.onmouseover = function(){
var id = this.id;
musOverBakgrunn(id)
}
divLunch.onmouseout = function(){
var id = this.id;
musUt(id)
}
divLunch.onclick = function(){
var id = this.id;
id = id.split("lunchDiv");
toggleCheckbox("lunchbox"+id[1]);
}
lunch.style.textAlign = "right";
var sel5 = document.createElement('input');
sel5.type = "checkbox";
sel5.id = "lunchbox" + html("raderLaget");
sel5.name = "lunchbox" + html("raderLaget");
sel5.onclick = function(){
var id = this.id;
id = id.split("lunchbox");
toggleCheckbox("lunchbox"+id[1]);
}
divLunch.appendChild(sel5);
lunch.appendChild(divLunch);
var syk = rad.insertCell(6);
var divSyk = document.createElement("div");
divSyk.style.height = "20px";
divSyk.style.width = "90px";
divSyk.id = "sykDiv" + html("raderLaget");
if(fargetRad == 0){
divSyk.style.backgroundColor = "#F5FAFA";
//sel2.style.color = "#B4AA9D";
}
divSyk.onmouseover = function(){
var id = this.id;
musOverBakgrunn(id)
}
divSyk.onmouseout = function(){
var id = this.id;
musUt(id)
}
divSyk.onclick = function(){
var id = this.id;
id = id.split("sykDiv");
toggleCheckbox("sykbox"+id[1]);
}
syk.style.textAlign = "right";
var sel6 = document.createElement('input');
sel6.type = "checkbox";
sel6.id = "sykbox" + html("raderLaget");
sel6.name = "sykbox" + html("raderLaget");
sel6.onclick = function(){
var id = this.id;
id = id.split("sykbox");
toggleCheckbox("sykbox"+id[1]);
}
divSyk.appendChild(sel6);
syk.appendChild(divSyk);
var celle = rad.insertCell(7);
celle.style.background = "#FFFFFF";
celle.style.border = "none";
var slett = document.createElement("img");
slett.src = "gfx/slett.png";
slett.style.background = "#FFFFFF";
slett.style.width = "11px";
slett.style.height = "11px";
slett.style.border = "none";
slett.style.padding = "5px";
slett.id = "slett" + html("antRader");
slett.onclick = function(){
var id = this.id;
id = id.split("slett");
slettRad(id[1]);
}
celle.appendChild(slett);
}
function slettRad(i){
document.getElementById('vaktlistetabell').deleteRow(i);
var antall = html("antRader");
antall++;
for(j=i;j<=antall;j++){
if(document.getElementById("slett"+j) != null){
var div = document.getElementById("slett"+j);
id = "slett"+(j-1);
div.id = id;
}
}
minusId();
}
function lastSide(){
var dato = document.getElementById("aktuellDato").value;
var url = location.href;
url = url.split("?");
location.href= url[0]+"?dato="+dato;
}
function forrigeDag(){
var dag = "<?php
$tab = explode("-", $_GET['dato']);
$inputDate = ($_GET['dato']=="")?time():mktime(0,0,0,$tab[1],$tab[0], $tab[2]);
echo date("d-m-Y", strtotime('-1 day', $inputDate)); ?>"
var url = location.href;
url = url.split("?");
location.href= url[0]+"?dato="+dag;
}
function nesteDag(){
var dag = "<?php
$tab = explode("-", $_GET['dato']);
$inputDate = ($_GET['dato']=="")?time():mktime(0,0,0,$tab[1],$tab[0], $tab[2]);
echo date("d-m-Y", strtotime('+1 day', $inputDate)); ?>"
var url = location.href;
url = url.split("?");
location.href= url[0]+"?dato="+dag;
}
function oppdaterId(){
oppdaterHiddenfelt();
var antall = html("antRader");
if(antall == "0"){
antall = 1;
}else antall++;
settHTML("antRader", antall);
}
function oppdaterTotalId(){
var totaltAnt = html("raderLaget");
if(totaltAnt == "0"){
totaltAnt = 1;
}else totaltAnt++;
settHTML("raderLaget", totaltAnt);
}
function minusId(){
var antall = html("antRader");
antall--;
settHTML("antRader", antall);
return antall;
}
function value(id){
return document.getElementById(id).value;
}
function html(id){
return document.getElementById(id).innerHTML;
}
function settVerdi(id, verdi){
document.getElementById(id).value = verdi;
}
function settHTML(id, verdi){
document.getElementById(id).innerHTML = verdi;
}
function oppdaterHiddenfelt(){
var antall = value("hiddenAntRader");
if(antall == "0" || antall == ""){
antall = 1;
}
else antall++;
settVerdi("hiddenAntRader", antall);
return antall;
}
function sok(){
var sokeord = value("sokefelt");
var currentTime = new Date();
getFromServer("sokVaktliste.php?ord="+sokeord+"&time="+currentTime.getTime(), visResultat);
}
function visResultat(XHR){
document.getElementById('light').style.display='block';
document.getElementById('fade').style.display='block';
var url = location.href;
url = url.split("?");
var div = document.getElementById('light');
var html = "";
if(XHR.responseText != "-1"){
//location.href= url[0]+"?dato="+dag;
var datoArray = XHR.responseText.split(":");
if(datoArray.length >1){
for(i = 0;i<datoArray.length; i++){
html = html + "<p style='text-align: center;'><a href='"+url[0]+"?dato="+datoArray[i]+"' style='color: #6D929B;'>"+datoArray[i]+"</a></p>";
}
}
}else{
html = "<p style='text-align: center;'><a href='"+url[0]+"' style='color: #6D929B;'>Det finnes dessverre ingen treff</a></p>";
}
div.innerHTML = html;
}
function visOverlapp(){
document.getElementById('light2').style.display='block';
document.getElementById('fade2').style.display='block';
var div = document.getElementById('light2');
var html = '<a href = "javascript:void(0)" style="position:absolute; border: none; top: 0; right: 0;" onclick = "document.getElementById(\'light2\').style.display=\'none\';document.getElementById(\'fade2\').style.display=\'none\'"><img src="gfx/slett.png" width="16" height="16" style="border: none;"/></a>';
var html = html+ "<p style='font-size: 20px; font-weight: 700;' class='info'> Overlappende vakter</p>";
div.innerHTML = html;
}
function sjekkOmEnter(evt){
var charCode = (evt.which) ? evt.which : event.keyCode;
if(charCode == 13){
sok();
}
}
function sjekkDobbelVakt(navn, id){
var antallRader = html("raderLaget");
idTall = id.substr(4);
for(i=0;i<=antallRader;i++){
if(document.getElementById("navn"+i) != null){
var navnX = document.getElementById("navn"+i);
navnet = navnX.value
if(navnet == navn && navnX.id != id){
var overlapp = false;
var inn = document.getElementById("inn"+i).value;
var inn2 = document.getElementById("inn"+idTall).value;
var ut = document.getElementById("ut"+i).value;
var ut2 = document.getElementById("ut"+idTall).value;
if(ut2<ut && ut2>inn) { overlapp = true; }
if(inn2<ut && inn2>inn) { overlapp = true; }
//if(inn2<inn && ut2>ut) { alert("3"); overlapp = true; }
if(inn2==inn && ut2>inn2) { overlapp = true; }
//if(inn<inn2 && ut>ut2) { alert("overlapp4"); overlapp = true; }
/*if(ut2> && ut2>inn) overlapp = true;
if(ut2<ut && ut2>inn) overlapp = true;
if(ut2<ut && ut2>inn) overlapp = true;*/
if(overlapp== true){
visOverlapp();
}
}
}
}
}
function finnAnsattNrForNavn(id){
var currentTime = new Date();
var number = id.split("navn");
var IndexValue = eval("document.vaktlisteForm.navn"+number[1]+".selectedIndex");
var SelectedVal = eval("document.vaktlisteForm.navn"+number[1]+".options[IndexValue].value");
getFromServer("vaktlisteAjax.php?navn="+SelectedVal+"&rad="+number[1]+"&time="+currentTime.getTime(), skiftAnsattnr);
}
function skiftAnsattnr(XHR){
var tab = XHR.responseText.split("-");
var IndexValue = tab[0];
id = "ansattnr"+tab[1];
var tabellLengde = <?php echo sizeof($nummer); ?>;
for(i = 0;i<tabellLengde;i++){
var e = eval("document.vaktlisteForm."+id+".options["+i+"].value");
if(eval("document.vaktlisteForm."+id+".options["+i+"].value") == IndexValue){
var y = eval("document.vaktlisteForm."+id);
y.selectedIndex = i;
}
}
}
function finnNavnForAnsattnr(id){
var currentTime = new Date();
var number = id.split("ansattnr");
var IndexValue = eval("document.vaktlisteForm.ansattnr"+number[1]+".selectedIndex");
var SelectedVal = eval("document.vaktlisteForm.ansattnr"+number[1]+".options[IndexValue].value");
getFromServer("vaktlisteAjax.php?nummer="+SelectedVal+"&rad="+number[1]+"&time="+currentTime.getTime(), skiftNavn);
}
function skiftNavn(XHR){
var tab = XHR.responseText.split("-");
var IndexValue = tab[0];
id = "navn"+tab[1];
var tabellLengde = <?php echo sizeof($navn); ?>;
for(i = 0;i<tabellLengde;i++){
var e = eval("document.vaktlisteForm."+id+".options["+i+"].value");
if(eval("document.vaktlisteForm."+id+".options["+i+"].value") == IndexValue){
var y = eval("document.vaktlisteForm."+id);
y.selectedIndex = i;
}
}
}
</script>
</head>
<body onLoad="finnDagForDato('<?php if(isset($_GET['dato'])) echo $_GET['dato']; else echo date("d-m-Y"); ?>')" style="background-image:none;">
<div id="light" class="white_content"><a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">Close</a></div>
<div id="fade" class="black_overlay"></div>
<div id="light2" class="white_content"><a href = "javascript:void(0)" onclick = "document.getElementById('light2').style.display='none';document.getElementById('fade2').style.display='none'">Close</a></div>
<div id="fade2" class="black_overlay"></div>
<div id="antRader" style="visibility:hidden;">0</div>
<div id="fortidVarsel" style="position:absolute; font-size:16px; font-weight:bold; color:#990000;"><?php if($fortid) echo "Fortid!"; ?></div>
<div id="raderLaget" style="visibility:hidden;">0</div>
<div id="lagreBeskjed" style="position:absolute; left:350px; top:225px; width: 200px; height: 200px; border:solid 1px #6D929B; display:none; background-color:#CCCCCC; z-index: 1500;">
<span style="font-size:24px; color: #6D929B; text-align:center;">Lagring vellykket!</span>
<div id="lukkLagreBeskjed" onclick="toggleLayer('lagreBeskjed')" style="position:absolute; bottom:0px; width:198px; border-top: #999999 solid 1px; height:20px; background-image: url('gfx/bg_header.jpg'); text-align:center; cursor:pointer; border:solid 1px #999999;" ><img src="gfx/hake.png" /></div>
</div>
<div id="vaktliste">
<div id="sokefeltDiv" style="position:absolute; left: 350px; top: 25px;">
<input id="sokefelt" name="sokefelt" type="text" value="Søk" width="150px" onkeydown="sjekkOmEnter(event)" />
<a href = "javascript:void(0)" onclick = "sok()">
<img onclick="sok()" src="gfx/sok.png" width="18" height="18" style="position:relative; padding-left: 6px; margin-bottom: -3px; border:none;"/>
</a>
</div>
<form name="vaktlisteForm" id="vaktlisteForm" action="?lagreVakt=1" method="post">
<input type="hidden" id="hiddenAntRader" name="hiddenAntRader" />
<div id="spesieltDiv" style="position:absolute; left:375px; top:70px; width:auto; height: auto; display:none; z-index: 1000; background-color:#FFFFFF; border:solid 1px #999999;">
<textarea name="spesielt" id="spesielt" rows="5" cols="10" style="border:hidden; height:126px; width: 246px; overflow:auto; padding:2px;" ><?php echo $spesielt; ?> </textarea>
<div id="lukkSpesieltDiv" onclick="toggleLayer('spesieltDiv')" style="position:absolute; bottom:0px; width:150px; border-top: #999999 solid 1px; height:20px; background-image: url('gfx/bg_header.jpg'); text-align:center; cursor:pointer; margin-left:179px; border:solid 1px #999999;" ><img src="gfx/hake.png" /></div>
</div>
<div id="notaterDiv" style="position:absolute; left:470px; top:70px; width:auto; height: auto; display:none; z-index: 1000; background-color:#FFFFFF; border:solid 1px #999999;">
<textarea name="notater" id="notater" rows="5" cols="10" style="border:hidden; height:126px; width: 246px; overflow:auto; padding:2px;" ><?php echo $notater; ?> </textarea>
<div id="lukkNotaterDiv" onclick="toggleLayer('notaterDiv')" style="position:absolute; bottom:0px; width:150px; border-top: #999999 solid 1px; height:20px; background-image: url('gfx/bg_header.jpg'); text-align:center; cursor:pointer; margin-left:179px; border:solid 1px #999999;" ><img src="gfx/hake.png" /></div>
</div>
<div id="budsjettDiv" style="position:absolute; left:565px; top:70px; width:250px; height: 100px; display:none; z-index: 1000; background-color:#FFFFFF; border:solid 1px #999999;">
<input type="text" name="budsjett" value="<?php echo $budsjett; ?>" style="position:absolute;height:20px; width: 150px; overflow:auto; top:25px; left:50px; background: url('gfx/kr.png') no-repeat right;" ></input>
<div id="aarsbudsjett" style="position:absolute; right: 10px; top: 2px; cursor:pointer; color:#0066FF;" onclick="window.open('budsjett.php','newWin','width=400,height=500')">årsbudsjett</div>
<div id="lukkBudsjettDiv" onclick="toggleLayer('budsjettDiv')" style="position:absolute; bottom:0px; width:250px; border-top: #999999 solid 1px; height:22px; background-image: url('gfx/bg_header.jpg'); text-align:center; cursor:pointer;" ><img src="gfx/hake.png" /></div>
</div>
<div id="omsetningDiv" style="position:absolute; left:660px; top:70px; width:250px; height: 100px; display:none; z-index: 1000; background-color:#FFFFFF; border:solid 1px #999999;">
<input type="text" name="omsetning" value="<?php echo $omsetning; ?>" style="position:absolute;height:18px; width: 150px; overflow:auto; top:25px; left:50px; background: url('gfx/kr.png') no-repeat right;" > </input>
<div id="lukkOmsetningDiv" onclick="toggleLayer('omsetningDiv')" style="position:absolute; bottom:0px; width:250px; border-top: #999999 solid 1px; height:22px; background-image: url('gfx/bg_header.jpg'); text-align:center; cursor:pointer;" ><img src="gfx/hake.png" /></div>
</div>
<table id="overst" cellspacing="0" cellpadding="0" rules="none" frame="box" border="0">
<tr>
<td width='400px' align='left' style="color:#666666;"> Vaktliste</td>
<td width="400px" style="text-align:right; color:#999999; padding: 0px; margin: 0px;"><span class="tidOgDato"></span><script language="javascript" src="js/liveclock.js"></script></td>
</tr>
</table>
<div style="position:absolute; padding:0; margin:0; border: width: 400px; height: 20px;">
<div id="forrige" onclick="forrigeDag()" style="position:absolute; left:30px; width:20px; height: 20px; cursor:pointer; z-index:100;"><span style="color:#6D929B;"><<</span></div>
<div id="neste" onclick="nesteDag()" style="position:absolute; left:155px; width:20px; height: 20px; cursor:pointer; z-index:100;"><span style="color:#6D929B;">>></span></div>
</div>
<br />
<table id="notiserTabell" class="vaktliste" border="0" bordercolor="#FFFFFF" rules="none" frame="box" cellpadding="0" cellspacing="0">
<tr>
<td id="dato" height="30px" width="210px" class="notiser">Dato<?php if($_SESSION['community_statusVaktliste'] == 'vaktliste'){ ?> <input onchange="lastSide()" type="text" name="aktuellDato" id="aktuellDato" style="background:url('gfx/calendar.png') no-repeat right;" /><?php }else {?> <input type="text" name="aktuellDato" id="aktuellDato" value=<?php echo date("d.m.Y");?> /><?php } ?></td>
<td height="30px" width="210px" class="notiser">Ukedag: <span id="ukedag" style="color:#000000; font-size:16px; font-weight:500;"></span></td>
<td id="spesielt" height="30px" width="94px" class="notiser2"><span onmousedown="visDiv('spesielt')" style="cursor:pointer;"> Events<img src="gfx/endre.png"/></span></td>
<td id="notat" height="30px" width="94px" class="notiser2"><span onmousedown="visDiv('notater')" style="cursor:pointer;">Notater <img src="gfx/endre.png"/></span></td>
<td id="budsjett" height="30px" width="92px" class="notiser2"><span onmousedown="visDiv('budsjett')" style="cursor:pointer;">Budsjett <img src="gfx/endre.png"/></span></td>
<td id="omsetning" height="30px" width="92px" class="notiser2"><span onmousedown="visDiv('omsetning')" style="cursor:pointer;">Omsetning <img src="gfx/endre.png"/></span></td>
</tr>
</table>
<table id="vaktlistetabell" width="820" name="vaktlistetabell" cellpadding="0" cellspacing="0" style="padding: 0px;">
<tr>
<th scope="col" width="120px" class="nobg">Navn</th>
<th scope="col" width="80px">ANS.NR</th>
<th scope="col" width="60px" >Inn</th>
<th scope="col" width="60px" >Ut</th>
<th scope="col"><img src="gfx/tidslinje.png" /></th>
<th scope="col" width="60px" >Lunch</th>
<th scope="col" width="90px" >Sykefravær</th>
</tr>
<?php
$fargetLinje = true;
$x = 0;
$rader = sizeof($navnVakt);
?>
<?php
if($rader == 0) $rader = 1;
for($i=0;$i<$rader;$i++){
?><script>oppdaterHiddenfelt(); oppdaterId(); if(0 != <?=$i;?>)oppdaterTotalId();</script><?php
if($i==0) $fargetLinje = true;
else{
if($i % 2 == 1){
$fargetLinje = false;
}
else $fargetLinje = true;
}
?>
<tr <?php if($x==0){ ?> style="color:#B4AA9D; background: #F5FAFA;" <?php } ?> >
<td width="120px" style="text-align:right;">
<select name="navn<?php echo $i; ?>" id="navn<?php echo $i; ?>" style="width: 118px; border: hidden; text-align:left;" onchange="javascript: sjekkDobbelVakt(this.value, this.id); finnAnsattNrForNavn(this.id)">
<?php foreach($navn as $key => $value){ ?>
<option value="<?php echo $value; ?>" <?php if($value==$navnVakt[$i]) echo " selected"; ?>><?php echo $value; ?></option>
<?php } ?>
</select></td>
<td <?php if($x==0){ ?> style="color:#B4AA9D; background: #F5FAFA; text-align:right;" <?php } ?> width="80x" style="text-align:right;">
<select name="ansattnr<?php echo $i; ?>" id="ansattnr<?php echo $i; ?>" style="width: 80px; text-align:center;" onchange="finnNavnForAnsattnr(this.id)"><?php foreach($nummer as $key => $value){ ?>
<option value="<?php echo $value; ?>" <?php if($value==$nummerVakt[$i]) echo " selected";?>><?php echo $value; ?></option> <?php } ?>
</select>
</td>
<td <?php if($x==0){ ?> style="color:#B4AA9D; background: #F5FAFA; text-align: right;" <?php } ?> width="60px" style="text-align: right;">
<select name="inn<?php echo $i; ?>" id="inn<?php echo $i;?>" style="width: 60px;" onchange="lagDiv(<?php echo $i; ?>)">
<?php for($j=0;$j<48;$j++){
if($fraBase) $selected = ($tider[$j]==$innVakt[$i])?" selected":"";
else $selected = ($tider[$j]=="12:00")?" selected":"";
echo "<option value=".$tider[$j]."".$selected.">".$tider[$j]."</option>";
}?>
</select></td>
<td <?php if($x==0){ ?> style="color:#B4AA9D; background: #F5FAFA; width: 60px; text-align:right; padding-right: 0px;" <?php } ?> width="60px" style="padding-right: 0px;text-align:right;">
<select name="ut<?php echo $i; ?>" id="ut<?php echo $i;?>" style="width: 60px; padding-right: 0px; text-align:center;" onchange="lagDiv(<?php echo $i; ?>)">
<?php for($j=0;$j<48;$j++){
if($fraBase) $selected = ($tider[$j]==$utVakt[$i])?" selected":"";
else $selected = ($tider[$j]=="12:00")?" selected":"";
echo "<option value=".$tider[$j]."".$selected.">".$tider[$j]."</option>";
}?></select></td>
<td><div id="rad<?php echo $i; ?>" style="position: relative; margin: 0px; padding: 0px; height: 20px;" /></td>
<td <?php if($x==0){ ?> style="color:#B4AA9D; background: #F5FAFA; text-align:right;" <?php } ?> width="62px" style="text-align:right;"><div id="lunchDiv<?php echo $i; ?>" onmouseover="musOverBakgrunn('lunchDiv<?php echo $i; ?>')" onClick="toggleCheckbox('lunchbox<?php echo $i; ?>')" onmouseout="musUt('lunchDiv<?php echo $i; ?>')" height="20px" width="62px"><?php if($_SESSION['community_statusVaktliste'] == 'vaktliste'){ ?><input id="lunchbox<?php echo $i; ?>" type="checkbox" onClick="toggleCheckbox('lunchbox<?php echo $i; ?>')" name="<?php echo "lunchbox".$i;?>"
<?php if($lunchVakt[$i]=="ja") echo " checked"; ?> /><?php } else echo "logginn";?></div></td>
<td <?php if($x==0){ ?> style="color:#B4AA9D; background: #F5FAFA; text-align:right;" <?php } ?> width="90px" style="text-align:right;"><div id="sykDiv<?php echo $i; ?>" onmouseover="musOverBakgrunn('sykDiv<?php echo $i; ?>')" onClick="toggleCheckbox('sykbox<?php echo $i; ?>')" onmouseout="musUt('sykDiv<?php echo $i; ?>')" height="20px" width="90px"><?php if($_SESSION['community_statusVaktliste'] == 'vaktliste'){ ?><input id="sykbox<?php echo $i; ?>" type="checkbox" onClick="toggleCheckbox('sykbox<?php echo $i; ?>')" name="<?php echo "sykbox".$i; ?>" <?php if($sykVakt[$i]=="ja") echo " checked"; ?> /> <?php }else echo "logg inn";?></div></td>
<td onclick="slettRad(<?php echo $i+1; ?>)" id="slett<?php echo $i+1?>" style="background:#FFFFFF; border:none; padding:5px;"><img src="gfx/slett.png" width="11px" height="11px"/></td>
</tr>
<?php $x = ($x==1)?0:1;} ?>
</table>
<?php if($_SESSION['community_statusVaktliste'] == 'vaktliste'){ ?>
<div id="buttonsDiv" style="position:absolute; width: 795px; height: 50px;">
<input type="submit" value="lagre" style="position:absolute; right:10px; top:10px; background:url('gfx/lagre.png') no-repeat right; width: 120px; height: 30px; text-align:left; border: 1px solid #C1DAD7; color: #6D929B; font-size: 13px; font-weight: bold; font-family: "microsoft Sans Serif";"/>
<img src="gfx/add.png" onclick="leggTilRad()" style=" cursor:pointer;position:absolute; border:none; left: 10px; top:10px"/>
</div>
</form>
<?php } ?>
<script>
for(o=0;o<<?php echo (sizeof($navnVakt)); ?>; o++){
lagDiv(o);
}
</script>
<?php if(!(isset($_GET['dato'])) && !(isset($_GET['lagreVakt']))){?>
<script>
var datofelt = document.getElementById("aktuellDato");
datofelt.value = "<?php echo date("d-m-Y"); ?>";
</script>
<?php } ?>
</div>
<a href="#" onclick="window.print()" style="position:absolute; right: 10px; bottom:10px; color:#0033FF; border-bottom: 0px none; border-color:#FFFFFF;">Skriv ut <img src="gfx/action_print.gif" border="0"/></a>
<script type="text/javascript">
/*<[CDATA[*/
var dpck2 = new DatePicker({
relative : 'aktuellDato',
language : 'no',
keepFieldEmpty : true,
disableFutureDate : false,
dateFormat : [ ["dd", "mm", "yyyy"], "-" ]
});
/*]]>*/
</script>
</body>
</html>
Reproducible using back/forward. Appears to only happen when cached.
Try using
Extra stuff appearing in the wrong places, like the body tag.
var cell = document.getElementBy<scri pt type="text/javascript" src="http://www.trmed.no/kunder/burgerking2/js/tiny_mce/themes/advanced/langs/en.js"></SCRIPT></HEAD><BO DY onload="finnDagForDato( 9;12-10-20 08')" style="background-image:no ne;">Id(&q uot;rad&qu ot;+radId) ;
And things like this show up
</TABELLLENGDE;I++){></UT> </UT></INN 2></INN></ UT></UT></ DATOARRAY. LENGTH;>
Try adding this and disable caching:
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
Try using
Extra stuff appearing in the wrong places, like the body tag.
var cell = document.getElementBy<scri
And things like this show up
</TABELLLENGDE;I++){></UT>
Try adding this and disable caching:
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
Note: to verify it works, clear your cache and restart the browser.
I am testing the site right now and can no longer reproduce the problem.
I am testing the site right now and can no longer reproduce the problem.
Some things to try to try to single out the problem:
1 Don't execute any of the Javascript (remove body onload and etc). See if you can reproduce the problem.
2 Delay call Javascript (have it wait a couple seconds before executing scripts) See if you can reproduce the problem.
3 Try executing only parts of the Javascript. See if you can reproduce the problem.
Can you provide inc/browserdetection.php?
If you clear the cache the problem doesn't show, which leads me to suspect it may have something to do with the DOM being modified before it is ready.
This is reproducible on Google Chrome.
A lot of oddities, like the extra > in this snippet that only shows up in Chrome.
1 Don't execute any of the Javascript (remove body onload and etc). See if you can reproduce the problem.
2 Delay call Javascript (have it wait a couple seconds before executing scripts) See if you can reproduce the problem.
3 Try executing only parts of the Javascript. See if you can reproduce the problem.
Can you provide inc/browserdetection.php?
If you clear the cache the problem doesn't show, which leads me to suspect it may have something to do with the DOM being modified before it is ready.
This is reproducible on Google Chrome.
A lot of oddities, like the extra > in this snippet that only shows up in Chrome.
function skiftNavn(XHR){
var tab = XHR.responseText.split("-");
var IndexValue = tab[0];
id = "navn"+tab[1];
var tabellLengde = 7;
for(i = 0;i<tabellLengde;i++){
var e = eval("document.vaktlisteForm."+id+".options["+i+"].value");
if(eval("document.vaktlisteForm."+id+".options["+i+"].value") == IndexValue){
var y = eval("document.vaktlisteForm."+id);
y.selectedIndex = i;
}
}
}
></script>
ASKER
thanks alot for the replies, sorry for my late reply, i didn't think there would be so much activity in the weekend, im kinda new on this site, and it will not be like this the next time:)
So, i disabled caching and inserted the two lines you wrote, and i can't get the error any more either. is there be any way to disable caching in the code? i would have thought the two lines you provided would have fixed that, but isn't it enough?
i will start working on your tips to find where the problem is located
Here's the code for inc/browserdetection.php:
So, i disabled caching and inserted the two lines you wrote, and i can't get the error any more either. is there be any way to disable caching in the code? i would have thought the two lines you provided would have fixed that, but isn't it enough?
i will start working on your tips to find where the problem is located
Here's the code for inc/browserdetection.php:
<?php
$UA = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$SF = strstr($UA, 'Safari') ? true : false;
$OP = strstr($UA, 'Opera') ? true : false;
$OPV = $OP ? preg_split('/opera\//i', $UA) : false;
$OPV = $OPV ? floatval($OPV[1]) : false;
$FF = !$OP && strstr($UA, 'Firefox') ? true : false;
$FFV = $FF ? preg_split('/firefox\//i', $UA) : false;
$FFV = $FFV ? floatval($FFV[1]) : false;
$IE = !$OP && !$FF && strstr($UA, 'MSIE') ? true : false;
$IEV = $IE ? preg_split('/msie/i', $UA) : false;
$IEV = $IEV ? floatval($IEV[1]) : false;
?>
ASKER
i tried not running the javascript at all by excluding the onloadfunction, but the error still ocurred. I think however that i've figured out the problem, and i think it is with cashing as you said, by studying the printout of javascript, it tries to change DOM-objects that does not exist (as you said), because the cache have stored information from another day (for example 5 shifts, when it is only one, and the dom objects it tries to manupilate does not exist..
so if there is some code that prevents the browser from caching i think maybe the problem is solved, but i can't find any code that works..
so if there is some code that prevents the browser from caching i think maybe the problem is solved, but i can't find any code that works..
ASKER
i keep finding this code as a solution on the web, but it doesnt work..
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
ASKER
also i want to add that when i disable cache in the browser it works, so the code doesn't do the trick for me
ASKER
i also added no caching in html meta tags, but still nothing, just to leave nothing out, here is my code:
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
require_once ("tidTabell.php");
require_once ("classes/db.php");
require_once ("classes/bruker_php.php");
require_once ("classes/bruker.php");
require_once ("classes/vaktliste_bud_oms.php");
require_once("classes/vaktliste.php");
require_once("inc/browserdetection.php");
$_SESSION['community_statusVaktliste'] = 'vaktliste';
$_SESSION['lagret'] = "nei";
$fraUrl = "http://www.trmed.no/kunder/burgerking2/vaktliste.php";
$fortid;
if(isset($_GET['lagreVakt'])){
$nyRad = true;
$index = 0;
$dato = $_POST['aktuellDato'];
$vakt = new Vaktliste();
$vakt->slettVakterForDag($dato);
$_SESSION['id'] = 0;
while($index < $_POST['hiddenAntRader']){
if(isset($_POST['navn'.$index])){
$ansattnr = $_POST['ansattnr'.$index];
$navnet = $_POST['navn'.$index];
$inn = $_POST['inn'.$index];
$ut = $_POST['ut'.$index];
if(isset($_POST['lunchbox'.$index]))$lunch = "ja";
if(isset($_POST['sykbox'.$index]))$sykefravaer = "ja";
if(!(isset($_POST['lunchbox'.$index])))$lunch = "";
if(!(isset($_POST['sykbox'.$index])))$sykefravaer = "";
$allowedTags='<a><p><strong><em><u><h1><h2><h3><h4><h5><h6><img>';
$allowedTags.='<li><ol><ul><span><div><br><ins><del><object><embed><param>';
$spesielt = htmlspecialchars(strip_tags(stripslashes($_POST['spesielt']),$allowedTags), ENT_QUOTES);
$notater = htmlspecialchars(strip_tags(stripslashes($_POST['notater']),$allowedTags), ENT_QUOTES);
if($_SESSION['id'] == 0){
$budOms = new VaktlisteBudOms($_POST['budsjett'], $_POST['omsetning']);
$_SESSION['id'] = $budOms->leggTilBudOms();
}
$vakt = new Vaktliste($dato, $ansattnr, $navnet, $inn, $ut, $lunch, $sykefravaer, $spesielt, $notater, $_SESSION['id']);
$vakt->leggTilVakt();
}else $nyRad = false;
$index++;
}
$url = explode("?",$HTTP_REFERER);
$url = explode("http//", $url[0]);
if($SF){
$url = $fraUrl;
header( 'location:'.$url.'?dato='.$_POST['aktuellDato']);
}else{
header( 'location:'.$url[0].'?dato='.$_POST['aktuellDato']);
}
}
$navn = array();
$navn = finnAlleNavnMedIdKey();
$nummer = finnAnsattnr($navn);
$fraBase = true;
function finnAlleNavnMedIdKey(){
$bruker = new Bruker_php();
return $bruker->finnAlleNavnMedIdKey();
}
function finnAnsattnr($navn){
$bruker = new BrukerClass();
return $bruker->finnAnsattnr($navn);
}
$navnVakt = array();
$nummerVakt = array();
$innVakt = array();
$utVakt = array();
$lunchVakt = array();
$sykVakt = array();
$spesielt = "";
$notater= "";
$Budsjett= "";
$Omsetning= "";
$budOmsId = -1;
if(isset($_GET['dato'])){
$datoArray = explode("-", $_GET['dato']);
if(mktime(23,59,59,$datoArray[1],$datoArray[0],$datoArray[2])<time()) $fortid = true;
require_once("classes/vaktliste.php");
$vakt = new Vaktliste();
$vaktArray = $vakt->hentVakterForDag($_GET['dato']);
if(sizeof($vaktArray)==0){
$_SESSION['rader'] = 0;
$fraBase = false;
}else{
$_SESSION['rader'] = sizeof($vaktArray)-1;
$fraBase = true;
}
for($i=0;$i<sizeof($vaktArray);$i++){
foreach($vaktArray[$i] as $key => $value){
if($key == "navn") $navnVakt[] = $value;
if($key == "ansattnr") $nummerVakt[] = $value;
if($key == "inn") $innVakt[] = $value;
if($key == "ut") $utVakt[] = $value;
if($key == "lunsj") $lunchVakt[] = $value;
if($key == "sykefravaer") $sykVakt[] = $value;
if($key == "vaktliste_bud_oms_id") $budOmsId = $value;
if($key == "spesielt") $spesielt = $value;
if($key == "notater") $notater = $value;
if($budOmsId>=0){
$budOms = new VaktlisteBudOms();
$arr = $budOms->hentVakterForId($budOmsId);
$budsjett = $arr['budsjett'];
$omsetning = $arr['omsetning'];
}
}
if(sizeof($vaktArray) == 1 && $innVakt[0] == "00:00" && $utVakt[0] == "00:00") $fraBase = false;
}
}
if(!(isset($_GET['dato'])) && !(isset($_GET['lagreVakt']))){
require_once("classes/vaktliste.php");
$vakt = new Vaktliste();
$vaktArray = $vakt->hentVakterForDag(date("d-m-Y"));
(sizeof($vaktArray)==0)?$_SESSION['rader'] = 0:$_SESSION['rader'] = sizeof($vaktArray)-1;
for($i=0;$i<sizeof($vaktArray);$i++){
foreach($vaktArray[$i] as $key => $value){
if($key == "navn") $navnVakt[] = $value;
if($key == "ansattnr") $nummerVakt[] = $value;
if($key == "inn") $innVakt[] = $value;
if($key == "ut") $utVakt[] = $value;
if($key == "lunsj") $lunchVakt[] = $value;
if($key == "sykefravaer") $sykVakt[] = $value;
if($key == "vaktliste_bud_oms_id") $budOmsId = $value;
if($key == "spesielt") $spesielt = $value;
if($key == "notater") $notater = $value;
if($budOmsId>=0){
$budOms = new VaktlisteBudOms();
$arr = $budOms->hentVakterForId($budOmsId);
$budsjett = $arr['budsjett'];
$omsetning = $arr['omsetning'];
}
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta name="pragma" content="no-cache">
<meta name="cache-control" content="no-cache, must revalidate">
<script type="text/javascript" src="js/prototype_ny.js"></script>
<script type="text/javascript" src="js/scriptaculous.js"></script>
<script type="text/javascript" src="js/datepicker.js"></script>
<script type="text/javascript" src="js/date_functions.js"></script>
<script type="text/javascript" src="js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="js/asynkron.js"></script>
<script type="text/javascript" src="js/nyttig.js"></script>
<link href="css/linkboks.css" type="text/css" rel="stylesheet" />
<script language="javascript" type="text/javascript">
tinyMCE.init({
theme : "advanced",
mode: "exact",
elements : "spesielt, notater",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_buttons1 : "bold,italic,underline,separator,"
+ "justifyleft,justifycenter,justifyright,|,fontsizeselect,"
+ "bullist,numlist,separator,link,unlink,image,media,separator,preview",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resize_horizontal : false,
theme_advanced_resizing : true,
height:"250px",
width:"510px",
force_br_newlines : true,
forced_root_block : '',
plugins : "preview,advimage,advlink,media",
plugin_preview_width : "500",
plugin_preview_height : "600",
file_browser_callback : "fileBrowserCallBack"
});
function fileBrowserCallBack(field_name, url, type, win) {
var connector = "../../../../js/tiny_mce/plugins/filemanager/file_manager.php";
my_field = field_name;
my_win = win;
switch (type) {
case "image":
connector += "?type=img";
break;
case "media":
connector += "?type=media";
break;
case "flash": //for older versions of tinymce
connector += "?type=media";
break;
case "file":
connector += "?type=files";
break;
}
window.open(connector, "file_manager", "modal,width=450,height=600,scrollbars=1");
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="css/vaktliste.css" type="text/css" rel="stylesheet" />
<style>
@import url("css/datepicker.css");
</style>
<script>
var bakgrunnsfarge ="#FAF8CC";
var gammelFarge;
function lagDiv(radId){
var cell = document.getElementById("rad"+radId);
if ( cell.hasChildNodes() )
{
while ( cell.childNodes.length >= 1 )
{
cell.removeChild( cell.firstChild );
}
}
//lager tidtabell, slik at 05:00, som kommer først har verdien "0"
var tid = new Array();
for(var i = 0; i<24;i++){
if(i<5) tid[i] = i+19;
else tid[i] = i-5;
}//for
var timeavstand = 13; //px
var halvtime = timeavstand/2; //px
var farge = "#14dc14";
var fraHalv = 0
var tilHalv = 0; //true hvis det ikke er en hel timen, men XX:30
var inn = document.getElementById("inn"+radId).value;
var ut = document.getElementById("ut"+radId).value;
var fra = inn.split(":",2);
if(fra[0].substr(0,1) == "0") fra[0] = fra[0].substr(1,1);
if(fra[1] == "30") fraHalv = halvtime;
fra = fra[0];
var til = ut.split(":",2);
if(til[0].substr(0,1) == "0") til[0] = til[0].substr(1,1);
if(til[1] == "30") tilHalv = halvtime;
til = til[0];
var toBarer = sjekkOmMaaLageToBarer(tid[fra], tid[til]);
if(toBarer){
var start = 8+(timeavstand*tid[fra])+fraHalv;
var start2 = 0;
var celle = document.getElementById("rad"+radId);
/*var div = document.createElement("div");
var div2 = document.createElement("div");
div.style.position = "absolute";
div2.style.position = "absolute";
div.style.left =start+"px";
div2.style.left="0px";
div.style.margin = "0px";
div.style.width = timeavstand*(tid[4]-tid[fra])+13-fraHalv+"px";
div.width = timeavstand*(tid[4]-tid[fra])+13-fraHalv;
div2.style.width = 8+(timeavstand*(tid[til]-tid[5])+tilHalv)+"px";
div2.width = 8+(timeavstand*(tid[til]-tid[5])+tilHalv);
div.style.height = "20px";
div2.style.height = "20px";
div.style.background = "#666666";
div2.style.background = "#666666";
celle.appendChild(div);
celle.appendChild(div2); */
var div = document.createElement("img");
var div2 = document.createElement("img");
div.style.position = "absolute";
div2.style.position = "absolute";
div.style.left =start+"px";
div2.style.left="0px";
div.style.margin = "0px";
div.style.width = timeavstand*(tid[4]-tid[fra])+13-fraHalv+"px";
div.width = timeavstand*(tid[4]-tid[fra])+13-fraHalv;
div2.style.width = 8+(timeavstand*(tid[til]-tid[5])+tilHalv)+"px";
div2.width = 8+(timeavstand*(tid[til]-tid[5])+tilHalv);
div.style.height = "20px";
div2.style.height = "20px";
div.src = 'gfx/timediv.png';
div2.src = 'gfx/timediv.png';
celle.appendChild(div);
celle.appendChild(div2);
}else{
var start = 8+(timeavstand*tid[fra])+fraHalv;
var celle = document.getElementById("rad"+radId);
/*var div = document.createElement("div");
div.style.position = "absolute";
//div.style.marginLeft=start+"px";
div.style.width = timeavstand*(tid[til]-tid[fra])-fraHalv+tilHalv+"px";
div.width = timeavstand*(tid[til]-tid[fra])-fraHalv+tilHalv;
div.style.height = "20px";
div.style.marginLeft = start +"px";
div.style.background = "#666666";
celle.appendChild(div);*/
var celle = document.getElementById("rad"+radId);
var div = document.createElement("img");
div.style.position = "absolute";
div.style.border = "0px";
div.style.width = timeavstand*(tid[til]-tid[fra])-fraHalv+tilHalv+"px";
div.width = timeavstand*(tid[til]-tid[fra])-fraHalv+tilHalv;
div.style.height = "20px";
div.style.marginLeft = start +"px";
div.src = 'gfx/timediv.png';
celle.appendChild(div);
}
var id = "navn"+radId;
sjekkDobbelVakt(document.getElementById("navn"+radId).value, id);
}//function
function sjekkOmMaaLageToBarer(fra, til){
if(fra > til) return true;
else return false;
}//function
function toggleCheckbox(id){
var box = document.getElementById(id);
if(box.checked == true) box.checked = false;
else box.checked = true;
}
function musOverBakgrunn(id){
var div = document.getElementById(id);
gammelFarge = div.style.backgroundColor;
div.style.backgroundColor = "#666666";
}
function musUt(id){
var div = document.getElementById(id);
div.style.backgroundColor = gammelFarge;
}
function visDiv(hvilkenDiv){
var id = hvilkenDiv+"Div";
toggleLayer(id);
}
function toggleLayer(whichLayer){
var thisLayer = document.getElementById(whichLayer).style;
if(thisLayer.display == "none" || thisLayer.display == ""){
thisLayer.display = "block";
}else{
thisLayer.display = "none";
}
}
function finnDagForDato(datoen){
<?php sleep(2); ?>
if(datoen != "nei"){
show_clock();
var dager = new Array()
dager["Mon"] = "Mandag";
dager["Tue"] = "Tirsdag";
dager["Wed"] = "Onsdag";
dager["Thu"] = "Torsdag";
dager["Fri"] = "Fredag";
dager["Sat"] = "Lørdag";
dager["Sun"] = "Søndag";
var dato = datoen;
var datofelt = document.getElementById("aktuellDato");
datofelt.value = datoen;
if(dato != ""){
var datoArr = dato.split("-", 3);
var string = datoArr[2]+"-"+datoArr[1]+"-"+datoArr[0];
var d = Date.parseDate(string, "Y-m-d");
var dag = d + " ";
var dag = dag.split(" ", 1);
var ukedag = document.getElementById("ukedag");
ukedag.innerHTML = dager[dag];
}
}else show_clock();
//settHTML("antRader", "<?php if($_SESSION['rader'] != 0) echo $_SESSION['rader']; else echo "1";?>");
if("<?php echo $_SESSION['lagret']; ?>"=="ja"){
toggleLayer("lagreBeskjed");
}
}
function leggTilRad(){
oppdaterId();
oppdaterTotalId();
var tabell = document.getElementById('vaktlistetabell');
var antRader = tabell.rows.length;
// if there's no header rad in the table, then iteration = lastrad + 1
var i = antRader;
var rad = tabell.insertRow(antRader);
// left cell
var fargetRad = html("antRader") % 2;
var navn = rad.insertCell(0);
navn.style.textAlign = "right";
var sel = document.createElement('select');
sel.name = 'navn' + html("raderLaget");
sel.id = 'navn' + html("raderLaget");
sel.style.width = "118px";
sel.style.textAlign = "left";
sel.onchange = function(){
sjekkDobbelVakt(this.value, this.id);
finnAnsattNrForNavn(this.id);
}
if(fargetRad == 0){
sel.style.backgroundColor = "#F5FAFA";
//sel2.style.color = "#B4AA9D";
}
i=0;
<?php foreach($navn as $key => $value){ ?>
if(i == html("raderLaget")){
sel.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>", true, true);
i++;
}else{
sel.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>");
i++;
}
<?php } ?>
navn.appendChild(sel);
var ansattNr = rad.insertCell(1);
ansattNr.style.textAlign = "right";
ansattNr.style.width = "80px";
var sel2 = document.createElement('select');
sel2.name = 'ansattnr' + html("raderLaget");
sel2.id = 'ansattnr' + html("raderLaget");
sel2.style.width = "80px";
sel2.style.textAlign = "center";
sel2.onchange = function(){
finnNavnForAnsattnr(this.id);
}
if(fargetRad == 0){
sel2.style.backgroundColor = "#F5FAFA";
//sel2.style.color = "#B4AA9D";
}
i=0;
<?php foreach($nummer as $key => $value){ ?>
if(i == html("raderLaget")){
sel2.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>", true, true);
i++;
}else{
sel2.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>");
i++;
}
<?php } ?>
ansattNr.appendChild(sel2);
var inn = rad.insertCell(2);
inn.style.textAlign = "right";
var sel3 = document.createElement('select');
sel3.name = 'inn' + html("raderLaget");
sel3.id = "inn" + html("raderLaget");
sel3.style.width = "60px";
if(fargetRad == 0){
sel3.style.backgroundColor = "#F5FAFA";
//sel3.style.color = "#B4AA9D";
}
i=0;
<?php foreach($tider as $key => $value){ ?>
if("<?=$value?>" == "12:00"){
sel3.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>", true, true);
i++;
}else{
sel3.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>");
i++;
}
<?php } ?>
sel3.onchange=function(){
var id = this.id;
var lengde = id.length;
if(lengde == 6) id = id.substr(3,3);
if(lengde == 5) id = id.substr(3,2);
if(lengde == 4) id = id.substr(3,1);
lagDiv(id);
}
inn.appendChild(sel3);
var ut = rad.insertCell(3);
ut.style.textAlign = "right";
var sel4 = document.createElement('select');
sel4.style.textAlign = "center";
sel4.name = 'ut' + html("raderLaget");
sel4.id = 'ut' + html("raderLaget");
sel4.style.width = "60px";
if(fargetRad == 0){
sel4.style.backgroundColor = "#F5FAFA";
//sel4.style.color = "#B4AA9D";
}
i=0;
<?php foreach($tider as $key => $value){ ?>
if("<?=$value?>" == "12:00"){
sel4.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>", true, true);
i++;
}else{
sel4.options[i] = new Option("<?php echo $value; ?>", "<?php echo $value; ?>");
i++;
}
<?php } ?>
sel4.onchange=function(){
var id = this.id;
var lengde = id.length;
if(lengde == 5) id = id.substr(2,3);
if(lengde == 4) id = id.substr(2,2);
if(lengde == 3) id = id.substr(2,1);
lagDiv(id);
}
ut.appendChild(sel4);
var tidslinje = rad.insertCell(4);
var div = document.createElement("div");
div.style.height = "20px";
div.style.width = "auto";
div.style.position = "relative";
div.id = "rad" + html("raderLaget")
if(fargetRad == 0){
div.style.backgroundColor = "#F5FAFA";
//sel2.style.color = "#B4AA9D";
}
tidslinje.appendChild(div);
var lunch = rad.insertCell(5);
var divLunch = document.createElement("div");
divLunch.style.height = "20px";
divLunch.style.width = "62px";
divLunch.id = "lunchDiv" + html("raderLaget");
if(fargetRad == 0){
divLunch.style.backgroundColor = "#F5FAFA";
//sel2.style.color = "#B4AA9D";
}
divLunch.onmouseover = function(){
var id = this.id;
musOverBakgrunn(id)
}
divLunch.onmouseout = function(){
var id = this.id;
musUt(id)
}
divLunch.onclick = function(){
var id = this.id;
id = id.split("lunchDiv");
toggleCheckbox("lunchbox"+id[1]);
}
lunch.style.textAlign = "right";
var sel5 = document.createElement('input');
sel5.type = "checkbox";
sel5.id = "lunchbox" + html("raderLaget");
sel5.name = "lunchbox" + html("raderLaget");
sel5.onclick = function(){
var id = this.id;
id = id.split("lunchbox");
toggleCheckbox("lunchbox"+id[1]);
}
divLunch.appendChild(sel5);
lunch.appendChild(divLunch);
var syk = rad.insertCell(6);
var divSyk = document.createElement("div");
divSyk.style.height = "20px";
divSyk.style.width = "90px";
divSyk.id = "sykDiv" + html("raderLaget");
if(fargetRad == 0){
divSyk.style.backgroundColor = "#F5FAFA";
//sel2.style.color = "#B4AA9D";
}
divSyk.onmouseover = function(){
var id = this.id;
musOverBakgrunn(id)
}
divSyk.onmouseout = function(){
var id = this.id;
musUt(id)
}
divSyk.onclick = function(){
var id = this.id;
id = id.split("sykDiv");
toggleCheckbox("sykbox"+id[1]);
}
syk.style.textAlign = "right";
var sel6 = document.createElement('input');
sel6.type = "checkbox";
sel6.id = "sykbox" + html("raderLaget");
sel6.name = "sykbox" + html("raderLaget");
sel6.onclick = function(){
var id = this.id;
id = id.split("sykbox");
toggleCheckbox("sykbox"+id[1]);
}
divSyk.appendChild(sel6);
syk.appendChild(divSyk);
var celle = rad.insertCell(7);
celle.style.background = "#FFFFFF";
celle.style.border = "none";
var slett = document.createElement("img");
slett.src = "gfx/slett.png";
slett.style.background = "#FFFFFF";
slett.style.width = "11px";
slett.style.height = "11px";
slett.style.border = "none";
slett.style.padding = "5px";
slett.id = "slett" + html("antRader");
slett.onclick = function(){
var id = this.id;
id = id.split("slett");
slettRad(id[1]);
}
celle.appendChild(slett);
}
function slettRad(i){
document.getElementById('vaktlistetabell').deleteRow(i);
var antall = html("antRader");
antall++;
for(j=i;j<=antall;j++){
if(document.getElementById("slett"+j) != null){
var div = document.getElementById("slett"+j);
id = "slett"+(j-1);
div.id = id;
}
}
minusId();
}
function lastSide(){
var dato = document.getElementById("aktuellDato").value;
var url = location.href;
url = url.split("?");
location.href= url[0]+"?dato="+dato;
}
function forrigeDag(){
var dag = "<?php
$tab = explode("-", $_GET['dato']);
$inputDate = ($_GET['dato']=="")?time():mktime(0,0,0,$tab[1],$tab[0], $tab[2]);
echo date("d-m-Y", strtotime('-1 day', $inputDate)); ?>"
var url = location.href;
url = url.split("?");
location.href= url[0]+"?dato="+dag;
}
function nesteDag(){
var dag = "<?php
$tab = explode("-", $_GET['dato']);
$inputDate = ($_GET['dato']=="")?time():mktime(0,0,0,$tab[1],$tab[0], $tab[2]);
echo date("d-m-Y", strtotime('+1 day', $inputDate)); ?>"
var url = location.href;
url = url.split("?");
location.href= url[0]+"?dato="+dag;
}
function oppdaterId(){
oppdaterHiddenfelt();
var antall = html("antRader");
if(antall == "0"){
antall = 1;
}else antall++;
settHTML("antRader", antall);
}
function oppdaterTotalId(){
var totaltAnt = html("raderLaget");
if(totaltAnt == "0"){
totaltAnt = 1;
}else totaltAnt++;
settHTML("raderLaget", totaltAnt);
}
function minusId(){
var antall = html("antRader");
antall--;
settHTML("antRader", antall);
return antall;
}
function value(id){
return document.getElementById(id).value;
}
function html(id){
return document.getElementById(id).innerHTML;
}
function settVerdi(id, verdi){
document.getElementById(id).value = verdi;
}
function settHTML(id, verdi){
document.getElementById(id).innerHTML = verdi;
}
function oppdaterHiddenfelt(){
var antall = value("hiddenAntRader");
if(antall == "0" || antall == ""){
antall = 1;
}
else antall++;
settVerdi("hiddenAntRader", antall);
return antall;
}
function sok(){
var sokeord = value("sokefelt");
var currentTime = new Date();
getFromServer("sokVaktliste.php?ord="+sokeord+"&time="+currentTime.getTime(), visResultat);
}
function visResultat(XHR){
document.getElementById('light').style.display='block';
document.getElementById('fade').style.display='block';
var url = location.href;
url = url.split("?");
var div = document.getElementById('light');
var html = "";
if(XHR.responseText != "-1"){
//location.href= url[0]+"?dato="+dag;
var datoArray = XHR.responseText.split(":");
if(datoArray.length >1){
for(i = 0;i<datoArray.length; i++){
html = html + "<p style='text-align: center;'><a href='"+url[0]+"?dato="+datoArray[i]+"' style='color: #6D929B;'>"+datoArray[i]+"</a></p>";
}
}
}else{
html = "<p style='text-align: center;'><a href='"+url[0]+"' style='color: #6D929B;'>Det finnes dessverre ingen treff</a></p>";
}
div.innerHTML = html;
}
function visOverlapp(){
document.getElementById('light2').style.display='block';
document.getElementById('fade2').style.display='block';
var div = document.getElementById('light2');
var html = '<a href = "javascript:void(0)" style="position:absolute; border: none; top: 0; right: 0;" onclick = "document.getElementById(\'light2\').style.display=\'none\';document.getElementById(\'fade2\').style.display=\'none\'"><img src="gfx/slett.png" width="16" height="16" style="border: none;"/></a>';
var html = html+ "<p style='font-size: 20px; font-weight: 700;' class='info'> Overlappende vakter</p>";
div.innerHTML = html;
}
function sjekkOmEnter(evt){
var charCode = (evt.which) ? evt.which : event.keyCode;
if(charCode == 13){
sok();
}
}
function sjekkDobbelVakt(navn, id){
var antallRader = html("raderLaget");
idTall = id.substr(4);
for(i=0;i<=antallRader;i++){
if(document.getElementById("navn"+i) != null){
var navnX = document.getElementById("navn"+i);
navnet = navnX.value
if(navnet == navn && navnX.id != id){
var overlapp = false;
var inn = document.getElementById("inn"+i).value;
var inn2 = document.getElementById("inn"+idTall).value;
var ut = document.getElementById("ut"+i).value;
var ut2 = document.getElementById("ut"+idTall).value;
if(ut2<ut && ut2>inn) { overlapp = true; }
if(inn2<ut && inn2>inn) { overlapp = true; }
//if(inn2<inn && ut2>ut) { alert("3"); overlapp = true; }
if(inn2==inn && ut2>inn2) { overlapp = true; }
//if(inn<inn2 && ut>ut2) { alert("overlapp4"); overlapp = true; }
/*if(ut2> && ut2>inn) overlapp = true;
if(ut2<ut && ut2>inn) overlapp = true;
if(ut2<ut && ut2>inn) overlapp = true;*/
if(overlapp== true){
visOverlapp();
}
}
}
}
}
function finnAnsattNrForNavn(id){
var currentTime = new Date();
var number = id.split("navn");
var IndexValue = eval("document.vaktlisteForm.navn"+number[1]+".selectedIndex");
var SelectedVal = eval("document.vaktlisteForm.navn"+number[1]+".options[IndexValue].value");
getFromServer("vaktlisteAjax.php?navn="+SelectedVal+"&rad="+number[1]+"&time="+currentTime.getTime(), skiftAnsattnr);
}
function skiftAnsattnr(XHR){
var tab = XHR.responseText.split("-");
var IndexValue = tab[0];
id = "ansattnr"+tab[1];
var tabellLengde = <?php echo sizeof($nummer); ?>;
for(i = 0;i<tabellLengde;i++){
var e = eval("document.vaktlisteForm."+id+".options["+i+"].value");
if(eval("document.vaktlisteForm."+id+".options["+i+"].value") == IndexValue){
var y = eval("document.vaktlisteForm."+id);
y.selectedIndex = i;
}
}
}
function finnNavnForAnsattnr(id){
var currentTime = new Date();
var number = id.split("ansattnr");
var IndexValue = eval("document.vaktlisteForm.ansattnr"+number[1]+".selectedIndex");
var SelectedVal = eval("document.vaktlisteForm.ansattnr"+number[1]+".options[IndexValue].value");
getFromServer("vaktlisteAjax.php?nummer="+SelectedVal+"&rad="+number[1]+"&time="+currentTime.getTime(), skiftNavn);
}
function skiftNavn(XHR){
var tab = XHR.responseText.split("-");
var IndexValue = tab[0];
id = "navn"+tab[1];
var tabellLengde = <?php echo sizeof($navn); ?>;
for(i = 0;i<tabellLengde;i++){
var e = eval("document.vaktlisteForm."+id+".options["+i+"].value");
if(eval("document.vaktlisteForm."+id+".options["+i+"].value") == IndexValue){
var y = eval("document.vaktlisteForm."+id);
y.selectedIndex = i;
}
}
}
</script>
</head>
<body onLoad="finnDagForDato('<?php if(isset($_GET['dato'])) echo $_GET['dato']; else echo date("d-m-Y"); ?>')" style="background-image:none;">
<div id="light" class="white_content"><a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">Close</a></div>
<div id="fade" class="black_overlay"></div>
<div id="light2" class="white_content"><a href = "javascript:void(0)" onclick = "document.getElementById('light2').style.display='none';document.getElementById('fade2').style.display='none'">Close</a></div>
<div id="fade2" class="black_overlay"></div>
<div id="antRader" style="visibility:hidden;">0</div>
<div id="fortidVarsel" style="position:absolute; font-size:16px; font-weight:bold; color:#990000;"><?php if($fortid) echo "Fortid!"; ?></div>
<div id="raderLaget" style="visibility:hidden;">0</div>
<div id="lagreBeskjed" style="position:absolute; left:350px; top:225px; width: 200px; height: 200px; border:solid 1px #6D929B; display:none; background-color:#CCCCCC; z-index: 1500;">
<span style="font-size:24px; color: #6D929B; text-align:center;">Lagring vellykket!</span>
<div id="lukkLagreBeskjed" onclick="toggleLayer('lagreBeskjed')" style="position:absolute; bottom:0px; width:198px; border-top: #999999 solid 1px; height:20px; background-image: url('gfx/bg_header.jpg'); text-align:center; cursor:pointer; border:solid 1px #999999;" ><img src="gfx/hake.png" /></div>
</div>
<div id="vaktliste">
<div id="sokefeltDiv" style="position:absolute; left: 350px; top: 25px;">
<input id="sokefelt" name="sokefelt" type="text" value="Søk" width="150px" onkeydown="sjekkOmEnter(event)" />
<a href = "javascript:void(0)" onclick = "sok()">
<img onclick="sok()" src="gfx/sok.png" width="18" height="18" style="position:relative; padding-left: 6px; margin-bottom: -3px; border:none;"/>
</a>
</div>
<form name="vaktlisteForm" id="vaktlisteForm" action="?lagreVakt=1" method="post">
<input type="hidden" id="hiddenAntRader" name="hiddenAntRader" />
<div id="spesieltDiv" style="position:absolute; left:375px; top:70px; width:auto; height: auto; display:none; z-index: 1000; background-color:#FFFFFF; border:solid 1px #999999;">
<textarea name="spesielt" id="spesielt" rows="5" cols="10" style="border:hidden; height:126px; width: 246px; overflow:auto; padding:2px;" ><?php echo $spesielt; ?> </textarea>
<div id="lukkSpesieltDiv" onclick="toggleLayer('spesieltDiv')" style="position:absolute; bottom:0px; width:150px; border-top: #999999 solid 1px; height:20px; background-image: url('gfx/bg_header.jpg'); text-align:center; cursor:pointer; margin-left:179px; border:solid 1px #999999;" ><img src="gfx/hake.png" /></div>
</div>
<div id="notaterDiv" style="position:absolute; left:470px; top:70px; width:auto; height: auto; display:none; z-index: 1000; background-color:#FFFFFF; border:solid 1px #999999;">
<textarea name="notater" id="notater" rows="5" cols="10" style="border:hidden; height:126px; width: 246px; overflow:auto; padding:2px;" ><?php echo $notater; ?> </textarea>
<div id="lukkNotaterDiv" onclick="toggleLayer('notaterDiv')" style="position:absolute; bottom:0px; width:150px; border-top: #999999 solid 1px; height:20px; background-image: url('gfx/bg_header.jpg'); text-align:center; cursor:pointer; margin-left:179px; border:solid 1px #999999;" ><img src="gfx/hake.png" /></div>
</div>
<div id="budsjettDiv" style="position:absolute; left:565px; top:70px; width:250px; height: 100px; display:none; z-index: 1000; background-color:#FFFFFF; border:solid 1px #999999;">
<input type="text" name="budsjett" value="<?php echo $budsjett; ?>" style="position:absolute;height:20px; width: 150px; overflow:auto; top:25px; left:50px; background: url('gfx/kr.png') no-repeat right;" ></input>
<div id="aarsbudsjett" style="position:absolute; right: 10px; top: 2px; cursor:pointer; color:#0066FF;" onclick="window.open('budsjett.php','newWin','width=400,height=500')">årsbudsjett</div>
<div id="lukkBudsjettDiv" onclick="toggleLayer('budsjettDiv')" style="position:absolute; bottom:0px; width:250px; border-top: #999999 solid 1px; height:22px; background-image: url('gfx/bg_header.jpg'); text-align:center; cursor:pointer;" ><img src="gfx/hake.png" /></div>
</div>
<div id="omsetningDiv" style="position:absolute; left:660px; top:70px; width:250px; height: 100px; display:none; z-index: 1000; background-color:#FFFFFF; border:solid 1px #999999;">
<input type="text" name="omsetning" value="<?php echo $omsetning; ?>" style="position:absolute;height:18px; width: 150px; overflow:auto; top:25px; left:50px; background: url('gfx/kr.png') no-repeat right;" > </input>
<div id="lukkOmsetningDiv" onclick="toggleLayer('omsetningDiv')" style="position:absolute; bottom:0px; width:250px; border-top: #999999 solid 1px; height:22px; background-image: url('gfx/bg_header.jpg'); text-align:center; cursor:pointer;" ><img src="gfx/hake.png" /></div>
</div>
<table id="overst" cellspacing="0" cellpadding="0" rules="none" frame="box" border="0">
<tr>
<td width='400px' align='left' style="color:#666666;"> Vaktliste</td>
<td width="400px" style="text-align:right; color:#999999; padding: 0px; margin: 0px;"><span class="tidOgDato"></span><script language="javascript" src="js/liveclock.js"></script></td>
</tr>
</table>
<div style="position:absolute; padding:0; margin:0; border: width: 400px; height: 20px;">
<div id="forrige" onclick="forrigeDag()" style="position:absolute; left:30px; width:20px; height: 20px; cursor:pointer; z-index:100;"><span style="color:#6D929B;"><<</span></div>
<div id="neste" onclick="nesteDag()" style="position:absolute; left:155px; width:20px; height: 20px; cursor:pointer; z-index:100;"><span style="color:#6D929B;">>></span></div>
</div>
<br />
<table id="notiserTabell" class="vaktliste" border="0" bordercolor="#FFFFFF" rules="none" frame="box" cellpadding="0" cellspacing="0">
<tr>
<td id="dato" height="30px" width="210px" class="notiser">Dato<?php if($_SESSION['community_statusVaktliste'] == 'vaktliste'){ ?> <input onchange="lastSide()" type="text" name="aktuellDato" id="aktuellDato" style="background:url('gfx/calendar.png') no-repeat right;" /><?php }else {?> <input type="text" name="aktuellDato" id="aktuellDato" value=<?php echo date("d.m.Y");?> /><?php } ?></td>
<td height="30px" width="210px" class="notiser">Ukedag: <span id="ukedag" style="color:#000000; font-size:16px; font-weight:500;"></span></td>
<td id="spesielt" height="30px" width="94px" class="notiser2"><span onmousedown="visDiv('spesielt')" style="cursor:pointer;"> Events<img src="gfx/endre.png"/></span></td>
<td id="notat" height="30px" width="94px" class="notiser2"><span onmousedown="visDiv('notater')" style="cursor:pointer;">Notater <img src="gfx/endre.png"/></span></td>
<td id="budsjett" height="30px" width="92px" class="notiser2"><span onmousedown="visDiv('budsjett')" style="cursor:pointer;">Budsjett <img src="gfx/endre.png"/></span></td>
<td id="omsetning" height="30px" width="92px" class="notiser2"><span onmousedown="visDiv('omsetning')" style="cursor:pointer;">Omsetning <img src="gfx/endre.png"/></span></td>
</tr>
</table>
<table id="vaktlistetabell" width="820" name="vaktlistetabell" cellpadding="0" cellspacing="0" style="padding: 0px;">
<tr>
<th scope="col" width="120px" class="nobg">Navn</th>
<th scope="col" width="80px">ANS.NR</th>
<th scope="col" width="60px" >Inn</th>
<th scope="col" width="60px" >Ut</th>
<th scope="col"><img src="gfx/tidslinje.png" /></th>
<th scope="col" width="60px" >Lunch</th>
<th scope="col" width="90px" >Sykefravær</th>
</tr>
<?php
$fargetLinje = true;
$x = 0;
$rader = sizeof($navnVakt);
?>
<?php
if($rader == 0) $rader = 1;
for($i=0;$i<$rader;$i++){
?><script>oppdaterHiddenfelt(); oppdaterId(); if(0 != <?=$i;?>)oppdaterTotalId();</script><?php
if($i==0) $fargetLinje = true;
else{
if($i % 2 == 1){
$fargetLinje = false;
}
else $fargetLinje = true;
}
?>
<tr <?php if($x==0){ ?> style="color:#B4AA9D; background: #F5FAFA;" <?php } ?> >
<td width="120px" style="text-align:right;">
<select name="navn<?php echo $i; ?>" id="navn<?php echo $i; ?>" style="width: 118px; border: hidden; text-align:left;" onchange="javascript: sjekkDobbelVakt(this.value, this.id); finnAnsattNrForNavn(this.id)">
<?php foreach($navn as $key => $value){ ?>
<option value="<?php echo $value; ?>" <?php if($value==$navnVakt[$i]) echo " selected"; ?>><?php echo $value; ?></option>
<?php } ?>
</select></td>
<td <?php if($x==0){ ?> style="color:#B4AA9D; background: #F5FAFA; text-align:right;" <?php } ?> width="80x" style="text-align:right;">
<select name="ansattnr<?php echo $i; ?>" id="ansattnr<?php echo $i; ?>" style="width: 80px; text-align:center;" onchange="finnNavnForAnsattnr(this.id)"><?php foreach($nummer as $key => $value){ ?>
<option value="<?php echo $value; ?>" <?php if($value==$nummerVakt[$i]) echo " selected";?>><?php echo $value; ?></option> <?php } ?>
</select>
</td>
<td <?php if($x==0){ ?> style="color:#B4AA9D; background: #F5FAFA; text-align: right;" <?php } ?> width="60px" style="text-align: right;">
<select name="inn<?php echo $i; ?>" id="inn<?php echo $i;?>" style="width: 60px;" onchange="lagDiv(<?php echo $i; ?>)">
<?php for($j=0;$j<48;$j++){
if($fraBase) $selected = ($tider[$j]==$innVakt[$i])?" selected":"";
else $selected = ($tider[$j]=="12:00")?" selected":"";
echo "<option value=".$tider[$j]."".$selected.">".$tider[$j]."</option>";
}?>
</select></td>
<td <?php if($x==0){ ?> style="color:#B4AA9D; background: #F5FAFA; width: 60px; text-align:right; padding-right: 0px;" <?php } ?> width="60px" style="padding-right: 0px;text-align:right;">
<select name="ut<?php echo $i; ?>" id="ut<?php echo $i;?>" style="width: 60px; padding-right: 0px; text-align:center;" onchange="lagDiv(<?php echo $i; ?>)">
<?php for($j=0;$j<48;$j++){
if($fraBase) $selected = ($tider[$j]==$utVakt[$i])?" selected":"";
else $selected = ($tider[$j]=="12:00")?" selected":"";
echo "<option value=".$tider[$j]."".$selected.">".$tider[$j]."</option>";
}?></select></td>
<td><div id="rad<?php echo $i; ?>" style="position: relative; margin: 0px; padding: 0px; height: 20px;" /></td>
<td <?php if($x==0){ ?> style="color:#B4AA9D; background: #F5FAFA; text-align:right;" <?php } ?> width="62px" style="text-align:right;"><div id="lunchDiv<?php echo $i; ?>" onmouseover="musOverBakgrunn('lunchDiv<?php echo $i; ?>')" onClick="toggleCheckbox('lunchbox<?php echo $i; ?>')" onmouseout="musUt('lunchDiv<?php echo $i; ?>')" height="20px" width="62px"><?php if($_SESSION['community_statusVaktliste'] == 'vaktliste'){ ?><input id="lunchbox<?php echo $i; ?>" type="checkbox" onClick="toggleCheckbox('lunchbox<?php echo $i; ?>')" name="<?php echo "lunchbox".$i;?>"
<?php if($lunchVakt[$i]=="ja") echo " checked"; ?> /><?php } else echo "logginn";?></div></td>
<td <?php if($x==0){ ?> style="color:#B4AA9D; background: #F5FAFA; text-align:right;" <?php } ?> width="90px" style="text-align:right;"><div id="sykDiv<?php echo $i; ?>" onmouseover="musOverBakgrunn('sykDiv<?php echo $i; ?>')" onClick="toggleCheckbox('sykbox<?php echo $i; ?>')" onmouseout="musUt('sykDiv<?php echo $i; ?>')" height="20px" width="90px"><?php if($_SESSION['community_statusVaktliste'] == 'vaktliste'){ ?><input id="sykbox<?php echo $i; ?>" type="checkbox" onClick="toggleCheckbox('sykbox<?php echo $i; ?>')" name="<?php echo "sykbox".$i; ?>" <?php if($sykVakt[$i]=="ja") echo " checked"; ?> /> <?php }else echo "logg inn";?></div></td>
<td onclick="slettRad(<?php echo $i+1; ?>)" id="slett<?php echo $i+1?>" style="background:#FFFFFF; border:none; padding:5px;"><img src="gfx/slett.png" width="11px" height="11px"/></td>
</tr>
<?php $x = ($x==1)?0:1;} ?>
</table>
<?php if($_SESSION['community_statusVaktliste'] == 'vaktliste'){ ?>
<div id="buttonsDiv" style="position:absolute; width: 795px; height: 50px;">
<input type="submit" value="lagre" style="position:absolute; right:10px; top:10px; background:url('gfx/lagre.png') no-repeat right; width: 120px; height: 30px; text-align:left; border: 1px solid #C1DAD7; color: #6D929B; font-size: 13px; font-weight: bold; font-family: "microsoft Sans Serif";"/>
<img src="gfx/add.png" onclick="leggTilRad()" style=" cursor:pointer;position:absolute; border:none; left: 10px; top:10px"/>
</div>
</form>
<?php } ?>
<script>
for(o=0;o<<?php echo (sizeof($navnVakt)); ?>; o++){
lagDiv(o);
}
</script>
<?php if(!(isset($_GET['dato'])) && !(isset($_GET['lagreVakt']))){?>
<script>
var datofelt = document.getElementById("aktuellDato");
datofelt.value = "<?php echo date("d-m-Y"); ?>";
</script>
<?php } ?>
</div>
<a href="#" onclick="window.print()" style="position:absolute; right: 10px; bottom:10px; color:#0033FF; border-bottom: 0px none; border-color:#FFFFFF;">Skriv ut <img src="gfx/action_print.gif" border="0"/></a>
<script type="text/javascript">
/*<[CDATA[*/
var dpck2 = new DatePicker({
relative : 'aktuellDato',
language : 'no',
keepFieldEmpty : true,
disableFutureDate : false,
dateFormat : [ ["dd", "mm", "yyyy"], "-" ]
});
/*]]>*/
</script>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And if you don't mind, can you host a bugged version of the page that I can report to the WebKit developers?
I'll post a ticket in the WebKit trac.
I'll post a ticket in the WebKit trac.
ASKER
Hi, thanks alot for helping me with this problem, it solved my problem, but i discovered it could actually be easier than that. i think the problem was in the tineMC, where you have to name which textarea should be altered, and this code was on the top, when the textareas haven not yet been created.
so i put the tinyMC code at the bottom of the file
tinyMCE.init({
theme : "advanced",
mode: "exact",
elements : "spesielt, notater", //HERE I THINK THE PROBLEM IS
.........
do you agree, or do you think there is another reason? it works this way anyway.
the bugged version is at the same url, but renamed to vaktliste2.php
Thanks alot for your help, you saved my day:)
regards
Stian
so i put the tinyMC code at the bottom of the file
tinyMCE.init({
theme : "advanced",
mode: "exact",
elements : "spesielt, notater", //HERE I THINK THE PROBLEM IS
.........
do you agree, or do you think there is another reason? it works this way anyway.
the bugged version is at the same url, but renamed to vaktliste2.php
Thanks alot for your help, you saved my day:)
regards
Stian
ASKER
thanks, excellent work!
ASKER
wanted to write a little summary of what the problem was.. the problem was javascript trying to alter/change html-objects that didn't exist yet. It could be solved with delaying the javascript, or moving the javascript at the bottom of the file. At least this is what i think the problem was:)
Does this only occur in Safari? What other browsers have you tried? What version of the browsers?
The code in the snippet will probably not be very helpful. The html source would be more helpful.
bol