Скальный наездник: различия между версиями
(→Другое) Метка: отменено |
м (→Другое) Метка: отменено |
||
| Строка 1: | Строка 1: | ||
/* Размещённый здесь JavaScript код будет загружаться всем пользователям при обращении к каждой странице */ | |||
/* test */ | |||
function comment_text () | |||
{ | |||
if ($( this ).attr('id') == "comment-hide") | |||
{ | |||
$( this ).children().last().show(); | |||
$( this ).attr("id", "comment-show"); | |||
return; | |||
} | |||
if ($( this ).attr('id') == "comment-show") | |||
{ | |||
$( this ).children().last().hide(); | |||
$( this ).attr("id", "comment-hide"); | |||
return; | |||
} | |||
} | |||
$('.comment').click(comment_text); | |||
function tab_work () { | |||
$( this ).parent().children("span").removeClass ("tab_active"); | |||
$( this ).addClass ("tab_active"); | |||
var tab_id = $( this ).attr('id'); | |||
var block = $( this ).parent().parent().next(); | |||
block.children("div").hide(); | |||
block.children( '#'+tab_id ).show(); | |||
} | |||
// $('.tab_click').each (function () { this.addEventListener ("click", tab_work ) } ) | |||
$('.tab_click').click(tab_work); | |||
function sort_list () { | |||
var list = $( this ).next(); | |||
list.children("li").sort( | |||
function(a, b) { | |||
var A = $(a).text().toUpperCase(); | |||
var B = $(b).text().toUpperCase(); | |||
return (A < B) ? -1 : (A > B) ? 1 : 0; | |||
} | |||
).appendTo(list); | |||
} | |||
/* test_s.onclick= tested_feb2024; */ | |||
/* document.getElementById('test_s').addEventListener('click', tested_feb2024); */ | |||
$('.sorted_click').each (function () { this.addEventListener ("click", sort_list ) } ) | |||
function includeScript(page, project) { | |||
var url = '/index.php?title=' + encodeURIComponent(page) + '&action=raw&ctype=text/javascript'; | |||
if (project) url = 'http://' + project + url; | |||
mw.loader.load(url); | |||
} | |||
if ((mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit') && mw.config.get('wgCanonicalNamespace') != 'Special') | |||
includeScript('MediaWiki:Editpage.js'); | |||
/*Collapsible stuff. Стырено из википедии */ | |||
var NavigationBarShowDefault = 2 | |||
var NavigationBarHide = '[скрыть]' | |||
var NavigationBarShow = '[показать]' | |||
var hasClass = (function (){ | |||
var reCache = {} | |||
return function (element, className){ | |||
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className) | |||
} | |||
})() | |||
function collapsibleTables(){ | |||
var Table, HRow, HCell, btn, a, tblIdx = 0, colTables = [] | |||
var allTables = document.getElementsByTagName('table') | |||
for (var i=0; Table = allTables[i]; i++){ | |||
if (!hasClass(Table, 'collapsible')) continue | |||
if (!(HRow=Table.rows[0])) continue | |||
if (!(HCell=HRow.getElementsByTagName('th')[0])) continue | |||
Table.id = 'collapsibleTable' + tblIdx | |||
btn = document.createElement('span') | |||
btn.style.cssText = 'float:right; font-weight:normal; font-size:smaller' | |||
a = document.createElement('a') | |||
a.id = 'collapseButton' + tblIdx | |||
a.href = 'javascript:collapseTable(' + tblIdx + ');' | |||
a.style.color = HCell.style.color | |||
a.appendChild(document.createTextNode(NavigationBarHide)) | |||
btn.appendChild(a) | |||
HCell.insertBefore(btn, HCell.childNodes[0]) | |||
colTables[tblIdx++] = Table | |||
} | |||
for (var i=0; i < tblIdx; i++) | |||
if ((tblIdx > NavigationBarShowDefault && i > 0 && hasClass(colTables[i], 'autocollapse')) || hasClass(colTables[i], 'collapsed')) | |||
collapseTable(i) | |||
} | |||
function collapseTable (idx){ | |||
var Table = document.getElementById('collapsibleTable' + idx) | |||
var btn = document.getElementById('collapseButton' + idx) | |||
if (!Table || !btn) return false | |||
var Rows = Table.rows | |||
var isShown = (btn.firstChild.data == NavigationBarHide) | |||
btn.firstChild.data = isShown ? NavigationBarShow : NavigationBarHide | |||
var disp = isShown ? 'none' : Rows[0].style.display | |||
for (var i=1; i < Rows.length; i++) | |||
Rows[i].style.display = disp | |||
} | |||
function collapsibleDivs(){ | |||
var navIdx = 0, colNavs = [], i, NavFrame | |||
var divs = document.getElementById('content').getElementsByTagName('div') | |||
for (i=0; NavFrame = divs[i]; i++) { | |||
if (!hasClass(NavFrame, 'NavFrame')) continue | |||
NavFrame.id = 'NavFrame' + navIdx | |||
var a = document.createElement('a') | |||
a.className = 'NavToggle' | |||
a.id = 'NavToggle' + navIdx | |||
a.href = 'javascript:collapseDiv(' + navIdx + ');' | |||
a.appendChild(document.createTextNode(NavigationBarHide)) | |||
for (var j=0; j < NavFrame.childNodes.length; j++) { | |||
var nvChild = NavFrame.childNodes[j] | |||
if (hasClass(nvChild, 'NavHead')) { | |||
nvChild.appendChild(a) | |||
} else { | |||
// uglyhack for CollapsedSection | |||
if (nvChild.tagName && (nvChild.tagName.charAt(0) == 'H')) { | |||
var nvSubChildren = nvChild.getElementsByTagName('SPAN') | |||
for (var u=0; u < nvSubChildren.length; u++) { | |||
var nvSubChild = nvSubChildren[u] | |||
if (hasClass(nvSubChild, 'NavHead')) { | |||
nvSubChild.appendChild(a) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
colNavs[navIdx++] = NavFrame | |||
} | |||
for (i=0; i < navIdx; i++) | |||
if ((navIdx > NavigationBarShowDefault && i > 0 && !hasClass(colNavs[i], 'expanded')) || hasClass(colNavs[i], 'collapsed')) | |||
collapseDiv(i) | |||
} | |||
function collapseDiv(idx) { | |||
var div = document.getElementById('NavFrame' + idx) | |||
var btn = document.getElementById('NavToggle' + idx) | |||
if (!div || !btn) return false | |||
var isShown = (btn.firstChild.data == NavigationBarHide) | |||
btn.firstChild.data = isShown ? NavigationBarShow : NavigationBarHide | |||
var disp = isShown ? 'none' : 'block' | |||
for (var child = div.firstChild; child != null; child = child.nextSibling) | |||
if (hasClass(child, 'NavPic') || hasClass(child, 'NavContent')) | |||
child.style.display = disp | |||
} | |||
if (mw.config.get('wgAction') != 'history'){ | |||
jQuery(document).ready(collapsibleDivs) | |||
jQuery(document).ready(collapsibleTables) | |||
} | |||
/*WikiEditor/Викификатор*/ | |||
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) { | |||
mw.loader.load( '//ru.wikipedia.org/w/index.php?title=MediaWiki:Gadget-wikificator.js&action=raw&ctype=text/javascript' ); | |||
} | |||
var customizeToolbar = function() { | |||
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | |||
'section': 'advanced', | |||
'group': 'format', | |||
'tools': { | |||
'wikify': { | |||
label: 'Викификатор', | |||
type: 'button', | |||
icon: '//upload.wikimedia.org/wikipedia/commons/0/06/Wikify-toolbutton.png', | |||
action: { | |||
type: 'callback', | |||
execute: function(context){ | |||
Wikify(); | |||
} | |||
} | |||
} | |||
} | |||
} ); | |||
}; | |||
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) { | |||
mw.loader.using( 'user.options', function () { | |||
if ( mw.user.options.get('usebetatoolbar') ) { | |||
mw.loader.using( 'ext.wikiEditor.toolbar', function () { | |||
$(document).ready( customizeToolbar ); | |||
} ); | |||
} | |||
} ); | |||
} | |||
// Written by User:Hellerhoff, 2011 | |||
/** Skript for Template:Imagestack */ | |||
jQuery( document ).ready(function() { | |||
$(".ImageStack_JS_required").hide(); | |||
if (document.URL.match(/printable/g)) return; | |||
var scrollobject = false; // flag for scroll-dragging | |||
var mouse_y = 0; | |||
$(document).on('mouseup', function(event) { | |||
var did_scroll = !scrollobject; | |||
scrollobject = false; // unset flag | |||
return did_scroll; | |||
}); // bind mouseup | |||
$("div.ImageStack").each( function () { | |||
var currentImage = 0, length, loop, | |||
$images, $t, $counter, $leftLink, | |||
$rightLink, $currentCount; | |||
$t = $( this ); | |||
loop = $t.find('.ImageStack_loop').length ? true : false; | |||
//Use when 1.17 final is in use | |||
//loop = $t.attr('data-loop') == 'true' ? true : false; //Get loop prop | |||
$images = $t.find('.ImageStackUnits div.center'); | |||
length = $images.length; | |||
if ( !length ) return true; | |||
$counter = $('<div class="ImageStackCounter">'); | |||
$leftLink = $('<a>', { href: '#', text : '< ' }).click( function() { | |||
toggleImage ( -1, loop ); | |||
return false; | |||
}); | |||
$rightLink = $('<a>', { href: '#', text : ' >' }).click( function() { | |||
toggleImage ( 1, loop ); | |||
return false; | |||
}); | |||
$currentCount = $('<span>', {'class' : 'ImageStackCounterCurrent', text: '0' }); | |||
$counter.append($leftLink, '(' , $currentCount, '/', length, ')', $rightLink); | |||
$counter.addClass('center'); | |||
$t.prepend( $counter ); | |||
$leftLink.add( $rightLink ).css({ fontSize : "110%", fontweight : "bold" }); | |||
// $images.on('mousewheel', function( event, delta ) { | |||
// console.log(delta, Math.floor( delta )) | |||
// delta = Math.floor( delta ); | |||
// if ( delta != 0 ) toggleImage( -delta, loop ); | |||
// return false; | |||
// }); | |||
$images.on('mousedown', function( event ) { // prepare scroll by drag | |||
mouse_y = event.screenY; // remember mouse-position | |||
scrollobject = true; // set flag | |||
return false; | |||
}); | |||
// $images.on('mousemove', function( event ) { | |||
// if ( scrollobject && Math.abs( mouse_y - event.screenY ) > 10 ) { | |||
// var offset = (mouse_y < event.screenY) ? 1 : -1; | |||
// mouse_y = event.screenY; // remember mouse-position for next event | |||
// toggleImage ( offset, loop ); | |||
// } | |||
// return false; | |||
// }); | |||
var toggleImage = function( offset, loop ) { | |||
console.log(currentImage, offset, loop) | |||
currentImage += offset; //add offset | |||
$leftLink.show(); | |||
$rightLink.show(); | |||
if ( !loop ) { | |||
if ( currentImage <= 0 ) { | |||
currentImage = 0; | |||
$leftLink.hide(); | |||
} else if ( currentImage >= $images.length -1 ) { | |||
currentImage = $images.length - 1; | |||
$rightLink.hide(); | |||
} | |||
} else { | |||
if ( currentImage < 0 ) currentImage = $images.length - 1; | |||
if ( currentImage >= $images.length ) currentImage = 0; | |||
} | |||
$images.hide(); //Hide all | |||
$images.eq( currentImage ).show(); | |||
$currentCount.text( currentImage + 1 ); | |||
}; | |||
toggleImage ( 0, loop ); | |||
}); | |||
}); | |||
// else { | |||
// commentText = currentimage.getAttribute("title"); | |||
// comment = document.createElement("span").appendChild(document.createTextNode(commentText)); | |||
// currentimage.removeAttribute("title"); | |||
// } | |||
// if(rightlink !== undefined) { | |||
// rightlink.setAttribute("title", commentText); | |||
// } | |||
Версия 02:40, 28 декабря 2025
/* Размещённый здесь JavaScript код будет загружаться всем пользователям при обращении к каждой странице */
/* test */
function comment_text ()
{
if ($( this ).attr('id') == "comment-hide")
{
$( this ).children().last().show();
$( this ).attr("id", "comment-show");
return;
}
if ($( this ).attr('id') == "comment-show")
{
$( this ).children().last().hide();
$( this ).attr("id", "comment-hide");
return;
}
}
$('.comment').click(comment_text);
function tab_work () { $( this ).parent().children("span").removeClass ("tab_active"); $( this ).addClass ("tab_active"); var tab_id = $( this ).attr('id'); var block = $( this ).parent().parent().next(); block.children("div").hide(); block.children( '#'+tab_id ).show(); }
// $('.tab_click').each (function () { this.addEventListener ("click", tab_work ) } )
$('.tab_click').click(tab_work);
function sort_list () { var list = $( this ).next(); list.children("li").sort( function(a, b) { var A = $(a).text().toUpperCase(); var B = $(b).text().toUpperCase(); return (A < B) ? -1 : (A > B) ? 1 : 0; } ).appendTo(list); }
/* test_s.onclick= tested_feb2024; */
/* document.getElementById('test_s').addEventListener('click', tested_feb2024); */
$('.sorted_click').each (function () { this.addEventListener ("click", sort_list ) } )
function includeScript(page, project) {
var url = '/index.php?title=' + encodeURIComponent(page) + '&action=raw&ctype=text/javascript'; if (project) url = 'http://' + project + url; mw.loader.load(url);
}
if ((mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit') && mw.config.get('wgCanonicalNamespace') != 'Special')
includeScript('MediaWiki:Editpage.js');
/*Collapsible stuff. Стырено из википедии */
var NavigationBarShowDefault = 2 var NavigationBarHide = '[скрыть]' var NavigationBarShow = '[показать]'
var hasClass = (function (){
var reCache = {}
return function (element, className){
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className)
}
})()
function collapsibleTables(){
var Table, HRow, HCell, btn, a, tblIdx = 0, colTables = []
var allTables = document.getElementsByTagName('table')
for (var i=0; Table = allTables[i]; i++){
if (!hasClass(Table, 'collapsible')) continue
if (!(HRow=Table.rows[0])) continue
if (!(HCell=HRow.getElementsByTagName('th')[0])) continue
Table.id = 'collapsibleTable' + tblIdx
btn = document.createElement('span')
btn.style.cssText = 'float:right; font-weight:normal; font-size:smaller'
a = document.createElement('a')
a.id = 'collapseButton' + tblIdx
a.href = 'javascript:collapseTable(' + tblIdx + ');'
a.style.color = HCell.style.color
a.appendChild(document.createTextNode(NavigationBarHide))
btn.appendChild(a)
HCell.insertBefore(btn, HCell.childNodes[0])
colTables[tblIdx++] = Table
}
for (var i=0; i < tblIdx; i++)
if ((tblIdx > NavigationBarShowDefault && i > 0 && hasClass(colTables[i], 'autocollapse')) || hasClass(colTables[i], 'collapsed'))
collapseTable(i)
}
function collapseTable (idx){
var Table = document.getElementById('collapsibleTable' + idx)
var btn = document.getElementById('collapseButton' + idx)
if (!Table || !btn) return false
var Rows = Table.rows
var isShown = (btn.firstChild.data == NavigationBarHide)
btn.firstChild.data = isShown ? NavigationBarShow : NavigationBarHide
var disp = isShown ? 'none' : Rows[0].style.display
for (var i=1; i < Rows.length; i++)
Rows[i].style.display = disp
}
function collapsibleDivs(){
var navIdx = 0, colNavs = [], i, NavFrame
var divs = document.getElementById('content').getElementsByTagName('div')
for (i=0; NavFrame = divs[i]; i++) {
if (!hasClass(NavFrame, 'NavFrame')) continue
NavFrame.id = 'NavFrame' + navIdx
var a = document.createElement('a')
a.className = 'NavToggle'
a.id = 'NavToggle' + navIdx
a.href = 'javascript:collapseDiv(' + navIdx + ');'
a.appendChild(document.createTextNode(NavigationBarHide))
for (var j=0; j < NavFrame.childNodes.length; j++) {
var nvChild = NavFrame.childNodes[j]
if (hasClass(nvChild, 'NavHead')) {
nvChild.appendChild(a)
} else {
// uglyhack for CollapsedSection
if (nvChild.tagName && (nvChild.tagName.charAt(0) == 'H')) {
var nvSubChildren = nvChild.getElementsByTagName('SPAN')
for (var u=0; u < nvSubChildren.length; u++) {
var nvSubChild = nvSubChildren[u]
if (hasClass(nvSubChild, 'NavHead')) {
nvSubChild.appendChild(a)
}
}
}
}
}
colNavs[navIdx++] = NavFrame
}
for (i=0; i < navIdx; i++)
if ((navIdx > NavigationBarShowDefault && i > 0 && !hasClass(colNavs[i], 'expanded')) || hasClass(colNavs[i], 'collapsed'))
collapseDiv(i)
}
function collapseDiv(idx) {
var div = document.getElementById('NavFrame' + idx)
var btn = document.getElementById('NavToggle' + idx)
if (!div || !btn) return false
var isShown = (btn.firstChild.data == NavigationBarHide)
btn.firstChild.data = isShown ? NavigationBarShow : NavigationBarHide
var disp = isShown ? 'none' : 'block'
for (var child = div.firstChild; child != null; child = child.nextSibling)
if (hasClass(child, 'NavPic') || hasClass(child, 'NavContent'))
child.style.display = disp
}
if (mw.config.get('wgAction') != 'history'){
jQuery(document).ready(collapsibleDivs) jQuery(document).ready(collapsibleTables)
}
/*WikiEditor/Викификатор*/ if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
mw.loader.load( '//ru.wikipedia.org/w/index.php?title=MediaWiki:Gadget-wikificator.js&action=raw&ctype=text/javascript' );
}
var customizeToolbar = function() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'advanced',
'group': 'format',
'tools': {
'wikify': {
label: 'Викификатор',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/0/06/Wikify-toolbutton.png',
action: {
type: 'callback',
execute: function(context){
Wikify();
}
}
}
}
} ); };
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
mw.loader.using( 'user.options', function () {
if ( mw.user.options.get('usebetatoolbar') ) {
mw.loader.using( 'ext.wikiEditor.toolbar', function () {
$(document).ready( customizeToolbar );
} );
}
} );
}
// Written by User:Hellerhoff, 2011 /** Skript for Template:Imagestack */ jQuery( document ).ready(function() {
$(".ImageStack_JS_required").hide();
if (document.URL.match(/printable/g)) return;
var scrollobject = false; // flag for scroll-dragging var mouse_y = 0;
$(document).on('mouseup', function(event) {
var did_scroll = !scrollobject; scrollobject = false; // unset flag return did_scroll;
}); // bind mouseup
$("div.ImageStack").each( function () {
var currentImage = 0, length, loop, $images, $t, $counter, $leftLink,
$rightLink, $currentCount;
$t = $( this );
loop = $t.find('.ImageStack_loop').length ? true : false;
//Use when 1.17 final is in use
//loop = $t.attr('data-loop') == 'true' ? true : false; //Get loop prop
$images = $t.find('.ImageStackUnits div.center'); length = $images.length; if ( !length ) return true;
$counter = $('
$leftLink = $('<a>', { href: '#', text : '< ' }).click( function() { toggleImage ( -1, loop ); return false; }); $rightLink = $('<a>', { href: '#', text : ' >' }).click( function() { toggleImage ( 1, loop ); return false; });
$currentCount = $('', {'class' : 'ImageStackCounterCurrent', text: '0' }); $counter.append($leftLink, '(' , $currentCount, '/', length, ')', $rightLink); $counter.addClass('center'); $t.prepend( $counter ); $leftLink.add( $rightLink ).css({ fontSize : "110%", fontweight : "bold" });
// $images.on('mousewheel', function( event, delta ) { // console.log(delta, Math.floor( delta )) // delta = Math.floor( delta ); // if ( delta != 0 ) toggleImage( -delta, loop ); // return false; // }); $images.on('mousedown', function( event ) { // prepare scroll by drag mouse_y = event.screenY; // remember mouse-position scrollobject = true; // set flag return false; }); // $images.on('mousemove', function( event ) { // if ( scrollobject && Math.abs( mouse_y - event.screenY ) > 10 ) { // var offset = (mouse_y < event.screenY) ? 1 : -1; // mouse_y = event.screenY; // remember mouse-position for next event // toggleImage ( offset, loop ); // } // return false; // });
var toggleImage = function( offset, loop ) {
console.log(currentImage, offset, loop)
currentImage += offset; //add offset $leftLink.show(); $rightLink.show(); if ( !loop ) { if ( currentImage <= 0 ) { currentImage = 0; $leftLink.hide(); } else if ( currentImage >= $images.length -1 ) { currentImage = $images.length - 1; $rightLink.hide(); } } else { if ( currentImage < 0 ) currentImage = $images.length - 1; if ( currentImage >= $images.length ) currentImage = 0; } $images.hide(); //Hide all $images.eq( currentImage ).show(); $currentCount.text( currentImage + 1 ); }; toggleImage ( 0, loop ); }); });
// else {
// commentText = currentimage.getAttribute("title");
// comment = document.createElement("span").appendChild(document.createTextNode(commentText));
// currentimage.removeAttribute("title");
// }
// if(rightlink !== undefined) {
// rightlink.setAttribute("title", commentText);
// }