|
|
@@ -310,7 +310,14 @@
|
|
|
var slot = document.getElementById(current_slot_id);
|
|
|
slot.appendChild(monsterPanel);
|
|
|
slot.setAttribute('onclick', 'selectLeader(this);');
|
|
|
- // TODO: X to remove
|
|
|
+
|
|
|
+ // X to remove
|
|
|
+ var x = document.createElement('input');
|
|
|
+ x.setAttribute('type', 'button');
|
|
|
+ x.setAttribute('value', 'x');
|
|
|
+ x.setAttribute('class', 'delete_unit');
|
|
|
+ x.setAttribute('onClick', 'deleteUnit(this.parentElement.parentElement);');
|
|
|
+ monsterPanel.appendChild(x);
|
|
|
|
|
|
// Set ID
|
|
|
var input_id = slot.getElementsByClassName('unit_id')[0];
|
|
|
@@ -330,28 +337,23 @@
|
|
|
|
|
|
/**
|
|
|
* Deletes a unit from the new team form.
|
|
|
- *
|
|
|
- * @param id Unit id.
|
|
|
*/
|
|
|
- function deleteUnit(id){
|
|
|
- var position = -1;
|
|
|
- for (var i = 0; i < units.length; i ++) {
|
|
|
- if (units[i].id == id){
|
|
|
- position = i;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (position >= 0 && position < units.length){
|
|
|
- units.splice(position, 1);
|
|
|
- document.getElementById('new_team_units').removeChild(document.getElementById('monster_panel_' + id));
|
|
|
- selected_units --;
|
|
|
- if (selected_units >= max_units){
|
|
|
- document.getElementById('new_unit').style.display = 'none';
|
|
|
- }
|
|
|
- else{
|
|
|
- document.getElementById('new_unit').style.display = 'block';
|
|
|
- }
|
|
|
+ function deleteUnit(slot){
|
|
|
+ console.log(slot.nodename)
|
|
|
+ var panel = slot.getElementsByClassName('monster_panel')[0];
|
|
|
+ slot.removeChild(panel);
|
|
|
+ var id = slot.getElementsByClassName('unit_id')[0];
|
|
|
+ id.value = '';
|
|
|
+ selected_units --;
|
|
|
+
|
|
|
+ // Remove leader symbol
|
|
|
+ if (slot.classList.contains('leader')){
|
|
|
+ slot.classList.remove('leader');
|
|
|
+ leader_id = '';
|
|
|
}
|
|
|
+
|
|
|
+ slot.setAttribute('onClick', 'showSearchUnit(this);');
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|