Benutzer:J*/Ka-Mel-Oh/Testgelände/Notizzettel: Unterschied zwischen den Versionen

aus Kamelopedia, der wüsten Enzyklopädie
Zur Navigation springen Zur Suche springen
(Neuer Abschnitt: UI)
Zeile 234: Zeile 234:
  
 
wiki.parse.start( { wiki: {title:"Test", source:"{{Bild}}"} }, ready )
 
wiki.parse.start( { wiki: {title:"Test", source:"{{Bild}}"} }, ready )
 +
-->
 +
 +
== UI ==
 +
 +
<!--
 +
dragger = {
 +
    item: null,
 +
    const: {pickupPrecision: 10, dropPrecision: 30},
 +
    object: {
 +
        original: {x: NaN, y: NaN},
 +
        current: {x: NaN, y:NaN}
 +
    },
 +
    pointer: {
 +
        original: {x: NaN, y:NaN},
 +
        current: {x: NaN, y:NaN}
 +
    },
 +
    handler: { klick: null, drag: null, drop: null },
 +
    dropzones: [ ],
 +
    pickup: function (e) {
 +
        if (dragger.item != null)
 +
            return;
 +
        dragger.object.original.x = this.offsetLeft;
 +
        dragger.object.original.y = this.offsetTop;
 +
        dragger.pointer.original.x = dragger.pointer.current.x;
 +
        dragger.pointer.original.y = dragger.pointer.current.y;
 +
        dragger.item=this;
 +
        return false;
 +
    },
 +
    mouseMove: function (e) {
 +
        dragger.pointer.current.x = document.all ? window.event.clientX : e.pageX;
 +
        dragger.pointer.current.y = document.all ? window.event.clientY : e.pageY;
 +
        if (dragger.item != null)
 +
        {
 +
            dragger.drag();
 +
        }
 +
    },
 +
    drag: function () {
 +
        dragger.object.current.y = dragger.object.original.y + dragger.pointer.current.y - dragger.pointer.original.y;
 +
        dragger.object.current.x = dragger.object.original.x + dragger.pointer.current.x - dragger.pointer.original.x;
 +
        dragger.item.style.top = dragger.object.current.y + "px";
 +
        dragger.item.style.left = dragger.object.current.x + "px";
 +
    },
 +
    drop: function () {
 +
        if ( Math.abs(dragger.object.original.x - dragger.object.current.x) < dragger.const.pickupPrecision &&
 +
            Math.abs(dragger.object.original.y - dragger.object.current.y) < dragger.const.pickupPrecision )
 +
        {
 +
            dragger.item.style.top = dragger.object.original.y + "px";
 +
            dragger.item.style.left = dragger.object.original.x + "px";
 +
            var d = dragger.item;
 +
            dragger.item = null;
 +
            if ( dragger.handler.klick != null )
 +
                dragger.handler.klick( d ) 
 +
        }
 +
       
 +
        dragger.item = null;
 +
    }
 +
}
 +
 +
document.onmousemove = dragger.mouseMove;
 +
document.onmouseup = dragger.drop;
 +
 +
for(c=0;c<(l=document.getElementsByClassName("handcard").length);c++)
 +
{
 +
    document.getElementsByClassName("handcard")[c].onmousedown = dragger.pickup;
 +
}
 
-->
 
-->

Version vom 23. Februar 2009, 20:31 Uhr


Framework: Array.prototype und Async

Klassenarchitektur der Karten

Wiki-Klasse

Achtung, wichtig: Umstellen auf api.php und JSON:

http://kamelopedia.mormo.org/api.php?format=jsonfm&indexpageids&action=query&prop=revisions&titles=Hauptseite&rvprop=ids%7Cflags%7Ctimestamp%7Cuser%7Ccontent%7Ccomment

... und dann den Timestamp zum Schreiben benutzen (vorher .replace(/[^0-9]/g, "")!)

UI