MediaWiki:HanziConverter.js:修订间差异

删除3字节 、​ 2021年4月15日 (星期四)
处理一个因加载时序问题导致的小问题
(.)
(处理一个因加载时序问题导致的小问题)
第22行: 第22行:
     const ignoreElements = ['TEXTAREA', 'STYLE', 'SCRIPT', 'INPUT'];
     const ignoreElements = ['TEXTAREA', 'STYLE', 'SCRIPT', 'INPUT'];
     const scanAttributes = ['title', 'placeholder'];
     const scanAttributes = ['title', 'placeholder'];
     const log = console.log, time = console.time, timeEnd = console.timeEnd, HanziConverter = window.HanziConverterFunction;
     const log = console.log, time = console.time, timeEnd = console.timeEnd;
     /**开关功能 */
     /**开关功能 */
     function userSwitch() {
     function userSwitch() {
第117行: 第117行:
         }, 1500);
         }, 1500);
         // 整活
         // 整活
         log(HanziConverter(prefix + ' 一只忧郁的台湾乌龟', type));
         log(window.HanziConverterFunction(prefix + ' 一只忧郁的台湾乌龟', type));
     }
     }
     /** */
     /** */
第138行: 第138行:
                 let node = nodes[i];
                 let node = nodes[i];
                 if (typeof node.textContent == 'string') {
                 if (typeof node.textContent == 'string') {
                     let _temp = HanziConverter(node.textContent, type);
                     let _temp = window.HanziConverterFunction(node.textContent, type);
                     if (node.textContent != _temp) // 防止过于频繁的写入
                     if (node.textContent != _temp) // 防止过于频繁的写入
                         node.textContent = _temp;
                         node.textContent = _temp;
第183行: 第183行:
             let n = nodes[i];
             let n = nodes[i];
             if (n instanceof HTMLElement && (_temp = (_a = n.getAttribute(attr)) !== null && _a !== void 0 ? _a : '').length > 0) {
             if (n instanceof HTMLElement && (_temp = (_a = n.getAttribute(attr)) !== null && _a !== void 0 ? _a : '').length > 0) {
                 let _temp_ = HanziConverter(_temp, type);
                 let _temp_ = window.HanziConverterFunction(_temp, type);
                 if (_temp_ != _temp)
                 if (_temp_ != _temp)
                     n.setAttribute(attr, _temp_);
                     n.setAttribute(attr, _temp_);