Split the game page into partials under src/, assembled into one index.html at build
site/index.html (900 KB of HTML, CSS and JS in one file) becomes src/: a shell (src/index.html), styles/ and game/, concatenated in path order by scripts/lib/page.js. The assembled page is byte-identical to the old file, so load time and in-game performance are unchanged. - scripts/build.js replaces build.sh (same env vars, same output) - npm run dev: a zero-dependency dev server that assembles on every request - tests assemble the page in memory; npm test runs every tests/*.test.js - perf-bench takes --base-ref to build a git ref's page - scripts/legacy/split-index-html.js is the splitter, kept for older branches
This commit is contained in:
parent
295e68cc46
commit
67a40942b4
113 changed files with 5584 additions and 5195 deletions
15
src/game/60-features/30-conferences.js
Normal file
15
src/game/60-features/30-conferences.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/* ---------- conference season ---------- */
|
||||
const CONFS=[{n:'NANOG',c:'chi',m:1},{n:'APRICOT',c:'sin',m:1},{n:'Peering Days',c:'waw',m:2},{n:'DKNOG',c:'cph',m:2,j:N_('The hallway track moved to a bar by the harbour, where the woman behind the bar kept pouring aquavit long past midnight and asked nobody about their AS path. Back at the hotel bar, someone said “just one more drink”. Your BGP sessions stayed up all night. So did you.')},{n:'UKNOF',c:'lon',m:3},{n:'MENOG',c:'dxb',m:3},{n:'NZNOG',c:'akl',m:3},{n:'RIPE',c:'ams',m:4},{n:'NANOG',c:'sea',m:5},{n:'IX Forum',c:'tok',m:6},{n:'AfPIF',c:'nbo',m:7},{n:'AusNOG',c:'syd',m:8},{n:'NLNOG Day',c:'ams',m:8},{n:'LACNOG',c:'sao',m:9},{n:'NANOG',c:'ash',m:9},{n:'DENOG',c:'fra',m:10},{n:'RIPE',c:'ber',m:10},{n:'PTT Forum',c:'sao',m:11},{n:'PacNOG',c:'suv',m:11}];
|
||||
const CONF_COST=8000,CONF_DAYS=45;
|
||||
const confDay=(cf,y)=>y*360+cf.m*30+9;
|
||||
function confKey(cf,y){return cf.n+'@'+cf.c+'@'+y;}
|
||||
function upcomingConfs(within){const y0=Math.floor(S.day/360),out=[];for(const y of [y0,y0+1])for(const cf of CONFS){const d=confDay(cf,y);if(d>=S.day&&d-S.day<=within)out.push({...cf,day:d,key:confKey(cf,y)});}return out.sort((a,b)=>a.day-b.day);}
|
||||
function confBoost(id){const cb=S.conf;if(!cb||!(cb.until>S.day))return 1;const n=NET[id];return n&&n.pops.some(c=>CITY[c]&&CITY[c].reg===cb.reg)?0.5:1;}
|
||||
function confTick(d){S.confReg=S.confReg||{};
|
||||
for(const cf of upcomingConfs(30)){if(cf.day-d===30&&!S.confReg[cf.key])toast(tr('<b>{conf} comes to {city} in 30 days.</b><br>Peering coordinators, hallway track, free stickers. Register in the Deals tab.',{conf:esc(cf.n),city:esc(CITY[cf.c].name)}),'goal',[{l:tr('Show me'),act:'leftTab',args:{t:'deals'}}]);}
|
||||
for(const cf of upcomingConfs(0)){if(cf.day!==d||!S.confReg[cf.key])continue;const reg=CITY[cf.c].reg;S.conf={until:d+CONF_DAYS,reg,name:cf.n};S.stats.confs=(S.stats.confs||0)+1;
|
||||
const r=Math.random();let extra='';if(r<0.3){const cash=5000+Math.floor(Math.random()*4)*5000;S.cash+=cash;extra=' '+tr('You also won the raffle: {cash} worth of optics, sold on eBuy the same evening.',{cash:fmt$(cash)});}else if(r<0.5)extra=' '+tr('Someone from Goggle bought you a beer. You did not get their name, only a sticker.');if(cf.j)extra=' '+tr(cf.j)+(r<0.3?extra:'');
|
||||
toast(tr('<b>{conf} in {city}</b><br>You shook a lot of hands. For {n} days, selective networks with a presence in {region} want half the usual traffic before they peer.',{conf:esc(cf.n),city:esc(CITY[cf.c].name),n:CONF_DAYS,region:esc(REG[reg])})+extra,'goal');sfx('coin');}}
|
||||
function confSection(){const up=upcomingConfs(75).slice(0,3),cb=S.conf&&S.conf.until>S.day?S.conf:null;if(!up.length&&!cb)return '';
|
||||
return `<h3 style="font-size:15px;margin:10px 0 4px">${tr('Conferences')}</h3>${cb?`<div class="inc" style="background:#EAF7EE"><div class="nm">${tr('{name} glow: {n} days left',{name:esc(cb.name),n:cb.until-S.day})}</div><div class="meta">${tr('Selective networks in {region} need half the usual traffic to peer. Now is the time to ask for that PNI.',{region:esc(REG[cb.reg])})}</div></div>`:''}${up.map(cf=>{const reg=S.confReg&&S.confReg[cf.key];return `<div class="row"><div class="grow"><div class="nm">${esc(cf.n)} · ${esc(CITY[cf.c].name)}</div><div class="meta">${cf.day===S.day?tr('Today'):tr('in {n} days',{n:cf.day-S.day})} · ${esc(REG[CITY[cf.c].reg])}</div></div>${reg?'<span class="tag st on">'+tr('Registered')+'</span>':cf.day<=S.day?'<span class="tag st">'+tr('Registration closed')+'</span>':btn(tr('Attend <small>{cost}</small>',{cost:fmt$(CONF_COST)}),'confGo',{key:cf.key},'sm',S.cash<CONF_COST)}</div>`;}).join('')}`;}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue