// shift-select-multiple-checkboxes-like-gmail
var checkboxes = document.getElementsByName('ftp');
for (var i = 0; i < checkboxes.length; i++) {
lastChecked = null;
checkboxes[i].addEventListener('click', function(e) {
if (!lastChecked) {
lastChecked = this;
return;
}
if (e.shiftKey) {
var thisIndex, lastIndex;
for (var ii = 0; ii < checkboxes.length; ii++) {
if (this == checkboxes[ii]) {
thisIndex = ii;
}
if (lastChecked == checkboxes[ii]) {
lastIndex = ii;
}
}
var start = Math.min(thisIndex, lastIndex);
var end = Math.max(thisIndex, lastIndex);
Array.prototype.slice.call(checkboxes).forEach(function(node, i) {
if (start <= i && i < end+1) {
node.checked = lastChecked.checked;
}
});
}
});
}
});
function checkAll(obj, name) {
if (typeof obj === 'undefined') {
console.log(obj);
return false;
}
var checkboxes = document.getElementsByName(name);
Array.prototype.forEach.call(checkboxes, function(el, i) {
checkboxes[i].checked = obj.checked;
});
}