-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.html
More file actions
80 lines (76 loc) · 2.57 KB
/
testing.html
File metadata and controls
80 lines (76 loc) · 2.57 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
<html>
<head>
<link rel="stylesheet" href="accordion.css">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="tabs.css">
<link rel="stylesheet" href="search.css">
</head>
<body>
<script type='module'>
import {resolveAll} from './util.js';
const modulenames = [
"data",
"locale",
"normalize",
"process",
"infobox",
"util",
"accordion",
"editjson",
"simplex",
"rational",
"solve",
"rational2",
"template",
"renderers",
"search",
];
const moduleps = {}
for (const modulename of modulenames) {
const modulep = import(`./${modulename}.js`);
moduleps[modulename] = modulep;
}
const modules = await resolveAll(moduleps);
for (const [modulename,module] of Object.entries(modules)) {
window['m'+modulename] = module;
}
const renderer=new mtemplate.Renderer();
renderer.renderers={accordion:mrenderers.accordion, editjson:mrenderers.editjson, json:mrenderers.json, icon:mrenderers.icon, texticon:mrenderers.texticon, richtext:mrenderers.richtext, tabs:mrenderers.tabs};
function tee(prefix) {
return function(arg) {
console.log(prefix, arg);
return arg;
}
}
let urlparams=new URLSearchParams(window.location.search);
const modpack = (urlparams.get('pack'))??'nullius';
let modsp=fetch('mods.json').then(r=>r.json()).then(tee('m'));
const datalocationp = modsp.then(mods=>mods.datalocations).then(tee('ml'));
let datap=datalocationp.then(locs=>fetch(locs[modpack].data)).then(r=>r.json()).then(data=>new mdata.FactorioData(data)).then(tee('d'));
let localep=datalocationp.then(locs=>fetch(locs[modpack].locale)).then(r=>r.json()).then(locale=>new mlocale.FactorioLocale(locale.en)).then(tee('l'));
window.initializedp=mutil.resolveAll({'data':datap,'locale':localep,'mods':modsp}).then(d=>{
window.data=d.data;
window.locale=d.locale;
window.mods=d.mods;
window.localizer=new mlocale.FactorioLocalizer(d.data,d.locale);
});
modsp.then(mods=>{
const container = document.querySelector('.links');
for (const imodpack of Object.keys(mods.datalocations)) {
if (imodpack == modpack) {
continue;
}
const link = document.createElement('a');
link.append(imodpack);
const thisurl = new URL(window.location.href);
const urlparams=new URLSearchParams(thisurl.search);
urlparams.set('pack',imodpack);
thisurl.search = '?'+urlparams;
link.href = thisurl.href;
container.append(link);
}
});
</script>
<div class="links"></div>
</body>
</html>