Difference between revisions of "MediaWiki:Common.js"

From Camp_2015_Wiki
Jump to: navigation, search
 
Line 19: Line 19:
 
   var switchLink = document.getElementById("showvillagecalendar");
 
   var switchLink = document.getElementById("showvillagecalendar");
 
   switchLink.innerHTML = '<a href="#calendar" name="#calendar" onClick="closeCalendar();">hide calendar</a>';
 
   switchLink.innerHTML = '<a href="#calendar" name="#calendar" onClick="closeCalendar();">hide calendar</a>';
 +
  switchLink.style.display = 'block';
 +
 
   var villageCalendar = document.getElementById("villagecalendar");
 
   var villageCalendar = document.getElementById("villagecalendar");
   villageCalendar.style.display = 'block';
+
   villageCalendar.style.visibility = 'visible';
   switchLink.style.display = 'block';
+
   villageCalendar.style.position = 'relative';
 +
 
 
   localStorage.setItem("villagecalender_open", "yes");
 
   localStorage.setItem("villagecalender_open", "yes");
 
}
 
}
Line 28: Line 31:
 
   var switchLink = document.getElementById("showvillagecalendar");
 
   var switchLink = document.getElementById("showvillagecalendar");
 
   switchLink.innerHTML = '<a href="#calendar" name="#calendar" onClick="openCalendar();">show calendar</a>';
 
   switchLink.innerHTML = '<a href="#calendar" name="#calendar" onClick="openCalendar();">show calendar</a>';
 +
  switchLink.style.display = 'block';
 +
 
   var villageCalendar = document.getElementById("villagecalendar");
 
   var villageCalendar = document.getElementById("villagecalendar");
   villageCalendar.style.display = 'none';
+
   villageCalendar.style.visibility = 'hidden';
   switchLink.style.display = 'block';
+
   villageCalendar.style.position = 'absolute';
 +
 
 
   localStorage.setItem("villagecalender_open", "no");
 
   localStorage.setItem("villagecalender_open", "no");
 
}
 
}

Latest revision as of 11:09, 6 August 2015

/** assings congress date information to body tag **/
function setupCalendar() {
  var bodyTag = null;
  try {
    bodyTag = document.getElementsByTagName("body")[0];
    bodyTag.year = 2015;
    bodyTag.month = 8;
    bodyTag.days = [13, 14, 15, 16, 17];
    return bodyTag;
  } catch(e) {
    return null;
  }
}

console.log("setup calendar dates");
var body = setupCalendar();

function openCalendar() {
  var switchLink = document.getElementById("showvillagecalendar");
  switchLink.innerHTML = '<a href="#calendar" name="#calendar" onClick="closeCalendar();">hide calendar</a>';
  switchLink.style.display = 'block';

  var villageCalendar = document.getElementById("villagecalendar");
  villageCalendar.style.visibility = 'visible';
  villageCalendar.style.position = 'relative';

  localStorage.setItem("villagecalender_open", "yes");
}

function closeCalendar() {
  var switchLink = document.getElementById("showvillagecalendar");
  switchLink.innerHTML = '<a href="#calendar" name="#calendar" onClick="openCalendar();">show calendar</a>';
  switchLink.style.display = 'block';

  var villageCalendar = document.getElementById("villagecalendar");
  villageCalendar.style.visibility = 'hidden';
  villageCalendar.style.position = 'absolute';

  localStorage.setItem("villagecalender_open", "no");
}

function prepareCalendar() {
  var opened = localStorage.getItem("villagecalender_open");
  if (opened == "yes") {
    openCalendar();
  } else {
    closeCalendar();
  }
}

window.setTimeout(prepareCalendar, 1000);