v 0.8.25b

This commit is contained in:
Azgaar 2019-05-29 20:26:35 +03:00
parent 2d5d008fe8
commit 46fb2fb1f8
2 changed files with 23 additions and 20 deletions

View file

@ -102,19 +102,19 @@ function GFontToDataURI(url) {
let s = document.createElement('style'); let s = document.createElement('style');
s.innerHTML = text; s.innerHTML = text;
document.head.appendChild(s); document.head.appendChild(s);
let styleSheet = Array.prototype.filter.call( const styleSheet = Array.prototype.filter.call(document.styleSheets, sS => sS.ownerNode === s)[0];
document.styleSheets,
sS => sS.ownerNode === s)[0];
let FontRule = rule => {
let src = rule.style.getPropertyValue('src');
let url = src.split('url(')[1].split(')')[0];
return {rule: rule, src: src, url: url.substring(url.length - 1, 1)};
};
let fontRules = [], fontProms = [];
for (let r of styleSheet.cssRules) { const FontRule = rule => {
const src = rule.style.getPropertyValue('src');
const url = src ? src.split('url(')[1].split(')')[0] : "";
return {rule, src, url: url.substring(url.length - 1, 1)};
}
const fontProms = [];
for (const r of styleSheet.cssRules) {
let fR = FontRule(r); let fR = FontRule(r);
fontRules.push(fR); if (!fR.url) continue;
fontProms.push( fontProms.push(
fetch(fR.url) // fetch the actual font-file (.woff) fetch(fR.url) // fetch the actual font-file (.woff)
.then(resp => resp.blob()) .then(resp => resp.blob())
@ -125,9 +125,7 @@ function GFontToDataURI(url) {
f.readAsDataURL(blob); f.readAsDataURL(blob);
}) })
}) })
.then(dataURL => { .then(dataURL => fR.rule.cssText.replace(fR.url, dataURL))
return fR.rule.cssText.replace(fR.url, dataURL);
})
) )
} }
document.head.removeChild(s); // clean up document.head.removeChild(s); // clean up

View file

@ -31,14 +31,18 @@ function editBurgs() {
const stateFilter = document.getElementById("burgsFilterState"); const stateFilter = document.getElementById("burgsFilterState");
const selectedState = stateFilter.value || 1; const selectedState = stateFilter.value || 1;
stateFilter.options.length = 0; // remove all options stateFilter.options.length = 0; // remove all options
stateFilter.options.add(new Option("all", -1, false, selectedState == -1)); stateFilter.options.add(new Option(`all`, -1, false, selectedState == -1));
pack.states.filter(s => !s.removed).forEach(s => stateFilter.options.add(new Option(s.name, s.i, false, s.i == selectedState))); stateFilter.options.add(new Option(pack.states[0].name, 0, false, !selectedState));
const statesSorted = pack.states.filter(s => s.i && !s.removed).sort((a, b) => (a.name > b.name) ? 1 : -1);
statesSorted.forEach(s => stateFilter.options.add(new Option(s.name, s.i, false, s.i == selectedState)));
const cultureFilter = document.getElementById("burgsFilterCulture"); const cultureFilter = document.getElementById("burgsFilterCulture");
const selectedCulture = cultureFilter.value || -1; const selectedCulture = cultureFilter.value || -1;
cultureFilter.options.length = 0; // remove all options cultureFilter.options.length = 0; // remove all options
cultureFilter.options.add(new Option("all", -1, false, selectedCulture == -1)); cultureFilter.options.add(new Option(`all`, -1, false, selectedCulture == -1));
pack.cultures.filter(c => !c.removed).forEach(c => cultureFilter.options.add(new Option(c.name, c.i, false, c.i == selectedCulture))); cultureFilter.options.add(new Option(pack.cultures[0].name, 0, false, !selectedCulture));
const culturesSorted = pack.cultures.filter(c => c.i && !c.removed).sort((a, b) => (a.name > b.name) ? 1 : -1);
culturesSorted.forEach(c => cultureFilter.options.add(new Option(c.name, c.i, false, c.i == selectedCulture)));
} }
// add line for each state // add line for each state
@ -154,12 +158,13 @@ function editBurgs() {
function toggleCapitalStatus() { function toggleCapitalStatus() {
const burg = +this.parentNode.parentNode.dataset.id, state = pack.burgs[burg].state; const burg = +this.parentNode.parentNode.dataset.id, state = pack.burgs[burg].state;
if (pack.burgs[burg].capital) {tip("To change capital please assign capital status to another burg", false, "error"); return;} if (pack.burgs[burg].capital) {tip("To change capital please assign a capital status to another burg", false, "error"); return;}
if (!state) {tip("Neutral lands cannot have a capital", false, "error"); return;} if (!state) {tip("Neutral lands do not have a capital", false, "error"); return;}
const old = pack.states[state].capital; const old = pack.states[state].capital;
// change statuses // change statuses
pack.states[state].capital = burg; pack.states[state].capital = burg;
pack.states[state].center = pack.burgs[burg].cell;
pack.burgs[burg].capital = true; pack.burgs[burg].capital = true;
pack.burgs[old].capital = false; pack.burgs[old].capital = false;
moveBurgToGroup(burg, "cities"); moveBurgToGroup(burg, "cities");