User:Huawei251/common.js: Difference between revisions
Content added Content deleted
mNo edit summary |
No edit summary |
||
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
// <pre> |
// <pre> |
||
⚫ | |||
/** |
|||
* Skrypt dla Szablon:Galeria |
|||
*/ |
|||
function toggleImage (group, remindex, shwindex) { |
|||
jQuery("#ImageGroupsGr" + group + "Im" + remindex).hide(); |
|||
jQuery("#ImageGroupsGr" + group + "Im" + shwindex).show(); |
|||
} |
|||
function ImageGroup() { |
|||
jQuery('div.ImageGroup').each(function(i, group) { |
|||
console.log(`group ${i}`); |
|||
var unitnode = jQuery('div.ImageGroupUnits', group).get(0); |
|||
if (unitnode == undefined) { |
|||
⚫ | |||
return 1; |
|||
} |
|||
var units = jQuery(unitnode).children().children('.center'); |
|||
var count = units.get().length; |
|||
if (count <= 1) { |
|||
console.log('B'); |
|||
return 1; |
|||
} |
|||
units.each(function(j, currentimage) { |
|||
console.log(`unit ${j}`); |
|||
jQuery(currentimage).attr('id', "ImageGroupsGr" + i + "Im" + j); |
|||
var leftlink = jQuery('<a href="#"/>'); |
|||
if (j != 0) { |
|||
leftlink.text('◀').click(function() { |
|||
toggleImage(i, j, j - 1); return false; |
|||
}); |
|||
} |
|||
var rightlink = jQuery('<a href="#"/>'); |
|||
if (j != count - 1) { |
|||
rightlink.text('▶').click(function() { |
|||
toggleImage(i, j, j + 1); return false; |
|||
}); |
|||
} |
|||
jQuery('<div/>').css({ 'font-size' : '110%', 'font-weight' : 'bold' }) |
|||
.addClass('disabled-user-selection') |
|||
.append(leftlink) |
|||
.append('<tt>(' + (j + 1) + '/' + count + ')</tt>') |
|||
.append(rightlink) |
|||
.prependTo(jQuery(currentimage)); |
|||
if (j != 0) { |
|||
jQuery(currentimage).hide().addClass('noprint'); |
|||
} |
|||
}); |
|||
}); |
|||
} |
|||
jQuery(ImageGroup); |
|||
// Wikiplus blocked by this site |
|||
//mw.loader.load('https://wikiplus-app.com/Main.js'); |
|||
//mw.loader.using(['mediawiki.util', 'ext.gadget.site-lib'], function () { |
|||
/* 當需要時載入對應的 scripts */ |
|||
/* |
|||
var importScriptRL=function(page){ |
|||
mw.loader.load(mw.config.get('wgScript')+'?title='+mw.util.wikiUrlencode(page)+'&action=raw&ctype=text/javascript&_='+Math.floor((new Date())/1000/60/60/24/7)); |
|||
}; |
|||
if (mw.config.get('wgAction') == "edit" || mw.config.get('wgAction') == "submit" || mw.config.get('wgCanonicalSpecialPageName') == 'Search') { // scripts specific to editing pages |
|||
console.log('A'); |
|||
importScriptRL('User:Huawei251/edit.js'); |
|||
} else { |
|||
mw.loader.using('ext.visualEditor.desktopArticleTarget.init', function () { |
|||
console.log('ext.visualEditor.desktopArticleTarget.init'); |
|||
mw.libs.ve.addPlugin(function () { |
|||
importScriptRL('User:Huawei251/edit.js'); |
|||
}); |
|||
}); |
|||
} |
|||
*/ |
|||
//}); |
|||
// </pre> |
// </pre> |