MediaWiki:Skin/Projekt:Adventure2/lib.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
J* (Diskussion | Beiträge) |
J* (Diskussion | Beiträge) |
||
Zeile 31: | Zeile 31: | ||
a2.log("Fire", event); | a2.log("Fire", event); | ||
var e = a2.events; | var e = a2.events; | ||
− | for( | + | for(i in e) |
if (e[i]) | if (e[i]) | ||
− | for( | + | for(j in e[i]) |
e[i][j](); | e[i][j](); | ||
}; | }; |
Version vom 6. Juli 2012, 19:21 Uhr
// A2lib
a2 = {};
a2.events = {};
a2.clearScope = function clearScope(sc) {
delete a2.events[sc];
};
a2.registerEventHandler = function registerEventHandler(e) {
if (!a2.events[e.scope])
a2.events[e.scope]={};
if (!a2.events[e.scope][e.trigger])
a2.events[e.scope][e.trigger] = [];
a2.events[e.scope][e.trigger].push(function(){
a2.log("run", e.name);
if (e.condition())
e.action();
});
};
if (console && console.log)
a2.log = console.log;
else
a2.log = function () {return;};
a2.fireEvent = function fireEvent (event) {
a2.log("Fire", event);
var e = a2.events;
for(i in e)
if (e[i])
for(j in e[i])
e[i][j]();
};
a2.loadPage = function loadPage(n){
response = $.ajax({
url: "/index.php/Kamel:J*/Test2/"+n+"?action=render",
async: false
});
$("#a2image").html(response.responseText);
console.log($("#a2image a"));
$("#a2image area").click(function (ev) {
a2.fireEvent("click."+ev.target.hash.substr(1));
return false;
});
};