2023-03-05 22:58:21 +00:00
|
|
|
// Get the spell json based on choosen language defaultLanguage
|
2023-03-05 01:03:48 +00:00
|
|
|
|
2023-03-05 22:58:21 +00:00
|
|
|
var jsonsource = "".concat(
|
|
|
|
"../data/spells/spells-grimoire-",
|
|
|
|
$.defaultLanguage.slice(0, 2),
|
|
|
|
".json"
|
2023-03-05 01:03:48 +00:00
|
|
|
);
|
2023-03-06 13:13:04 +00:00
|
|
|
var alldata;
|
2023-03-05 22:58:21 +00:00
|
|
|
// Fetch data from server
|
|
|
|
fetch(jsonsource)
|
|
|
|
.then((response) => response.json())
|
|
|
|
.then((data) => {
|
|
|
|
// load fetched data into grid
|
2023-03-06 13:13:04 +00:00
|
|
|
alldata = data.spell;
|
|
|
|
console.log(alldata);
|
2023-03-05 01:03:48 +00:00
|
|
|
|
2023-03-05 22:58:21 +00:00
|
|
|
//document.getElementById("spell-list")
|
2023-03-06 23:06:27 +00:00
|
|
|
var grid = $("#spell-list").w2grid({
|
2023-03-05 22:58:21 +00:00
|
|
|
name: "Spells",
|
|
|
|
box: "#spellgrid",
|
|
|
|
show: {
|
2023-03-06 23:06:27 +00:00
|
|
|
header: false,
|
2023-03-05 22:58:21 +00:00
|
|
|
toolbar: true,
|
|
|
|
footer: false,
|
2023-03-06 23:06:27 +00:00
|
|
|
selectColumn: true,
|
|
|
|
},
|
|
|
|
multiSelect: true,
|
|
|
|
liveSearch: true,
|
|
|
|
multiSearch: true,
|
|
|
|
fixedBody: false,
|
2023-03-06 13:13:04 +00:00
|
|
|
records: alldata,
|
2023-03-05 22:58:21 +00:00
|
|
|
columns: [
|
2023-03-06 23:06:27 +00:00
|
|
|
{ field: "name", text: "Name", sortable: true, resizable: true,searchable: { operator: 'contains' }, },
|
|
|
|
{
|
|
|
|
field: "desc",
|
|
|
|
text: "Description",
|
|
|
|
size: "500%",
|
|
|
|
style: "test",
|
|
|
|
resizable: true,
|
|
|
|
searchable: { operator: 'contains' },
|
|
|
|
render(record, extra) {
|
|
|
|
return (
|
|
|
|
'<a href="http://w2ui.com" target="_blank" title="Click Me!"><u>' +
|
|
|
|
extra.value +
|
|
|
|
"</u></a>"
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ field: "source", text: "Source", sortable: true, tooltip: 'Which book is this from ?',searchable: { operator: 'contains' } },
|
|
|
|
{ field: "page", text: "Page", sortable: true },
|
|
|
|
{ field: "level", text: "Level", sortable: true, size: 65 },
|
|
|
|
{ field: "school", text: "School", sortable: true },
|
|
|
|
{
|
|
|
|
field: "components", text: "Components", render(record) {
|
|
|
|
var v = (record.components.v) ? '<span data-localize="verbal">V</span>' : ''
|
|
|
|
var s = (record.components.s) ? 'S' : ''
|
|
|
|
var m = (record.components.m) ? record.components.m : ''
|
|
|
|
return v.concat()
|
|
|
|
if (record.components.v = true) {
|
|
|
|
console.log(record.components)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ field: "duration", text: "Duration" },
|
2023-03-05 22:58:21 +00:00
|
|
|
],
|
|
|
|
async onSelect(event) {
|
2023-03-06 23:06:27 +00:00
|
|
|
await event.complete;
|
|
|
|
console.log("select", event.detail, this.getSelection());
|
|
|
|
},
|
|
|
|
onClick(event) {
|
|
|
|
let record = this.get(event.detail.recid);
|
2023-03-05 22:58:21 +00:00
|
|
|
//grid2.clear()
|
|
|
|
/*grid2.add([
|
|
|
|
{ recid: 0, name: 'ID:', value: record.recid },
|
|
|
|
{ recid: 1, name: 'First Name:', value: record.fname },
|
|
|
|
{ recid: 2, name: 'Last Name:', value: record.lname },
|
|
|
|
{ recid: 3, name: 'Email:', value: record.email },
|
|
|
|
{ recid: 4, name: 'Date:', value: record.sdate }
|
|
|
|
])*/
|
2023-03-06 23:06:27 +00:00
|
|
|
console.log(record);
|
|
|
|
},
|
|
|
|
onRender(event) {
|
|
|
|
// TODO: find the event after grid generate the html end signal and apply loc
|
|
|
|
event.done(function(){
|
|
|
|
console.log('object '+ this.name + ' is rendered');
|
|
|
|
$("[data-localize]").localize("main", { pathPrefix: "lang" });
|
|
|
|
})
|
|
|
|
|
2023-03-05 22:58:21 +00:00
|
|
|
}
|
2023-03-05 01:03:48 +00:00
|
|
|
|
2023-03-06 23:06:27 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
});
|
2023-03-05 01:03:48 +00:00
|
|
|
|
|
|
|
|