4ec46f9eada332ba184e9df7909321fcd42e2001
1 /* The person who associated a work with this deed has dedicated the
2 work to the public domain by waiving all of his or her rights to
3 the work worldwide under copyright law, including all related and
4 neighboring rights, to the extent allowed by law.
6 You can copy, modify, distribute and perform the work, even for
7 commercial purposes, all without asking permission.
14 var _window
= window
.parent
;
16 function clamp (i
, hi
) { return Math
.max(0, Math
.min(hi
, +i
| 0)); }
17 function force10 (i
) { return clamp(i
, 1023); }
18 function force16 (i
) { return clamp(i
, 65535); }
19 function forcebool (i
) { return !!(+i
|| i
=== "true"); }
20 function forcestr (s
) { return (s
|| "").toString().substring(0, 1023); }
23 MapX
: force10
, MapY
: force10
,
25 Misc0
: force16
, Misc1
: force16
, Misc2
: force16
, Misc3
: force16
,
26 Switch0
: forcebool
, Switch1
: forcebool
,
27 Switch2
: forcebool
, Switch3
: forcebool
,
28 Switch4
: forcebool
, Switch5
: forcebool
,
29 Switch6
: forcebool
, Switch7
: forcebool
32 function generateMessage () {
35 r
[k
] = KEYS
[k
](localStorage
["WEBCART1000 " + k
]);
39 function storeMessage (data
) {
40 if (!data
|| typeof data
!== "object")
44 localStorage
["WEBCART1000 " + k
] = KEYS
[k
](data
[k
]);
49 function postMessage () {
50 _window
.postMessage(generateMessage(), "*");
53 function onMessage (event
) {
56 if (event
.data
=== "refresh") {
57 _window
= event
.source
;
60 storeMessage(event
.data
);
64 function onStorage (event
) {
68 window
.addEventListener("load", function () {
70 localStorage
.setItem("WEBCART1000", "WEBCART1000");
75 window
.addEventListener("message", onMessage
, false);
76 window
.addEventListener("storage", onStorage
, false);
80 }).call(window
.webcart1000
= {});