Difference between revisions of "MediaWiki:Common.js"

From MunichBeerGardens.com
Jump to: navigation, search
m
m
Line 19: Line 19:
 
function accept_cookies(){
 
function accept_cookies(){
  
/* if GDPR_table_rejected exists, remove it  
+
/* if GDPR_table_rejected exists, remove it */
 
let GDPR_table_rejected = document.getElementById("GDPR_table_rejected");
 
let GDPR_table_rejected = document.getElementById("GDPR_table_rejected");
 
if (typeof(GDPR_table_rejected) !== 'undefined' && GDPR_table_rejected!== null){
 
if (typeof(GDPR_table_rejected) !== 'undefined' && GDPR_table_rejected!== null){
 
GDPR_table_rejected.remove();
 
GDPR_table_rejected.remove();
 
}
 
}
*/
 
  
 
var GDPR_cookie = "GDPR=accepted";
 
var GDPR_cookie = "GDPR=accepted";
Line 109: Line 108:
 
console.log("undecided");
 
console.log("undecided");
 
console.log("accepted block");
 
console.log("accepted block");
console.log("hid let");
+
console.log("add let");
 
}
 
}
  

Revision as of 11:37, 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'
 };


/* GDPR */

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

function accept_cookies(){

/* if GDPR_table_rejected exists, remove it */
let GDPR_table_rejected = document.getElementById("GDPR_table_rejected");
if (typeof(GDPR_table_rejected) !== 'undefined' && GDPR_table_rejected!== null){
GDPR_table_rejected.remove();
}

var GDPR_cookie = "GDPR=accepted";

var GDPR_year = new Date(); // create date
GDPR_year.setFullYear(GDPR_year.getFullYear() +1) // add 1 year from now
var GDPR_end = "expires=" + GDPR_year.toGMTString() + ";path=/; samesite=strict";  // make endcookie and path variable


document.cookie = GDPR_cookie + ";" + GDPR_end;
console.log("Added cookie: " + document.cookie);

accepted();

}


function run_onload(){

GDPR_state_value = "undecided";

if(document.cookie.indexOf("GDPR") != -1){

var state_pos = document.cookie.indexOf("GDPR=");
var state_start = state_pos + 5;
var state_end =  state_start + 8;
GDPR_state_value = document.cookie.substring(state_start,state_end);
console.log(GDPR_state_value);
console.log(document.cookie);
}

if (GDPR_state_value == "accepted"){
accepted();
}

if (GDPR_state_value == "rejected"){
rejected();
}


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 */

console.log("undecided");
console.log("accepted block");
console.log("add let");
}

function remove_GDPR_cookie(){
console.log("Removed cookie: " + document.cookie);
document.cookie = "GDPR=; expires=Thu, 18 Dec 2013 12:00:00 UTC; path=/; samesite=strict";

}