470
edits
No edit summary |
No edit summary |
||
(38 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
$( function(){ | $( function(){ | ||
if (window.matchMedia("(max-width: 768px)").matches) { | |||
if( mw.config.get("skin") !== "minerva" ){ | |||
const currWikiUrl = new URL(window.location.href); | |||
currWikiUrl.searchParams.set('mobileaction', 'toggle_view_mobile'); | |||
window.location.replace(currWikiUrl); | |||
} | |||
} else { | |||
if( mw.config.get("skin") !== "vector" ){ | |||
const currWikiUrl = new URL(window.location.href); | |||
currWikiUrl.searchParams.set('mobileaction', 'toggle_view_desktop'); | |||
window.location.replace(currWikiUrl); | |||
} | |||
} | |||
if( mw.config.get('wgIsMainPage') ){ | if( mw.config.get('wgIsMainPage') ){ | ||
$('#firstHeading').remove(); | $('#firstHeading').remove(); | ||
var mainpageLeft = $(".mainpage-left"); | |||
var mainpageRight = $(".mainpage-right"); | |||
mainpageLeft.css("position", "relative"); | |||
mainpageRight.css("position", "relative"); | |||
function animateLeft(){ | |||
mainpageRight.animate({'left': '15px'}, 1000, function(){ | |||
mainpageRight.animate( {"left": "0px" }, 1000, animateLeft() ); | |||
}); | |||
} | |||
animateLeft(); | |||
function animateRight(){ | |||
mainpageLeft.animate({'left': '-15px'}, 1000, function(){ | |||
mainpageLeft.animate( {"left": "0px" }, 1000, animateRight() ); | |||
}); | |||
} | |||
animateRight(); | |||
} | } | ||
Line 8: | Line 45: | ||
var tempPageName = mw.config.get('wgPageName').split( '/' )[0]; | var tempPageName = mw.config.get('wgPageName').split( '/' )[0]; | ||
var tempLink ='< <a href="https://wiki.ekatrafoundation.org/wiki/' + tempPageName + '">' + tempPageName.replaceAll("_", " ") + '</a>'; | var tempLink ='< <a href="https://wiki.ekatrafoundation.org/wiki/' + tempPageName + '">' + tempPageName.replaceAll("_", " ") + '</a>'; | ||
$("#top").after( $( '<p>').html( tempLink ) ); | $("#top").after( $( '<p>').css( 'font-size', '17px').html( tempLink ) ); | ||
} | } | ||
if( mw.config.get('wgUserName') === null ){ | if( mw.config.get('wgUserName') === null ){ | ||
Line 19: | Line 56: | ||
mw.loader.load( '/index.php?title=MediaWiki:OCR.js&action=raw&ctype=text/javascript'); | mw.loader.load( '/index.php?title=MediaWiki:OCR.js&action=raw&ctype=text/javascript'); | ||
mw.loader.load( '/index.php?title=MediaWiki:PoemButtons.js&action=raw&ctype=text/javascript'); | |||
} | |||
if( $(".wikiaudioplayer").length ){ | |||
mw.loader.load( '/index.php?title=MediaWiki:Green-audio-player.min.css&action=raw&ctype=text/css', 'text/css'); | |||
$.when( | |||
mw.loader.getScript( 'https://wiki.ekatrafoundation.org/index.php?title=MediaWiki:Green-audio-player.min.js&action=raw&ctype=text/javascript' ) | |||
) | |||
.then( | |||
function () { | |||
GreenAudioPlayer.init({ | |||
selector: '.wikiaudioplayer', | |||
stopOthersOnPlay: true | |||
}); | |||
$( ".wikiaudioplayer > audio").css("display", "none"); | |||
}, | |||
function ( e ) { | |||
mw.log.error( e.message ); | |||
} | |||
); | |||
} | } | ||
Line 90: | Line 147: | ||
}); | }); | ||
// Long list into col | |||
$( document ).ready( function(){ | |||
var longList = $("#longList").addClass("grid_row"), | |||
dlElements = longList.children().filter("dl"), | |||
dlElementsLength = dlElements.length; | |||
var list1 = [], | |||
list2 = []; | |||
var count = 0; | |||
dlElements.each( function(index, ele){ | |||
if( count < dlElementsLength/2 ){ | |||
list1.push(ele); | |||
list1.push( $(ele).next() ); | |||
} else { | |||
list2.push(ele); | |||
list2.push( $(ele).next() ); | |||
} | |||
count = count + 1; | |||
}); | |||
longList.empty(); | |||
var leftDiv = $("<div/>").addClass("grid_col"); | |||
list1.forEach( function(value, index){ | |||
leftDiv.append(value); | |||
}); | |||
var rightDiv = $("<div/>").addClass("grid_col"); | |||
list2.forEach( function(value, index){ | |||
rightDiv.append(value); | |||
}); | |||
longList.append(leftDiv, rightDiv ); | |||
}); | |||
$( function(){ | $( function(){ | ||
if( poemElement.length ){ | var countPoem2 = $(".Poem2-Ekatra"); | ||
if( countPoem2.length > 0 ){ | |||
var Poem2lenghtArray = []; | |||
for (var k = 0; k <= countPoem2.length; k++) { | |||
Poem2lenghtArray.push(k); | |||
} | |||
Poem2lenghtArray.forEach(function(j) { | |||
var poemElement = $(".Poem2-Ekatra").eq(j); | |||
if( poemElement.length ){ | |||
var poemText = poemElement.html(); | |||
var poemArray = poemText.split("\n"); | |||
poemElement.text(""); | |||
// First measure | |||
poemArray.forEach( function(i) { | |||
poemElement.append( '<p style="text-indent: 2em;">' + i + '</p>' ); | |||
}); | |||
// Second measure | |||
poemElement.children('p').each(function () { | |||
$(this).css('text-indent', '2em'); | |||
}); | |||
} | |||
}); | |||
} | |||
}); | |||
$( function() { | |||
var divide2cols = $("#divide2cols"); | |||
if( divide2cols.length ){ | |||
var leftDiv = $("<div/>").addClass("grid_col"); | |||
var rightDiv = $("<div/>").addClass("grid_col"); | |||
var parentHieght = divide2cols.height()/2; | |||
divide2cols.children().filter("dl").each(function() { | |||
console.log( $(this).offset().top , parentHieght ); | |||
if ( $(this).offset().top > parentHieght ) { | |||
rightDiv.append( $(this), $(this).next() ); | |||
} else { | |||
leftDiv.append( $(this), $(this).next() ); | |||
} | |||
}); | |||
divide2cols.before( $("<div/>").addClass("grid_row").append(leftDiv, rightDiv) ); | |||
divide2cols.remove(); | |||
} | |||
}); | |||
$( function(){ | |||
// toggled by toggle button. also determines which toggle button image to use | |||
var useCustom = false; | |||
// toggleImgs[0] to switch to custom, toggleImgs[1] to revert to default | |||
var toggleImgs = [ | |||
}); | '//storage.googleapis.com/material-icons/external-assets/v4/icons/svg/ic_search_black_24px.svg', | ||
'//storage.googleapis.com/material-icons/external-assets/v4/icons/svg/ic_youtube_searched_for_black_24px.svg' | |||
]; | |||
var zoomInImg = '//storage.googleapis.com/material-icons/external-assets/v4/icons/svg/ic_zoom_in_black_24px.svg'; | |||
var zoomOutImg = '//storage.googleapis.com/material-icons/external-assets/v4/icons/svg/ic_zoom_out_black_24px.svg'; | |||
// create DOM elements | |||
$('#content').prepend('<div id="zoomButtons" style="z-index: 9999;">\ | |||
<img id="zoomInIcon" src="' + zoomInImg + '" alt="zoom in"">\ | |||
<img id="zoomOutIcon" src="' + zoomOutImg + '" alt="zoom out"">\ | |||
<img id="toggleButton" src="' + toggleImgs[+ useCustom] + '" alt="toggle zoom"> </div>'); | |||
$('#zoomButtons').css({'float': 'right'}); | |||
// find DOM elements used later | |||
var $bodyContent = $('.mw-body-content'); | |||
var $toggleButton = $('#toggleButton'); | |||
// sizes[0] is default, sizes[1] is custom | |||
var sizes = [parseFloat($('.mw-body-content').css('font-size'))]; | |||
// default custom zoom of 2 | |||
sizes[1] = sizes[0] + 2; | |||
// the + converts bool to 0 or 1 to use as array index | |||
function updateSize() { | |||
$bodyContent.css({'font-size':(sizes[+ useCustom] + 'pt')}); | |||
} | |||
function toggle() { | |||
useCustom = !useCustom; | |||
$toggleButton.attr('src',toggleImgs[+ useCustom]); | |||
updateSize(); | |||
} | |||
function zoom(dif) { | |||
sizes[1] += dif; | |||
if (useCustom) { | |||
updateSize(); | |||
} else { | |||
toggle(); | |||
} | |||
} | } | ||
$( '#zoomInIcon' ).on( 'click', function(){ | |||
console.log("Zoom +"); | |||
zoom(1); | |||
}); | |||
$( '#zoomOutIcon' ).on( 'click', function(){ | |||
console.log("Zoom -"); | |||
zoom(-1); | |||
}); | |||
$( '#toggleButton' ).on( 'click', toggle ); | |||
}); | }); | ||