Difference between revisions of "MediaWiki:Common.js"
From Reallusion Wiki!
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
$(document).ready( function() { | $(document).ready( function() { | ||
− | + | ||
+ | if (location.pathname.toLowerCase().indexOf('/ic_python_api')===0) { | ||
+ | var tree = $('#wikitext-sidebar'); | ||
+ | |||
+ | /* | ||
+ | tree.prototype.makeTitleVisible = function(title) { | ||
var local = this.ext.mediawiki; | var local = this.ext.mediawiki; | ||
if(typeof(title) === 'undefined') title = mw.config.get('wgTitle'); | if(typeof(title) === 'undefined') title = mw.config.get('wgTitle'); | ||
this.visit(function(node) { | this.visit(function(node) { | ||
+ | console.log(node.title); | ||
var nt = $('<div />').html(node.title); | var nt = $('<div />').html(node.title); | ||
nt = $('a:first', nt).attr('title'); | nt = $('a:first', nt).attr('title'); | ||
Line 15: | Line 21: | ||
}); | }); | ||
}; | }; | ||
+ | */ | ||
+ | |||
+ | |||
− | |||
− | |||
$(tree).detach().appendTo("#mw-panel"); | $(tree).detach().appendTo("#mw-panel"); | ||
$(tree).show(); | $(tree).show(); | ||
$(tree).bind('fancytreeinit', function(event, data) { | $(tree).bind('fancytreeinit', function(event, data) { | ||
+ | console.log(data); | ||
data.tree.makeTitleVisible(); | data.tree.makeTitleVisible(); | ||
}); | }); | ||
} | } | ||
}); | }); |
Latest revision as of 03:51, 7 May 2020
/* Any JavaScript here will be loaded for all users on every page load. */
$(document).ready( function() {
if (location.pathname.toLowerCase().indexOf('/ic_python_api')===0) {
var tree = $('#wikitext-sidebar');
/*
tree.prototype.makeTitleVisible = function(title) {
var local = this.ext.mediawiki;
if(typeof(title) === 'undefined') title = mw.config.get('wgTitle');
this.visit(function(node) {
console.log(node.title);
var nt = $('<div />').html(node.title);
nt = $('a:first', nt).attr('title');
//if(nt == title) { //hack below from https://www.mediawiki.org/w/index.php?title=Extension_talk:TreeAndMenu&oldid=1681501#Open_at_current_page_not_working
if (node.title.includes('<strong class="selflink">')) {
node.makeVisible({ noAnimation: true, noEvents: true, scrollIntoView: false });
node.setActive({ noEvents: true });
return false;
}
});
};
*/
$(tree).detach().appendTo("#mw-panel");
$(tree).show();
$(tree).bind('fancytreeinit', function(event, data) {
console.log(data);
data.tree.makeTitleVisible();
});
}
});