跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
站规和指南
所有页面
最近更改
随机页面
所有分类
青岛二中Wiki
搜索
搜索
外观
创建账号
登录
个人工具
创建账号
登录
未登录编辑者的页面
了解详情
贡献
讨论
查看“︁MediaWiki:Common.js”︁的源代码
系统消息
讨论
English
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
页面信息
外观
移至侧栏
隐藏
←
MediaWiki:Common.js
因为以下原因,您没有权限编辑该页面:
此页面为本wiki上的软件提供界面文本,并受到保护以防止滥用。 如欲修改所有wiki的翻译,请访问
translatewiki.net
上的MediaWiki本地化项目。
您无权编辑此JavaScript页面,因为编辑此页面可能会影响所有访问者。
您可以查看和复制此页面的源代码。
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ /* 倒计时 */ (function ($) { 'use strict'; var countdowns = []; var NO_LEADING_ZEROS = 1, SHORT_FORMAT = 2, NO_ZEROS = 4; function formatTime(unit, value, isShort) { if (isShort) { return value + ' ' + (unit === 'day' ? 'd' : unit[0]); } return value + ' ' + unit; } function output(i, diff) { var delta, result, parts = []; var isShort = Boolean(countdowns[i].opts & SHORT_FORMAT); delta = diff % 60; parts.unshift(formatTime('秒', delta, isShort)); diff = Math.floor(diff / 60); delta = diff % 60; parts.unshift(formatTime('分', delta, isShort)); diff = Math.floor(diff / 60); delta = diff % 24; parts.unshift(formatTime('小时', delta, isShort)); diff = Math.floor(diff / 24); parts.unshift(formatTime('天', diff, isShort)); if (countdowns[i].opts & NO_LEADING_ZEROS) { while (parts.length && parts[0].startsWith('0 ')) { parts.shift(); } } if (countdowns[i].opts & NO_ZEROS) { parts = parts.filter(function (part) { return !part.startsWith('0 '); }); } if (parts.length) { if (isShort) { countdowns[i].node.text(parts.join(' ')); } else { // 不在分和秒之间加 "和" countdowns[i].node.text(parts.join(', ')); } } else { countdowns[i].node.text('0 秒'); } } function end(i) { var c = countdowns[i].node.parent(); switch (c.data('end')) { case 'remove': c.remove(); return true; case 'stop': output(i, 0); return true; case 'toggle': var toggle = c.data('toggle'); if (toggle && toggle === 'next') { c.next().show(); c.hide(); return true; } if (toggle && $(toggle).length) { $(toggle).show(); c.hide(); return true; } break; case 'callback': var callback = c.data('callback'); if (callback && typeof module[callback] === 'function') { output(i, 0); module[callback].call(c); return true; } break; } countdowns[i].countup = true; output(i, 0); return false; } function update() { var now = Date.now(); var countdownsToRemove = []; $.each(countdowns.slice(0), function (i, countdown) { var diff = Math.floor((countdown.date - now) / 1000); if (diff <= 0 && !countdown.countup) { if (end(i)) countdownsToRemove.push(i); } else { output(i, diff); } }); var x; while ((x = countdownsToRemove.pop()) !== undefined) { countdowns.splice(x, 1); } if (countdowns.length) { setTimeout(update, 1000); } } function getOptions(node) { var text = node.parent().data('options'), opts = 0; if (text) { if (/no-leading-zeros/.test(text)) { opts |= NO_LEADING_ZEROS; } if (/short-format/.test(text)) { opts |= SHORT_FORMAT; } if (/no-zeros/.test(text)) { opts |= NO_ZEROS; } } return opts; } function init() { var countdown = $('.countdown:not(.handled)'); if (!countdown.length) return; $('.nocountdown').hide(); countdown .show() .find('.countdowndate') .each(function () { var $this = $(this), date = (new Date($this.text())).valueOf(); if (isNaN(date)) { $this.text('错误的日期格式'); return; } countdowns.push({ node: $this, opts: getOptions($this), date: date, }); }); countdown.addClass('handled'); if (countdowns.length) { update(); } } // 初始化倒计时 init(); })(jQuery);
返回
MediaWiki:Common.js
。
搜索
搜索
查看“︁MediaWiki:Common.js”︁的源代码
添加话题