Difference between revisions of "MediaWiki:Common.js"

From MunichBeerGardens.com
Jump to: navigation, search
m
m
Line 9: Line 9:
 
  };
 
  };
  
/* start rotating banner */
 
/* Banner 160x600 */
 
/* Add image and URL in array and upload/protect image and preload
 
  (first letter or image name must be capitalised) */
 
  
/* define the images directory including trailing slash */
+
/* emulate sticky CSS
var beergarden_banner_dir = '/images/beer/';
+
if (document.getElementById('p-Matched_content') !=null) {
 
+
window.onscroll = function() { 
var beergarden_banners = new Array("Muhlenpark_01.jpg",
+
var header_height = document.getElementById("p-Matched_content").scrollHeight;
                                  "Aujaeger_03.jpg",
+
if (window.scrollY + 330 > header_height){
                                  "Aujaeger_04_en.jpg",
+
document.getElementById("p-Matched_content").style.position="fixed";
                                  "Alter_Wirt_Etterschlag_01.jpg",
+
document.getElementById("p-Matched_content").style.top="0px";
                                  "Kneissl_04.jpg",
 
                                  "Hofbrauhaus_Keller_Freising_03.jpg",
 
                                  "Zur_Einkehr_03.jpg");
 
 
 
/*
 
 
 
Quick workaround without UTF8 aware redirect: Set up page with ASCII and create
 
a js-link and wiki redirect page, e.g.: Biergarten_Muehlenpark REDIRECT [[Biergarten_Mühlenpark]]
 
alternatively and easier, by-pass the redirect page and don't log clicks
 
 
 
*/
 
 
 
 
var beergarden_links = new Array("/admin/munichbeergardens.com/redirect.cgi?url=/Biergarten_Muehlenpark",
 
                                "/Aujäger",
 
                                "/Aujäger",
 
                                "/Alter_Wirt_Etterschlag",
 
                                "/Räuber-Kneißl-Garten",
 
                                "/admin/munichbeergardens.com/redirect.cgi?url=/Hofbrauhaus-Keller_Freising",
 
                                "/admin/munichbeergardens.com/redirect.cgi?url=/Rothmeyer%27s_Zur_Einkehr");
 
 
 
function start_animation(){
 
setTimeout('beergarden_blender()',15000); /* 15 second */
 
 
}
 
}
 
+
else{
beergarden_banner1 = new Image(160,600);
+
document.getElementById("p-Matched_content").style.position="static";
beergarden_banner1.src = beergarden_banner_dir + "Muhlenpark_01.jpg";
 
 
 
beergarden_banner2 = new Image(160,600);
 
beergarden_banner2.src = beergarden_banner_dir + "Aujaeger_03.jpg";
 
 
 
beergarden_banner3 = new Image(160,600);
 
beergarden_banner3.src = beergarden_banner_dir + "Aujaeger_04_en.jpg";
 
 
 
beergarden_banner4 = new Image(160,600);
 
beergarden_banner4.src = beergarden_banner_dir + "Alter_Wirt_Etterschlag_01.jpg";
 
 
 
beergarden_banner5 = new Image(160,600);
 
beergarden_banner5.src = beergarden_banner_dir + "Kneissl_04.jpg";
 
 
 
beergarden_banner6 = new Image(160,600);
 
beergarden_banner6.src = beergarden_banner_dir + "Zur_Einkehr_03.jpg";
 
 
 
beergarden_banner7 = new Image(160,600);
 
beergarden_banner7.src = beergarden_banner_dir + "Hofbrauhaus_Keller_Freising_03.jpg";
 
 
 
 
 
function beergarden_swap(){
 
opacity = 0;
 
IE_opacity = 0;
 
 
 
if (navigator.appVersion.indexOf("MSIE") != -1){
 
document.getElementById("blendinger").style.filter = "alpha(opacity=0)";
 
interval = setInterval("blendinger_IE()",50)
 
 
 
 
}
 
}
else {
 
document.getElementById("blendinger").style.opacity=0;
 
interval = setInterval("blendinger_opacity()",50)
 
 
}
 
}
 
}
 
}
  
