imported>=海豚= |
imported>Irukaza |
第1行: |
第1行: |
| // <pre>
| | <div style="position: relative; width: 97%; margin-top: .5em; padding: 10px; -moz-border-radius: 15px; -webkit-border-radius: 15px; border-radius: 15px; font-size: 110 %"> |
| /* 这里的任何JavaScript将只在移动端加载 */
| | <div style="position: relative; z-index:2;"> |
| (function($, mw) { //使用匿名函数以避免污染顶级变量
| | |
| /* 函数定义体 */
| | <center>'''<big><big> ~欢迎来到头像上传界面~</big></big>'''</center> |
| //用户资料页相关
| | |
| function isUserProfile() {
| | '''{{color|red|➤当您已经上传了头像,但没有改动时——}}<u> 请等待片刻并尝试清除浏览器缓存</u> !''' |
| return mw.config.get('wgCanonicalSpecialPageName') === "UserProfile" && mw.config.get('wgArticleId') === "0";
| | *浏览器缓存会将''' 默认头像数据''' 保存在本地,导致您看不到新上传的头像。 |
| }
| | *''' 请不要多次反复上传头像,这并没有用。''' |
| //页顶提示模板相关
| | *您可尝试按住<code>CTRL+SHIFT+DEL</code> 来清除缓存! |
| function commonBoxs() {
| | '''{{color|red|➤上传头像时,请确保您的头像合规——}}''' |
| if (window.mw && !!mw.config.get('wgNamespaceNumber')) return;
| | *<u> 包含广告内容的头像可能导致您被封禁</u>! |
| var contentParent = $('#mw-content-text')[0] ? $('#mw-content-text') : $('#content'),
| | *最好不要上传惊吓、恐吓等令人不适的头像。 |
| commonBoxes = contentParent.find('.common-box');
| | ➤''' 下方显示的是你现在正在使用的头像,它将显 示 在编辑记录你用户名的左边和你 用户页 的标题栏里。''' |
| if (!commonBoxes[0]) return;
| | </div> |
| var commonBoxContainer = $('<div id="commonBoxContainer"><div id="commonBoxInfo"></div></div>').prependTo(contentParent),
| | </div> |
| commonBoxList = $('<div id="commonBoxList"></div>').appendTo('#commonBoxInfo');
| | <br> |
| commonBoxes.each(function() {
| |
| var commonBoxButton = $('<div class="commonBoxButton"></div>').appendTo(commonBoxList),
| |
| commonBox = $(this);
| |
| commonBoxButton.data('element', commonBox).css({
| |
| 'border-color': commonBox.css('border-left-color'),
| |
| 'background-image': 'url(' + commonBox.find('tbody > tr > td:first-child img').prop('src') + ')',
| |
| }).on('click', function() {
| |
| if (commonBox.is(':visible')[0]) {
| |
| commonBoxes.hide();
| |
| $(this).add($(this).siblings()).removeClass('current');
| |
| commonBoxList.removeClass('open');
| |
| } else {
| |
| commonBoxes.filter(':visible').not(commonBox).hide();
| |
| commonBox.show();
| |
| $(this).toggleClass('current', commonBox.is(':visible')).siblings().removeClass('current');
| |
| commonBoxList.toggleClass('open', commonBox.is(':visible'));
| |
| }
| |
| });
| |
| }).appendTo(commonBoxContainer).hide();
| |
| }
| |
| //uuid
| |
| function uuidv4() {
| |
| var result;
| |
| do {
| |
| result = ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function(c) {
| |
| return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16);
| |
| });
| |
| } while (document.querySelector('a[data-linkid="' + result + '"]'));
| |
| return result;
| |
| }
| |
| // Mobile Navmenu by GFwiki
| |
| function menuadjust(){var a = $("body").height()+"px";document.getElementById("mw-mf-page-left").style.height = a;};
| |
| $(function(){menuadjust();});
| |
| $(window).resize(function(){menuadjust()});
| |
| var navbar = function(data, textStatus, jqxhr) {
| |
| var navlist = data.parse.text["*"];
| |
| $(navlist).insertBefore(".menu > .hlist")
| |
| };
| |
| var mfSidebar = function() {
| |
| var purl = "/api.php?action=parse&page=MediaWiki:MFSidebar&format=json";
| |
| $.ajax({
| |
| url: purl,
| |
| success: navbar,
| |
| error: function () {console.error("can\'t load customized navmenu")},
| |
| dataType: "json"
| |
| });
| |
| };
| |
| $(function(){mfSidebar();});
| |
| /* 函数执行体 */
| |
| $(function() {
| |
| //页顶提 示 模板相关
| |
| commonBoxs();
| |
| // 用户 资料 页
| |
| if (isUserProfile()) {
| |
| var cardContainer = $('.card-container'),
| |
| containerImage = cardContainer.find('.card'),
| |
| containerImageFile = containerImage.find('a.image'),
| |
| containerImageCaption = containerImage.find('.caption');
| |
| containerImageCaption.css("padding", "0 8px");
| |
| containerImageFile.before('<div id="#containerImage" class="listThumb list-thumb-placeholder" style="text-align: center;"><img src="http://static.mengniang.org/common/a/a4/Placeholder-upload.png" style="height:32px" /></div>');
| |
| }
| |
| //黑幕
| |
| $('.heimu a').on("click", function() {
| |
| if (!$(this).closest('.heimu').is(':active, :focus')) return false;
| |
| });
| |
| //Template:hide
| |
| if ($('.mw-collapsible')[0]) mw.loader.using('jquery.makeCollapsible').then(function() {
| |
| //console.debug('jquery.makeCollapsible is loaded.');
| |
| $('.mw-collapsible').makeCollapsible();
| |
| });
| |
| //桌面版页面外链改为移动端域名
| |
| mw.loader.using("mediawiki.Uri").then(function() {
| |
| $('a[target="_blank"]').each(function() {
| |
| var url = new mw.Uri(this.href);
| |
| if (url.host === "www.hmoegirl.com" && url.query.mobileaction !== "toggle_view_desktop") {
| |
| url.host = "m.hmoegirl.com";
| |
| this.href = url;
| |
| }
| |
| });
| |
| });
| |
| });
| |
| })(jQuery, mediaWiki); //立即执行匿名函数并传递原始变量
| |
| // </pre>
| |