/** * The Vanity page, Preview tab: what the world servers would load with the scheduled events that are on at some time, * or with events picked here. The server loads it as the worlds do (VanityEvents::LoadWorld): which vanity files are * read and why (as the files say, or switched by an event), the events in the order they are laid on, the NPCs, the * conflicts between events and anything that couldn't be read. #preview:ID previews that event on its own. */ (function () { 'use strict'; var events = []; var pending = null; // an event id from the hash, previewed once the events are known function get(id) { return document.getElementById(id); } function toInput(ts) { var d = new Date(ts * 1000); d.setMinutes(d.getMinutes() - d.getTimezoneOffset()); return d.toISOString().slice(0, 16); } function renderEvents() { var chosen = {}; Array.prototype.forEach.call(document.querySelectorAll('[data-vp-event]:checked'), function (c) { chosen[c.value] = true; }); if (pending) chosen[pending] = true; get('vpEvents').innerHTML = events.map(function (e) { return '
| Vanity file | Loaded | Why |
|---|---|---|
| ' + esc(f.name) + ' | ' + '' + (f.loaded ? 'loaded' : 'not loaded') + (changed ? ' (' + (f.loaded ? 'not' : 'loaded') + ' without events)' : '') + ' | ' + '' + why(f) + ' |
Loading…
'; api.post('/api/vanity/preview', body).then(function (d) { if (!d.success) { out.innerHTML = '' + ('at' in body || !body.ids ? 'At ' + esc(fmt.unix(d.at)) + ': ' : '') + (d.events.length ? d.events.length + ' event(s) with vanity changes, laid on in this order:' : 'no event with vanity changes.') + '
' + (d.events.length ? '' + esc(d.npcs) + ' NPCs and props: ' + esc(d.fileNpcs) + ' from the vanity files that are loaded, then the overlays and removals. ' + 'Without any event: ' + esc(d.baseNpcs) + '.