“MediaWiki:Common.js”的版本间的差异
来自小鱼君和他的朋友们
小 (//InPageEdit) 标签:InPageEdit |
((InPageEdit-preference-summary-default)) |
||
(未显示同一用户的58个中间版本) | |||
第1行: | 第1行: | ||
− | /** | + | /** 外部链接 */ |
− | mw.loader. | + | mw.loader.using(['oojs-ui-windows', 'oojs-ui-core'], function() { |
− | + | $('a.external').each(function() { | |
− | + | var href = $(this).attr('href'), | |
− | + | href1 = href.split('/')[2] | |
− | + | if (href1.substring(href1.length - 8) === 'wjghj.cn') return | |
− | + | $(this).click(function(e) { | |
− | + | e.preventDefault() | |
− | + | OO.ui | |
− | + | .confirm(' 你确定要访问这个外部链接吗: ' + href) | |
− | + | .done(function(confirmed) { | |
− | + | if (confirmed) { | |
− | + | location.href = href | |
− | + | } | |
− | + | }) | |
− | + | }) | |
− | + | }) | |
− | + | }) | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
/** Global script (gtag.js) - Google Analytics **/ | /** Global script (gtag.js) - Google Analytics **/ | ||
− | + | !(function() { | |
− | + | var $script = $('<script>', { | |
− | + | src: 'https://www.googletagmanager.com/gtag/js?id=UA-148909815-1', | |
− | + | }) | |
− | + | $script.appendTo('body') | |
− | gtag('config', 'UA-148909815-1') | + | window.dataLayer = window.dataLayer || [] |
− | }) | + | function gtag() { |
+ | dataLayer.push(arguments) | ||
+ | } | ||
+ | gtag('js', new Date()) | ||
+ | gtag('config', 'UA-148909815-1') | ||
+ | })() | ||
/** 方便上传相册缺少的图片 **/ | /** 方便上传相册缺少的图片 **/ | ||
− | $('.gallery .thumb').prepend(function () { | + | $('.gallery .thumb').prepend(function() { |
− | var galleryfile = $(this).text() | + | var galleryfile = $(this).text() |
if (galleryfile == '') { | if (galleryfile == '') { | ||
− | return | + | return |
} else { | } else { | ||
− | $(this).html('<a href="https://wjghj.cn/index.php?title=Special:Upload&wpDestFile='+galleryfile+'" class="new" target="_blank">点击上传<br/>' + galleryfile + '</a>') | + | $(this).html( |
+ | '<a href="https://common.wjghj.cn/index.php?title=Special:Upload&wpDestFile=' + | ||
+ | galleryfile + | ||
+ | '" class="new" target="_blank">点击上传<br/>' + | ||
+ | galleryfile + | ||
+ | '</a>' | ||
+ | ) | ||
} | } | ||
− | }) | + | }) |
/** In page dialog **/ | /** In page dialog **/ | ||
− | $(function () { | + | $(function() { |
− | var DialogId, | + | var DialogId, BtnId, NextId, LastId |
− | + | $('.ipd').html(function() { | |
− | + | DialogId = this.dataset.dialogid | |
− | |||
− | $('.ipd').html(function () { | ||
− | DialogId = this.dataset.dialogid | ||
if (DialogId != '1') { | if (DialogId != '1') { | ||
− | $(this).hide() | + | $(this).hide() |
} | } | ||
− | }) | + | }) |
− | $('.ipd-next-btn').click(function () { | + | $('.ipd-next-btn').click(function() { |
− | BtnId = this.dataset.btnid | + | BtnId = this.dataset.btnid |
− | LastId = this.dataset.lastid | + | LastId = this.dataset.lastid |
if (LastId === 'last') { | if (LastId === 'last') { | ||
− | $('#game-selector').show(300) | + | $('#game-selector').show(300) |
− | $(this).css('color', 'green') | + | $(this).css('color', 'green') |
} else { | } else { | ||
− | BtnId = parseInt(BtnId) | + | BtnId = parseInt(BtnId) |
− | NextId = ++BtnId | + | NextId = ++BtnId |
− | $(this).css('color', 'green') | + | $(this).css('color', 'green') |
− | $('.ipd[data-dialogid=' + NextId + ']').show(300) | + | $('.ipd[data-dialogid=' + NextId + ']').show(300) |
} | } | ||
− | }) | + | }) |
− | }) | + | }) |
/** Game saver **/ | /** Game saver **/ | ||
− | $('.GameSaver').html(function(){ | + | $('.GameSaver').html(function() { |
− | var game,time,user,title,page | + | var game, time, user, title, page |
− | if ( wgUserName =='' || wgUserName == null ) { | + | var wgUserName = mw.config.get('wgUserName') |
− | unlogin = true | + | if (wgUserName == '' || wgUserName == null) { |
+ | unlogin = true | ||
} else { | } else { | ||
− | user = 'User:'+wgUserName | + | user = 'User:' + wgUserName |
− | } | + | } |
− | game = this.dataset.game | + | game = this.dataset.game |
− | time = this.dataset.time | + | time = this.dataset.time |
− | title = this.dataset.title | + | title = this.dataset.title |
− | page = this.dataset.page | + | page = this.dataset.page |
− | $(this).html('<input type=button class="save" value="保存游戏"/> <input type=button class="load" value="读取存档"/>') | + | $(this).html( |
− | if ( unlogin ) { | + | '<input type=button class="save" value="保存游戏"/> <input type=button class="load" value="读取存档"/>' |
− | $('.GameSaver .load').click(function(){alert('无法读取存档,请登录后再试') | + | ) |
+ | if (unlogin) { | ||
+ | $('.GameSaver .load').click(function() { | ||
+ | alert('无法读取存档,请登录后再试') | ||
+ | }) | ||
} else { | } else { | ||
− | $('.GameSaver .load').click(function(){location.href='/wiki/'+user+'/gamesave/'+game}) | + | $('.GameSaver .load').click(function() { |
+ | location.href = '/wiki/' + user + '/gamesave/' + game | ||
+ | }) | ||
} | } | ||
$('.GameSaver .save').click(function() { | $('.GameSaver .save').click(function() { | ||
− | if ( unlogin ) { | + | if (unlogin) { |
− | $('.GameSaver .save').unbind().attr({ | + | $('.GameSaver .save') |
− | return | + | .unbind() |
+ | .attr({ value: '存档失败,请登录后再试', disabled: '' }) | ||
+ | return | ||
} | } | ||
− | var note = prompt('有什么要备注的吗?','无') | + | var note = prompt('有什么要备注的吗?', '无') |
− | if (note === null||note === 'null') { | + | if (note === null || note === 'null') { |
− | return | + | return |
} | } | ||
− | $('.GameSaver .save').attr('value','SILI努力帮你存档中…') | + | $('.GameSaver .save').attr('value', 'SILI努力帮你存档中…') |
− | new mw.Api().post({ | + | new mw.Api() |
− | + | .post({ | |
− | + | action: 'edit', | |
− | + | title: user + '/gamesave/' + game, | |
− | + | summary: '/*' + title + ' | ' + time + '*/新增游戏' + game + '存档', | |
− | + | appendtext: | |
− | + | '\n== ' + | |
− | + | title + | |
− | + | ' | ' + | |
− | + | time + | |
− | + | ' ==\n*游戏:[[Game:' + | |
− | + | game + | |
− | + | ']]\n*时间:' + | |
− | + | time + | |
− | }) | + | '\n*[[' + |
− | }) | + | page + |
+ | '|继续游戏]]\n*备注:' + | ||
+ | note + | ||
+ | '\n\n', | ||
+ | token: mw.user.tokens.get('editToken'), | ||
+ | }) | ||
+ | .done(function() { | ||
+ | $('.GameSaver .save') | ||
+ | .unbind() | ||
+ | .attr({ value: '存档完毕!', disabled: '' }) | ||
+ | }) | ||
+ | .fail(function() { | ||
+ | alert( | ||
+ | '啊哦,存档失败了!\n1)请检查您的网络连接?\n2)您是否没有登录?\n3)刷新页面再试?' | ||
+ | ) | ||
+ | $('.GameSaver .save').attr('value', '重试') | ||
+ | }) | ||
+ | }) | ||
+ | }) | ||
/** 顶部公告 **/ | /** 顶部公告 **/ | ||
− | function siteNoticeScroll(obj,interval) { | + | function siteNoticeScroll(obj, interval) { |
$(obj).animate({ | $(obj).animate({ | ||
height: 'show', | height: 'show', | ||
第126行: | 第153行: | ||
paddingBottom: 'show', | paddingBottom: 'show', | ||
marginBottom: 'show', | marginBottom: 'show', | ||
− | }) | + | }) |
setInterval(function() { | setInterval(function() { | ||
− | $(obj).find('ul:first').animate({ | + | $(obj) |
− | + | .find('ul:first') | |
− | + | .animate( | |
− | + | { | |
− | + | marginTop: '-25px', | |
− | + | }, | |
− | + | 300, | |
− | + | function() { | |
− | + | $(this) | |
− | }, | + | .css({ |
− | + | marginTop: '0px', | |
+ | }) | ||
+ | .find('li:first') | ||
+ | .appendTo(this) | ||
+ | } | ||
+ | ) | ||
+ | }, interval) | ||
} | } | ||
− | siteNoticeScroll('.siteNoticeScroll', | + | siteNoticeScroll('.siteNoticeScroll', 12 * 1000) |
− | /** | + | /** 头像系统 **/ |
− | $(function(){ | + | $(function() { |
− | $(' | + | $('#personal h2').prepend( |
− | + | $('<a>', { | |
− | + | href: '/wiki/Special:Uploadavatar', | |
− | + | class: 'user-avatar-link', | |
− | + | }) | |
− | + | .click(function(e) { | |
− | }) | + | href = $(this).attr('href') |
− | + | e.preventDefault() | |
− | + | if ($(window).width() > 1100) { | |
− | + | location.href = href | |
− | + | } | |
− | + | }) | |
− | function | + | .append( |
− | + | $('<img>', { | |
− | + | src: '/avatar/' + mw.config.get('wgUserName'), | |
− | + | class: 'user-avatar', | |
− | + | }) | |
− | + | ) | |
− | + | ) | |
− | + | $('.mw-userlink').before(function() { | |
− | + | var user = $(this).attr('title'), | |
− | + | avatar = $('<img>', { | |
− | + | src: '/avatar/' + user, | |
− | + | class: 'user-avatar', | |
− | + | }) | |
− | + | return avatar | |
− | + | }) | |
− | + | }) | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | $('. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | ' | ||
− | ' | ||
− | }) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | // | + | /** |
+ | * Cloudflare Web Analytics | ||
+ | */ | ||
+ | $('body').append( | ||
+ | '<!-- Cloudflare Web Analytics --><script defer src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon=\'{"token": "bcc7ebd8bc4442feb16d89e12674080b"}\'></script><!-- End Cloudflare Web Analytics -->' | ||
+ | ) |
2023年11月23日 (四) 04:49的最新版本
/** 外部链接 */ mw.loader.using(['oojs-ui-windows', 'oojs-ui-core'], function() { $('a.external').each(function() { var href = $(this).attr('href'), href1 = href.split('/')[2] if (href1.substring(href1.length - 8) === 'wjghj.cn') return $(this).click(function(e) { e.preventDefault() OO.ui .confirm('你确定要访问这个外部链接吗: ' + href) .done(function(confirmed) { if (confirmed) { location.href = href } }) }) }) }) /** Global script (gtag.js) - Google Analytics **/ !(function() { var $script = $('<script>', { src: 'https://www.googletagmanager.com/gtag/js?id=UA-148909815-1', }) $script.appendTo('body') window.dataLayer = window.dataLayer || [] function gtag() { dataLayer.push(arguments) } gtag('js', new Date()) gtag('config', 'UA-148909815-1') })() /** 方便上传相册缺少的图片 **/ $('.gallery .thumb').prepend(function() { var galleryfile = $(this).text() if (galleryfile == '') { return } else { $(this).html( '<a href="https://common.wjghj.cn/index.php?title=Special:Upload&wpDestFile=' + galleryfile + '" class="new" target="_blank">点击上传<br/>' + galleryfile + '</a>' ) } }) /** In page dialog **/ $(function() { var DialogId, BtnId, NextId, LastId $('.ipd').html(function() { DialogId = this.dataset.dialogid if (DialogId != '1') { $(this).hide() } }) $('.ipd-next-btn').click(function() { BtnId = this.dataset.btnid LastId = this.dataset.lastid if (LastId === 'last') { $('#game-selector').show(300) $(this).css('color', 'green') } else { BtnId = parseInt(BtnId) NextId = ++BtnId $(this).css('color', 'green') $('.ipd[data-dialogid=' + NextId + ']').show(300) } }) }) /** Game saver **/ $('.GameSaver').html(function() { var game, time, user, title, page var wgUserName = mw.config.get('wgUserName') if (wgUserName == '' || wgUserName == null) { unlogin = true } else { user = 'User:' + wgUserName } game = this.dataset.game time = this.dataset.time title = this.dataset.title page = this.dataset.page $(this).html( '<input type=button class="save" value="保存游戏"/> <input type=button class="load" value="读取存档"/>' ) if (unlogin) { $('.GameSaver .load').click(function() { alert('无法读取存档,请登录后再试') }) } else { $('.GameSaver .load').click(function() { location.href = '/wiki/' + user + '/gamesave/' + game }) } $('.GameSaver .save').click(function() { if (unlogin) { $('.GameSaver .save') .unbind() .attr({ value: '存档失败,请登录后再试', disabled: '' }) return } var note = prompt('有什么要备注的吗?', '无') if (note === null || note === 'null') { return } $('.GameSaver .save').attr('value', 'SILI努力帮你存档中…') new mw.Api() .post({ action: 'edit', title: user + '/gamesave/' + game, summary: '/*' + title + ' | ' + time + '*/新增游戏' + game + '存档', appendtext: '\n== ' + title + ' | ' + time + ' ==\n*游戏:[[Game:' + game + ']]\n*时间:' + time + '\n*[[' + page + '|继续游戏]]\n*备注:' + note + '\n\n', token: mw.user.tokens.get('editToken'), }) .done(function() { $('.GameSaver .save') .unbind() .attr({ value: '存档完毕!', disabled: '' }) }) .fail(function() { alert( '啊哦,存档失败了!\n1)请检查您的网络连接?\n2)您是否没有登录?\n3)刷新页面再试?' ) $('.GameSaver .save').attr('value', '重试') }) }) }) /** 顶部公告 **/ function siteNoticeScroll(obj, interval) { $(obj).animate({ height: 'show', paddingTop: 'show', marginTop: 'show', paddingBottom: 'show', marginBottom: 'show', }) setInterval(function() { $(obj) .find('ul:first') .animate( { marginTop: '-25px', }, 300, function() { $(this) .css({ marginTop: '0px', }) .find('li:first') .appendTo(this) } ) }, interval) } siteNoticeScroll('.siteNoticeScroll', 12 * 1000) /** 头像系统 **/ $(function() { $('#personal h2').prepend( $('<a>', { href: '/wiki/Special:Uploadavatar', class: 'user-avatar-link', }) .click(function(e) { href = $(this).attr('href') e.preventDefault() if ($(window).width() > 1100) { location.href = href } }) .append( $('<img>', { src: '/avatar/' + mw.config.get('wgUserName'), class: 'user-avatar', }) ) ) $('.mw-userlink').before(function() { var user = $(this).attr('title'), avatar = $('<img>', { src: '/avatar/' + user, class: 'user-avatar', }) return avatar }) }) /** * Cloudflare Web Analytics */ $('body').append( '<!-- Cloudflare Web Analytics --><script defer src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon=\'{"token": "bcc7ebd8bc4442feb16d89e12674080b"}\'></script><!-- End Cloudflare Web Analytics -->' )