2015-04-20 02:12:11 +00:00
|
|
|
|
//jumpserver 自定义js 2015-01-29
|
|
|
|
|
|
|
|
|
|
//此函数用于checkbox的全选和反选
|
|
|
|
|
var checked=false;
|
|
|
|
|
function check_all(form) {
|
|
|
|
|
var checkboxes = document.getElementById(form);
|
|
|
|
|
if (checked == false) {
|
|
|
|
|
checked = true
|
|
|
|
|
} else {
|
|
|
|
|
checked = false
|
|
|
|
|
}
|
|
|
|
|
for (var i = 0; i < checkboxes.elements.length; i++) {
|
|
|
|
|
if (checkboxes.elements[i].type == "checkbox") {
|
|
|
|
|
checkboxes.elements[i].checked = checked;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-19 09:26:34 +00:00
|
|
|
|
function checkAll(id, name){
|
|
|
|
|
var checklist = document.getElementsByName(name);
|
|
|
|
|
if(document.getElementById(id).checked)
|
|
|
|
|
{
|
|
|
|
|
for(var i=0;i<checklist.length;i++)
|
|
|
|
|
{
|
|
|
|
|
checklist[i].checked = 1;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
for(var j=0;j<checklist.length;j++)
|
|
|
|
|
{
|
|
|
|
|
checklist[j].checked = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-20 02:12:11 +00:00
|
|
|
|
//提取指定行的数据,JSON格式
|
|
|
|
|
function GetRowData(row){
|
|
|
|
|
var rowData = {};
|
|
|
|
|
for(var j=0;j<row.cells.length; j++) {
|
|
|
|
|
name = row.parentNode.rows[0].cells[j].getAttribute("Name");
|
|
|
|
|
if (name) {
|
|
|
|
|
var value = row.cells[j].getAttribute("Value");
|
|
|
|
|
if (!value) {
|
|
|
|
|
value = row.cells[j].innerHTML;
|
|
|
|
|
}
|
|
|
|
|
rowData[name] = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return rowData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//此函数用于在多选提交时至少要选择一行
|
|
|
|
|
function GetTableDataBox() {
|
|
|
|
|
var tabProduct = document.getElementById("editable");
|
|
|
|
|
var tableData = new Array();
|
|
|
|
|
var returnData = new Array();
|
|
|
|
|
var checkboxes = document.getElementById("contents_form");
|
|
|
|
|
var id_list = new Array();
|
|
|
|
|
len = checkboxes.elements.length;
|
|
|
|
|
for (var i=0; i < len; i++) {
|
|
|
|
|
if (checkboxes.elements[i].type == "checkbox" && checkboxes.elements[i].checked == true && checkboxes.elements[i].value != "checkall") {
|
|
|
|
|
id_list.push(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
console.log(id_list);
|
|
|
|
|
for (i in id_list) {
|
|
|
|
|
console.log(tabProduct);
|
|
|
|
|
tableData.push(GetRowData(tabProduct.rows[id_list[i]]));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (id_list.length == 0){
|
|
|
|
|
alert('请至少选择一行!');
|
|
|
|
|
}
|
|
|
|
|
returnData.push(tableData);
|
|
|
|
|
returnData.push(id_list.length);
|
|
|
|
|
return returnData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function move(from, to, from_o, to_o) {
|
|
|
|
|
$("#" + from + " option").each(function () {
|
|
|
|
|
if ($(this).prop("selected") == true) {
|
|
|
|
|
$("#" + to).append(this);
|
|
|
|
|
if( typeof from_o !== 'undefined'){
|
|
|
|
|
$("#"+to_o).append($("#"+from_o +" option[value='"+this.value+"']"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function move_left(from, to, from_o, to_o) {
|
|
|
|
|
$("#" + from + " option").each(function () {
|
|
|
|
|
if ($(this).prop("selected") == true) {
|
|
|
|
|
$("#" + to).append(this);
|
|
|
|
|
if( typeof from_o !== 'undefined'){
|
|
|
|
|
$("#"+to_o).append($("#"+from_o +" option[value='"+this.value+"']"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$(this).attr("selected",'true');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//function move_all(from, to) {
|
|
|
|
|
// $("#" + from).children().each(function () {
|
|
|
|
|
// $("#" + to).append(this);
|
|
|
|
|
// });
|
|
|
|
|
//}
|
|
|
|
|
//
|
|
|
|
|
|
2015-12-19 09:26:34 +00:00
|
|
|
|
//function selectAllOption(){
|
|
|
|
|
// var checklist = document.getElementsByName ("selected");
|
|
|
|
|
// if(document.getElementById("select_all").checked)
|
|
|
|
|
// {
|
|
|
|
|
// for(var i=0;i<checklist.length;i++)
|
|
|
|
|
// {
|
|
|
|
|
// checklist[i].checked = 1;
|
|
|
|
|
// }
|
|
|
|
|
// }else{
|
|
|
|
|
// for(var j=0;j<checklist.length;j++)
|
|
|
|
|
// {
|
|
|
|
|
// checklist[j].checked = 0;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
2015-04-20 02:12:11 +00:00
|
|
|
|
function selectAll(){
|
2015-12-19 09:26:34 +00:00
|
|
|
|
// 选择该页面所有option
|
|
|
|
|
$('option').each(function(){
|
|
|
|
|
$(this).attr('selected', true)
|
|
|
|
|
})
|
|
|
|
|
}
|
2015-04-20 02:12:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
//function move_all(from, to){
|
|
|
|
|
// $("#"+from).children().each(function(){
|
|
|
|
|
// $("#"+to).append(this);
|
|
|
|
|
// });
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//function commit_select(form_array){
|
|
|
|
|
// $('#{0} option'.format(form_array)).each(function(){
|
|
|
|
|
// $(this).prop('selected', true)
|
|
|
|
|
// })
|
|
|
|
|
//}
|
|
|
|
|
|
2015-12-19 09:26:34 +00:00
|
|
|
|
function getIDall() {
|
|
|
|
|
var check_array = [];
|
|
|
|
|
$(".gradeX input:checked").each(function () {
|
|
|
|
|
var id = $(this).attr("value");
|
|
|
|
|
check_array.push(id);
|
|
|
|
|
});
|
|
|
|
|
return check_array.join(",");
|
|
|
|
|
}
|