“MediaWiki:Common.js”的版本间的差异
来自小鱼君和他的朋友们
小 (//InPageEdit) 标签:InPageEdit |
|||
第173行: | 第173行: | ||
if (title != '' && title != undefined) { | if (title != '' && title != undefined) { | ||
− | title = '< | + | title = '<h2 id="popup-window-title">' + title + '</h2>'; |
} else { | } else { | ||
title = ''; | title = ''; | ||
} | } | ||
if (content == undefined || content == '') { | if (content == undefined || content == '') { | ||
− | title = '< | + | title = '<h2 id="popup-window-title" class="error"> Error in Popup Window </h2>'; |
content = 'No content!'; | content = 'No content!'; | ||
} | } | ||
第184行: | 第184行: | ||
'<div id="popup-window-bg"></div>' + | '<div id="popup-window-bg"></div>' + | ||
'<div id="popup-window">' + | '<div id="popup-window">' + | ||
+ | '<div id="dragArea" style="width: 100%; text-align: center; color:white; background: gray; height:14px;"><span class="m-icon">drag_handle</span></div>'+ | ||
closeBtn+ | closeBtn+ | ||
title + | title + |
2019年10月10日 (四) 19:25的版本
/** jQuery cookie **/ mw.loader.load("https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js"); $(window).on('load',function(){ if ($.cookie('use-cookie-notify') !== 'showed') { $.toast({ heading:'我们使用cookie', text:'是的,我们的网站使用cookie技术来满足某些功能的使用需求,更多信息请阅读我们的<a href="/wiki/Project:关于/Cookie" style="text-decoration:underline">Cookie使用声明</a>。', icon:'info', hideAfter:false, afterHidden: function(){$.cookie('use-cookie-notify','showed',{expires:60});}, position:'top-left' }); } }); /** 分享按钮 **/ mw.loader.load('/index.php?title=MediaWiki:Share-btn.js&action=raw&ctype=text/javascript'); /** ToastNotify **/ mw.loader.load('https://common.wjghj.cn/js/toast'); /** ToastrNotify **/ // mw.loader.load('https://common.wjghj.cn/js/toastr'); /** 版权提示 **/ mw.loader.load('/index.php?title=MediaWiki:NotifyWhenCopy.js&action=raw&ctype=text/javascript'); /** Global script (gtag.js) - Google Analytics **/ mw.loader.load('https://www.googletagmanager.com/gtag/js?id=UA-148909815-1'); $(window).load(function(){ 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://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; 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',5000); /** [[T:Notify]] **/ $(function(){ $('.notify').html(function(){ var type = $(this).attr('data-type'), content = $(this).html(); $.toast({ text: content, icon: type }); }).remove(); }); /** Custom Modal**/ function PopupWindow(content,title,settings) { PopupWindow(content,title,settings); } function Modal(content,title,settings) { function close(){ $('#popup-window, #popup-window-bg').fadeOut(400); setTimeout(function(){$('#popup-window, #popup-window-bg').remove()},400); } var closeBtn = '<div id="popup-window-close"><img class="close-modal" src="https://wjghj.cn/images/d/d0/Close-btn.png"/></div>'; if (settings !== undefined) { if (settings.closeBtn == false) { closeBtn = ''; } } if (title != '' && title != undefined) { title = '<h2 id="popup-window-title">' + title + '</h2>'; } else { title = ''; } if (content == undefined || content == '') { title = '<h2 id="popup-window-title" class="error"> Error in Popup Window </h2>'; content = 'No content!'; } $('body').append( '<div id="popup-window-bg"></div>' + '<div id="popup-window">' + '<div id="dragArea" style="width: 100%; text-align: center; color:white; background: gray; height:14px;"><span class="m-icon">drag_handle</span></div>'+ closeBtn+ title + '<div id="popup-window-content">' + content + '</div>'+ '</div>' ); $('#popup-window, #popup-window-bg').fadeIn(300); $('#popup-window').css({ 'position': 'absolute', 'top': $(window).scrollTop()+120 }); $('#popup-window-bg, #popup-window .close-modal').click(close); if (settings.disableBg === true) { $('#popup-window-bg').unbind(); } // Dragable function bindDragging(e) { var element = $(this); var baseX = e.clientX; var baseY = e.clientY; var baseOffsetX = element.parent().offset().left; var baseOffsetY = element.parent().offset().top; $(document).mousemove(function(e) { element.parent().css({ 'left': baseOffsetX + e.clientX - baseX, 'top': baseOffsetY + e.clientY - baseY }); }); $(document).mouseup(function() { $(document).unbind('mousemove'); $(document).unbind('mouseup'); bindDragging(element); }); }; $('#popup-window-title').mousedown(bindDragging); } //ALL CLEAR