mirror of
https://github.com/modernw/App-Installer-For-Windows-8.x-Reset.git
synced 2026-06-17 21:00:08 +10:00
Update Shell and Fix Bugs
This commit is contained in:
@@ -357,4 +357,47 @@ Windows.UI.Event.Util.removeEvent(window, "resize", handler);
|
||||
};
|
||||
}
|
||||
module.exports = { debounce: debounce };
|
||||
})(this);
|
||||
|
||||
(function(global) {
|
||||
"use strict";
|
||||
|
||||
var eToEvent = {}; // 存储元素和回调
|
||||
var lastContent = {}; // 存储上一次的 textContent
|
||||
|
||||
// 注册文本变化事件
|
||||
global.setTextChangeEvent = function(el, fn) {
|
||||
if (!el || typeof fn !== "function") return;
|
||||
|
||||
var id = el.__textChangeId;
|
||||
if (!id) {
|
||||
id = Math.random().toString(36).substr(2, 9);
|
||||
el.__textChangeId = id;
|
||||
lastContent[id] = el.textContent;
|
||||
}
|
||||
|
||||
eToEvent[id] = { el: el, callback: fn };
|
||||
};
|
||||
|
||||
// 定时轮询
|
||||
setInterval(function() {
|
||||
var keys = Object.keys(eToEvent);
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
var obj = eToEvent[key];
|
||||
var el = obj.el;
|
||||
var currentText = el.textContent;
|
||||
|
||||
if (currentText !== lastContent[key]) {
|
||||
lastContent[key] = currentText;
|
||||
try {
|
||||
obj.callback.call(el, currentText);
|
||||
} catch (e) {
|
||||
// 忽略回调错误
|
||||
if (typeof console !== "undefined") console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 20);
|
||||
|
||||
})(this);
|
||||
@@ -127,4 +127,64 @@
|
||||
};
|
||||
}
|
||||
}
|
||||
})(this);
|
||||
})(this);
|
||||
// attachEvent / detachEvent polyfill for IE11+
|
||||
(function() {
|
||||
if (!Element.prototype.attachEvent) {
|
||||
Element.prototype.attachEvent = function(eventName, handler) {
|
||||
// IE attachEvent 的事件名需要 "on" 前缀
|
||||
eventName = eventName.toLowerCase();
|
||||
|
||||
// 包装函数,模仿旧 IE 的 event 对象
|
||||
var wrapper = function(e) {
|
||||
e = e || window.event;
|
||||
|
||||
// 兼容 IE 风格 event 属性
|
||||
e.srcElement = e.target || this;
|
||||
e.returnValue = true;
|
||||
e.cancelBubble = false;
|
||||
|
||||
// 模拟 IE 的防止默认行为
|
||||
Object.defineProperty(e, "cancelBubble", {
|
||||
set: function(val) {
|
||||
if (val) e.stopPropagation();
|
||||
}
|
||||
});
|
||||
Object.defineProperty(e, "returnValue", {
|
||||
set: function(val) {
|
||||
if (val === false) e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
// 调用原事件处理函数
|
||||
return handler.call(this, e);
|
||||
};
|
||||
|
||||
// 存储 handler 映射,供 detachEvent 用
|
||||
if (!this._attachEventWrappers) this._attachEventWrappers = {};
|
||||
if (!this._attachEventWrappers[eventName]) this._attachEventWrappers[eventName] = [];
|
||||
|
||||
this._attachEventWrappers[eventName].push({
|
||||
original: handler,
|
||||
wrapped: wrapper
|
||||
});
|
||||
|
||||
this.addEventListener(eventName.replace(/^on/, ""), wrapper, false);
|
||||
};
|
||||
|
||||
Element.prototype.detachEvent = function(eventName, handler) {
|
||||
eventName = eventName.toLowerCase();
|
||||
if (!this._attachEventWrappers || !this._attachEventWrappers[eventName]) return;
|
||||
|
||||
var list = this._attachEventWrappers[eventName];
|
||||
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
if (list[i].original === handler) {
|
||||
this.removeEventListener(eventName.replace(/^on/, ""), list[i].wrapped, false);
|
||||
list.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user