MediaWiki:Global.js: Difference between revisions

From Wiki Grepolis EN
Jump to navigation
No edit summary
No edit summary
 
Line 3: Line 3:
var anunt_curent
var anunt_curent
var anunt_timer, hint_timer;
var anunt_timer, hint_timer;
function ch_hints() {
  var hint_nr=Math.round(Math.random()*45);
  $("#grepo_nl_hints").slideUp("slow");
  hint_nr++;
  $.get("/index.php",{title:"Overleg:FAQ",action:"raw",section:hint_nr}, function(response,succes) {
      if (succes) {
      resp= "__NOEDITSECTION__" + response
      $.get("/api.php",{action:"parse",text:resp,format:"xml"},function(xresp,succ) {
          if (succ) {
              $("#grepo_nl_hints").html(xresp.getElementsByTagName("text")[0].childNodes[0].nodeValue);
          }
      },"xml");
      };
},"html");
  $("#grepo_nl_hints").slideDown("slow");
}




Line 31: Line 48:
   }
   }
   if ((wgAction != "edit") && (wgCanonicalNamespace != "Special") && (wgCanonicalNamespace != "Template") && (wgCanonicalNamespace != "Help") && (wgCanonicalNamespace != "Project") && (wgCanonicalNamespace != "File") && (wgTitle != "Global.js") && (wgTitle != "Overleg:FAQ") ) {
   if ((wgAction != "edit") && (wgCanonicalNamespace != "Special") && (wgCanonicalNamespace != "Template") && (wgCanonicalNamespace != "Help") && (wgCanonicalNamespace != "Project") && (wgCanonicalNamespace != "File") && (wgTitle != "Global.js") && (wgTitle != "Overleg:FAQ") ) {
$("#content").before("<div style='clear:both'></div><div id='grepo_nl_hints_container' style='padding: 10px 15px; background: url(&quot;/skins/grepolis/content_bg.jpg&quot;) repeat scroll 0% 0% transparent; width: 772px; min-height:1px; text-align: center;'> <span id='grepo_nl_hints' style='width:80%'></span></div>");
$("#content").before("<div style='clear:both'></div><div id='grepo_nl_hints_container' style='padding: 10px 15px; background: url(&quot;/skins/grepolis/content_bg.jpg&quot;) repeat scroll 0% 0% transparent; width: 772px; min-height:100px; text-align: center;'><a title='Close' href='#' id='grepo_nl_close_hints'><img style='float:right; height:20px; width:20px;' src='http://wiki.nl.grepolis.com/images/a/ab/Sluiten.png'/></a><img id='grepo_nl_hints_image' style='position:relative; float:right; height:75px; width:75; top:35px; left:0px;' src='http://wiki.nl.grepolis.com/images/5/56/Vraagteken.png' alt='Instructions' /> <span id='grepo_nl_hints' style='width:80%'></span></div>");
   ch_hints();
   ch_hints();
   hint_timer=window.setInterval("ch_hints()",30000);
   hint_timer=window.setInterval("ch_hints()",30000);
Line 45: Line 62:
   }
   }
    
    
/* Any JavaScript here will be loaded for all users on every page load. */
  if ((wgTitle == "Global.js") && (wgAction != "edit") && (wgAction != "history") && (wgAction != "historysubmit")) {
// Old Global.js.
    $("#bodyContent").html("<p>Deze pagina is gesloten!</p><p>Team <a href='http://nl.grepolis.com'>Grepolis.nl</a>!</p>");
// Rewrite of announcement display. (by Menidan)
    }
$ (function () {
// Changes the announcement to the next announcement in the list.
function changeAnnouncement () {
$ (announcementList [currentAnnouncement]).fadeOut ("normal", function () {
++currentAnnouncement;
if (currentAnnouncement >= announcementList.length)
currentAnnouncement = 0;
$ (announcementList [currentAnnouncement]).fadeIn ();
});
}
 
var announcementList = $ (".announcement");
var currentAnnouncement = 0;
var announcementVisibilityTime = 5000; // ms
 
announcementList.hide ();
if (announcementList.length > 1) {
$ (announcementList [0]).fadeIn ();
setInterval (changeAnnouncement, announcementVisibilityTime);
} else if (announcementList.length > 0)
announcementList.fadeIn ();
 
 
// Piwik is undefined -> comment it out.
/*
try {
var piwikTracker = Piwik.getTracker (pkBaseURL + "piwik.php", 2);
piwikTracker.trackPageView ();
piwikTracker.enableLinkTracking ();
} catch (err) {}
*/
});
 
