Fixed sorting and print selection bugs
This commit is contained in:
parent
8d34765204
commit
2cd002c053
5 changed files with 124 additions and 62 deletions
66
dist/app.js
vendored
66
dist/app.js
vendored
|
@ -104,7 +104,7 @@ const discoverClasses = spells => {
|
|||
* Emphasis on important string bits
|
||||
* @param {string} string
|
||||
*/
|
||||
const emphasis = str => {
|
||||
const emphasis = (str = '') => {
|
||||
let keywords = ['constitution', 'con', 'intelligence', 'int', 'wisdom', 'wis', 'strength', 'str', 'dexterity', 'dex', 'charisma', 'cha', 'comeliness', 'com', 'saving throw', 'ability check', 'skill check'];
|
||||
keywords.forEach(word => {
|
||||
let r = new RegExp(` ${ word } `, 'gi');
|
||||
|
@ -229,6 +229,41 @@ const spellDetails = name => {
|
|||
clipboard.on('success', e => $('#toast')[0].MaterialSnackbar.showSnackbar({ message: 'Copied link' })).on('error', e => $('#toast')[0].MaterialSnackbar.showSnackbar({ message: 'Sorry! Unable to copy link' }));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Render Print Page
|
||||
*/
|
||||
const renderPrint = () => {
|
||||
let selectedSpells = $('form[data-selected]')
|
||||
// Get array of items in form
|
||||
.serializeArray()
|
||||
// Find spells based on array from form
|
||||
.map(sel => store.spells.find(spell => sel.value === spell.name))
|
||||
// Sort by level then alphabetically
|
||||
.sort((a, b) => {
|
||||
let aName = a.name.toLowerCase();
|
||||
let bName = b.name.toLowerCase();
|
||||
if (a.level > b.level) return 1;
|
||||
if (a.level < b.level) return -1;
|
||||
if (aName > bName) return 1;
|
||||
if (aName < bName) return -1;
|
||||
return 0;
|
||||
})
|
||||
// Prettify Descriptions
|
||||
.map(spell => {
|
||||
spell = clone(spell);
|
||||
spell.description = descriptionPrettifier(spell.description);
|
||||
return spell;
|
||||
});
|
||||
view.spell_list_print.update({ data: selectedSpells });
|
||||
if (selectedSpells.length) {
|
||||
$('[data-action=print] [data-badge]').attr('data-badge', selectedSpells.length);
|
||||
$('[data-action=print]').slideDown('fast');
|
||||
} else {
|
||||
$('[data-action=print]').slideUp('fast');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Event Bindings
|
||||
*/
|
||||
|
@ -288,33 +323,8 @@ $('body')
|
|||
this.checked = e.target.checked;
|
||||
if (this.checked) $(this).closest('label').addClass('is-checked');else $(this).closest('label').removeClass('is-checked');
|
||||
});
|
||||
$('[name=selected]').trigger('change');
|
||||
}).on('change', 'input[name=selected][type=checkbox]', e => {
|
||||
let selectedSpells = $('form[data-selected]')
|
||||
// Get array of items in form
|
||||
.serializeArray()
|
||||
// Find spells based on array from form
|
||||
.map(sel => store.spells.find(spell => sel.value === spell.name))
|
||||
// Sort alphabetically
|
||||
.sort((a, b) => {
|
||||
if (a.name > b.name) return 1;
|
||||
if (a.name < b.name) return -1;
|
||||
return 0;
|
||||
})
|
||||
// Prettify Descriptions
|
||||
.map(spell => {
|
||||
spell = clone(spell);
|
||||
spell.description = descriptionPrettifier(spell.description);
|
||||
return spell;
|
||||
});
|
||||
view.spell_list_print.update({ data: selectedSpells });
|
||||
if (selectedSpells.length) {
|
||||
$('[data-action=print] [data-badge]').attr('data-badge', selectedSpells.length);
|
||||
$('[data-action=print]').slideDown('fast');
|
||||
} else {
|
||||
$('[data-action=print]').slideUp('fast');
|
||||
}
|
||||
}).on('click', '[data-action=print]', e => {
|
||||
renderPrint();
|
||||
}).on('change', 'input[name=selected][type=checkbox]', renderPrint).on('click', '[data-action=print]', e => {
|
||||
window.print();
|
||||
})
|
||||
// Article Scroll with User
|
||||
|
|
49
dist/view.js
vendored
49
dist/view.js
vendored
|
@ -618,6 +618,8 @@ function spell_list_print_for0() {
|
|||
var text12 = document.createTextNode('');
|
||||
var for0 = document.createComment('if');
|
||||
var child0 = {};
|
||||
var for1 = document.createComment('if');
|
||||
var child2 = {};
|
||||
var unsafe0 = document.createComment('unsafe');
|
||||
var unsafeNodes0 = [];
|
||||
|
||||
|
@ -637,6 +639,7 @@ function spell_list_print_for0() {
|
|||
td6.appendChild(strong11);
|
||||
td6.appendChild(text12);
|
||||
td6.appendChild(for0);
|
||||
td6.appendChild(for1);
|
||||
td6.appendChild(unsafe0);
|
||||
td6.setAttribute("class", "spell-description");
|
||||
tr0.appendChild(td1);
|
||||
|
@ -651,7 +654,8 @@ function spell_list_print_for0() {
|
|||
text8.textContent = spell.range;
|
||||
text10.textContent = spell.casting_time;
|
||||
text12.textContent = spell.duration;
|
||||
Monkberry.cond(_this, for0, child0, spell_list_print_for0_if0, spell.ritual);
|
||||
Monkberry.cond(_this, for0, child0, spell_list_print_for0_if0, (spell.components) && (spell.components.raw));
|
||||
Monkberry.cond(_this, for1, child2, spell_list_print_for0_if2, spell.ritual);
|
||||
__unsafe(unsafe0, unsafeNodes0, spell.description);
|
||||
}
|
||||
};
|
||||
|
@ -661,6 +665,9 @@ function spell_list_print_for0() {
|
|||
if (child0.ref) {
|
||||
child0.ref.update(__data__);
|
||||
}
|
||||
if (child2.ref) {
|
||||
child2.ref.update(__data__);
|
||||
}
|
||||
};
|
||||
|
||||
// Set root nodes
|
||||
|
@ -682,6 +689,38 @@ spell_list_print_for0.prototype.update = function (__data__) {
|
|||
function spell_list_print_for0_if0() {
|
||||
Monkberry.call(this);
|
||||
|
||||
// Create elements
|
||||
var strong0 = document.createElement('strong');
|
||||
var text1 = document.createTextNode('');
|
||||
|
||||
// Construct dom
|
||||
strong0.appendChild(document.createTextNode(" Components: "));
|
||||
|
||||
// Update functions
|
||||
this.__update__ = {
|
||||
spell: function (spell) {
|
||||
text1.textContent = spell.components.raw;
|
||||
}
|
||||
};
|
||||
|
||||
// Set root nodes
|
||||
this.nodes = [strong0, text1];
|
||||
}
|
||||
spell_list_print_for0_if0.prototype = Object.create(Monkberry.prototype);
|
||||
spell_list_print_for0_if0.prototype.constructor = spell_list_print_for0_if0;
|
||||
spell_list_print_for0_if0.pool = [];
|
||||
spell_list_print_for0_if0.prototype.update = function (__data__) {
|
||||
if (__data__.spell !== undefined) {
|
||||
this.__update__.spell(__data__.spell);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
function spell_list_print_for0_if2() {
|
||||
Monkberry.call(this);
|
||||
|
||||
// Create elements
|
||||
var strong0 = document.createElement('strong');
|
||||
|
||||
|
@ -691,10 +730,10 @@ function spell_list_print_for0_if0() {
|
|||
// Set root nodes
|
||||
this.nodes = [strong0];
|
||||
}
|
||||
spell_list_print_for0_if0.prototype = Object.create(Monkberry.prototype);
|
||||
spell_list_print_for0_if0.prototype.constructor = spell_list_print_for0_if0;
|
||||
spell_list_print_for0_if0.pool = [];
|
||||
spell_list_print_for0_if0.prototype.update = function (__data__) {
|
||||
spell_list_print_for0_if2.prototype = Object.create(Monkberry.prototype);
|
||||
spell_list_print_for0_if2.prototype.constructor = spell_list_print_for0_if2;
|
||||
spell_list_print_for0_if2.pool = [];
|
||||
spell_list_print_for0_if2.prototype.update = function (__data__) {
|
||||
};
|
||||
|
||||
window.spell_list_print = spell_list_print;
|
||||
|
|
2
dist/view.js.map
vendored
2
dist/view.js.map
vendored
|
@ -1 +1 @@
|
|||
{"version":3,"sources":["class-list.monk","search-field.monk","spell-details.monk","spell-list-print.monk","spell-list.monk","table-sort.monk"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mEAAM,IAAN,C;AAAA,oE;;;;;;AAAA;AAAA;AAAA,K;AAAA;AAAA;AAAA,K;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACI,kEAAc,IAAd,kB;;;;;;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;;;;;;;;;;;;;;;;EACI,6C;EACI,yC;;;;EAMI,2C;;;;;EAAM,4BAAO,mBAAP,E;;;EANL,2BAAO,+CAAP,E;;EADF,6BAAO,sBAAP,E;;;;;;AAEC,4EAAM,QAAQ,QAAR,CAAiB,GAAjB,CAAN,C;AAAA,6E;;;AAMI,0BAAG,G;;;;;;AANP;AAAA;AAAA,K;AAAA;AAAA;AAAA,K;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EACI,6C;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;;;;;EAYA,2C;;EAIA,qC;;;;;;;EAhBG,yBAAO,oCAAP,E;;;;EAgBA,yBAAO,8DAAP,E;;;;EAjB2B,0BAAO,oCAAP,E;;;;;AAE1B,+DAAM,YAAS,OAAT,CAAN,C;AAGA,+DAAM,YAAS,MAAT,CAAN,C;AAGA,+DAAM,YAAS,QAAT,CAAN,C;AAMO,0BAAG,I;AAdd,2CAAqB,IAArB,E;;;AAkBI,0BAAG,QAAM,mBAAN,GAA4B,qB;;;AADhC,gCAAO,8DAAP,KAAsE,aAAS,OAAT,KAAmB,0BAAnB,GAAgD,0BAAtH,G;;;AAjB2B,iCAAO,oCAAP,KAA4C,gBAAY,SAAZ,KAAwB,qCAAxB,GAAgE,EAA5G,G;;;;;;AAE1B;AAAA;AAAA,K;AAGA;AAAA;AAAA,K;AAGA;AAAA;AAAA,K;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBANyB,qC;;;;;;;;;;;;;;;gBAGD,qC;;;;;;;;;;;;;;;gBAGE,mC;;;;;;;AAdtC;AAAA","file":"view.js"}
|
||||
{"version":3,"sources":["class-list.monk","search-field.monk","spell-details.monk","spell-list-print.monk","spell-list.monk","table-sort.monk"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mEAAM,IAAN,C;AAAA,oE;;;;;;AAAA;AAAA;AAAA,K;AAAA;AAAA;AAAA,K;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACI,kEAAc,IAAd,kB;;;;;;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;;;;;;;;;;;;;;;;EACI,6C;EACI,yC;;;;EAMI,2C;;;;;EAAM,4BAAO,mBAAP,E;;;EANL,2BAAO,+CAAP,E;;EADF,6BAAO,sBAAP,E;;;;;;AAEC,4EAAM,QAAQ,QAAR,CAAiB,GAAjB,CAAN,C;AAAA,6E;;;AAMI,0BAAG,G;;;;;;AANP;AAAA;AAAA,K;AAAA;AAAA;AAAA,K;;;;;;;;;;;;;;;;;;;;;;;;;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;EADtC,6BAAO,0EAAP,E;EAAiF,2BAAK,cAAL,E;;;;;;AAI5F,8DAAe,IAAf,mB;;;;;;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;;;;;;;;;;;;;;;;EACI,uC;EACI,qC;;;;;;;EAYA,2C;;EAIA,qC;;;;;;;EAhBG,yBAAO,oCAAP,E;;;;EAgBA,yBAAO,8DAAP,E;;;;EAjB2B,0BAAO,oCAAP,E;;;;;AAE1B,+DAAM,YAAS,OAAT,CAAN,C;AAGA,+DAAM,YAAS,MAAT,CAAN,C;AAGA,+DAAM,YAAS,QAAT,CAAN,C;AAMO,0BAAG,I;AAdd,2CAAqB,IAArB,E;;;AAkBI,0BAAG,QAAM,mBAAN,GAA4B,qB;;;AADhC,gCAAO,8DAAP,KAAsE,aAAS,OAAT,KAAmB,0BAAnB,GAAgD,0BAAtH,G;;;AAjB2B,iCAAO,oCAAP,KAA4C,gBAAY,SAAZ,KAAwB,qCAAxB,GAAgE,EAA5G,G;;;;;;AAE1B;AAAA;AAAA,K;AAGA;AAAA;AAAA,K;AAGA;AAAA;AAAA,K;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBANyB,qC;;;;;;;;;;;;;;;gBAGD,qC;;;;;;;;;;;;;;;gBAGE,mC;;;;;;;AAdtC;AAAA","file":"view.js"}
|
66
src/app.js
66
src/app.js
|
@ -105,7 +105,7 @@ const discoverClasses = spells => {
|
|||
* Emphasis on important string bits
|
||||
* @param {string} string
|
||||
*/
|
||||
const emphasis = str => {
|
||||
const emphasis = (str = '') => {
|
||||
let keywords = ['constitution', 'con', 'intelligence', 'int', 'wisdom', 'wis', 'strength', 'str', 'dexterity', 'dex', 'charisma', 'cha', 'comeliness', 'com', 'saving throw', 'ability check', 'skill check'];
|
||||
keywords.forEach(word => {
|
||||
let r = new RegExp(` ${word} `, 'gi');
|
||||
|
@ -240,6 +240,41 @@ const spellDetails = name => {
|
|||
.on('error', e => $('#toast')[0].MaterialSnackbar.showSnackbar({message: 'Sorry! Unable to copy link'}));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render Print Page
|
||||
*/
|
||||
const renderPrint = () => {
|
||||
let selectedSpells = $('form[data-selected]')
|
||||
// Get array of items in form
|
||||
.serializeArray()
|
||||
// Find spells based on array from form
|
||||
.map(sel => store.spells.find(spell => sel.value === spell.name))
|
||||
// Sort by level then alphabetically
|
||||
.sort((a, b) => {
|
||||
let aName = a.name.toLowerCase();
|
||||
let bName = b.name.toLowerCase();
|
||||
if (a.level > b.level) return 1;
|
||||
if (a.level < b.level) return -1;
|
||||
if (aName > bName) return 1;
|
||||
if (aName < bName) return -1;
|
||||
return 0;
|
||||
})
|
||||
// Prettify Descriptions
|
||||
.map(spell => {
|
||||
spell = clone(spell);
|
||||
spell.description = descriptionPrettifier(spell.description);
|
||||
return spell;
|
||||
});
|
||||
view.spell_list_print.update({data: selectedSpells});
|
||||
if (selectedSpells.length) {
|
||||
$('[data-action=print] [data-badge]').attr('data-badge', selectedSpells.length);
|
||||
$('[data-action=print]').slideDown('fast');
|
||||
} else {
|
||||
$('[data-action=print]').slideUp('fast');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Event Bindings
|
||||
*/
|
||||
|
@ -299,34 +334,9 @@ $('body')
|
|||
if(this.checked) $(this).closest('label').addClass('is-checked');
|
||||
else $(this).closest('label').removeClass('is-checked');
|
||||
});
|
||||
$('[name=selected]').trigger('change');
|
||||
})
|
||||
.on('change', 'input[name=selected][type=checkbox]', e => {
|
||||
let selectedSpells = $('form[data-selected]')
|
||||
// Get array of items in form
|
||||
.serializeArray()
|
||||
// Find spells based on array from form
|
||||
.map(sel => store.spells.find(spell => sel.value === spell.name))
|
||||
// Sort alphabetically
|
||||
.sort((a, b) => {
|
||||
if (a.name > b.name) return 1;
|
||||
if (a.name < b.name) return -1;
|
||||
return 0
|
||||
})
|
||||
// Prettify Descriptions
|
||||
.map(spell => {
|
||||
spell = clone(spell);
|
||||
spell.description = descriptionPrettifier(spell.description);
|
||||
return spell;
|
||||
});
|
||||
view.spell_list_print.update({data: selectedSpells});
|
||||
if (selectedSpells.length) {
|
||||
$('[data-action=print] [data-badge]').attr('data-badge', selectedSpells.length);
|
||||
$('[data-action=print]').slideDown('fast');
|
||||
} else {
|
||||
$('[data-action=print]').slideUp('fast');
|
||||
}
|
||||
renderPrint();
|
||||
})
|
||||
.on('change', 'input[name=selected][type=checkbox]', renderPrint)
|
||||
.on('click', '[data-action=print]', e => {
|
||||
window.print();
|
||||
})
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
<strong> Range: </strong>{{ spell.range }}
|
||||
<strong> Casting Time: </strong>{{ spell.casting_time }}
|
||||
<strong> Duration: </strong>{{ spell.duration }}
|
||||
{% if spell.components && spell.components.raw %}
|
||||
<strong> Components: </strong>{{ spell.components.raw }}
|
||||
{% endif %}
|
||||
{% if spell.ritual %}
|
||||
<strong> Ritual</strong>
|
||||
{% endif %}
|
||||
|
|
Loading…
Add table
Reference in a new issue