window.protectedNamespace = [ "2020", "2020_talk", "2021", "2021_talk", "2022", "2022_talk", "2023", "2024", "2025" ]; // $( document ).ready( function(){// $('body').addClass('_responsive');// console.log('Yes we can edit by jQuery');// });
$( document ).ready( function(){
// Open all UIF link in new tab
$('#p-UIF').children().find('a').attr('target', '_blank');
// Hide login link from nav
if ( mw.config.get( 'wgPageName' ) === "Special:Badtitle" ){
$('#pt-login').hide();
}
// Remove the navigation from Training namespaces
if( mw.config.get("wgCanonicalNamespace") === "Training" && !(mw.config.get( 'wgUserGroups' ).indexOf("bureaucrat") !== -1) ) {
$("#left-navigation").empty();
$("#right-navigation").empty();
}
// Redirect Topic page to their parent pages
if( mw.config.get( 'wgNamespaceNumber') === mw.config.get( 'wgNamespaceIds' ).topic ){
location.replace( mw.config.get( 'wgServer') + $("#contentSub").children().attr("href") );
}
// Image copy link widget
if( mw.config.get("wgCanonicalNamespace") === "File" ){
mw.loader.using('mediawiki.widgets').then( function (){
var copyImageLink = new mw.widgets.CopyTextLayout( {
title: 'Copy image link',
copyText: mw.config.get( 'wgServer' ) + "/wiki/" + mw.config.get("wgPageName")
} );
$( '#firstHeading' ).after( copyImageLink.$element );
});
}
// CategoryTree Sorting
var container = $( $( "div.CategoryTreeSection" ).first().children().last()[0] ),
items = container.children();
items.sort( function(a, b){
if (
$(a).find(".CategoryTreeLabelNs14").length === 0
&& $(a).find(".CategoryTreeLabelNs3762").length === 0
&& $(a).find(".CategoryTreeLabelNs3752").length === 0
&& $(a).find(".CategoryTreeLabelNs3756").length === 0
) {
return 0;
}
// Get text of the category link
firstText = $(a).find("a").text();
secondText = $(b).find("a").text();
// Regex to get the cohort year
firstMatch = /(\d{4})/ig.exec( firstText.trim() );
secondMatch = /(\d{4})/ig.exec( secondText.trim() );
// If nothing is found, status will remain same
if( firstMatch === null && secondMatch === null ) {
if ( firstText.includes("Faculty Champion:") ){
// Now campare with second element
if( secondText.includes("School:") || secondText.includes("Priorities:") ){
return -1;
} else {
return 0;
}
} else if( firstText.includes("School:") ){
// Now campare with second element
if( secondText.includes("Faculty Champion:") ){
return 1;
} else if( secondText.includes("Priorities:") ){
return -1;
} else {
return 0;
}
} else if( firstText.includes("Priorities:") ){
// Now campare with second element
if( secondText.includes("Faculty Champion:") || secondText.includes("School:") ){
return 1;
} else {
return 0;
}
} else {
return 0;
}
}
// If first element match
if( firstMatch !== null) {
if( secondMatch !== null ){
return firstMatch[1] > secondMatch[1] ? -1 : 1;
} else {
return -1;
}
} else {
return secondMatch !== null ? 1 : 0;
}
});
container.append( items );
// CategoryTree
$('.CategoryTreeLabelPage').first().prev().before("---------------------------<br>");
$('.CategoryTreeEmptyBullet').each( function(){
if( $(this).next().next().val() === undefined){
$(this).parent().hide();
}
});
});
$( function(){
pageId = $("#embedWikiPage");
page = pageId.attr("data-page");
pageId.css( {
"overflow": "scroll",
"height": pageId.attr("data-height"),
"width": pageId.attr("data-width")
});
loadWikiPage( page );
function loadWikiPage( page ){
pageId.load("/wiki/"+ page + " .mw-parser-output", function(){
$( this ).find( ".mw-editsection" ).hide();
$( this ).find( "#toc" ).hide();
$( this ).scrollTop(0);
anchors = $( this ).find("a");
anchors.on("click", function(e){
link = $( this )[0].href.split("https://universityinnovation.org/wiki/");
if( link.length > 1 ){
newPage = link.pop();
if( newPage.includes("Main_Page") || newPage.includes("File:")
|| newPage.includes("Special:") || newPage.includes("Category:")
|| newPage.includes("#") || newPage.includes("Talk:") ){
$( this ).attr('target', '_blank').get(0).click();
} else {
e. preventDefault();
loadWikiPage( newPage );
}
} else {
$( this ).attr('target', '_blank').get(0).click();
}
});
});
}
});
if( window.protectedNamespace.indexOf( mw.config.get( 'wgCanonicalNamespace' )) !== -1 ){
$("#firstHeading").text( mw.config.get( 'wgTitle' ) );
$('#p-navigation > .body ul').empty();
$('#p-tb').remove();
$("#right-navigation").empty();
}
$.when( mw.loader.using( 'mediawiki.util' ), $.ready ).then( function () {
mw.util.addPortletLink(
'p-views',
mw.config.get( 'wgScript' ) + '?veaction=edit&title=' + mw.util.wikiUrlencode( mw.config.get( 'wgPageName' ) ),
'Edit',
null,
'Edit in Visual Editor',
null,
'#ca-edit'
);
});
// Navigation Links
ModifySidebar( 'navigation', 'Back to Main Page', 'https://universityinnovation.org/wiki/Main_Page' );
} else {
ModifySidebar( 'navigation', 'Back to Overview', 'https://universityinnovation.org/wiki/2020'+ mw.config.get( 'wgCanonicalNamespace' ).slice(0,4) + ':Training_Overview' );
}
mw.loader.using( 'mediawiki.api', function(){
// Gadget-HotCat
if( mw.config.get("wgUserGroups").indexOf("bureaucrat") !== -1) { mw.loader.load( '/index.php?title=MediaWiki:Gadget-HotCat.js&action=raw&ctype=text/javascript' );}
// Gadget - QRCode
// mw.loader.load('/index.php?title=MediaWiki:QRCode.js&action=raw&ctype=text/javascript'); // Gadget - CreateFellowPage$( document ).ready( function (){
function init() { // Remove the default contentGadget - CreateFellow2020 $('#mw-content-text > p').remove(); $('#firstHeading')loader.textload('Create Fellow Page'); // Create widget var bio = new OO.ui.MultilineTextInputWidget( { placeholder: 'Bio', autosize: true, rows: 10 } ), achievements = new OO.ui.MultilineTextInputWidget( { placeholder: 'Achievements', autosize: true, rows: 10 } ), social = new OO.ui.MultilineTextInputWidget( { placeholder: 'Social media profiles', autosize: true, rows: 10 } ), name = new OO.ui.TextInputWidget( { placeholder: 'Name' } ), cohort = new OO.ui.TextInputWidget( { placeholder: 'Cohort' } ), school = new OO.ui.TextInputWidget( { placeholder: 'School' } ), major = new OO.uiindex.TextInputWidget( { placeholder: 'Majoring in' } ), country php?title= new OO.ui.TextInputWidget( { placeholder: 'Country' } ), createBtn = new OO.ui.ButtonWidget( { labelMediaWiki: 'Create Page', flags: [ 'progressive', 'primary' ] } ), cancelBtn = new OO.ui.ButtonWidget( { label: 'Cancel', flags: [ 'primary', 'destructive' ], href: mw.config.get( 'wgServer' ) } ), label1 = $('<p>').text('Name:').css('fontGadget-weight','bold' ), label2 = $('<p>')2020Cohort.text('Cohort:').css('font-weight','bold' ), label3 js&action= $('<p>').text('School:').css('font-weight','bold' ), label4 = $('<p>').text('Majoring in:').css('font-weight','bold' ), label5 = $('<p>').text('Country:').css('font-weight','bold' ), label6 = $('<p>').text('Bio:').css('font-weight','bold' ), label7 = $('<p>').text('Achievements:').css('font-weight','bold' ), label8 raw&ctype= $('<p>').text('Social media profiles:').css('font-weight','bold' ), divMainBox = $('<div />').css( { 'box-shadow': '0 .5rem 1rem rgba(0, 0, 0, .15)', 'border': '1px solid', 'padding': '1rem', 'margin-bottom': '3rem', javascript'border-radius': '.5rem' }); divMainBox.append( label1, name.$element, label2, cohort.$element, label3, school.$element, label4, major.$element, label5, country.$element, label6, bio.$element, label7, achievements.$element, label8, social.$element, '<br/>', createBtn.$element, cancelBtn.$element ); $( '#mw-content-text' ).append( divMainBox ); // Create button click event handler createBtn.on( 'click', function() { nameResp = name.getValue().trim(), cohortResp = cohort.getValue().trim(); schoolResp = school.getValue().trim(), majorResp = major.getValue().trim(); countryResp = country.getValue().trim(), bioResp = bio.getValue().trim(); achievementsResp = achievements.getValue().trim(), socialResp = social.getValue().trim(); // Check whether the all fields are enough to run the function if( nameResp !== "" && cohortResp !== "" && schoolResp !== "" && majorResp !== "" && countryResp !== "" ) { api = new mw.Api();
wikiContent = "==Intro==\n";// Gadget - UpdateWikiBio wikiContent +mw.loader.load('/index.php?title= ";NameMediaWiki: " + nameResp + "\n"; wikiContent += ";Cohort: " + cohortResp + "\n"; wikiContent += ";School: " + schoolResp + "\n"; wikiContent += ";Majoring in: " + majorResp + "\n"; wikiContent += ";Country: " + countryResp + "\n"; wikiContent += "==Bio==\n" + bioResp + "\n"; wikiContent += "==Achievements==\n" + achievementsResp + "\n"; wikiContent += "==Social media profilesGadget-UpdateWikiBio.js&action=raw&ctype=\n" + socialResp + "\n"text/javascript');
pageTitle = "Fellow:" + nameResp;
api.get( {
formatversion: 2,
action: 'query',
titles: pageTitle,
redirects: true
}, { async: false } ).then( function ( response ) {
var page = response.query.pages[ 0 ];
if ( page.missing || page.invalid ) {
doEdit( pageTitle, wikiContent );
} else {
api.get( {
formatversion: 2,
action: 'query',
titles: pageTitle + " (" + cohortResp + ")",
redirects: true
}, { async: false } ).then( function ( response ) {
var page = response.query.pages[ 0 ];
if ( page.missing || page.invalid ) {
doEdit( pageTitle + " (" + cohortResp + ")", wikiContent );
} else {
doEdit( pageTitle + " (" + schoolResp + ", " + cohortResp + ")", wikiContent );
}
});
}
} );
} else {
mw.notify( "Some fields have no text :( Please fill them." );
return;
}
}); function doEdit(title, wikiContent){ // Edit the page var editParams = { action: 'edit', title: title, text: wikiContent, summary: "Created Fellow Page", format: 'json' }; api.postWithToken( 'csrf', editParams, { async: false } ).done( function ( res ) { if( res.edit.result === "Success"){ mw.notify( title + " page has created :)"); window.location.replace( mw.config.get( 'wgServer' ) + "/wiki/" + title ); } else{ mw.notify( "Something went worng :(" ); } } ); } } // On every page $.when(mw.loader.using('mediawiki.util'), $.ready).then(function () { mw.util.addPortletLink( 'p-tb', mw.util.getUrl('Special:BlankPage/CreateFellowPage'), 'Create Fellow Page' ); }); if ( mw.config.get('wgCanonicalSpecialPageName') === 'Blankpage' && mw.config.get('wgTitle').split('/', 2)[1] === 'CreateFellowPage' ) { mw.loader.using( ['oojs-ui-core', 'mediawiki.api', 'mediawiki.notify', 'mediawiki.Title'], init ); }});_responsive chabges