mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Plugin editor tables are now populated.
This commit is contained in:
@@ -98,10 +98,10 @@ var pluginCardProto = Object.create(HTMLElement.prototype, {
|
||||
|
||||
showEditorTable: {
|
||||
value: function(evt) {
|
||||
var tableClass = evt.target.getAttribute('data-for');
|
||||
var tables = evt.target.parentElement.querySelectorAll('table');
|
||||
var tableId = evt.target.getAttribute('data-for');
|
||||
var tables = evt.target.parentElement.parentElement.querySelectorAll('table');
|
||||
for (var i = 0; i < tables.length; ++i) {
|
||||
if (tables[i].className.indexOf(tableClass) == -1) {
|
||||
if (tables[i].id != tableId) {
|
||||
hideElement(tables[i]);
|
||||
} else {
|
||||
showElement(tables[i]);
|
||||
@@ -460,6 +460,8 @@ var EditableTableProto = Object.create(HTMLTableElement.prototype, {
|
||||
}
|
||||
/* Add deletion listener. */
|
||||
row.getElementsByClassName('fa-trash-o')[0].addEventListener('click', this.removeRow, false);
|
||||
|
||||
return row;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -42,6 +42,22 @@ function Plugin(obj) {
|
||||
|
||||
this.id = this.name.replace(/\s+/g, '');
|
||||
|
||||
Plugin.prototype.getTagObj = function(tag) {
|
||||
var data = {
|
||||
type: '',
|
||||
name: '',
|
||||
condition: tag.condition
|
||||
};
|
||||
if (tag.name[0] == '-') {
|
||||
data.type = 'remove';
|
||||
data.name = tag.name.substr(1);
|
||||
} else {
|
||||
data.type = 'add';
|
||||
data.name = tag.name;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
Plugin.prototype.getTagsStrings = function () {
|
||||
var tagsAdded = [];
|
||||
var tagsRemoved = [];
|
||||
@@ -158,9 +174,103 @@ function Plugin(obj) {
|
||||
}
|
||||
|
||||
/* Fill in editor table data. */
|
||||
var tables = card.shadowRoot.getElementsByTagName('editable-table');
|
||||
var tables = card.shadowRoot.getElementsByTagName('table');
|
||||
for (var i = 0; i < tables.length; ++i) {
|
||||
if (tables[i].id == 'loadAfter') {
|
||||
|
||||
if (this.masterlist && this.masterlist.after) {
|
||||
this.masterlist.after.forEach(function(file) {
|
||||
tables[i].addRow(file).querySelector('.fa-trash-o').classList.toggle('hidden');
|
||||
});
|
||||
}
|
||||
if (this.userlist && this.userlist.after) {
|
||||
this.userlist.after.forEach(function(file) {
|
||||
tables[i].addRow(file);
|
||||
});
|
||||
}
|
||||
|
||||
} else if (tables[i].id == 'req') {
|
||||
|
||||
if (this.masterlist && this.masterlist.req) {
|
||||
this.masterlist.req.forEach(function(file) {
|
||||
tables[i].addRow(file).querySelector('.fa-trash-o').classList.toggle('hidden');
|
||||
});
|
||||
}
|
||||
if (this.userlist && this.userlist.req) {
|
||||
this.userlist.req.forEach(function(file) {
|
||||
tables[i].addRow(file);
|
||||
});
|
||||
}
|
||||
|
||||
} else if (tables[i].id == 'inc') {
|
||||
|
||||
if (this.masterlist && this.masterlist.inc) {
|
||||
this.masterlist.inc.forEach(function(file) {
|
||||
tables[i].addRow(file).querySelector('.fa-trash-o').classList.toggle('hidden');
|
||||
});
|
||||
}
|
||||
if (this.userlist && this.userlist.inc) {
|
||||
this.userlist.inc.forEach(function(file) {
|
||||
tables[i].addRow(file);
|
||||
});
|
||||
}
|
||||
|
||||
} else if (tables[i].id == 'message') {
|
||||
|
||||
if (this.masterlist && this.masterlist.msg) {
|
||||
this.masterlist.msg.forEach(function(message) {
|
||||
var data = {
|
||||
type: message.type,
|
||||
content: message.content[0].str,
|
||||
condition: message.condition,
|
||||
language: message.content[0].lang
|
||||
};
|
||||
tables[i].addRow(data).querySelector('.fa-trash-o').classList.toggle('hidden');
|
||||
});
|
||||
}
|
||||
if (this.userlist && this.userlist.msg) {
|
||||
this.userlist.msg.forEach(function(message) {
|
||||
var data = {
|
||||
type: message.type,
|
||||
content: message.content[0].str,
|
||||
condition: message.condition,
|
||||
language: message.content[0].lang
|
||||
};
|
||||
tables[i].addRow(data);
|
||||
});
|
||||
}
|
||||
|
||||
} else if (tables[i].id == 'tags') {
|
||||
|
||||
if (this.masterlist && this.masterlist.tag) {
|
||||
this.masterlist.tag.forEach(function(tag) {
|
||||
var data = this.getTagObj(tag);
|
||||
tables[i].addRow(data).querySelector('.fa-trash-o').classList.toggle('hidden');
|
||||
}, this);
|
||||
}
|
||||
if (this.userlist && this.userlist.tag) {
|
||||
this.userlist.tag.forEach(function(tag) {
|
||||
var data = this.getTagObj(tag);
|
||||
tables[i].addRow(data);
|
||||
}, this);
|
||||
}
|
||||
|
||||
} else if (tables[i].id == 'dirty') {
|
||||
|
||||
if (this.masterlist && this.masterlist.dirty) {
|
||||
this.masterlist.dirty.forEach(function(info) {
|
||||
info.crc = info.crc.toString(16);
|
||||
tables[i].addRow(info).querySelector('.fa-trash-o').classList.toggle('hidden');
|
||||
});
|
||||
}
|
||||
if (this.userlist && this.userlist.dirty) {
|
||||
this.userlist.dirty.forEach(function(info) {
|
||||
info.crc = info.crc.toString(16);
|
||||
tables[i].addRow(info);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('main').appendChild(card);
|
||||
|
||||
@@ -253,7 +253,7 @@ function handlePluginDrop(evt) {
|
||||
|
||||
if (evt.currentTarget.tagName == 'TABLE' && (evt.currentTarget.className.indexOf('req') != -1 || evt.currentTarget.className.indexOf('inc') != -1 || evt.currentTarget.className.indexOf('loadAfter') != -1)) {
|
||||
var data = {
|
||||
file: evt.dataTransfer.getData('text/plain')
|
||||
name: evt.dataTransfer.getData('text/plain')
|
||||
};
|
||||
evt.currentTarget.addRow(data);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
#tableTabs > span:not(:first-child) {
|
||||
border-left: none;
|
||||
}
|
||||
#tableTabs > span:hover, .tableTabs span.selected {
|
||||
#tableTabs > span:hover, #tableTabs span.selected {
|
||||
background: #f8f8f8;
|
||||
}
|
||||
#tableTabs .editable {
|
||||
@@ -291,7 +291,7 @@
|
||||
|
||||
<template id="fileRow">
|
||||
<tr>
|
||||
<td><input class="file" type="text" readonly required>
|
||||
<td><input class="name" type="text" readonly required>
|
||||
<td><input class="display" type="text" readonly>
|
||||
<td><input class="condition" type="text" readonly>
|
||||
<td class="fa fa-trash-o fa-fw">
|
||||
@@ -325,8 +325,8 @@
|
||||
<td><input class="crc" type="text" maxlength="8" minlength="8" pattern="[0-9A-Fa-f]{8}" readonly required>
|
||||
<td><input class="itm" type="number" min="0" step="1" readonly>
|
||||
<td><input class="udr" type="number" min="0" step="1" readonly>
|
||||
<td><input class="navmesh" type="number" min="0" step="1" readonly>
|
||||
<td><input class="utility" type="text" readonly required>
|
||||
<td><input class="nav" type="number" min="0" step="1" readonly>
|
||||
<td><input class="util" type="text" readonly required>
|
||||
<td class="fa fa-trash-o fa-fw">
|
||||
</template>
|
||||
<template id="gameRow">
|
||||
|
||||
Reference in New Issue
Block a user