//Wikiwyg4Docuwiki.js start
Wikiwyg.uri = function() {
    var uri=
        location.protocol + '//' + location.host + ':' + 
        location.port + '/wiki/doku.php';
//    if (! uri.match(/wikiwyg\.net/))
//        alert(\"This demo only works on wikiwyg.net\");
    return uri;
}
 
proto = new Subclass('Wikiwyg.ClientServer', 'Wikiwyg');
 
proto.saveChanges = function() {
    var self = this;
    this.current_mode.toHtml( function(html) { self.fromHtml(html) });
    this.displayMode();
}
 
proto.modeClasses = [
    'Wikiwyg.Wysiwyg',
    'Wikiwyg.Wikitext.ClientServer',
    'Wikiwyg.Preview'
];
    
proto = new Subclass('Wikiwyg.Wikitext.ClientServer', 'Wikiwyg.Wikitext');
 
proto.convertWikitextToHtml = function(wikitext, func) {
    var pageid=Wikiwyg.pageid();
    var pagerev='';
    var pagedate=Wikiwyg.pagedate();
    var pageprefix='';
    var pagesuffix='';
    var pagedo=Wikiwyg.pagedo();
    var dwpd = 'action='+pageid+'&rev='+pagerev+'&date='+pagedate+'&prefix='+pageprefix+'&suffix='+pagesuffix+'&do='+pagedo+'&wikitext=';
//    var postdata = 'action=wikiwyg_wikitext_to_html;content=' + 
    var postdata = dwpd + encodeURIComponent(wikitext);
    alert('Wikiwyg.uri()='+Wikiwyg.uri()+'\npostdata'+postdata);
    Wikiwyg.liveUpdate(
        'POST',
        Wikiwyg.uri(),
        postdata,
        func
    );
}
proto.config = Wikiwyg.Wikitext.prototype.config;
proto.config.markupRules.link = ['bound_phrase', '[[', ']]'];
proto.config.markupRules.bold = ['bound_phrase', '**', '**'];
proto.config.markupRules.code = ['bound_phrase', '\'\'', '\'\''];
proto.config.markupRules.italic = ['bound_phrase', '/', '/'];
proto.config.markupRules.underline = ['bound_phrase', '_', '_'];
proto.config.markupRules.strike = ['bound_phrase', '<del>', '</del>'];
proto.config.markupRules.p = ['start_lines', ''];
proto.config.markupRules.pre = ['start_lines', '    '];
proto.config.markupRules.h1 = ['bound_phrase', '====== ',' ======\n'];
proto.config.markupRules.h2 = ['bound_phrase', '===== ',' =====\n'];
proto.config.markupRules.h3 = ['bound_phrase', '==== ',' ====\n'];
proto.config.markupRules.h4 = ['bound_phrase', '=== ',' ===\n'];
proto.config.markupRules.h5 = ['bound_phrase', '== ',' ==\n'];
proto.config.markupRules.h6 = ['bound_phrase', '= ',' =\n'];
proto.config.markupRules.ordered = ['start_lines', '  - '];
proto.config.markupRules.unordered = ['start_lines', '  * '];
proto.config.markupRules.indent = ['start_lines', '>'];
proto.config.markupRules.hr = ['line_alone', '----'];
proto.config.markupRules.table = ['line_alone', '| A | B | C |\n|   |   |   |\n|   |   |   |'];
//Wikiwyg4Docuwiki.js end

