MediaWiki:Skin/Projekt:Adventure2/lib.js: Unterschied zwischen den Versionen

aus Kamelopedia, der wüsten Enzyklopädie
Zur Navigation springen Zur Suche springen
K
Zeile 8: Zeile 8:
 
};
 
};
  
a2.registerEventHandler = function registerEventHandler(sc,tr,co,ac) {
+
a2.registerEventHandler = function registerEventHandler(e) {
    if (!a2.events[sc])
 
        a2.events[sc]={};
 
  
     if (!a2.events[sc][tr])
+
     if (!a2.events[e.scope])
         a2.events[sc][tr] = [];
+
         a2.events[e.scope]={};
  
     a2.events[sc][tr].push(function(){if (co()) ac();});
+
     if (!a2.events[e.scope][e.trigger])
 +
        a2.events[e.scope][e.trigger] = [];
 +
 
 +
    a2.events[e.scope][e.trigger].push(function(){if (e.condition()) e.action();});
 
};
 
};
  

Version vom 6. Juli 2012, 18:34 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(){if (e.condition()) e.action();});
};

a2.fireEvent = function fireEvent (event) {
    var e = a2.events;
    for(var i=0; i<e.length; i++)
        if (e[i])
            for(var j=0; j<e[i].length; j++)
                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;
    });
};