|
|
| Zeile 1: |
Zeile 1: |
| var wiki = {
| |
| /*
| |
| * getSource: fragt wiki nach Seitenquelltexten
| |
| * Argumente und Rückgabewerte als Objekt:
| |
| * objekt.wiki.title = Seitentitel (benötigtes Argument)
| |
| * objekt.wiki.source = Seitenquelltext (Rückgabewert)
| |
| * objekt.wiki.args = Seitenargumente
| |
| */
| |
| getSource: new Async([
| |
| function ( args ) {
| |
| if (args == null)
| |
| args = {};
| |
| if (args.wiki == null)
| |
| args.wiki = {};
| |
|
| |
|
| jQuery.ajax( {
| |
| url: wgServer+wgScript,
| |
| data: 'action=raw&title='+encodeURIComponent(args.wiki.title)+'&'+args.wiki.args,
| |
| dataType: "text",
| |
| context: window,
| |
| success: function( transport ) { args.wiki.source = transport; wiki.getSource.continue(args) },
| |
| error: function() { args.wiki.source = null; wiki.getSource.continue( args ) }
| |
| })
| |
| },
| |
| null
| |
| ]),
| |
| /*
| |
| * getHTML: fragt wiki nach gerenderten Seiten
| |
| * Argumente und Rückgabewerte als Objekt:
| |
| * objekt.wiki.title = Seitentitel (benötigtes Argument)
| |
| * objekt.wiki.HTML = SeitenHTML (Rückgabewert)
| |
| * objekt.wiki.args = Seitenargumente
| |
| */
| |
| getHTML: new Async([
| |
| function ( args ) {
| |
| if (args == null)
| |
| args = {};
| |
| if (args.wiki == null)
| |
| args.wiki = {};
| |
|
| |
| jQuery.ajax( {
| |
| url: wgServer+wgScript,
| |
| data: 'action=render&title='+encodeURIComponent(args.wiki.title)+'&'+args.wiki.args,
| |
| dataType: "html",
| |
| context: window,
| |
| success: function( transport ) { args.wiki.HTML = transport; wiki.getHTML.continue(args) },
| |
| error: function() { args.wiki.HTML = null; wiki.getHTML.continue( args ) }
| |
| })
| |
| },
| |
| null
| |
| ]),
| |
| /*
| |
| * parse: lässt Wiki beliebigen Wiki-Quelltext rendern
| |
| * Argumente und Rückgabewerte als Objekt:
| |
| * objekt.wiki.source = Quelltext (benötigtes Argument)
| |
| * objekt.wiki.title = Seitentitel (für {{PAGENAME}} oder ähnliches)
| |
| * objekt.wiki.HTML = SeitenHTML (Rückgabewert)
| |
| */
| |
| parse: new Async([
| |
| function ( args ) {
| |
| if (args == null)
| |
| args = {};
| |
| if (args.wiki == null)
| |
| args.wiki = {};
| |
|
| |
| jQuery.ajax( {
| |
| url: wgServer+"/api.php",
| |
| data: 'action=parse&format=xml&text='+encodeURIComponent(args.wiki.source)+"&title="+encodeURIComponent(args.wiki.title),
| |
| datatype: "text",
| |
| context: window,
| |
| success: function( transport ) { args.wiki.HTML = transport; wiki.parse.continue(args) },
| |
| error: function() { args.wiki.HTML = null; wiki.parse.continue( args ) }
| |
| })
| |
| },
| |
| null
| |
| ])
| |
| };
| |