Benutzer:J*/vector.js: Unterschied zwischen den Versionen

aus Kamelopedia, der wüsten Enzyklopädie
Zur Navigation springen Zur Suche springen
K (-debug, +Formatierung)
K
 
(20 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
 
/* für's Bürokratenspiel */
 
/* für's Bürokratenspiel */
function bksp ()
+
/*function bksp ()
 
{
 
{
 
if (wgPageName.indexOf("Projekt:Bürokratenspiel") != -1 )
 
if (wgPageName.indexOf("Projekt:Bürokratenspiel") != -1 )
Zeile 9: Zeile 9:
 
}
 
}
 
}
 
}
addOnloadHook(bksp);
+
addOnloadHook(bksp);*/
  
 
/* Zusammenfassungs-Warnung */
 
/* Zusammenfassungs-Warnung */
Zeile 55: Zeile 55:
 
}
 
}
  
 +
/* Bt-extras-bibliothek */
 +
function bt_extras_load () {
  
/* Zeug für die Buschtrommel */
+
        console.log("Hallo");
  
function serialize (obj)
+
/* --- prepare --- */
{
+
 
if (obj == null)
+
/* dbcheat */
return "z";
+
 
 +
if (window.bt_extra_dbcheat == null)
 +
window.bt_extra_dbcheat = false;
  
switch (typeof obj)
+
/* --- add ui --- */
{
 
case "string":
 
return "s"+escape(obj);
 
break;
 
case "number":
 
return "n"+escape(String(obj));
 
break;
 
case "object":
 
var arr = [];
 
for (var k in obj)
 
{
 
arr.push(serialize(k) + "=" + serialize(obj[k]));
 
}
 
if (obj instanceof Array)
 
return "a"+escape(arr.join("&"));
 
else
 
return "o"+escape(arr.join("&"));
 
break;
 
default:
 
throw "Cannot serialize " + (typeof obj) + " type.";
 
}
 
}
 
  
function deserialize (str)
+
jQuery("#buschtrommel-eingabe .options").append("<br/>")
{
+
jQuery("#buschtrommel-eingabe .options").append("<span id='bt-extra-dbcheat'>Drumbot austricksen: </span><span id='bt-extra-show-dbcheat'>ein</span> ")
var type = str[0];
+
jQuery("#buschtrommel-eingabe .options").append("&nbsp;&nbsp; ")
var data = str.substr(1);
+
jQuery("#buschtrommel-eingabe .options").append("<span id='bt-extra-jaja'>Jaja-ich-habs-gesehen</span>")
  
switch(type)
+
/* --- add functionality --- */
{
 
case "z":
 
return null;
 
break;
 
case "s": //string
 
return unescape(data);
 
break;
 
case "n": //number
 
if (data == "Infinity")
 
return Infinity;
 
else if (data == "-Infinity")
 
return -Infinity;
 
else
 
return parseInt(unescape(data));
 
break;
 
case "a": // Array
 
case "o": //Object
 
var ret = {};
 
if (type == "a")
 
ret = [];
 
  
var pairs = unescape(data).split("&");
+
/* jaja */
for (var i=0; i<pairs.length; i++)
 
{
 
var kv = pairs[i].split("=");
 
ret[deserialize(kv[0])] = deserialize(kv[1]);
 
}
 
return ret;
 
break;
 
default:
 
throw "Cannot deserialize " + type + " type."
 
}
 
}
 
  
if (wgPageName=="Spezial:KamelBox")
+
jQuery("#bt-extra-jaja").click( function () {
{
+
document.title = "–⚑–";
addOnloadHook( function () {
+
})
jQuery("#buschtrommel").append("<div id='buschtrommel-log'/>");
 
var oldPrepare = prepare;
 
prepare = function (j)
 
{
 
if (window.log)
 
window.log(j);
 
return oldPrepare(j);
 
}
 
});
 
}
 
  
chatLog = {log:[]};
 
loadChatLog();
 
  
function saveChatLog ()
+
/* dbcheat */
{
 
document.cookie = "kpChatLog="+serialize(chatLog.log);
 
}
 
  
function loadChatLog ()
+
var toggleDBCheat = function () {
{
+
window.bt_extra_dbcheat = ! window.bt_extra_dbcheat;
chatLog.current = null;
+
jQuery("#bt-extra-show-dbcheat").text(window.bt_extra_dbcheat ?"ein":"aus");
var cookie = document.cookie.match(/(^|;)\s*kpChatLog=([^;]+);/);
 
try
 
{
 
if (cookie != null)
 
chatLog.log = deserialize(cookie[2]);   
 
else
 
throw 1;
 
 
}
 
}
catch (e)
 
{
 
chatLog.log = [];
 
}
 
}
 
  
function log (d)
+
// init
{
+
window.bt_extra_dbcheat = (! window.bt_extra_dbcheat);
if (chatLog.log.length > 0 && parseInt(chatLog.log[chatLog.log.length-1].last_ts) >= parseInt(d.time) )
+
toggleDBCheat();
{
 
// do not log as it is already logged
 
// switch to append mode
 
chatLog.current = chatLog.log[chatLog.log.length-1];
 
listChatLogs();
 
return;
 
}
 
else if (chatLog.current == null || chatLog.log.length == 0)
 
{
 
// init
 
chatLog.current = {data: []};
 
chatLog.log.push(chatLog.current);
 
}
 
  
chatLog.current.last_ts = d.time;
+
jQuery("#bt-extra-dbcheat").click(toggleDBCheat);
chatLog.current.data.push(d);
 
saveChatLog();
 
listChatLogs();
 
}
 
  
function showChatLog(idx)
+
jQuery("#buschtrommel-form").submit( function() {
{
+
if (!window.bt_extra_cheatDrumbot)
str = "";
+
return true;
var entries = chatLog.log[idx].data;
 
for (var i in entries)
 
{
 
str += prepareLog(entries[i]);
 
}
 
newwin = window.open();
 
newwin.document.write(str);
 
}
 
  
function listChatLogs ()
+
var bti = jQuery("#buschtrommel-input")[0];
{
+
bti.value = bti.value.replace("o","ο");
jQuery("#buschtrommel-log").empty();
+
return true;
for(var i in chatLog.log)
+
});
{
 
var time = new Date();
 
time.setTime(chatLog.log[i].data[0].time);
 
var showButton = jQuery("<input type='button' onclick='showChatLog("+parseInt(i)+")' value='Anzeigen'>");
 
var deleteButton = jQuery("<input type='button' onclick='deleteChatLog("+parseInt(i)+")' value='Löschen'>");
 
var container = jQuery("<div/>");
 
container.append(time.toLocaleString());
 
container.append(showButton);
 
container.append(deleteButton);
 
jQuery("#buschtrommel-log").append(container);
 
}
 
}
 
  
function deleteChatLog(i)
 
{
 
chatLog.log.splice(i,1);
 
saveChatLog();
 
loadChatLog();
 
listChatLogs();
 
 
}
 
}
  
