Benutzer:J*/lib/wiki.js: Unterschied zwischen den Versionen
< Benutzer:J* | lib
J* (Diskussion | Beiträge) temporär alles weg, bringt meinen Browser zum Absturz |
J* (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
| 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", | |||
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", | |||
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", | |||
success: function( transport ) { args.wiki.HTML = transport; wiki.parse.continue(args) }, | |||
error: function() { args.wiki.HTML = null; wiki.parse.continue( args ) } | |||
}) | |||
}, | |||
null | |||
]) | |||
}; | |||
Version vom 10. Oktober 2010, 21:38 Uhr
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",
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",
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",
success: function( transport ) { args.wiki.HTML = transport; wiki.parse.continue(args) },
error: function() { args.wiki.HTML = null; wiki.parse.continue( args ) }
})
},
null
])
};