/** * Tab constructor * * @param tabId * Tab ID * @param tabName * Tab name * @return Nothing */ var Tab = function(tabId) { this.tabId = tabId; this.tabName = null; this.tab = null; }; /** * Initialize the tab * * @param tabName * Tab name to initialize * @return Nothing */ Tab.prototype.init = function() { // Create a division containing the tab this.tab = $('
'); var tabList = $('' + msg + '
'); infoBar.append(msg); return infoBar; } /** * Create a loader * * @param loaderId * Loader ID * @return Nothing */ function createLoader(loaderId) { var loader = $('
');
return loader;
}
/**
* Create a button
*
* @param name
* Name of the button
* @return Nothing
*/
function createButton(name) {
var button = $('');
return button;
}
/**
* Create a menu
*
* @param items
* An array of items to go into the menu
* @return A division containing the menu
*/
function createMenu(items) {
var menu = $('');
// Loop through each item
for ( var i in items) {
// Append item to menu
var item = $('');
// 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]);
}
// Do not add border for 1st item
if (i > 0) {
item.css( {
'border-left' : '1px solid #BDBDBD'
});
}
menu.append(item);
}
return menu;
}
/**
* Initialize the page
*
* @return Nothing
*/
function initPage() {
// Get the page being loaded
var url = window.location.pathname;
var page = url.replace('/xcat/', '');
var headers = $('#header ul li a');
// Show the page
$('div.content').hide();
if (page == 'index.php') {
$("#nodes_page").show();
headers.eq(0).css('background-color', '#A9D0F5');
loadNodesPage();
} else if (page == 'configure.php') {
$('#configure_page').show();
headers.eq(1).css('background-color', '#A9D0F5');
loadConfigPage();
} else if (page == 'provision.php') {
$('#provision_page').show();
headers.eq(2).css('background-color', '#A9D0F5');
loadProvisionPage();
} else if (page == 'monitor.php') {
$('#monitor_page').show();
headers.eq(3).css('background-color', '#A9D0F5');
loadMonitorPage();
} else {
$("#nodes_page").show();
headers.eq(0).css('background-color', '#A9D0F5');
loadNodesPage();
}
// Bind each link to open the page on click
for ( var i = 0; i < headers.length; i++) {
var title = headers.eq(i).text();
var link = headers.eq(i);
link.attr('href', '#');
if (title == 'Nodes') {
link.bind('click', function(event) {
$('div.content').hide();
$('#nodes_page').show();
headers.css('background-color', '');
$(this).css('background-color', '#A9D0F5');
loadNodesPage();
});
} else if (title == 'Configure') {
link.bind('click', function(event) {
$('div.content').hide();
$('#configure_page').show();
headers.css('background-color', '');
$(this).css('background-color', '#A9D0F5');
loadConfigPage();
});
} else if (title == 'Provision') {
link.bind('click', function(event) {
$('div.content').hide();
$('#provision_page').show();
headers.css('background-color', '');
$(this).css('background-color', '#A9D0F5');
loadProvisionPage();
});
} else if (title == 'Monitor') {
link.bind('click', function(event) {
$('div.content').hide();
$('#monitor_page').show();
headers.css('background-color', '');
$(this).css('background-color', '#A9D0F5');
loadMonitorPage();
});
}
}
}