// ?
var importScript_ = importScript;
 
 
// Makes the sidebar foldable (by Menidan)
var sidebar_settings = JSON.parse (localStorage.getItem ("sidebar_settings")) || {};
 
function save_sidebar () {
localStorage.setItem ("sidebar_settings", JSON.stringify (sidebar_settings));
}
 
function set_sidebar (id, folded) {
if (document.getElementById (id).parentElement.id != "column-one")
return;
if (folded)
sidebar_settings [id] = true;
else
delete sidebar_settings [id];
save_sidebar ();
}
 
var fold = "https://wiki.de.grepolis.com/images/7/7e/Einklappen.png";
var unfold = "https://wiki.de.grepolis.com/images/0/06/Ausklappen.png";
function sidebar_click (node) {
var content = $ (node.parentElement.lastElementChild);
if (content.css ("display") == "none") {
content.css ("display", "block");
node.firstElementChild.alt = "[-]";
node.firstElementChild.src = fold;
set_sidebar (node.parentElement.id, false);
} else {
content.css ("display", "none");
node.firstElementChild.alt = "[+]";
node.firstElementChild.src = unfold;
set_sidebar (node.parentElement.id, true);
}
return false;
}
 
var sidebar_links = $ ("#column-one .generated-sidebar.portlet h5").slice (1).replaceWith (function () {
if (! sidebar_settings [this.parentElement.id])
return $ ('<a href="#" style="text-align:center"><img src="' + fold + '" style="float:left" alt="[-]" /><h5>' + this.innerHTML + '</h5></a>').click (function () {
return sidebar_click (this);
});
 
$ (this.nextElementSibling).css ("display", "none");
return $ ('<a href="#" style="text-align:center"><img src="' + unfold + '" style="float:left" alt="[+]" /><h5>' + this.innerHTML + '</h5></a>').click (function () {
return sidebar_click (this);
});
});
 
 
// Halloween 2013 (by Menidan)
if (location.pathname == "/wiki/Halloween_2013_im_Wiki" && ! localStorage.getItem ("halloween-2013")) {
localStorage.setItem ("halloween-2013", "delete this entry to show the window again");
var overlay = $ ('<div></div>').appendTo (document.body);
overlay.css ({
"background-color": "black",
"background-position": "center",
"background-size": "contain",
"background-repeat": "no-repeat",
"background-attachment": "fixed",
"backgound-image": "url(/images/e/ea/Test.gif)",
position: "absolute",
left: 0,
right: 0,
top: 0,
bottom: 0,
"z-index": 10
});
overlay [0].style.backgroundImage = "url(/images/e/ea/Test.gif)";
$ (document.body).css ("overflow", "hidden");
 
var close_button = $ ('<a href="#"><img src="/images/7/75/Grepolis_Wiki_307.png" /></a>').appendTo (overlay).css ({
position: "absolute",
top: "10px",
right: "10px"
}).click (function () {
$ (document.body).css ("overflow", "");
overlay.remove ();
$ (audio).remove ();
});
 
var audio = $ ('<audio preload="preload" autostart="autostart"><source src="http://www.horror-grusel.de/horror0407/sounds/hexe.wav" /></audio>').appendTo (overlay) [0];
audio.addEventListener ("load", function () {
alert ("loaded");
audio.play ();
});
audio.addEventListener ("ended", function () {
setTimeout (function () {
audio.currentTime = 0;
audio.play ();
}, 1); // die 1 durch beliebige Anzahl an Millisekunden zwischen dem einzelnen Abspielen des Geräusches ersetzen
});
audio.load ();
audio.play ();
}
 
 
 
