-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloader.js
More file actions
83 lines (71 loc) · 3.31 KB
/
loader.js
File metadata and controls
83 lines (71 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
if (window.location.host=="thewandcompany.github.io") {
document.getElementById("apploaderlinks").innerHTML =
'How did this get here?';
} else if (window.location.hostname==='localhost') {
document.title += " [Local]";
Const.APPS_JSON_FILE = "apps.local.json";
document.getElementById("apploaderlinks").innerHTML =
'Localhost, ahoy!';
} else {
document.title += " [Unofficial]";
document.getElementById("apploaderlinks").innerHTML =
'This is an improved version of the official Mod Tool - you can try the <a href="https://thewandcompany.github.io/pip-boy/">original version</a> here.';
}
var RECOMMENDED_VERSION = "2v24.446";
// We're only interested in
DEVICEINFO = [
{
id : "PIPBOY",
name : "Pip-Boy",
features : ["GRAPHICS"],
g : { width : 480, height : 320, bpp : 16 },
img : ""
}
];
Const.FILES_IN_FS = true;
Const.HAS_E_SHOWMESSAGE = false;
Const.CODE_PROGRESSBAR = "g.drawRect(10,g.getHeight()-16,g.getWidth()-10,g.getHeight()-8).flip();p=x=>g.fillRect(10,g.getHeight()-16,10+(g.getWidth()-20)*x/100,g.getHeight()-8);",
Const.NO_RESET = true;
Const.LOAD_APP_AFTER_UPLOAD = true;
Const.UPLOAD_CHUNKSIZE = 2048;
Const.PACKET_UPLOAD_CHUNKSIZE = 1024*7;
Const.PACKET_UPLOAD_NOACK = true; // we're over USB and confident in flow control
// Set up source code URL
(function() {
let username = "thewandcompany";
let githubMatch = window.location.href.match(/\/([\w-]+)\.github\.io/);
if (githubMatch) username = githubMatch[1];
Const.APP_SOURCECODE_URL = `https://github.com/${username}/pip-boy/tree/master/apps`;
})();
// When a device is found, filter the apps accordingly
function onFoundDeviceInfo(deviceId, deviceVersion) {
var fwURL = "#", fwExtraText = "";
if (deviceId == "PIPBOY") {
Const.MESSAGE_RELOAD = 'Press power button to reload';
}
if (deviceId != "PIPBOY") {
showToast(`You're using ${deviceId}, not a Pip-Boy! Did you want <a href="https://espruino.com/apps">espruino.com/apps</a> instead?` ,"warning", 20000);
} else if (versionLess(deviceVersion, RECOMMENDED_VERSION)) {
// showToast(`You're using an old firmware (${deviceVersion}) and ${RECOMMENDED_VERSION} is available (<a href="https://www.espruino.com/ChangeLog" target="_blank">see changes</a>). <a href="https://thewand.co/pip-boy" target="_blank">Click here to update</a>` ,"warning", 20000);
showToast(`You're using an old firmware (${deviceVersion}) and ${RECOMMENDED_VERSION} is available. <a href="https://thewand.co/pip-boy/upgrade/?file=fwupdate_${RECOMMENDED_VERSION}.zip">Click here to update</a>` ,"warning", 20000);
}
}
// Called when we refresh the list of installed apps
//function onRefreshMyApps() { }
window.addEventListener('load', (event) => {
});
//function onAppJSONLoaded() {}
/**
* Warn the page must be served over HTTPS
* The `beforeinstallprompt` event won't fire if the page is served over HTTP.
* Installability requires a service worker with a fetch event handler, and
* if the page isn't served over HTTPS, the service worker won't load.
*/
if (window.location.protocol === 'http:' && window.location.hostname!="localhost") {
const requireHTTPS = document.getElementById('requireHTTPS');
const link = requireHTTPS.querySelector('a');
link.href = window.location.href.replace('http://', 'https://');
requireHTTPS.classList.remove('hidden');
}
// DEBUGGING
//UART.debug=3;