Github-bot(留言 | 贡献) (Git更新:代码仓库同步更新) |
Github-bot(留言 | 贡献) (Git更新:([https://github.com/TopRealm/InterfaceCodes/commit/cd60c5c62c21aace3bfd2e325f57010dffe9da71 cd60c5c]) Various code update. (#154)) |
||
第4行: | 第4行: | ||
* |
* |
||
* @base <https://zh.wikipedia.org/wiki/Special:Permalink/59753812> |
* @base <https://zh.wikipedia.org/wiki/Special:Permalink/59753812> |
||
* @base <https://zh.wikipedia.org/wiki/MediaWiki:Gadget-ding.css> |
|||
* @source <https://git.qiuwen.wiki/InterfaceAdmin/Gadgets/src/branch/master/src/Gadgets/Ding> |
* @source <https://git.qiuwen.wiki/InterfaceAdmin/Gadgets/src/branch/master/src/Gadgets/Ding> |
||
*/ |
*/ |
||
第13行: | 第14行: | ||
* | otherwise they will be lost. | |
* | otherwise they will be lost. | |
||
* +--------------------------------------------------------+ |
* +--------------------------------------------------------+ |
||
* | |
* | Changes to this page may affect many users. | |
||
* | Please discuss changes at |
* | Please discuss changes at talk page before editing. | |
||
* +--------------------------------------------------------+ |
* +--------------------------------------------------------+ |
||
*/ |
*/ |
||
/* <nowiki> */ |
/* <nowiki> */ |
||
'use strict'; |
|||
window.DingExposedInterface = function ding() { |
window.DingExposedInterface = function ding() { |
||
var dingMain = function dingMain(message) { |
var dingMain = function dingMain(message) { |
||
第26行: | 第25行: | ||
var persist = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; |
var persist = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; |
||
if (!document.querySelector('#ding')) { |
if (!document.querySelector('#ding')) { |
||
document. |
var dingDiv = document.createElement('div'); |
||
dingDiv.id = 'ding'; |
|||
dingDiv.className = 'noprint'; |
|||
document.body.insertAdjacentElement('afterbegin', dingDiv); |
|||
} |
} |
||
var dingElement = document.querySelector('#ding'); |
var dingElement = document.querySelector('#ding'); |
||
第32行: | 第34行: | ||
if (previousMessage) { |
if (previousMessage) { |
||
var previousMessageStyle = previousMessage.style; |
var previousMessageStyle = previousMessage.style; |
||
previousMessageStyle.transform = 'translateY( |
previousMessageStyle.transform = 'translateY(125%)'; |
||
setTimeout(function () { |
setTimeout(function () { |
||
previousMessage.remove(); |
previousMessage.remove(); |
||
}, 500); |
}, 500); |
||
} |
} |
||
var dingInnerElement = document.createElement('div'); |
|||
dingElement.insertAdjacentHTML('beforeend', "<div class=\"ding_inner ding_".concat(type, "\">").concat(message, "</div>")); |
|||
// The following classes are used here: |
|||
// * ding_inner |
|||
// * ding_info |
|||
// * ding_success |
|||
// * ding_warning |
|||
dingInnerElement.className = "ding_inner ding_".concat(type); |
|||
dingInnerElement.innerHTML = message; |
|||
dingElement.insertAdjacentElement('beforeend', dingInnerElement); |
|||
var noticeElement = dingElement.lastChild; |
var noticeElement = dingElement.lastChild; |
||
var noticeElementStyle = noticeElement.style; |
var noticeElementStyle = noticeElement.style; |
||
if (persist) { |
if (persist) { |
||
noticeElement === null || noticeElement === void 0 |
noticeElement === null || noticeElement === void 0 || noticeElement.addEventListener('click', function () { |
||
noticeElementStyle.transform = 'translateY( |
noticeElementStyle.transform = 'translateY(125%)'; |
||
setTimeout(function () { |
setTimeout(function () { |
||
noticeElement.remove(); |
noticeElement.remove(); |
||
第53行: | 第63行: | ||
if (ttl !== 'long') { |
if (ttl !== 'long') { |
||
setTimeout(function () { |
setTimeout(function () { |
||
noticeElementStyle.transform = 'translateY( |
noticeElementStyle.transform = 'translateY(125%)'; |
||
}, ttl + 10); |
}, ttl + 10); |
||
setTimeout(function () { |
setTimeout(function () { |
||
noticeElement === null || noticeElement === void 0 |
noticeElement === null || noticeElement === void 0 || noticeElement.remove(); |
||
}, ttl + 510); |
}, ttl + 510); |
||
} |
} |
2023年10月5日 (四) 00:06的版本
/**
* SPDX-License-Identifier: CC-BY-SA-4.0
* _addText: '{{Gadget Header|license=CC-BY-SA-4.0}}'
*
* @base <https://zh.wikipedia.org/wiki/Special:Permalink/59753812>
* @base <https://zh.wikipedia.org/wiki/MediaWiki:Gadget-ding.css>
* @source <https://git.qiuwen.wiki/InterfaceAdmin/Gadgets/src/branch/master/src/Gadgets/Ding>
*/
/**
* +--------------------------------------------------------+
* | === WARNING: GLOBAL GADGET FILE === |
* +--------------------------------------------------------+
* | All changes should be made in the repository, |
* | otherwise they will be lost. |
* +--------------------------------------------------------+
* | Changes to this page may affect many users. |
* | Please discuss changes at talk page before editing. |
* +--------------------------------------------------------+
*/
/* <nowiki> */
window.DingExposedInterface = function ding() {
var dingMain = function dingMain(message) {
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'info';
var ttl = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3600;
var persist = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
if (!document.querySelector('#ding')) {
var dingDiv = document.createElement('div');
dingDiv.id = 'ding';
dingDiv.className = 'noprint';
document.body.insertAdjacentElement('afterbegin', dingDiv);
}
var dingElement = document.querySelector('#ding');
var previousMessage = dingElement.lastChild;
if (previousMessage) {
var previousMessageStyle = previousMessage.style;
previousMessageStyle.transform = 'translateY(125%)';
setTimeout(function () {
previousMessage.remove();
}, 500);
}
var dingInnerElement = document.createElement('div');
// The following classes are used here:
// * ding_inner
// * ding_info
// * ding_success
// * ding_warning
dingInnerElement.className = "ding_inner ding_".concat(type);
dingInnerElement.innerHTML = message;
dingElement.insertAdjacentElement('beforeend', dingInnerElement);
var noticeElement = dingElement.lastChild;
var noticeElementStyle = noticeElement.style;
if (persist) {
noticeElement === null || noticeElement === void 0 || noticeElement.addEventListener('click', function () {
noticeElementStyle.transform = 'translateY(125%)';
setTimeout(function () {
noticeElement.remove();
}, 500);
});
}
setTimeout(function () {
noticeElementStyle.transform = 'translateY(0%)';
}, 10);
if (ttl !== 'long') {
setTimeout(function () {
noticeElementStyle.transform = 'translateY(125%)';
}, ttl + 10);
setTimeout(function () {
noticeElement === null || noticeElement === void 0 || noticeElement.remove();
}, ttl + 510);
}
};
return dingMain;
}();
/* </nowiki> */