| 1 |
<script type="text/javascript"> |
| 2 |
(function() { |
| 3 |
var abj404ConditionIndex = {initial_index}; |
| 4 |
|
| 5 |
window.abj404AddConditionRow = function() { |
| 6 |
var template = document.getElementById('abj404-condition-row-template'); |
| 7 |
if (!template) { return; } |
| 8 |
var html = template.innerHTML.replace(/__IDX__/g, String(abj404ConditionIndex)); |
| 9 |
var container = document.getElementById('abj404-conditions-container'); |
| 10 |
if (!container) { return; } |
| 11 |
var div = document.createElement('div'); |
| 12 |
div.innerHTML = html; |
| 13 |
while (div.firstChild) { |
| 14 |
container.appendChild(div.firstChild); |
| 15 |
} |
| 16 |
abj404UpdateConditionSortOrders(); |
| 17 |
abj404ConditionIndex++; |
| 18 |
}; |
| 19 |
|
| 20 |
window.abj404RemoveConditionRow = function(btn) { |
| 21 |
var row = btn.closest('.abj404-condition-row'); |
| 22 |
if (row) { |
| 23 |
row.parentNode.removeChild(row); |
| 24 |
abj404UpdateConditionSortOrders(); |
| 25 |
} |
| 26 |
}; |
| 27 |
|
| 28 |
function abj404UpdateConditionSortOrders() { |
| 29 |
var rows = document.querySelectorAll('#abj404-conditions-container .abj404-condition-row'); |
| 30 |
for (var i = 0; i < rows.length; i++) { |
| 31 |
var so = rows[i].querySelector('.abj404-condition-sort-order'); |
| 32 |
if (so) { so.value = String(i); } |
| 33 |
} |
| 34 |
} |
| 35 |
}()); |
| 36 |
</script> |
| 37 |
|