// Simple Culture Point Calculator (by Menidan)
(function () {
function is_right_page () {
if (location.pathname == "/wiki/Kulturpunkte")
return true;
if (location.pathname != "/index.php")
return false;
var query = location.search.substring (1).split ("&").map (function (s) { return s.split ("="); });
if (! query.find (function (s) { return s [0] == "title" && s [1] == "Kulturpunkte"; }))
return false;
return ! query.find (function (s) { return s [0] == "action" && s [1] != "view"; });
}
if (! is_right_page ())
return;


var table = $ ("table.wikitable");
var tr = $ ("<tr>").insertAfter (table.find ("tr:first"));
function level_from_points (points) { return Math.floor (3 / 2 + Math.sqrt (1 / 4 + 2 / 3 * points)); }
function points_from_level (level) { return Math.floor (3 / 2 * (level - 1) * (level - 2)); }
var level  = $ ('<input type="text" value="5" />').bind ("propertychange keyup input paste", function () {
points.val (points_from_level (level.val ()));
}).appendTo ($ ("<th>").appendTo (tr));
var points = $ ('<input type="text" value="18" />').bind ("propertychange keyup input paste", function () {
level.val (level_from_points (points.val ()));
}).appendTo ($ ("<th>").appendTo (tr));
}) ();


});
});

Latest revision as of 13:35, 26 November 2017

var anunt_list
var nr_anunturi
var anunt_curent
var anunt_timer, hint_timer;

function ch_hints() {
   var hint_nr=Math.round(Math.random()*45);
   $("#grepo_nl_hints").slideUp("slow");
   hint_nr++;
   $.get("/index.php",{title:"Overleg:FAQ",action:"raw",section:hint_nr}, function(response,succes) {
      if (succes) {
      resp= "__NOEDITSECTION__" + response
      $.get("/api.php",{action:"parse",text:resp,format:"xml"},function(xresp,succ) {
          if (succ) {
              $("#grepo_nl_hints").html(xresp.getElementsByTagName("text")[0].childNodes[0].nodeValue);
          }
      },"xml");
      };
},"html");
   $("#grepo_nl_hints").slideDown("slow");
}


function ch_anunt() {
        $(anunt_list[anunt_curent]).fadeOut("normal",function() {
             anunt_curent++;
             if (anunt_curent >= nr_anunturi) {
                 anunt_curent=0;
             }
             $(anunt_list[anunt_curent]).fadeIn();
        });
}


$(document).ready(function() {
   $(".Aankondiging_Hoofdpagina").hide();
   anunt_list = $(".Aankondiging_Hoofdpagina").toArray();
   nr_anunturi=anunt_list.length;
   anunt_curent=0;
  // console.info("a:"+anunt_list+"; nr:"+nr_anunturi);
   if (nr_anunturi > 1) {
       $(anunt_list[0]).fadeIn();
       anunt_timer=window.setInterval("ch_anunt()",5000);
   } else {
       if (nr_anunturi > 0) {
            $(".anunt_primapagina").fadeIn();
        }
   }
   if ((wgAction != "edit") && (wgCanonicalNamespace != "Special") && (wgCanonicalNamespace != "Template") && (wgCanonicalNamespace != "Help") && (wgCanonicalNamespace != "Project") && (wgCanonicalNamespace != "File") && (wgTitle != "Global.js") && (wgTitle != "Overleg:FAQ") ) {
$("#content").before("<div style='clear:both'></div><div id='grepo_nl_hints_container' style='padding: 10px 15px; background: url(&quot;/skins/grepolis/content_bg.jpg&quot;) repeat scroll 0% 0% transparent; width: 772px; min-height:100px; text-align: center;'><a title='Close' href='#' id='grepo_nl_close_hints'><img style='float:right; height:20px; width:20px;' src='http://wiki.nl.grepolis.com/images/a/ab/Sluiten.png'/></a><img id='grepo_nl_hints_image' style='position:relative; float:right; height:75px; width:75; top:35px; left:0px;' src='http://wiki.nl.grepolis.com/images/5/56/Vraagteken.png' alt='Instructions' /> <span id='grepo_nl_hints' style='width:80%'></span></div>");
   ch_hints();
   hint_timer=window.setInterval("ch_hints()",30000);
   $("#grepo_nl_close_hints").click(function() {
        hint_timer=window.clearInterval(hint_timer);
        $("#grepo_nl_hints").slideUp("slow", function() {
             $("#grepo_nl_close_hints").hide();
             $("#grepo_nl_hints_image").hide();
             $("#grepo_nl_hints_container").css("min-height","0px");
        });
   });
        
   }
   
   if ((wgTitle == "Global.js") && (wgAction != "edit") && (wgAction != "history") && (wgAction != "historysubmit")) {
     $("#bodyContent").html("<p>Deze pagina is gesloten!</p><p>Team <a href='http://nl.grepolis.com'>Grepolis.nl</a>!</p>");
    }


});