משתמש:גיא/monobook.js
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
- אופרה: ללחוץ על Ctrl-F5.
/* <pre><nowiki> */
var year = 2007; //YYYY
var month = 03; //MM
var day = 04; //DD
var hour = 16; //HH
var minute = 30; //MM
var second = 00; //SS
function EnforceWikiBreak() {
var currentdate = new Date();
var enforced_break_end = new Date(year,changemonth(),day,hour,minute,second);
if (currentdate > enforced_break_end) {
// alert ("ברוך השב!");
} else {
alert ("חופשה מאולצת עד " + enforced_break_end.toLocaleString() + " (כעת " + currentdate.toLocaleString() + "). להתראות!");
window.location.href = ("http://"+document.location.host+"/w/index.php?title=Special:Userlogout&returnto=Main_Page");
}
}
function changemonth() {
//thing to subtract 1 from the month. you can't use month-1 because it removes the '0' from the front
if(month==01) return 00;
if(month==02) return 01;
if(month==03) return 02;
if(month==04) return 03;
if(month==05) return 04;
if(month==06) return 05;
if(month==07) return 06;
if(month==08) return 07;
if(month==09) return 08;
if(month==10) return 09;
if(month==11) return 10;
if(month==12) return 11;
return 00;
}
$(function() { EnforceWikiBreak(); });
/* </nowiki></pre> */
// Add date and time to your monobook "personal menu" list at the very top of the page.
// Created by [[User:Mathwiz2020]]
// Indicate where you would like the time to appear:
// 1 is first (before username), 2 is second (before talk link), ... 7 is last (after log out link)
insertBeforeNum = 7;
// Do NOT edit below this line unless you're experiened in javascript
insertBeforeArr = new Array("","pt-userpage","pt-mytalk","pt-preferences","pt-watchlist","pt-mycontris","pt-logout","");
insertBefore = insertBeforeArr[insertBeforeNum];
function makeTime()
{
var li = document.createElement( 'li' );
li.id = 'pt-time';
var mySpan = document.createElement( 'span' );
mySpan.appendChild( document.createTextNode( 'date and time' ) );
li.appendChild( mySpan );
if ( insertBefore )
{
var before = document.getElementById( insertBefore );
before.appendChild( li, before );
}
else // append to end (right) of list
{
document.getElementById( 'pt-logout' ).parentNode.appendChild( li );
}
getTime();
}
if ( window.addEventListener ) window.addEventListener ( 'load', makeTime, false );
else if ( window.attachEvent ) window.attachEvent ( 'onload', makeTime );
function getTime()
{
var time = new Date();
var hours = '0' + time.getUTCHours();
hours = hours.substr(hours.length-2, hours.length);
hours = eval(hours + ' + 2');
if (hours==24) { hours = 00; }
if (hours==25) { hours = 01; }
var minutes = '0' + time.getUTCMinutes();
minutes = minutes.substr(minutes.length-2, minutes.length);
var seconds = '0' + time.getUTCSeconds();
seconds = seconds.substr(seconds.length-2, seconds.length);
var curTime = ' ' + hours + ":" + minutes + ":" + seconds + ' ';
datePlace = document.getElementById('pt-time').childNodes[0].childNodes[0];
datePlace.replaceData(0, datePlace.length, curTime);
doTime = window.setTimeout("getTime()", 1000);
}