MediaWiki:Common.js

From Camp_2015_Wiki
Revision as of 11:05, 6 August 2015 by Nexus (talk | contribs)
Jump to: navigation, search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/** 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>';
  var villageCalendar = document.getElementById("villagecalendar");
  villageCalendar.style.display = 'block';
  switchLink.style.display = 'block';
  localStorage.setItem("villagecalender_open", "yes");
}

function closeCalendar() {
  var switchLink = document.getElementById("showvillagecalendar");
  switchLink.innerHTML = '<a href="#calendar" name="#calendar" onClick="openCalendar();">show calendar</a>';
  var villageCalendar = document.getElementById("villagecalendar");
  villageCalendar.style.display = 'none';
  switchLink.style.display = 'block';
  localStorage.setItem("villagecalender_open", "no");
}

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

window.setTimeout(prepareCalendar, 1000);