Cleaned up compatibility declarations.
This commit is contained in:
parent
7564765317
commit
1c797565b7
3 changed files with 25 additions and 22 deletions
|
@ -1,26 +1,32 @@
|
||||||
#include server.js
|
#include server.js
|
||||||
|
|
||||||
// backwards compat for scripts
|
const MamiCompat = (current, path, handler) => {
|
||||||
if(!Umi) window.Umi = {};
|
if(typeof path !== 'string')
|
||||||
|
throw 'path must be a string';
|
||||||
|
if(typeof handler !== 'function')
|
||||||
|
throw 'handler must be a function';
|
||||||
|
|
||||||
if(!Umi.Server) Umi.Server = {};
|
path = path.split('.');
|
||||||
if(!Umi.Server.sendMessage) Umi.Server.sendMessage = function() { console.log('Umi.Server.sendMessage called'); };
|
|
||||||
if(!Umi.Server.SendMessage) Umi.Server.SendMessage = Umi.Server.sendMessage.bind(Umi.Server);
|
|
||||||
|
|
||||||
if(!Umi.Protocol) Umi.Protocol = {};
|
const final = path.pop();
|
||||||
if(!Umi.Protocol.SockLegacy) Umi.Protocol.SockLegacy = {};
|
if(final === undefined)
|
||||||
if(!Umi.Protocol.SockLegacy.Protocol) Umi.Protocol.SockLegacy.Protocol = {};
|
throw 'invalid path';
|
||||||
if(!Umi.Protocol.SockLegacy.Protocol.Instance) Umi.Protocol.SockLegacy.Protocol.Instance = {};
|
|
||||||
if(!Umi.Protocol.SockLegacy.Protocol.Instance.SendMessage) Umi.Protocol.SockLegacy.Protocol.Instance.SendMessage = Umi.Server.sendMessage.bind(Umi.Server);
|
|
||||||
|
|
||||||
if(!Umi.Parser) Umi.Parser = {};
|
for(const part of path) {
|
||||||
if(!Umi.Parser.SockChatBBcode) Umi.Parser.SockChatBBcode = {};
|
if(!(part in current))
|
||||||
if(!Umi.Parser.SockChatBBcode.EmbedStub) Umi.Parser.SockChatBBcode.EmbedStub = function() {};
|
current[part] = {};
|
||||||
|
current = current[part];
|
||||||
|
}
|
||||||
|
|
||||||
if(!Umi.UI) Umi.UI = {};
|
if(!(final in current))
|
||||||
if(!Umi.UI.View) Umi.UI.View = {};
|
current[final] = handler;
|
||||||
if(!Umi.UI.View.SetText) Umi.UI.View.SetText = function() { console.log('Umi.UI.View.SetText called'); };
|
};
|
||||||
|
|
||||||
if(!Umi.UI.Menus) Umi.UI.Menus = {};
|
// Backwards compat for scripts
|
||||||
if(!Umi.UI.Menus.Add) Umi.UI.Menus.Add = function() { console.log('Umi.UI.Menus.Add called'); };
|
// Keep in sync with <https://fii.moe/fp/13176> for as long as possible
|
||||||
if(!Umi.UI.Menus.Get) Umi.UI.Menus.Get = function() { console.log('Umi.UI.Menus.Get called'); };
|
MamiCompat(Umi, 'Server.SendMessage', Umi.Server.sendMessage.bind(Umi.Server));
|
||||||
|
MamiCompat(Umi, 'Protocol.SockLegacy.Protocol.Instance.SendMessage', Umi.Server.sendMessage.bind(Umi.Server));
|
||||||
|
MamiCompat(Umi, 'Parser.SockChatBBcode.EmbedStub', function() {}); // intentionally a no-op
|
||||||
|
MamiCompat(Umi, 'UI.View.SetText', function() { console.log('Umi.UI.View.SetText called'); });
|
||||||
|
MamiCompat(Umi, 'UI.Menus.Add', function() { console.log('Umi.UI.Menus.Add called'); });
|
||||||
|
MamiCompat(Umi, 'UI.Menus.Get', function() { console.log('Umi.UI.Menus.Get called'); });
|
||||||
|
|
|
@ -702,8 +702,6 @@ Umi.Settings = function(metaData) {
|
||||||
localStorage.removeItem(prefix + name);
|
localStorage.removeItem(prefix + name);
|
||||||
};
|
};
|
||||||
|
|
||||||
removeRaw('cookiesMigrated');
|
|
||||||
|
|
||||||
const hasValue = function(name) {
|
const hasValue = function(name) {
|
||||||
if(!mutable.includes(name))
|
if(!mutable.includes(name))
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include ui/loading-overlay.jsx
|
#include ui/loading-overlay.jsx
|
||||||
#include sound/umisound.js
|
#include sound/umisound.js
|
||||||
|
|
||||||
if(!Umi) window.Umi = {};
|
|
||||||
if(!Umi.Protocol) Umi.Protocol = {};
|
if(!Umi.Protocol) Umi.Protocol = {};
|
||||||
if(!Umi.Protocol.SockChat) Umi.Protocol.SockChat = {};
|
if(!Umi.Protocol.SockChat) Umi.Protocol.SockChat = {};
|
||||||
if(!Umi.Protocol.SockChat.Protocol) Umi.Protocol.SockChat.Protocol = {};
|
if(!Umi.Protocol.SockChat.Protocol) Umi.Protocol.SockChat.Protocol = {};
|
||||||
|
|
Loading…
Reference in a new issue