function blendinger_IE(){
+
if (document.getElementById('p-advertisement') !=null) {
if (IE_opacity < 100){
+
window.onscroll = function() {
IE_opacity = IE_opacity +4;
+
var header_height = document.getElementById("p-advertisement").scrollHeight;
document.getElementById("blendinger").style.filter = "alpha(opacity="+IE_opacity+")";
+
if (window.scrollY + 330 > header_height){
 
+
document.getElementById("p-advertisement").style.position="fixed";
 +
document.getElementById("p-advertisement").style.top="0px";
 
}
 
}
 
 
else{
 
else{
clearInterval(interval);
+
document.getElementById("p-advertisement").style.position="static";
IE_count = 0;
 
 
}
 
}
 
}
 
}
 +
}
 +
*/
  
function blendinger_opacity(){
 
 
if (opacity < 1){
 
opacity = (Math.floor(opacity * 100) +4) / 100;
 
document.getElementById("blendinger").style.opacity=opacity;
 
  
 +
/* GDPR */
 +
 +
if (window.addEventListener)
 +
{
 +
window.addEventListener('load', run_onload, false);
 
}
 
}
else{
 
clearInterval(interval);
 
  
 +
function run_onload(){
 +
GDPR_state_value = "undecided";
 +
if (GDPR_state_value == "undecided"){
 +
undecided();
 
}
 
}
 +
 
}
 
}
  
var beergarden_array_index = beergarden_links.length -1;
+
function undecided(){
var first_beergarden_index = Math.round(beergarden_array_index * Math.random())
 
 
 
var beergarden_cycle = first_beergarden_index;
 
var beergarden_total = beergarden_banners.length -1;
 
var beergarden_link = beergarden_links[beergarden_cycle]; /* initially the first */
 
  
function beergarden_blender(){
+
var GDPR_table_undecided = document.createElement("table");
 +
GDPR_table_undecided.setAttribute("id","GDPR_table_undecided");
 +
var GDPR_row = document.createElement("tr");
 +
var GDPR_cell = document.createElement("td");
  
/* first set current image as background */
+
var GDPR_reject_button = document.createElement("span");
 +
GDPR_reject_button.setAttribute("id","GDPR_reject_button");
 +
GDPR_reject_button.style.cursor="pointer";
 +
GDPR_reject_button.appendChild(document.createTextNode("REJECT COOKIES"));
  
document.getElementById('background_image').style.backgroundImage='url('+beergarden_banner_dir+beergarden_banners[beergarden_cycle]+')';
+
var GDPR_accept_button = document.createElement("span");
 +
GDPR_accept_button.setAttribute("id","GDPR_accept_button");
 +
GDPR_accept_button.style.cursor="pointer";
 +
GDPR_accept_button.appendChild(document.createTextNode("ACCEPT COOKIES"));
  
beergarden_cycle++;
+
GDPR_table_undecided.appendChild(GDPR_row);
 +
GDPR_row.appendChild(GDPR_cell);
  
if (beergarden_cycle == beergarden_banners.length){
+
GDPR_cell.appendChild(GDPR_reject_button);
beergarden_cycle = 0;
+
GDPR_cell.appendChild(GDPR_accept_button);
}
 
 
beergarden_swap();
 
  
setTimeout("document.images.beergarden_animation.src=beergarden_banner_dir + beergarden_banners[beergarden_cycle];",10)
+
document.body.appendChild(GDPR_table_undecided);
             
 
beergarden_link = beergarden_links[beergarden_cycle] /* update link values */
 
 
}
 
  
/* end rotaing banner */
+
GDPR_table_undecided.style.width="100%";
 +
GDPR_table_undecided.style.border="1px dashed blue";
 +
GDPR_table_undecided.style.textAlign="center";
 +
GDPR_table_undecided.style.position="fixed";
 +
GDPR_table_undecided.style.bottom="0";
 +
GDPR_reject_button.style.border="1px solid green";
 +
GDPR_accept_button.style.border="1px solid green";
 +
GDPR_table_undecided.style.verticalAlign="middle"; /* some old IE convention */
  
  
 
/* emulate sticky CSS */
 
if (document.getElementById('p-Matched_content') !=null) {
 
window.onscroll = function() { 
 
var header_height = document.getElementById("p-Matched_content").scrollHeight;
 
if (window.scrollY + 330 > header_height){
 
document.getElementById("p-Matched_content").style.position="fixed";
 
document.getElementById("p-Matched_content").style.top="0px";
 
}
 
else{
 
document.getElementById("p-Matched_content").style.position="static";
 
}
 
}
 
}
 
 
if (document.getElementById('p-advertisement') !=null) {
 
window.onscroll = function() { 
 
var header_height = document.getElementById("p-advertisement").scrollHeight;
 
if (window.scrollY + 330 > header_height){
 
document.getElementById("p-advertisement").style.position="fixed";
 
document.getElementById("p-advertisement").style.top="0px";
 
}
 
else{
 
document.getElementById("p-advertisement").style.position="static";
 
}
 
}
 
 
}
 
}

