2010-06-16 18:21:58 +00:00
|
|
|
/**
|
|
|
|
* Tab constructor
|
|
|
|
*
|
|
|
|
* @param tabId
|
|
|
|
* Tab ID
|
|
|
|
* @param tabName
|
|
|
|
* Tab name
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
var Tab = function(tabId) {
|
2012-05-04 00:54:58 +00:00
|
|
|
this.tabId = tabId;
|
|
|
|
this.tabName = null;
|
|
|
|
this.tab = null;
|
2010-06-16 18:21:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the tab
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param tabName Tab name to initialize
|
2010-06-16 18:21:58 +00:00
|
|
|
*/
|
|
|
|
Tab.prototype.init = function() {
|
2012-05-04 00:54:58 +00:00
|
|
|
// Create a division containing the tab
|
|
|
|
this.tab = $('<div class="tab" id="' + this.tabId + '"></div>');
|
|
|
|
var tabList = $('<ul></ul>');
|
|
|
|
var tabItem = $('<li><a href="#">Dummy tab item</a></li>');
|
|
|
|
tabList.append(tabItem);
|
|
|
|
this.tab.append(tabList);
|
|
|
|
|
|
|
|
// Create a template with close button
|
|
|
|
var tabs = this.tab.tabs();
|
|
|
|
|
|
|
|
tabs.bind('tabsselect', function(event, ui){
|
|
|
|
// Save the order tabs were selected
|
|
|
|
var order;
|
|
|
|
if ($.cookie('tabindex_history')) {
|
|
|
|
order = $.cookie('tabindex_history').split(',');
|
|
|
|
order[1] = order[0]; // Set index 1 to last selected tab
|
|
|
|
order[0] = ui.index; // Set index 0 to currently selected tab
|
|
|
|
} else {
|
|
|
|
// Create an array to track the tab selected
|
|
|
|
order = new Array;
|
|
|
|
order[0] = ui.index;
|
|
|
|
order[1] = ui.index;
|
|
|
|
}
|
|
|
|
|
|
|
|
$.cookie('tabindex_history', order);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Remove dummy tab
|
|
|
|
this.tab.tabs("remove", 0);
|
|
|
|
|
|
|
|
// Hide tab
|
|
|
|
this.tab.hide();
|
2010-06-16 18:21:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the tab object
|
|
|
|
*
|
|
|
|
* @return Object representing the tab
|
|
|
|
*/
|
|
|
|
Tab.prototype.object = function() {
|
2012-05-04 00:54:58 +00:00
|
|
|
return this.tab;
|
2010-06-16 18:21:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a new tab
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param tabId Tab ID
|
|
|
|
* @param tabName Tab name
|
|
|
|
* @param tabCont Tab content
|
|
|
|
* @param closeable Is tab closeable
|
2010-06-16 18:21:58 +00:00
|
|
|
*/
|
2010-12-03 22:09:36 +00:00
|
|
|
Tab.prototype.add = function(tabId, tabName, tabCont, closeable) {
|
2012-05-04 00:54:58 +00:00
|
|
|
// Show tab
|
|
|
|
if (this.tab.css("display") == "none") {
|
|
|
|
this.tab.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
var newTab = $('<div class="tab" id="' + tabId + '"></div>');
|
|
|
|
newTab.append(tabCont);
|
|
|
|
this.tab.append(newTab);
|
|
|
|
this.tab.tabs("add", "#" + tabId, tabName);
|
|
|
|
|
|
|
|
// Append close button
|
|
|
|
if (closeable) {
|
|
|
|
var header = this.tab.find('ul.ui-tabs-nav a[href="#' + tabId +'"]').parent();
|
|
|
|
header.append('<span class=\"tab-close ui-icon ui-icon-close\"></span>');
|
|
|
|
|
|
|
|
// Get this tab
|
|
|
|
var tabs = this.tab;
|
|
|
|
var tabLink = 'a[href="\#' + tabId + '"]';
|
|
|
|
var thisTab = $(tabLink, tabs).parent();
|
|
|
|
|
|
|
|
// Close tab when close button is clicked
|
|
|
|
thisTab.find('span.tab-close').bind('click', function(event) {
|
|
|
|
var tabIndex = ($('li', tabs).index(thisTab));
|
|
|
|
|
|
|
|
// Do not remove first tab
|
|
|
|
if (tabIndex != 0) {
|
|
|
|
// Go back to last tab if user is trying to close currently selected tab
|
|
|
|
if (tabs.tabs('option', 'selected') == tabIndex) {
|
|
|
|
// Get last selected tab from history
|
|
|
|
var order = $.cookie('tabindex_history').split(',');
|
|
|
|
if (order[1]) {
|
|
|
|
tabs.tabs('select', parseInt(order[1]));
|
|
|
|
} else {
|
|
|
|
tabs.tabs('select', 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tabs.tabs('remove', tabIndex);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2010-06-16 18:21:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Select a tab
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param id Tab ID to select
|
2010-06-16 18:21:58 +00:00
|
|
|
*/
|
|
|
|
Tab.prototype.select = function(id) {
|
2012-05-04 00:54:58 +00:00
|
|
|
this.tab.tabs("select", "#" + id);
|
2010-06-16 18:21:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a tab
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param id Tab ID to remove
|
2010-06-16 18:21:58 +00:00
|
|
|
*/
|
|
|
|
Tab.prototype.remove = function(id) {
|
2012-05-04 00:54:58 +00:00
|
|
|
var selectorStr = 'a[href="\#' + id + '"]';
|
|
|
|
var selectTab = $(selectorStr, this.tab).parent();
|
|
|
|
var index = ($('li', this.tab).index(selectTab));
|
|
|
|
this.tab.tabs("remove", index);
|
2010-06-16 18:21:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Table constructor
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param tabId Tab ID
|
|
|
|
* @param tabName Tab name
|
2010-06-16 18:21:58 +00:00
|
|
|
*/
|
|
|
|
var Table = function(tableId) {
|
2012-05-04 00:54:58 +00:00
|
|
|
if ($('#' + tableId).length) {
|
|
|
|
this.tableId = tableId;
|
|
|
|
this.table = $('#' + tableId);
|
|
|
|
} else {
|
|
|
|
this.tableId = tableId;
|
|
|
|
this.table = null;
|
|
|
|
}
|
2010-06-16 18:21:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the table
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param Headers Array of table headers
|
2010-06-16 18:21:58 +00:00
|
|
|
*/
|
|
|
|
Table.prototype.init = function(headers) {
|
2012-05-04 00:54:58 +00:00
|
|
|
// Create a table
|
|
|
|
this.table = $('<table id="' + this.tableId + '"></table>');
|
|
|
|
var thead = $('<thead class="ui-widget-header"></thead>');
|
|
|
|
var headRow = $('<tr></tr>');
|
|
|
|
|
|
|
|
// Append headers
|
|
|
|
for ( var i in headers) {
|
|
|
|
headRow.append('<th>' + headers[i] + '</th>');
|
|
|
|
}
|
|
|
|
|
|
|
|
thead.append(headRow);
|
|
|
|
this.table.append(thead);
|
|
|
|
|
|
|
|
// Append table body
|
|
|
|
var tableBody = $('<tbody></tbody>');
|
|
|
|
this.table.append(tableBody);
|
2010-06-16 18:21:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the table object
|
|
|
|
*
|
|
|
|
* @return Object representing the table
|
|
|
|
*/
|
|
|
|
Table.prototype.object = function() {
|
2012-05-04 00:54:58 +00:00
|
|
|
return this.table;
|
2010-06-16 18:21:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a row to the table
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param rowCont Array of table row contents
|
2010-06-16 18:21:58 +00:00
|
|
|
*/
|
|
|
|
Table.prototype.add = function(rowCont) {
|
2012-05-04 00:54:58 +00:00
|
|
|
// Create table row
|
|
|
|
var tableRow = $('<tr></tr>');
|
|
|
|
|
|
|
|
// Create a column for each content
|
|
|
|
var tableCol;
|
|
|
|
for ( var i in rowCont) {
|
|
|
|
tableCol = $('<td></td>');
|
|
|
|
tableCol.append(rowCont[i]);
|
|
|
|
tableRow.append(tableCol);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Append table row to table
|
|
|
|
this.table.find('tbody').append(tableRow);
|
2010-06-16 18:21:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a footer to the table
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param rowCont Array of table row contents
|
2010-06-16 18:21:58 +00:00
|
|
|
*/
|
|
|
|
Table.prototype.addFooter = function(rowCont) {
|
2012-05-04 00:54:58 +00:00
|
|
|
// Create table row
|
|
|
|
var tableFoot = $('<tfoot></tfoot>');
|
|
|
|
tableFoot.append(rowCont);
|
2010-06-16 18:21:58 +00:00
|
|
|
|
2012-05-04 00:54:58 +00:00
|
|
|
// Append table row to table
|
|
|
|
this.table.append(tableFoot);
|
2010-06-16 18:21:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a row from the table
|
|
|
|
*/
|
|
|
|
Table.prototype.remove = function(id) {
|
2012-05-04 00:54:58 +00:00
|
|
|
// To be continued
|
2010-06-16 18:21:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Datatable class constructor
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param tabId Tab ID
|
|
|
|
* @param tabName Tab name
|
2010-06-16 18:21:58 +00:00
|
|
|
*/
|
|
|
|
var DataTable = function(tableId) {
|
2012-05-04 00:54:58 +00:00
|
|
|
this.dataTableId = tableId;
|
|
|
|
this.dataTable = null;
|
2010-06-16 18:21:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the datatable
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param Headers Array of table headers
|
2010-06-16 18:21:58 +00:00
|
|
|
*/
|
|
|
|
DataTable.prototype.init = function(headers) {
|
2012-05-04 00:54:58 +00:00
|
|
|
// Create a table
|
|
|
|
this.dataTable = $('<table class="datatable" id="' + this.dataTableId + '"></table>');
|
|
|
|
var thead = $('<thead class="ui-widget-header"></thead>');
|
|
|
|
var headRow = $('<tr></tr>');
|
|
|
|
|
|
|
|
// Append headers
|
|
|
|
for ( var i in headers) {
|
|
|
|
headRow.append('<th>' + headers[i] + '</th>');
|
|
|
|
}
|
|
|
|
|
|
|
|
thead.append(headRow);
|
|
|
|
this.dataTable.append(thead);
|
|
|
|
|
|
|
|
// Append table body
|
|
|
|
var tableBody = $('<tbody></tbody>');
|
|
|
|
this.dataTable.append(tableBody);
|
2010-06-16 18:21:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the datatable object
|
|
|
|
*
|
|
|
|
* @return Object representing the table
|
|
|
|
*/
|
|
|
|
DataTable.prototype.object = function() {
|
2012-05-04 00:54:58 +00:00
|
|
|
return this.dataTable;
|
2010-06-16 18:21:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a row to the datatable
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param rowCont Array of table row contents
|
2010-06-16 18:21:58 +00:00
|
|
|
*/
|
|
|
|
DataTable.prototype.add = function(rowCont) {
|
2012-05-04 00:54:58 +00:00
|
|
|
// Create table row
|
|
|
|
var tableRow = $('<tr></tr>');
|
|
|
|
|
|
|
|
// Create a column for each content
|
|
|
|
var tableCol;
|
|
|
|
for ( var i in rowCont) {
|
|
|
|
tableCol = $('<td></td>');
|
|
|
|
tableCol.append(rowCont[i]);
|
|
|
|
tableRow.append(tableCol);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Append table row to table
|
|
|
|
this.dataTable.find('tbody').append(tableRow);
|
2010-06-16 18:21:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create status bar
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param barId Status bar ID
|
2010-06-16 18:21:58 +00:00
|
|
|
*/
|
|
|
|
function createStatusBar(barId) {
|
2012-08-30 14:01:04 +00:00
|
|
|
// Do not change the background color or color! This is handled by the theme
|
|
|
|
// the user selects.
|
|
|
|
var statusBar = $('<div class="ui-state-highlight ui-corner-all" id="' + barId + '"></div>').css({
|
2012-05-04 00:54:58 +00:00
|
|
|
'margin-bottom': '5px',
|
2012-07-23 10:13:30 +00:00
|
|
|
'min-height': '30px',
|
2012-07-27 04:54:26 +00:00
|
|
|
'max-height': '150px',
|
|
|
|
'overflow': 'auto'
|
2012-05-04 00:54:58 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Create info icon
|
|
|
|
var icon = $('<span class="ui-icon ui-icon-circle-check"></span>').css({
|
|
|
|
'display': 'inline-block',
|
|
|
|
'margin': '10px 5px',
|
|
|
|
'vertical-align': 'top'
|
|
|
|
});
|
|
|
|
|
|
|
|
// Create message section
|
|
|
|
var msg = $('<div></div>').css({
|
|
|
|
'display': 'inline-block',
|
|
|
|
'margin': '10px 0px',
|
|
|
|
'width': '90%'
|
|
|
|
});
|
|
|
|
|
|
|
|
// Create hide button
|
|
|
|
var hide = $('<span class="ui-icon ui-icon-minus"></span>').css({
|
|
|
|
'display': 'inline-block',
|
|
|
|
'float': 'right',
|
|
|
|
'margin': '10px 5px',
|
|
|
|
'cursor': 'pointer'
|
|
|
|
}).click(function() {
|
|
|
|
// Remove info box on-click
|
|
|
|
$(this).parent().hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
statusBar.append(icon);
|
|
|
|
statusBar.append(msg);
|
|
|
|
statusBar.append(hide);
|
|
|
|
return statusBar;
|
2010-06-16 18:21:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create info bar
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param msg Info message
|
2010-06-16 18:21:58 +00:00
|
|
|
* @return Info bar
|
|
|
|
*/
|
|
|
|
function createInfoBar(msg) {
|
2012-08-30 14:01:04 +00:00
|
|
|
// Do not change the background color or color! This is handled by the theme
|
|
|
|
// the user selects.
|
|
|
|
var infoBar = $('<div class="ui-state-highlight ui-corner-all"></div>').css({
|
2012-08-31 02:48:04 +00:00
|
|
|
'margin': '5px 0px'
|
2012-07-23 10:13:30 +00:00
|
|
|
});
|
2012-05-04 00:54:58 +00:00
|
|
|
var icon = $('<span class="ui-icon ui-icon-info"></span>').css({
|
|
|
|
'display': 'inline-block',
|
|
|
|
'margin': '10px 5px'
|
|
|
|
});
|
|
|
|
var barMsg = $('<p>' + msg + '</p>').css({
|
|
|
|
'display': 'inline-block',
|
|
|
|
'width': '90%'
|
|
|
|
});
|
|
|
|
|
|
|
|
infoBar.append(icon);
|
|
|
|
infoBar.append(barMsg);
|
|
|
|
return infoBar;
|
2010-06-16 18:21:58 +00:00
|
|
|
}
|
|
|
|
|
2010-09-23 20:43:10 +00:00
|
|
|
/**
|
|
|
|
* Create warning bar
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param msg Warning message
|
2010-09-23 20:43:10 +00:00
|
|
|
* @return Warning bar
|
|
|
|
*/
|
|
|
|
function createWarnBar(msg) {
|
2012-05-04 00:54:58 +00:00
|
|
|
var warnBar = $('<div class="ui-state-error ui-corner-all"></div>');
|
|
|
|
var icon = $('<span class="ui-icon ui-icon-alert"></span>').css({
|
|
|
|
'display': 'inline-block',
|
|
|
|
'margin': '10px 5px'
|
|
|
|
});
|
|
|
|
var barMsg = $('<p>' + msg + '</p>').css({
|
|
|
|
'display': 'inline-block',
|
|
|
|
'width': '90%'
|
|
|
|
});
|
|
|
|
|
|
|
|
warnBar.append(icon);
|
|
|
|
warnBar.append(barMsg);
|
|
|
|
return warnBar;
|
2010-09-23 20:43:10 +00:00
|
|
|
}
|
|
|
|
|
2010-06-16 18:21:58 +00:00
|
|
|
/**
|
|
|
|
* Create a loader
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param loaderId Loader ID
|
2010-06-16 18:21:58 +00:00
|
|
|
*/
|
|
|
|
function createLoader(loaderId) {
|
2012-05-04 00:54:58 +00:00
|
|
|
var loader = $('<img id="' + loaderId + '" src="images/loader.gif"></img>');
|
|
|
|
return loader;
|
2010-06-16 18:21:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a button
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param name Name of the button
|
2010-06-16 18:21:58 +00:00
|
|
|
*/
|
|
|
|
function createButton(name) {
|
2012-05-04 00:54:58 +00:00
|
|
|
var button = $('<button>' + name + '</button>').button();
|
|
|
|
return button;
|
2010-06-16 18:21:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a menu
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param items An array of items to go into the menu
|
2010-06-16 18:21:58 +00:00
|
|
|
* @return A division containing the menu
|
|
|
|
*/
|
|
|
|
function createMenu(items) {
|
2012-05-04 00:54:58 +00:00
|
|
|
var menu = $('<ul class="sf-menu ui-state-default"></ul>');
|
|
|
|
|
|
|
|
// Loop through each item
|
|
|
|
for ( var i in items) {
|
|
|
|
// Append item to menu
|
|
|
|
var item = $('<li></li>');
|
|
|
|
|
|
|
|
// If it is a sub menu
|
|
|
|
if (items[i] instanceof Array) {
|
|
|
|
// 1st index = Sub menu title
|
|
|
|
item.append(items[i][0]);
|
|
|
|
// 2nd index = Sub menu
|
|
|
|
item.append(items[i][1]);
|
|
|
|
} else {
|
|
|
|
item.append(items[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
menu.append(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return menu;
|
2010-06-16 18:21:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the page
|
|
|
|
*/
|
2012-05-04 00:54:58 +00:00
|
|
|
function initPage() {
|
|
|
|
// Load theme
|
|
|
|
var theme = $.cookie('xcat_theme');
|
|
|
|
if (theme) {
|
|
|
|
switch (theme) {
|
|
|
|
case 'cupertino':
|
|
|
|
includeCss("css/themes/jquery-ui-cupertino.css");
|
|
|
|
break;
|
|
|
|
case 'dark_hive':
|
|
|
|
includeCss("css/themes/jquery-ui-dark_hive.css");
|
|
|
|
break;
|
|
|
|
case 'redmond':
|
|
|
|
includeCss("css/themes/jquery-ui-redmond.css");
|
|
|
|
break;
|
|
|
|
case 'start':
|
|
|
|
includeCss("css/themes/jquery-ui-start.css");
|
|
|
|
break;
|
|
|
|
case 'sunny':
|
|
|
|
includeCss("css/themes/jquery-ui-sunny.css");
|
|
|
|
break;
|
|
|
|
case 'ui_dark':
|
|
|
|
includeCss("css/themes/jquery-ui-ui_darkness.css");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
includeCss("css/themes/jquery-ui-start.css");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
includeCss("css/themes/jquery-ui-start.css");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load jQuery stylesheets
|
|
|
|
includeCss("css/jquery.dataTables.css");
|
|
|
|
includeCss("css/superfish.css");
|
|
|
|
includeCss("css/jstree.css");
|
|
|
|
includeCss("css/jquery.jqplot.css");
|
|
|
|
|
|
|
|
// Load custom stylesheet
|
|
|
|
includeCss("css/style.css");
|
|
|
|
|
|
|
|
// JQuery plugins
|
|
|
|
includeJs("js/jquery/jquery.dataTables.min.js");
|
|
|
|
includeJs("js/jquery/jquery.form.min.js");
|
|
|
|
includeJs("js/jquery/jquery.jeditable.min.js");
|
|
|
|
includeJs("js/jquery/jquery.contextmenu.min.js");
|
|
|
|
includeJs("js/jquery/superfish.min.js");
|
|
|
|
includeJs("js/jquery/hoverIntent.min.js");
|
|
|
|
includeJs("js/jquery/jquery.jstree.min.js");
|
|
|
|
includeJs("js/jquery/tooltip.min.js");
|
|
|
|
includeJs("js/jquery/jquery.serverBrowser.min.js");
|
|
|
|
includeJs("js/jquery/jquery.jqplot.min.js");
|
2011-06-16 02:48:34 +00:00
|
|
|
includeJs("js/jquery/jqplot.pieRenderer.min.js");
|
|
|
|
includeJs("js/jquery/jqplot.dateAxisRenderer.min.js");
|
2013-02-11 00:22:33 +00:00
|
|
|
includeJs("js/jquery/jquery.topzindex.min.js");
|
2011-06-16 02:48:34 +00:00
|
|
|
|
2012-05-04 00:54:58 +00:00
|
|
|
// Page plugins
|
|
|
|
includeJs("js/configure/configure.js");
|
|
|
|
includeJs("js/monitor/monitor.js");
|
|
|
|
includeJs("js/nodes/nodes.js");
|
|
|
|
includeJs("js/provision/provision.js");
|
|
|
|
|
|
|
|
// Custom plugins
|
|
|
|
includeJs("js/custom/esx.js");
|
|
|
|
includeJs("js/custom/kvm.js");
|
|
|
|
includeJs("js/custom/blade.js");
|
|
|
|
includeJs("js/custom/ipmi.js");
|
|
|
|
includeJs("js/custom/zvm.js");
|
|
|
|
includeJs("js/custom/hmc.js");
|
|
|
|
includeJs("js/custom/customUtils.js");
|
|
|
|
|
|
|
|
// Enable settings link
|
|
|
|
$('#xcat_settings').click(function() {
|
|
|
|
openSettings();
|
|
|
|
});
|
|
|
|
|
|
|
|
// Set header to theme
|
|
|
|
var background = '', color = '';
|
|
|
|
var theme = $.cookie('xcat_theme');
|
|
|
|
if (theme) {
|
|
|
|
switch (theme) {
|
|
|
|
case 'cupertino':
|
|
|
|
background = '#3BAAE3';
|
|
|
|
color = 'white';
|
|
|
|
break;
|
|
|
|
case 'dark_hive':
|
|
|
|
background = '#0972A5';
|
|
|
|
break;
|
|
|
|
case 'redmond':
|
|
|
|
background = '#F5F8F9';
|
|
|
|
color = '#E17009';
|
|
|
|
break;
|
|
|
|
case 'start':
|
|
|
|
background = '#6EAC2C';
|
|
|
|
break;
|
|
|
|
case 'sunny':
|
|
|
|
background = 'white';
|
|
|
|
color = '#0074C7';
|
|
|
|
break;
|
|
|
|
case 'ui_dark':
|
|
|
|
background = '#F58400';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
background = '#6EAC2C';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
background = '#6EAC2C';
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#header').addClass('ui-state-default');
|
|
|
|
$('#header').css('border', '0px');
|
|
|
|
|
|
|
|
// Set theme to user span
|
|
|
|
$('#login_user').css('color', color);
|
|
|
|
|
|
|
|
// Style for selected page
|
|
|
|
var style = {
|
|
|
|
'background-color': background,
|
|
|
|
'color': color
|
|
|
|
};
|
|
|
|
|
|
|
|
// Get the page being loaded
|
|
|
|
var url = window.location.pathname;
|
|
|
|
var page = url.replace('/xcat/', '');
|
|
|
|
var headers = $('#header ul li a');
|
|
|
|
|
|
|
|
// Show the page
|
|
|
|
$("#content").children().remove();
|
|
|
|
if (page == 'configure.php') {
|
|
|
|
includeJs("js/configure/update.js");
|
|
|
|
includeJs("js/configure/discover.js");
|
|
|
|
includeJs("js/configure/service.js");
|
2013-02-05 15:43:57 +00:00
|
|
|
includeJs("js/configure/users.js");
|
2012-05-04 00:54:58 +00:00
|
|
|
headers.eq(1).css(style);
|
|
|
|
loadConfigPage();
|
|
|
|
} else if (page == 'provision.php') {
|
|
|
|
includeJs("js/provision/images.js");
|
|
|
|
headers.eq(2).css(style);
|
|
|
|
loadProvisionPage();
|
|
|
|
} else if (page == 'monitor.php') {
|
|
|
|
includeJs("js/monitor/xcatmon.js");
|
|
|
|
includeJs("js/monitor/rmcmon.js");
|
|
|
|
includeJs("js/monitor/gangliamon.js");
|
|
|
|
headers.eq(3).css(style);
|
|
|
|
loadMonitorPage();
|
|
|
|
} else if (page == 'help.php') {
|
|
|
|
includeJs("js/help/help.js");
|
|
|
|
headers.eq(4).css(style);
|
2011-11-23 17:59:48 +00:00
|
|
|
loadHelpPage();
|
2012-05-04 00:54:58 +00:00
|
|
|
} else {
|
|
|
|
// Load nodes page by default
|
2011-04-28 08:00:00 +00:00
|
|
|
includeJs("js/nodes/nodeset.js");
|
|
|
|
includeJs("js/nodes/rnetboot.js");
|
|
|
|
includeJs("js/nodes/updatenode.js");
|
|
|
|
includeJs("js/nodes/physical.js");
|
|
|
|
includeJs("js/nodes/mtm.js");
|
2013-02-05 15:43:57 +00:00
|
|
|
includeJs("js/nodes/rscan.js");
|
2012-05-04 00:54:58 +00:00
|
|
|
headers.eq(0).css(style);
|
|
|
|
loadNodesPage();
|
|
|
|
}
|
2010-07-14 20:11:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-15 13:41:29 +00:00
|
|
|
* Include javascript file in <head>
|
2010-07-14 20:11:07 +00:00
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param file File to include
|
2010-07-14 20:11:07 +00:00
|
|
|
*/
|
|
|
|
function includeJs(file) {
|
2012-05-04 00:54:58 +00:00
|
|
|
var script = $("head script[src='" + file + "']");
|
|
|
|
|
|
|
|
// If <head> does not contain the javascript
|
|
|
|
if (!script.length) {
|
|
|
|
// Append the javascript to <head>
|
|
|
|
var script = $('<script></script>');
|
|
|
|
script.attr( {
|
|
|
|
type : 'text/javascript',
|
|
|
|
src : file
|
|
|
|
});
|
|
|
|
|
|
|
|
$('head').append(script);
|
|
|
|
}
|
2010-07-27 19:50:01 +00:00
|
|
|
}
|
|
|
|
|
2011-09-21 20:38:15 +00:00
|
|
|
/**
|
|
|
|
* Include CSS link in <head>
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param file File to include
|
2011-09-21 20:38:15 +00:00
|
|
|
*/
|
|
|
|
function includeCss(file) {
|
2012-05-04 00:54:58 +00:00
|
|
|
var link = $("head link[href='" + file + "']");
|
|
|
|
|
|
|
|
// If <head> does not contain the link
|
|
|
|
if (!link.length) {
|
|
|
|
// Append the CSS link to <head>
|
|
|
|
var link = $('<link>');
|
|
|
|
link.attr( {
|
|
|
|
type : 'text/css',
|
|
|
|
rel : 'stylesheet',
|
|
|
|
href : file
|
|
|
|
});
|
|
|
|
|
|
|
|
$('head').append(link);
|
|
|
|
}
|
2011-09-21 20:38:15 +00:00
|
|
|
}
|
|
|
|
|
2010-07-27 19:50:01 +00:00
|
|
|
/**
|
|
|
|
* Write ajax response to a paragraph
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param rsp Ajax response
|
|
|
|
* @param pattern Pattern to replace with a break
|
2010-07-27 19:50:01 +00:00
|
|
|
* @return Paragraph containing ajax response
|
|
|
|
*/
|
2010-07-27 22:56:42 +00:00
|
|
|
function writeRsp(rsp, pattern) {
|
2012-05-04 00:54:58 +00:00
|
|
|
// Create paragraph to hold ajax response
|
|
|
|
var prg = $('<pre></pre>');
|
|
|
|
|
|
|
|
for ( var i in rsp) {
|
|
|
|
if (rsp[i]) {
|
|
|
|
// Create regular expression for given pattern
|
|
|
|
// Replace pattern with break
|
|
|
|
if (pattern) {
|
|
|
|
rsp[i] = rsp[i].replace(new RegExp(pattern, 'g'), '<br/>');
|
|
|
|
prg.append(rsp[i]);
|
|
|
|
} else {
|
|
|
|
prg.append(rsp[i]);
|
|
|
|
prg.append('<br/>');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return prg;
|
2010-09-23 20:43:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open a dialog and show given message
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param type Type of dialog, i.e. warn or info
|
|
|
|
* @param msg Message to show
|
2010-09-23 20:43:10 +00:00
|
|
|
*/
|
2010-09-24 12:27:54 +00:00
|
|
|
function openDialog(type, msg) {
|
2013-02-08 05:54:14 +00:00
|
|
|
var msgDialog = $('<div></div>');
|
|
|
|
var title = "";
|
2012-05-04 00:54:58 +00:00
|
|
|
if (type == "warn") {
|
|
|
|
// Create warning message
|
2013-02-08 05:54:14 +00:00
|
|
|
msgDialog.append(createWarnBar(msg));
|
|
|
|
title = "Warning";
|
2012-05-04 00:54:58 +00:00
|
|
|
} else {
|
|
|
|
// Create info message
|
2013-02-08 05:54:14 +00:00
|
|
|
msgDialog.append(createInfoBar(msg));
|
|
|
|
title = "Info";
|
2012-05-04 00:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Open dialog
|
|
|
|
msgDialog.dialog({
|
2013-02-08 05:54:14 +00:00
|
|
|
title: title,
|
2012-05-04 00:54:58 +00:00
|
|
|
modal: true,
|
|
|
|
close: function(){
|
|
|
|
$(this).remove();
|
2012-04-12 16:11:00 +00:00
|
|
|
},
|
2012-05-04 00:54:58 +00:00
|
|
|
width: 500,
|
|
|
|
buttons: {
|
|
|
|
"Ok": function(){
|
|
|
|
$(this).dialog("close");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2010-09-23 20:43:10 +00:00
|
|
|
}
|
2011-04-12 19:46:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create an iframe to hold the output of an xCAT command
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param src The URL of the document to show in the iframe
|
2011-04-12 19:46:01 +00:00
|
|
|
* @return Info box containing the iframe
|
|
|
|
*/
|
|
|
|
function createIFrame(src) {
|
2012-05-04 00:54:58 +00:00
|
|
|
// Put an iframe inside an info box
|
|
|
|
var infoBar = $('<div class="ui-state-highlight ui-corner-all"></div>').css({
|
|
|
|
'margin-bottom': '5px'
|
|
|
|
});
|
|
|
|
|
|
|
|
// Create info and close icons
|
|
|
|
var icon = $('<span class="ui-icon ui-icon-info"></span>').css({
|
|
|
|
'display': 'inline-block',
|
|
|
|
'margin': '10px 5px'
|
|
|
|
});
|
|
|
|
var close = $('<span class="ui-icon ui-icon-close"></span>').css({
|
|
|
|
'display': 'inline-block',
|
|
|
|
'float': 'right',
|
|
|
|
'margin': '10px 5px'
|
|
|
|
}).click(function() {
|
|
|
|
// Remove info box on-click
|
|
|
|
$(this).parent().remove();
|
|
|
|
});
|
|
|
|
|
|
|
|
var iframe = $('<iframe></iframe>').attr('src', src).css({
|
|
|
|
'display': 'block',
|
|
|
|
'border': '0px',
|
|
|
|
'margin': '10px',
|
|
|
|
'width': '100%'
|
|
|
|
});
|
|
|
|
|
|
|
|
var loader = createLoader('iLoader').css({
|
|
|
|
'display': 'block',
|
|
|
|
'margin': '10px 0px'
|
|
|
|
});
|
|
|
|
|
|
|
|
infoBar.append(icon);
|
|
|
|
infoBar.append($('<div style="display: inline-block; width: 90%;"></div>').append(loader, iframe));
|
|
|
|
infoBar.append(close);
|
|
|
|
|
|
|
|
// Remove loader when done
|
|
|
|
iframe.load(function() {
|
|
|
|
loader.remove();
|
|
|
|
});
|
|
|
|
|
|
|
|
return infoBar;
|
2011-04-12 19:46:01 +00:00
|
|
|
}
|
2011-09-21 20:38:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open dialog to set xCAT UI settings
|
|
|
|
*/
|
|
|
|
function openSettings() {
|
2012-05-04 00:54:58 +00:00
|
|
|
// Create form to add node range
|
|
|
|
var dialog = $('<div class="form"></div>');
|
|
|
|
var info = createInfoBar('Select from the following options');
|
|
|
|
dialog.append(info);
|
|
|
|
|
|
|
|
var style = {
|
|
|
|
'color': 'blue',
|
|
|
|
'cursor': 'pointer',
|
|
|
|
'padding': '5px'
|
|
|
|
};
|
|
|
|
|
|
|
|
var changeThemeOption = $('<div><center><a style="color: blue;">Change xCAT theme</a></center></div>').css(style);
|
|
|
|
dialog.append(changeThemeOption);
|
|
|
|
|
|
|
|
var changePasswordOption = $('<div><center><a style="color: blue;">Change password</a></center></div>').css(style);
|
|
|
|
dialog.append(changePasswordOption);
|
|
|
|
|
|
|
|
// Open form as a dialog
|
|
|
|
dialog.dialog({
|
|
|
|
modal: true,
|
|
|
|
close: function(){
|
|
|
|
$(this).remove();
|
2012-04-12 16:11:00 +00:00
|
|
|
},
|
2012-05-04 00:54:58 +00:00
|
|
|
title: 'Settings',
|
|
|
|
width: 400,
|
|
|
|
buttons: {
|
|
|
|
"Cancel": function(){
|
|
|
|
$(this).dialog("close");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Bind to click event
|
|
|
|
changeThemeOption.click(function() {
|
|
|
|
dialog.dialog("close");
|
|
|
|
changeTheme();
|
|
|
|
});
|
|
|
|
|
|
|
|
changePasswordOption.click(function() {
|
|
|
|
dialog.dialog("close");
|
|
|
|
changePassword();
|
|
|
|
});
|
2012-03-14 04:32:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open dialog to change xCAT theme
|
|
|
|
*/
|
|
|
|
function changeTheme() {
|
2012-05-04 00:54:58 +00:00
|
|
|
// Create form to add node range
|
|
|
|
var dialog = $('<div class="form"></div>');
|
|
|
|
var info = createInfoBar('Select the xCAT theme you desire');
|
|
|
|
dialog.append(info);
|
|
|
|
|
|
|
|
// Create select drop down for themes
|
|
|
|
var oList = $('<ol></ol>');
|
|
|
|
oList.append($('<li><input type="radio" name="theme" value="cupertino">Cupertino</li>'));
|
|
|
|
oList.append($('<li><input type="radio" name="theme" value="dark_hive">Dark Hive</li>'));
|
|
|
|
oList.append($('<li><input type="radio" name="theme" value="redmond">Redmond</li>'));
|
|
|
|
oList.append($('<li><input type="radio" name="theme" value="start">Start (default)</li>'));
|
|
|
|
oList.append($('<li><input type="radio" name="theme" value="sunny">Sunny</li>'));
|
|
|
|
oList.append($('<li><input type="radio" name="theme" value="ui_dark">UI Darkness</li>'));
|
|
|
|
dialog.append(oList);
|
|
|
|
|
|
|
|
if ($.cookie('xcat_theme')) {
|
|
|
|
// Select theme
|
|
|
|
oList.find('input[value="' + $.cookie('xcat_theme') + '"]').attr('checked', true);
|
|
|
|
} else {
|
|
|
|
oList.find('input[value="start"]').attr('checked', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Open form as a dialog
|
|
|
|
dialog.dialog({
|
|
|
|
modal: true,
|
|
|
|
close: function(){
|
|
|
|
$(this).remove();
|
2012-04-12 16:11:00 +00:00
|
|
|
},
|
2012-05-04 00:54:58 +00:00
|
|
|
title: 'xCAT Theme',
|
|
|
|
width: 400,
|
|
|
|
buttons: {
|
|
|
|
"Ok": function(){
|
|
|
|
// Save selected theme
|
|
|
|
var theme = $(this).find('input[name="theme"]:checked').val();
|
|
|
|
$.cookie('xcat_theme', theme); // Do not expire cookie, keep it as long as possible
|
|
|
|
|
|
|
|
// Show instructions to apply theme
|
|
|
|
$(this).empty();
|
|
|
|
var info = createInfoBar('You will need to reload this page in order for changes to take effect');
|
|
|
|
$(this).append(info);
|
|
|
|
|
|
|
|
// Only show close button
|
|
|
|
$(this).dialog("option", "buttons", {
|
|
|
|
"Close" : function() {
|
|
|
|
$(this).dialog( "close" );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
"Cancel": function(){
|
|
|
|
$(this).dialog( "close" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2011-09-28 21:38:12 +00:00
|
|
|
}
|
|
|
|
|
2012-03-14 04:32:06 +00:00
|
|
|
/**
|
|
|
|
* Open dialog to change user password
|
|
|
|
*/
|
|
|
|
function changePassword() {
|
2012-05-04 00:54:58 +00:00
|
|
|
// Create form to add node range
|
|
|
|
var dialog = $('<div id="changePassword" class="form"></div>');
|
|
|
|
var info = createInfoBar('Change your password');
|
|
|
|
dialog.append(info);
|
|
|
|
|
|
|
|
dialog.append('<div><label>New password:</label><input type="password" name="newPassword"/></div>');
|
|
|
|
dialog.append('<div><label>Confirm password:</label><input type="password" name="confirmPassword"/></div>');
|
|
|
|
|
|
|
|
// Open form as a dialog
|
|
|
|
dialog.dialog({
|
|
|
|
modal: true,
|
|
|
|
close: function(){
|
|
|
|
$(this).remove();
|
2012-04-12 16:11:00 +00:00
|
|
|
},
|
2012-05-04 00:54:58 +00:00
|
|
|
title: 'Change Password',
|
|
|
|
width: 400,
|
|
|
|
buttons: {
|
|
|
|
"Ok": function(){
|
|
|
|
// Remove any warning messages
|
|
|
|
$(this).find('.ui-state-error').remove();
|
|
|
|
|
|
|
|
var errorMessage = "";
|
|
|
|
|
|
|
|
// Check each input is provided
|
|
|
|
$('#changePassword input').each(function() {
|
|
|
|
if (!$(this).val()) {
|
|
|
|
errorMessage = "Please provide a value for each missing input!";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Do not continue if error found
|
|
|
|
if (errorMessage) {
|
|
|
|
dialog.prepend(createWarnBar(errorMessage));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check new and confirm passwords match
|
|
|
|
var user = $.cookie('xcat_username');
|
|
|
|
var newPassword = $('#changePassword input[name="newPassword"]').val();
|
|
|
|
var confirmPassword = $('#changePassword input[name="confirmPassword"]').val();
|
|
|
|
if (newPassword != confirmPassword) {
|
|
|
|
dialog.prepend(createWarnBar("Please confirm new password!"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Change dialog buttons
|
|
|
|
$('#changePassword').dialog('option', 'buttons', {
|
|
|
|
'Close':function(){
|
|
|
|
$('#changePassword').dialog('close');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Send request to change password
|
|
|
|
var url = window.location.pathname;
|
|
|
|
var page = url.replace('/xcat/', '');
|
|
|
|
var url = 'lib/cmd.php';
|
|
|
|
// Service portal does not have access to cmd.php
|
|
|
|
if (page == 'service.php')
|
|
|
|
url = 'lib/srv_cmd.php';
|
|
|
|
$.ajax( {
|
|
|
|
url : url,
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'webrun',
|
|
|
|
tgt : '',
|
|
|
|
args : 'passwd;' + user + ';' + newPassword,
|
|
|
|
msg : ''
|
|
|
|
},
|
|
|
|
|
|
|
|
success : function (data) {
|
|
|
|
// Show response message
|
|
|
|
var rspMessage = "";
|
|
|
|
for (var i in data.rsp)
|
|
|
|
rspMessage += data.rsp[i] + "<br/>";
|
|
|
|
|
|
|
|
$('#changePassword').prepend(createInfoBar(rspMessage));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
"Cancel": function(){
|
|
|
|
$(this).dialog( "close" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2012-03-14 04:32:06 +00:00
|
|
|
}
|
|
|
|
|
2011-09-28 22:22:13 +00:00
|
|
|
/**
|
|
|
|
* Adjust datatable column size
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param tableId Table ID
|
2011-09-28 22:22:13 +00:00
|
|
|
*/
|
|
|
|
function adjustColumnSize(tableId) {
|
2013-02-05 15:43:57 +00:00
|
|
|
var dTable = $('#' + tableId).dataTable();
|
|
|
|
dTable.fnAdjustColumnSizing();
|
2011-09-28 22:22:13 +00:00
|
|
|
}
|
|
|
|
|
2011-09-28 21:38:12 +00:00
|
|
|
/**
|
|
|
|
* Set menu theme
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param menu Menu object
|
2011-09-28 21:38:12 +00:00
|
|
|
*/
|
|
|
|
function setMenu2Theme(menu) {
|
2012-05-04 00:54:58 +00:00
|
|
|
// On hover
|
|
|
|
var background = '', color = '';
|
|
|
|
var theme = $.cookie('xcat_theme');
|
|
|
|
if (theme) {
|
|
|
|
switch (theme) {
|
|
|
|
case 'cupertino':
|
|
|
|
background = '#3BAAE3';
|
|
|
|
color = 'white';
|
|
|
|
break;
|
|
|
|
case 'dark_hive':
|
|
|
|
background = '#0972A5';
|
|
|
|
break;
|
|
|
|
case 'redmond':
|
|
|
|
background = '#F5F8F9';
|
|
|
|
color = '#E17009';
|
|
|
|
break;
|
|
|
|
case 'start':
|
|
|
|
background = '#6EAC2C';
|
|
|
|
break;
|
|
|
|
case 'sunny':
|
|
|
|
background = 'white';
|
|
|
|
color = '#0074C7';
|
|
|
|
break;
|
|
|
|
case 'ui_dark':
|
|
|
|
background = '#F58400';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
background = '#6EAC2C';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
background = '#6EAC2C';
|
|
|
|
}
|
|
|
|
|
|
|
|
menu.css('background', background);
|
|
|
|
menu.find('a:eq(0)').css('color', color);
|
2011-09-28 21:38:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set menu back to normal before applying theme
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param menu Menu object
|
2011-09-28 21:38:12 +00:00
|
|
|
*/
|
|
|
|
function setMenu2Normal(menu) {
|
2012-05-04 00:54:58 +00:00
|
|
|
// Change back to normal
|
|
|
|
menu.css('background', '');
|
|
|
|
menu.find('a:eq(0)').css('color', '');
|
2012-04-02 15:43:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get nodes that are checked in a given datatable
|
|
|
|
*
|
2012-05-04 00:54:58 +00:00
|
|
|
* @param datatableId The datatable ID
|
2012-04-02 15:43:37 +00:00
|
|
|
* @return Nodes that were checked
|
|
|
|
*/
|
|
|
|
function getNodesChecked(datatableId) {
|
2012-05-04 00:54:58 +00:00
|
|
|
var tgts = '';
|
|
|
|
|
|
|
|
// Get nodes that were checked
|
|
|
|
var nodes = $('#' + datatableId + ' input[type=checkbox]:checked');
|
|
|
|
for (var i in nodes) {
|
|
|
|
var tgtNode = nodes.eq(i).attr('name');
|
|
|
|
|
2013-02-05 15:43:57 +00:00
|
|
|
if (tgtNode) {
|
2012-05-04 00:54:58 +00:00
|
|
|
tgts += tgtNode;
|
|
|
|
|
|
|
|
// Add a comma at the end
|
|
|
|
if (i < nodes.length - 1) {
|
|
|
|
tgts += ',';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return tgts;
|
2012-08-31 02:48:04 +00:00
|
|
|
}
|
2012-10-19 20:26:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if return message contains errors
|
|
|
|
*
|
2013-02-05 15:43:57 +00:00
|
|
|
* @param msg Return message
|
2012-10-19 20:26:08 +00:00
|
|
|
* @return 0 If return message contains no errors
|
|
|
|
* -1 If return message contains errors
|
|
|
|
*/
|
|
|
|
function containErrors(msg) {
|
|
|
|
if (msg.indexOf('Failed') > -1 || msg.indexOf('Error') > -1) {
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2013-02-05 15:43:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if a value is an integer
|
|
|
|
*
|
|
|
|
* @param value Value to be checked
|
|
|
|
* @returns true If value is an integer
|
|
|
|
false If value is not an integer
|
|
|
|
*/
|
|
|
|
function isInteger(value){
|
|
|
|
if ((parseFloat(value) == parseInt(value)) && !isNaN(value)) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|