User:Cqm/wikimarks.js

/** * Wikimarks * * Based on Wikimarks by Pecoes * @author Cqm * @version 0.1 * @todo CSS */


 * ( function ( window, document, $, mw, dev ) {

'use strict';

dev.wikimarks = ( function {

var config = mw.config.get( [               'skin'            ] ), self = { init: function {

if ( config.skin !== 'oasis' ) { return; }

self.getWikimarks;

},               getWikimarks: function  {

var params = { action: 'parse', page: 'User:Cqm/wikimarks', format: 'json', // currently bugged //  disablepp: 'true' };

$.ajax( {                       url: 'http://community.wikia.com/api.php',                        data: params,                        dataType: 'jsonp',                        success: function ( response ) {                            var res = response.parse.text['*'];                            // strip preprocessor report                            // see above for bug report link                            res = res.replace( /<!-- \nNewPP limit report[\s\S]+/, '' );                            self.createContainer( res );                        },                        crossDomain: true                    } );

},               createContainer: function ( html ) { $( 'body' ).append(                       $( ' ' )                            .attr( 'id', 'wikimarks-container' )                            .css( 'display', 'none' )                            .html( html )                    );

self.addClasses; },               addClasses: function  { var $cont = $( '#wikimarks-container' ), $ul = $cont.find( '>ul' ), $li = $ul.find( '>li' ), $a = $li.find( '>a' );

// @todo fix for level 3/4 menus $ul.addClass( 'subnav-2 accent firstChild' ); $li.addClass( 'subnav-2-item' ); $a.addClass( 'subnav-2a' );

self.navReplace; },               navReplace: function  {

var $nav = $( '#WikiHeader > .WikiNav > .nav > .nav-item:first-child' ).children, $cont = $( '#wikimarks-container > ul' ).clone;

$nav.remove( 'ul' ) .append( $cont ); console.log( $nav, $cont );

}           };

return self;

} );

$( dev.wikimarks.init );

}( this, this.document, this.jQuery, this.mediaWiki, this.dev = this.dev || {} ) );