1
0
Fork 0

Better styled with markdown support

This commit is contained in:
Joe Wroten 2016-08-07 23:28:41 -05:00
parent 2059f4aca8
commit 8d34765204
6 changed files with 123 additions and 20 deletions

View file

@ -24,7 +24,14 @@
vertical-align: top; vertical-align: top;
} }
.spell-description { .spell-description p {
font-size: 8pt; font-size: 8pt;
line-height: 10pt;
margin: .75em 0;
color: gray;
}
.spell-description br {
display: none;
} }
} }

33
dist/app.js vendored
View file

@ -115,6 +115,19 @@ const emphasis = str => {
return str; return str;
}; };
/**
* Description Prettifier
*/
const descriptionPrettifier = description => {
let md = new Remarkable();
description = Array.isArray(description) ? description.join('\n') : description;
description = emphasis(description);
description = md.render(description);
description = description.replace(/\n/g, '<br>');
return description;
};
/** /**
* Init Spells * Init Spells
*/ */
@ -205,11 +218,7 @@ const spellDetails = name => {
$('body').removeClass('details'); $('body').removeClass('details');
} else { } else {
let data = clone(store.spells.find(spell => name === spell.name)); let data = clone(store.spells.find(spell => name === spell.name));
let md = new Remarkable(); data.description = descriptionPrettifier(data.description);
data.description = Array.isArray(data.description) ? data.description.join('\n') : data.description;
data.description = emphasis(data.description);
data.description = md.render(data.description);
data.description = data.description.replace(/\n/g, '<br>');
view.spell_details.update({ view.spell_details.update({
data, data,
@ -281,10 +290,22 @@ $('body')
}); });
$('[name=selected]').trigger('change'); $('[name=selected]').trigger('change');
}).on('change', 'input[name=selected][type=checkbox]', e => { }).on('change', 'input[name=selected][type=checkbox]', e => {
let selectedSpells = $('form[data-selected]').serializeArray().map(sel => store.spells.find(spell => sel.value === spell.name)).sort((a, b) => { 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;
if (a.name < b.name) return -1; if (a.name < b.name) return -1;
return 0; return 0;
})
// Prettify Descriptions
.map(spell => {
spell = clone(spell);
spell.description = descriptionPrettifier(spell.description);
return spell;
}); });
view.spell_list_print.update({ data: selectedSpells }); view.spell_list_print.update({ data: selectedSpells });
if (selectedSpells.length) { if (selectedSpells.length) {

61
dist/view.js vendored
View file

@ -553,6 +553,8 @@ spell_details_else1.prototype.update = function (__data__) {
window.spell_details = spell_details; window.spell_details = spell_details;
var __unsafe = function unsafe(root, nodes, html) {var node,j,i = nodes.length,element = document.createElement('div');element.innerHTML = html;while (i-- > 0) {nodes[i].parentNode.removeChild(nodes.pop());}for (i = j = element.childNodes.length - 1; j >= 0; j--) {nodes.push(element.childNodes[j]);}++i;if (root.nodeType == 8) {if (root.parentNode) while (i-- > 0) {root.parentNode.insertBefore(nodes[i], root);} else throw "Can not insert child view into parent node. You need append your view first and then update.";} else while (i-- > 0) {root.appendChild(nodes[i]);}};
/** /**
* @class * @class
*/ */
@ -598,6 +600,7 @@ spell_list_print.prototype.update = function (__data__) {
function spell_list_print_for0() { function spell_list_print_for0() {
Monkberry.call(this); Monkberry.call(this);
this.__state__ = {}; this.__state__ = {};
var _this = this;
// Create elements // Create elements
var tr0 = document.createElement('tr'); var tr0 = document.createElement('tr');
@ -607,8 +610,16 @@ function spell_list_print_for0() {
var td4 = document.createElement('td'); var td4 = document.createElement('td');
var text5 = document.createTextNode(''); var text5 = document.createTextNode('');
var td6 = document.createElement('td'); var td6 = document.createElement('td');
var p7 = document.createElement('p'); var strong7 = document.createElement('strong');
var text8 = document.createTextNode(''); var text8 = document.createTextNode('');
var strong9 = document.createElement('strong');
var text10 = document.createTextNode('');
var strong11 = document.createElement('strong');
var text12 = document.createTextNode('');
var for0 = document.createComment('if');
var child0 = {};
var unsafe0 = document.createComment('unsafe');
var unsafeNodes0 = [];
// Construct dom // Construct dom
strong2.appendChild(text3); strong2.appendChild(text3);
@ -616,8 +627,17 @@ function spell_list_print_for0() {
td1.setAttribute("class", "spell-name"); td1.setAttribute("class", "spell-name");
td4.appendChild(text5); td4.appendChild(text5);
td4.setAttribute("class", "spell-level"); td4.setAttribute("class", "spell-level");
p7.appendChild(text8); strong7.appendChild(document.createTextNode(" Range: "));
td6.appendChild(p7); strong9.appendChild(document.createTextNode(" Casting Time: "));
strong11.appendChild(document.createTextNode(" Duration: "));
td6.appendChild(strong7);
td6.appendChild(text8);
td6.appendChild(strong9);
td6.appendChild(text10);
td6.appendChild(strong11);
td6.appendChild(text12);
td6.appendChild(for0);
td6.appendChild(unsafe0);
td6.setAttribute("class", "spell-description"); td6.setAttribute("class", "spell-description");
tr0.appendChild(td1); tr0.appendChild(td1);
tr0.appendChild(td4); tr0.appendChild(td4);
@ -628,7 +648,18 @@ function spell_list_print_for0() {
spell: function (spell) { spell: function (spell) {
text3.textContent = spell.name; text3.textContent = spell.name;
text5.textContent = spell.level; text5.textContent = spell.level;
text8.textContent = spell.description; 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);
__unsafe(unsafe0, unsafeNodes0, spell.description);
}
};
// On update actions
this.onUpdate = function (__data__) {
if (child0.ref) {
child0.ref.update(__data__);
} }
}; };
@ -642,6 +673,28 @@ spell_list_print_for0.prototype.update = function (__data__) {
if (__data__.spell !== undefined && __data__.__index__ !== undefined) { if (__data__.spell !== undefined && __data__.__index__ !== undefined) {
this.__update__.spell(__data__.spell); this.__update__.spell(__data__.spell);
} }
this.onUpdate(__data__);
};
/**
* @class
*/
function spell_list_print_for0_if0() {
Monkberry.call(this);
// Create elements
var strong0 = document.createElement('strong');
// Construct dom
strong0.appendChild(document.createTextNode(" Ritual"));
// 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__) {
}; };
window.spell_list_print = spell_list_print; window.spell_list_print = spell_list_print;

2
dist/view.js.map vendored
View file

@ -1 +1 @@
{"version":3,"sources":["class-list.monk","search-field.monk","spell-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;;;;;;;;;;;;;EAQL,yC;;;EAAK,2BAAO,sCAAP,E;;;;;;;;;;AAjCrB;AAAA;;;;;;;;;;ECAA,uC;EACI,6C;EACI,6C;;;;;EAAO,4BAAM,UAAN,E;EAAgB,YAAI,cAAJ,C;EAAkB,6BAAO,qBAAP,E;;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"} {"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,kEAA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E;;;;;;;;;;;;;;;;;;EAQL,yC;;;EAAK,2BAAO,sCAAP,E;;;;;;;;;;AAjCrB;AAAA;;;;;;;;;;ECAA,uC;EACI,6C;EACI,6C;;;;;EAAO,4BAAM,UAAN,E;EAAgB,YAAI,cAAJ,C;EAAkB,6BAAO,qBAAP,E;;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"}

View file

@ -116,6 +116,19 @@ const emphasis = str => {
return str; return str;
}; };
/**
* Description Prettifier
*/
const descriptionPrettifier = description => {
let md = new Remarkable();
description = Array.isArray(description) ? description.join('\n') : description;
description = emphasis(description);
description = md.render(description);
description = description.replace(/\n/g, '<br>');
return description;
};
/** /**
* Init Spells * Init Spells
*/ */
@ -214,11 +227,7 @@ const spellDetails = name => {
$('body').removeClass('details'); $('body').removeClass('details');
} else { } else {
let data = clone(store.spells.find(spell => name === spell.name)); let data = clone(store.spells.find(spell => name === spell.name));
let md = new Remarkable(); data.description = descriptionPrettifier(data.description);
data.description = Array.isArray(data.description) ? data.description.join('\n') : data.description;
data.description = emphasis(data.description);
data.description = md.render(data.description);
data.description = data.description.replace(/\n/g, '<br>');
view.spell_details.update({ view.spell_details.update({
data, data,
@ -294,12 +303,21 @@ $('body')
}) })
.on('change', 'input[name=selected][type=checkbox]', e => { .on('change', 'input[name=selected][type=checkbox]', e => {
let selectedSpells = $('form[data-selected]') let selectedSpells = $('form[data-selected]')
// Get array of items in form
.serializeArray() .serializeArray()
// Find spells based on array from form
.map(sel => store.spells.find(spell => sel.value === spell.name)) .map(sel => store.spells.find(spell => sel.value === spell.name))
// Sort alphabetically
.sort((a, b) => { .sort((a, b) => {
if (a.name > b.name) return 1; if (a.name > b.name) return 1;
if (a.name < b.name) return -1; if (a.name < b.name) return -1;
return 0 return 0
})
// Prettify Descriptions
.map(spell => {
spell = clone(spell);
spell.description = descriptionPrettifier(spell.description);
return spell;
}); });
view.spell_list_print.update({data: selectedSpells}); view.spell_list_print.update({data: selectedSpells});
if (selectedSpells.length) { if (selectedSpells.length) {

View file

@ -9,9 +9,13 @@
{{ spell.level }} {{ spell.level }}
</td> </td>
<td class="spell-description"> <td class="spell-description">
<p> <strong> Range: </strong>{{ spell.range }}
{{ spell.description }} <strong> Casting Time: </strong>{{ spell.casting_time }}
</p> <strong> Duration: </strong>{{ spell.duration }}
{% if spell.ritual %}
<strong> Ritual</strong>
{% endif %}
{% unsafe spell.description %}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}