Revision as of 09:33, 23 June 2023

/* Any JavaScript here will be loaded for all users on every page load. */

//setTimeout("alert('test')",10000);

//document.getElementsByTagName('body')[0].style.margin = '110px';

var RecaptchaOptions = {
    theme : 'white'
 };


/* emulate sticky CSS
if (document.getElementById('p-Matched_content') !=null) {
window.onscroll = function() {  
var header_height = document.getElementById("p-Matched_content").scrollHeight;
if (window.scrollY + 330 > header_height){
document.getElementById("p-Matched_content").style.position="fixed";
document.getElementById("p-Matched_content").style.top="0px";
}
else{
document.getElementById("p-Matched_content").style.position="static";
}
}
}

if (document.getElementById('p-advertisement') !=null) {
window.onscroll = function() {  
var header_height = document.getElementById("p-advertisement").scrollHeight;
if (window.scrollY + 330 > header_height){
document.getElementById("p-advertisement").style.position="fixed";
document.getElementById("p-advertisement").style.top="0px";
}
else{
document.getElementById("p-advertisement").style.position="static";
}
}
}
*/


/* GDPR */

if (window.addEventListener)
{
window.addEventListener('load', run_onload, false);
}

function run_onload(){
GDPR_state_value = "undecided";
if (GDPR_state_value == "undecided"){
undecided();
}

}

function undecided(){

var GDPR_table_undecided = document.createElement("table");
GDPR_table_undecided.setAttribute("id","GDPR_table_undecided");
var GDPR_row = document.createElement("tr");
var GDPR_cell = document.createElement("td");

var GDPR_reject_button = document.createElement("span");
GDPR_reject_button.setAttribute("id","GDPR_reject_button");
GDPR_reject_button.style.cursor="pointer";
GDPR_reject_button.appendChild(document.createTextNode("REJECT COOKIES"));

var GDPR_accept_button = document.createElement("span");
GDPR_accept_button.setAttribute("id","GDPR_accept_button");
GDPR_accept_button.style.cursor="pointer";
GDPR_accept_button.appendChild(document.createTextNode("ACCEPT COOKIES"));

GDPR_table_undecided.appendChild(GDPR_row);
GDPR_row.appendChild(GDPR_cell);

GDPR_cell.appendChild(GDPR_reject_button);
GDPR_cell.appendChild(GDPR_accept_button);

document.body.appendChild(GDPR_table_undecided);

GDPR_table_undecided.style.width="100%";
GDPR_table_undecided.style.border="1px dashed blue";
GDPR_table_undecided.style.textAlign="center";
GDPR_table_undecided.style.position="fixed";
GDPR_table_undecided.style.bottom="0";
GDPR_reject_button.style.border="1px solid green";
GDPR_accept_button.style.border="1px solid green";
GDPR_table_undecided.style.verticalAlign="middle"; /* some old IE convention */


}