// fast unverändert aus der Kamelbox kopiert
+
//jQuery("body.mw-special-Buschtrommel").load(bt_extras_load);
function prepareLog(response)
+
window.setTimeout(bt_extras_load,"3000");
{
 
var d = new Date();
 
d.setTime(response.time);
 
var currentHours  = ( d.getHours() < 10 ? "0" : "" ) + d.getHours();
 
var currentMinutes = ( d.getMinutes() < 10 ? "0" : "" ) + d.getMinutes();
 
var mytime = currentHours+':'+currentMinutes;
 
if (mytime != oldmytime) {
 
oldmytime = mytime;
 
} else {
 
mytime = "<span style='color:#aaa;'>≀</span>" ;
 
};
 
var tempnick = response.nickname;
 
var tempnick2 = " '@"+response.nickname+" '";
 
if (tempnick.length > 16)  {
 
tempnick = tempnick.substr(0, 16)+"~"
 
}
 
if ((tempnick != '&nbsp;') && (tempnick != wgUserName ) ){
 
var nick = '<span style="color:#00137F; cursor:pointer;" onclick="document.Trommel.message.value += '+tempnick2+';document.Trommel.message.focus()" title="Nachricht an '+response.nickname+'">'+tempnick+'</span>';
 
} else if (tempnick == wgUserName ){
 
nick = '<span style="color:#7F0000;">'+tempnick+'</span>';
 
} else {
 
var nick = '&nbsp;'  ;
 
 
var checkkamel = response.message;
 
var kamel = wgUserName+" ";
 
var kamel2 = wgUserName+":";
 
if ((checkkamel.indexOf (kamel) != -1 || checkkamel.indexOf (kamel2) != -1) && tempnick != '&nbsp;' ) {
 
var string = '<table width="100%" cellspacing="0" cellpadding="0" class="buschtrommel-list">'
 
+ '<tr><td width="35px" class="buschtrommel-list-time" valign="top" align="right">'+mytime+'</td>'
 
+ '<td width="115px" style="text-align:right;" class="buschtrommel-kamelname" valign="top">'+nick+'</td>'
 
+ '<td class="buschtrommel-list-message"  valign="top"><span style="background-color:#FFFF00;border:1px solid #FFFF00;border-radius:.5em;">'+response.message+'</span></td>'
 
+'</tr></table>';
 
} else {
 
var string = '<table width="100%" cellspacing="0" cellpadding="0" class="buschtrommel-list">'
 
+ '<tr><td width="35px" class="buschtrommel-list-time" valign="top" align="right">'+mytime+'</td>'
 
+ '<td width="115px" style="text-align:right;" class="buschtrommel-kamelname" valign="top">'+nick+'</td>'
 
+ '<td class="buschtrommel-list-message" style="padding-left:.3em;" valign="top">'+response.message+'</td>'
 
+'</tr></table>';
 
}
 
if (tempnick == "&nbsp;") {
 
tempnick="";
 
};
 
 
 
if (tempnick.indexOf("&" != -1)) {
 
tempnick = tempnick.replace(/&Auml;/g, "Ä");
 
tempnick = tempnick.replace(/&auml;/g, "ä");
 
tempnick = tempnick.replace(/&ouml;/g, "ö");
 
tempnick = tempnick.replace(/&Ouml;/g, "Ö");
 
tempnick = tempnick.replace(/&uuml;/g, "ü");
 
tempnick = tempnick.replace(/&Uuml;/g, "Ü");
 
tempnick = tempnick.replace(/&szlig;/g, "ß");
 
}
 
return string;
 
}
 

Aktuelle Version vom 22. Mai 2015, 06:50 Uhr

/* für's Bürokratenspiel */
/*function bksp ()
{
	if (wgPageName.indexOf("Projekt:Bürokratenspiel") != -1 )
	{
		var t = wgTitle.split("/");
		var e = (wgAction = "edit") ? "$ " : "";
		document.title = t[t.length-1];
	}
}
addOnloadHook(bksp);*/

/* Zusammenfassungs-Warnung */

addOnloadHook( function () {
	jQuery("#wpSummary, #wpTextbox1").bind("keypress", function() {
		jQuery("#wpSummary").css("background-color","#ffffff");
		try {
			clearInterval(summaryWarnInterval);
			summaryWarnInterval = null;
		}
		catch (e) {}
		summaryWarnState = -1;
	});

	jQuery("#editform").bind("submit", function (e) {

		if ( e.originalEvent.explicitOriginalTarget != jQuery("#wpSave")[0] )
			return true;

		if (! jQuery("#wpSummary").val().replace(/^\s+/,"").replace(/\s+$/,"").replace(/\/\*.*?\*\//,"") && summaryWarnState == -1)
		{
                        jQuery("#wpSummary").focus();
			summaryWarnInterval = window.setInterval(summaryWarn,70);
			return false;
		}

		return true;
	});
});

summaryWarnState = -1;
summaryWarnInterval = null;

function summaryWarn() 
{
	summaryWarnState ++;
	if (summaryWarnState % 2 == 0)
		jQuery("#wpSummary").css("background-color","#ffff99");
	else
		jQuery("#wpSummary").css("background-color","#ffffff");

	if (summaryWarnState > 11)
		clearInterval(summaryWarnInterval);
}

/* Bt-extras-bibliothek */
function bt_extras_load () {

        console.log("Hallo");

	/* --- prepare --- */

	/* dbcheat */

	if (window.bt_extra_dbcheat == null)
		window.bt_extra_dbcheat = false;

	/* --- add ui --- */

	jQuery("#buschtrommel-eingabe .options").append("<br/>")
	jQuery("#buschtrommel-eingabe .options").append("<span id='bt-extra-dbcheat'>Drumbot austricksen: </span><span id='bt-extra-show-dbcheat'>ein</span> ")
	jQuery("#buschtrommel-eingabe .options").append("&nbsp;&nbsp; ")
	jQuery("#buschtrommel-eingabe .options").append("<span id='bt-extra-jaja'>Jaja-ich-habs-gesehen</span>")

	/* --- add functionality --- */

	/* jaja */

	jQuery("#bt-extra-jaja").click( function () {
		document.title = "–⚑–";
		})


	/* dbcheat */

	var toggleDBCheat = function () {
	window.bt_extra_dbcheat = ! window.bt_extra_dbcheat;
	jQuery("#bt-extra-show-dbcheat").text(window.bt_extra_dbcheat ?"ein":"aus");
	}

	// init
	window.bt_extra_dbcheat = (! window.bt_extra_dbcheat);
	toggleDBCheat();

	jQuery("#bt-extra-dbcheat").click(toggleDBCheat);

	jQuery("#buschtrommel-form").submit( function() {
		if (!window.bt_extra_cheatDrumbot)
			return true;

		var bti = jQuery("#buschtrommel-input")[0];
		bti.value = bti.value.replace("o","ο");
		return true;
	});

}

//jQuery("body.mw-special-Buschtrommel").load(bt_extras_load);
window.setTimeout(bt_extras_load,"3000");