/** * 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() { // Load javascripts includeJs("js/jquery/jquery.dataTables.min.js"); includeJs("js/jquery/jquery.form.js"); includeJs("js/jquery/jquery.jeditable.js"); includeJs("js/jquery/jquery.autocomplete.js"); includeJs("js/jquery/jquery.contextmenu.js"); includeJs("js/jquery/jquery.cookie.js"); includeJs("js/jquery/jquery-impromptu.3.0.min.js"); includeJs("js/jquery/superfish.js"); includeJs("js/jquery/hoverIntent.js"); includeJs("js/jquery/jquery.tree.js"); includeJs("js/jquery/jquery.flot.js"); 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/blade.js"); includeJs("js/custom/fsp.js"); includeJs("js/custom/hmc.js"); includeJs("js/custom/ipmi.js"); includeJs("js/custom/ivm.js"); includeJs("js/custom/zvm.js"); includeJs("js/custom/customUtils.js"); // 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 == 'index.php') { includeJs("js/nodes/nodeset.js"); includeJs("js/nodes/rnetboot.js"); includeJs("js/nodes/updatenode.js"); headers.eq(0).css('background-color', '#A9D0F5'); loadNodesPage(); } else if (page == 'configure.php') { includeJs("js/configure/update.js"); headers.eq(1).css('background-color', '#A9D0F5'); loadConfigPage(); } else if (page == 'provision.php') { headers.eq(2).css('background-color', '#A9D0F5'); loadProvisionPage(); } else if (page == 'monitor.php') { includeJs("js/monitor/xcatmon.js"); includeJs("js/monitor/rmcmon.js"); headers.eq(3).css('background-color', '#A9D0F5'); loadMonitorPage(); } else { headers.eq(0).css('background-color', '#A9D0F5'); loadNodesPage(); } } /** * Include javascript file in * * @param file * File to include * @return Nothing */ function includeJs(file) { var script = $("head script[src='" + file + "']"); // If does not contain the javascript if (!script.length) { // Append the javascript to var script = $(''); script.attr( { type : 'text/javascript', src : file }); $('head').append(script); } } /** * Write ajax response to a paragraph * * @param rsp * Ajax response * @param pattern * Pattern to replace with a break * @return Paragraph containing ajax response */ function writeRsp(rsp, pattern) { // Create paragraph to hold ajax response var prg = $(''); 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'), '