/** * Copyright (C) 2010 Cloud.com, Inc. All rights reserved. * * This software is licensed under the GNU General Public License v3 or later. * * It is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ // Version: @VERSION@ var DomRTemplateId = 1; function showTemplatesTab() { // Manage Templates // *** Template (begin) *** activateDialog($("#dialog_edit_template").dialog({ width:450, autoOpen: false, modal: true, zIndex: 2000 })); activateDialog($("#dialog_add_template").dialog({ width:450, autoOpen: false, modal: true, zIndex: 2000 })); activateDialog($("#dialog_copy_template").dialog({ width:300, autoOpen: false, modal: true, zIndex: 2000 })); activateDialog($("#dialog_create_vm_from_template").dialog({ width:300, autoOpen: false, modal: true, zIndex: 2000 })); var g_zoneIds = [], g_zoneNames = []; var addTemplateZoneField = $("#dialog_add_template #add_template_zone"); var addIsoZoneField = $("#dialog_add_iso #add_iso_zone"); // Add default zone if (isAdmin()) { addTemplateZoneField.append(""); addIsoZoneField.append(""); } $.ajax({ data: createURL("command=listZones&available=true&response=json"+maxPageSize), dataType: "json", success: function(json) { var zones = json.listzonesresponse.zone; if (zones != null && zones.length > 0) { for (var i = 0; i < zones.length; i++) { addTemplateZoneField.append(""); addIsoZoneField.append(""); g_zoneIds.push(zones[i].id); g_zoneNames.push(zones[i].name); } } } }); function populateZoneField(zoneField, excludeZoneId) { zoneField.empty(); if (g_zoneIds != null && g_zoneIds.length > 0) { for (var i = 0; i < g_zoneIds.length; i++) { if(g_zoneIds[i] != excludeZoneId) zoneField.append(""); } } } $.ajax({ data: createURL("command=listOsTypes&response=json"), dataType: "json", success: function(json) { types = json.listostypesresponse.ostype; if (types != null && types.length > 0) { var templateSelect = $("#dialog_add_template #add_template_os_type, #dialog_edit_template #edit_template_os_type").empty(); var isoSelect = $("#dialog_add_iso #add_iso_os_type").empty(); for (var i = 0; i < types.length; i++) { var html = ""; templateSelect.append(html); isoSelect.append(html); } } } }); $.ajax({ data: createURL("command=listServiceOfferings&response=json"), dataType: "json", success: function(json) { var items = json.listserviceofferingsresponse.serviceoffering; if(items != null && items.length > 0 ) { var serviceOfferingField = $("#dialog_create_vm_from_template #service_offering").empty(); for(var i = 0; i < items.length; i++) serviceOfferingField.append(""); } } }); $.ajax({ data: createURL("command=listDiskOfferings&response=json"), dataType: "json", success: function(json) { var items = json.listdiskofferingsresponse.diskoffering; if(items != null && items.length > 0 ) { var diskOfferingField = $("#dialog_create_vm_from_template #disk_offering").empty(); for(var i = 0; i < items.length; i++) diskOfferingField.append(""); } } }); $("#template_action_new").show(); var formatSelect = $("#add_template_format").empty(); if (getHypervisorType() == "kvm") { formatSelect.append(""); } else if (getHypervisorType() == "xenserver") { formatSelect.append(""); } $("#template_action_new").bind("click", function(event) { $("#dialog_add_template") .dialog('option', 'buttons', { "Create": function() { var thisDialog = $(this); // validate values var isValid = true; isValid &= validateString("Name", thisDialog.find("#add_template_name"), thisDialog.find("#add_template_name_errormsg")); isValid &= validateString("Display Text", thisDialog.find("#add_template_display_text"), thisDialog.find("#add_template_display_text_errormsg")); isValid &= validateString("URL", thisDialog.find("#add_template_url"), thisDialog.find("#add_template_url_errormsg")); if (!isValid) return; var name = trim(thisDialog.find("#add_template_name").val()); var desc = trim(thisDialog.find("#add_template_display_text").val()); var url = trim(thisDialog.find("#add_template_url").val()); var zoneId = thisDialog.find("#add_template_zone").val(); var format = thisDialog.find("#add_template_format").val(); var password = thisDialog.find("#add_template_password").val(); var isPublic = thisDialog.find("#add_template_public").val(); var osType = thisDialog.find("#add_template_os_type").val(); var moreCriteria = []; if(thisDialog.find("#add_template_featured_container").css("display")!="none") { var isFeatured = thisDialog.find("#add_template_featured").val(); moreCriteria.push("&isfeatured="+isFeatured); } thisDialog.dialog("close"); var submenuContent = $("#submenu_content_template"); var template = $("#vm_template_template").clone(true); var loadingImg = template.find(".adding_loading"); var rowContainer = template.find("#row_container"); loadingImg.find(".adding_text").text("Adding...."); loadingImg.show(); rowContainer.hide(); submenuContent.find("#grid_content").prepend(template.fadeIn("slow")); $.ajax({ data: createURL("command=registerTemplate&name="+encodeURIComponent(name)+"&displayText="+encodeURIComponent(desc)+"&url="+encodeURIComponent(url)+"&zoneid="+zoneId+"&ispublic="+isPublic+moreCriteria.join("")+"&format="+format+"&passwordEnabled="+password+"&osTypeId="+osType+"&response=json"), dataType: "json", success: function(json) { var result = json.registertemplateresponse; if($("#template_type").val() == "self") { templateJSONToTemplate(result.template[0], template); changeGridRowsTotal(submenuContent.find("#grid_rows_total"), 1); loadingImg.hide(); rowContainer.show(); if(result.template.length > 1) { for(var i=1; i is used by all zones. Please confirm you want to delete it from all zones.

"; else htmlMsg = "

Please confirm you want to delete your template "+name+".

"; $("#dialog_confirmation") .html(htmlMsg) .dialog('option', 'buttons', { "Confirm": function() { $(this).dialog("close"); var loadingImg = thisTemplate.find(".adding_loading"); var rowContainer = thisTemplate.find("#row_container"); loadingImg.find(".adding_text").text("Deleting...."); loadingImg.show(); rowContainer.hide(); $.ajax({ data: createURL("command=deleteTemplate&id="+id+moreCriteria.join("")+"&response=json"), dataType: "json", success: function(json) { var jobId = json.deletetemplateresponse.jobid; var timerKey = "deleteTemplateJob"+jobId; $("body").everyTime(2000, timerKey, function() { $.ajax({ data: createURL("command=queryAsyncJobResult&jobId="+json.deletetemplateresponse.jobid+"&response=json"), dataType: "json", success: function(json) { var result = json.queryasyncjobresultresponse; if (result.jobstatus == 0) { return; //Job has not completed } else { $("body").stopTime(timerKey); if (result.jobstatus == 1) { //success that.slideUp("slow", function() { $(this).remove() }); changeGridRowsTotal($("#submenu_content_template").find("#grid_rows_total"), -1); } else if (result.jobstatus == 2) { $("#dialog_alert").html("

" + sanitizeXSS(result.jobresult) + "

").dialog("open"); loadingImg.hide(); rowContainer.show(); } } }, error: function(XMLHttpResponse) { $("body").stopTime(timerKey); handleError(XMLHttpResponse); loadingImg.hide(); rowContainer.show(); } }); }, 0); }, error: function(XMLHttpResponse) { handleError(XMLHttpResponse); loadingImg.hide(); rowContainer.show(); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); }); template.find("#template_copy").data("parentElementId", "template"+json.id+"_zone"+json.zoneid).unbind("click").bind("click", function(event) { var parentElementId = $(this).data("parentElementId"); var thisTemplate = $("#"+parentElementId); var id = thisTemplate.data("templateId"); var name = thisTemplate.data("name"); var sourceZoneId = thisTemplate.data("zoneId"); populateZoneField($("#dialog_copy_template #copy_template_zone"), sourceZoneId); $("#dialog_copy_template #copy_template_name_text").text(name); var sourceZoneName = thisTemplate.data("zoneName"); $("#dialog_copy_template #copy_template_source_zone_text").text(sourceZoneName); $("#dialog_copy_template") .dialog('option', 'buttons', { "OK": function() { var thisDialog = $(this); var isValid = true; isValid &= validateDropDownBox("Zone", thisDialog.find("#copy_template_zone"), thisDialog.find("#copy_template_zone_errormsg"), false); //reset error text if (!isValid) return; var destZoneId = thisDialog.find("#copy_template_zone").val(); thisDialog.dialog("close"); var loadingImg = thisTemplate.find(".adding_loading"); var rowContainer = thisTemplate.find("#row_container"); loadingImg.find(".adding_text").text("Copying...."); loadingImg.show(); rowContainer.hide(); $.ajax({ data: createURL("command=copyTemplate&id="+id+"&sourcezoneid="+sourceZoneId+"&destzoneid="+destZoneId+"&response=json"), dataType: "json", success: function(json) { var jobId = json.copytemplateresponse.jobid; var timerKey = "copyTemplateJob"+jobId; $("body").everyTime(2000, timerKey, function() { $.ajax({ data: createURL("command=queryAsyncJobResult&jobId="+json.copytemplateresponse.jobid+"&response=json"), dataType: "json", success: function(json) { var result = json.queryasyncjobresultresponse; if (result.jobstatus == 0) { return; //Job has not completed } else { $("body").stopTime(timerKey); if (result.jobstatus == 1) { $("#dialog_info").html("

Template download started (ID: "+result.copytemplateresponse[0].id+", Zone: "+sanitizeXSS(result.copytemplateresponse[0].zonename)+", Name: "+sanitizeXSS(result.copytemplateresponse[0].name)+") . Check the progress...

").dialog("open"); loadingImg.hide(); rowContainer.show(); $("#template_type").val("self"); $("#template_type").change(); } else if (result.jobstatus == 2) { $("#dialog_alert").html("

" + sanitizeXSS(result.jobresult) + "

").dialog("open"); loadingImg.hide(); rowContainer.show(); } } }, error: function(XMLHttpResponse) { $("body").stopTime(timerKey); handleError(XMLHttpResponse); loadingImg.hide(); rowContainer.show(); } }); }, 0); }, error: function(XMLHttpResponse) { handleError(XMLHttpResponse); loadingImg.hide(); rowContainer.show(); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); }); template.find("#template_create_vm").data("parentElementId", "template"+json.id+"_zone"+json.zoneid).unbind("click").bind("click", function(event) { createVMFromTemplateOrISO($(this), "template"); }); } function createVMFromTemplateOrISO(actionLink, sourceType) { var parentElementId = actionLink.data("parentElementId"); var thisTemplate = $("#"+parentElementId); var id = (sourceType == "template")? thisTemplate.data("templateId"): thisTemplate.data("isoId"); var name = thisTemplate.data("name"); var zoneId = thisTemplate.data("zoneId"); var createVmDialog = $("#dialog_create_vm_from_template"); createVmDialog.find("#template").text(name); createVmDialog .dialog('option', 'buttons', { "Create": function() { var thisDialog = $(this); // validate values var isValid = true; isValid &= validateString("Name", thisDialog.find("#name"), thisDialog.find("#name_errormsg"), true); isValid &= validateString("Group", thisDialog.find("#group"), thisDialog.find("#group_errormsg"), true); if (!isValid) return; var name = trim(thisDialog.find("#name").val()); var group = trim(thisDialog.find("#group").val()); var serviceOfferingId = thisDialog.find("#service_offering").val(); var diskOfferingId = thisDialog.find("#disk_offering").val(); thisDialog.dialog("close"); var loadingImg = thisTemplate.find(".adding_loading"); var rowContainer = thisTemplate.find("#row_container"); loadingImg.find(".adding_text").text("Creating VM...."); loadingImg.show(); rowContainer.hide(); $.ajax({ data: createURL("command=deployVirtualMachine&zoneId="+zoneId+"&serviceOfferingId="+serviceOfferingId+"&diskOfferingId="+diskOfferingId+"&templateId="+id+"&group="+encodeURIComponent(group)+"&displayname="+encodeURIComponent(name)+"&response=json"), dataType: "json", success: function(json) { var jobId = json.deployvirtualmachineresponse.jobid; var timerKey = "newVMFromTemplate"+jobId; $("body").everyTime( 10000, timerKey, function() { $.ajax({ data: createURL("command=queryAsyncJobResult&jobId="+jobId+"&response=json"), dataType: "json", success: function(json) { var result = json.queryasyncjobresultresponse; if (result.jobstatus == 0) { return; //Job has not completed } else { $("body").stopTime(timerKey); if (result.jobstatus == 1) { // Succeeded var htmlMsg; if (result.virtualmachine[0].passwordenabled == 'true') htmlMsg = "Your instance from " + sanitizeXSS(name) + " has been successfully created. Your new password is : " + result.virtualmachine[0].password + " . Please change it as soon as you log into your new instance"; else htmlMsg = "Your instance from " + sanitizeXSS(name) + " has been successfully created."; $("#dialog_info").html(htmlMsg).dialog("open"); loadingImg.hide(); rowContainer.show(); } else if (result.jobstatus == 2) { // Failed $("#dialog_info").html("Unable to create your new instance from " + sanitizeXSS(name) + " due to the error: " + sanitizeXSS(result.jobresult)).dialog("open"); loadingImg.hide(); rowContainer.show(); } } }, error: function(XMLHttpResponse) { $("body").stopTime(timerKey); handleError(XMLHttpResponse); loadingImg.hide(); rowContainer.show(); } }); }, 0 ); }, error: function(XMLHttpResponse) { handleError(XMLHttpResponse); loadingImg.hide(); rowContainer.show(); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); } function listTemplates() { var submenuContent = $("#submenu_content_template"); var type = $("#template_type").val(); //my template, featured, community var commandString; var advanced = submenuContent.find("#search_button").data("advanced"); if (advanced != null && advanced) { var name = submenuContent.find("#advanced_search #adv_search_name").val(); var moreCriteria = []; if (name!=null && trim(name).length > 0) moreCriteria.push("&name="+encodeURIComponent(trim(name))); commandString = "command=listTemplates&page="+currentPage+moreCriteria.join("")+"&templatefilter="+type+"&response=json"; } else { var searchInput = $("#submenu_content_template #search_input").val(); //search button if (searchInput != null && searchInput.length > 0) commandString = "command=listTemplates&page="+currentPage+"&templatefilter="+type+"&keyword="+searchInput+"&response=json"; else commandString = "command=listTemplates&page="+currentPage+"&templatefilter="+type+"&response=json"; } //listItems(submenuContent, commandString, jsonResponse1, jsonResponse2, template, fnJSONToTemplate); listItems(submenuContent, commandString, "listtemplatesresponse", "template", $("#vm_template_template"), templateJSONToTemplate); } submenuContentEventBinder($("#submenu_content_template"), listTemplates); $("#template_type").bind("change", function(event){ currentPage=1; event.preventDefault(); listTemplates(); }); $("#submenu_template").bind("click",function(event){ event.preventDefault(); $(this).toggleClass("submenu_links_on").toggleClass("submenu_links_off"); currentSubMenu.toggleClass("submenu_links_off").toggleClass("submenu_links_on"); currentSubMenu = $(this); var submenuContent = $("#submenu_content_template").show(); $("#submenu_content_iso").hide(); currentPage=1; listTemplates(); }); // *** Template (end) *** // *** ISO (begin) *** activateDialog($("#dialog_edit_iso").dialog({ width:450, autoOpen: false, modal: true, zIndex: 2000 })); activateDialog($("#dialog_add_iso").dialog({ width:450, autoOpen: false, modal: true, zIndex: 2000 })); activateDialog($("#dialog_copy_iso").dialog({ width:300, autoOpen: false, modal: true, zIndex: 2000 })); $("#iso_action_new").show(); $("#iso_action_new").bind("click", function(event) { $("#dialog_add_iso") .dialog('option', 'buttons', { "Create": function() { var thisDialog = $(this); // validate values var isValid = true; isValid &= validateString("Name", thisDialog.find("#add_iso_name"), thisDialog.find("#add_iso_name_errormsg")); isValid &= validateString("Display Text", thisDialog.find("#add_iso_display_text"), thisDialog.find("#add_iso_display_text_errormsg")); isValid &= validateString("URL", thisDialog.find("#add_iso_url"), thisDialog.find("#add_iso_url_errormsg")); if (!isValid) return; var submenuContent = $("#submenu_content_iso"); var template = $("#vm_iso_template").clone(true); var loadingImg = template.find(".adding_loading"); var rowContainer = template.find("#row_container"); loadingImg.find(".adding_text").text("Adding...."); loadingImg.show(); rowContainer.hide(); submenuContent.find("#grid_content").prepend(template.fadeIn("slow")); var name = trim(thisDialog.find("#add_iso_name").val()); var desc = trim(thisDialog.find("#add_iso_display_text").val()); var url = trim(thisDialog.find("#add_iso_url").val()); var zoneId = thisDialog.find("#add_iso_zone").val(); //var isPublic = thisDialog.find("#add_iso_public").val(); var isPublic = "false"; //default to private for now var osType = thisDialog.find("#add_iso_os_type").val(); var bootable = thisDialog.find("#add_iso_bootable").val(); thisDialog.dialog("close"); $.ajax({ data: createURL("command=registerIso&name="+encodeURIComponent(name)+"&displayText="+encodeURIComponent(desc)+"&url="+encodeURIComponent(url)+"&zoneId="+zoneId+"&isPublic="+isPublic+"&osTypeId="+osType+"&bootable="+bootable+"&response=json"), dataType: "json", success: function(json) { var result = json.registerisoresponse; if($("#iso_type").val() == "self") { isoJSONToTemplate(result.iso[0], template); changeGridRowsTotal(submenuContent.find("#grid_rows_total"), 1); loadingImg.hide(); rowContainer.show(); if(result.iso.length > 1) { for(var i=1; i is used by all zones. Please confirm you want to delete it from all zones.

"; else htmlMsg = "

Please confirm you want to delete your ISO "+name+".

"; $("#dialog_confirmation") .html(htmlMsg) .dialog('option', 'buttons', { "Confirm": function() { $(this).dialog("close"); var loadingImg = thisTemplate.find(".adding_loading"); var rowContainer = thisTemplate.find("#row_container"); loadingImg.find(".adding_text").text("Deleting...."); loadingImg.show(); rowContainer.hide(); $.ajax({ data: createURL("command=deleteIso&id="+id+moreCriteria.join("")+"&response=json"), dataType: "json", success: function(json) { var jobId = json.deleteisosresponse.jobid; var timerKey = "deleteIsoJob"+jobId; $("body").everyTime(2000, timerKey, function() { $.ajax({ data: createURL("command=queryAsyncJobResult&jobId="+json.deleteisosresponse.jobid+"&response=json"), dataType: "json", success: function(json) { var result = json.queryasyncjobresultresponse; if (result.jobstatus == 0) { return; //Job has not completed } else { $("body").stopTime(timerKey); if (result.jobstatus == 1) { //success that.slideUp("slow", function() { $(this).remove() }); changeGridRowsTotal($("#submenu_content_iso").find("#grid_rows_total"), -1); } else if (result.jobstatus == 2) { $("#dialog_alert").html("

" + sanitizeXSS(result.jobresult) + "

").dialog("open"); loadingImg.hide(); rowContainer.show(); } } }, error: function(XMLHttpResponse) { $("body").stopTime(timerKey); handleError(XMLHttpResponse); loadingImg.hide(); rowContainer.show(); } }); }, 0); }, error: function(XMLHttpResponse) { handleError(XMLHttpResponse); loadingImg.hide(); rowContainer.show(); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); }); template.find("#iso_copy").data("parentElementId", "iso"+json.id+"_zone"+json.zoneid).bind("click", function(event) { var moreCriteria = []; var parentElementId = $(this).data("parentElementId"); var thisTemplate = $("#"+parentElementId); var id = thisTemplate.data("isoId"); var name = thisTemplate.data("name"); var sourceZoneId = thisTemplate.data("zoneId"); if (sourceZoneId != null) moreCriteria.push("&sourcezoneid="+sourceZoneId); populateZoneField($("#dialog_copy_iso #copy_iso_zone"), sourceZoneId); $("#dialog_copy_iso #copy_iso_name_text").text(name); //ISO name var sourceZoneName = thisTemplate.data("zoneName"); $("#dialog_copy_iso #copy_iso_source_zone_text").text(sourceZoneName); // source zone $("#dialog_copy_iso") .dialog('option', 'buttons', { "OK": function() { var thisDialog = $(this); var isValid = true; isValid &= validateDropDownBox("Zone", thisDialog.find("#copy_iso_zone"), thisDialog.find("#copy_iso_zone_errormsg"), false); //reset error text if (!isValid) return; var destZoneId = thisDialog.find("#copy_iso_zone").val(); thisDialog.dialog("close"); var loadingImg = thisTemplate.find(".adding_loading"); var rowContainer = thisTemplate.find("#row_container"); loadingImg.find(".adding_text").text("Copying...."); loadingImg.show(); rowContainer.hide(); $.ajax({ data: createURL("command=copyIso&id="+id+"&sourcezoneid="+sourceZoneId+"&destzoneid="+destZoneId+"&response=json"), dataType: "json", success: function(json) { var jobId = json.copyisoresponse.jobid; var timerKey = "copyIsoJob"+jobId; $("body").everyTime(2000, timerKey, function() { $.ajax({ data: createURL("command=queryAsyncJobResult&jobId="+json.copyisoresponse.jobid+"&response=json"), dataType: "json", success: function(json) { var result = json.queryasyncjobresultresponse; if (result.jobstatus == 0) { return; //Job has not completed } else { $("body").stopTime(timerKey); if (result.jobstatus == 1) { $("#dialog_info").html("

ISO download started (ID: "+result.copytemplateresponse[0].id+", Zone: "+sanitizeXSS(result.copytemplateresponse[0].zonename)+", Name: "+sanitizeXSS(result.copytemplateresponse[0].name)+") . Check the progress...

").dialog("open"); loadingImg.hide(); rowContainer.show(); currentPage=1; //refresh the whole ISO grid until Keshav changes copyIso to return the newly created ISO. listIsos(); } else if (result.jobstatus == 2) { $("#dialog_alert").html("

" + sanitizeXSS(result.jobresult) + "

").dialog("open"); loadingImg.hide(); rowContainer.show(); } } }, error: function(XMLHttpResponse) { $("body").stopTime(timerKey); handleError(XMLHttpResponse); loadingImg.hide(); rowContainer.show(); } }); }, 0); }, error: function(XMLHttpResponse) { handleError(XMLHttpResponse); loadingImg.hide(); rowContainer.show(); } }); }, "Cancel": function() { $(this).dialog("close"); } }).dialog("open"); }); template.find("#iso_create_vm").data("parentElementId", "iso"+json.id+"_zone"+json.zoneid).bind("click", function(event) { createVMFromTemplateOrISO($(this), "iso"); }); } //*** isoJSONToTemplate (end) ******************************* function listIsos() { var submenuContent = $("#submenu_content_iso"); var type = $("#iso_type").val(); //my template, community var commandString; var advanced = submenuContent.find("#search_button").data("advanced"); if (advanced != null && advanced) { var name = submenuContent.find("#advanced_search #adv_search_name").val(); var moreCriteria = []; if (name!=null && trim(name).length > 0) moreCriteria.push("&name="+encodeURIComponent(trim(name))); commandString = "command=listIsos&page="+currentPage+moreCriteria.join("")+"&isofilter="+type+"&response=json"; } else { var searchInput = $("#submenu_content_iso #search_input").val(); //keyword if (searchInput != null && searchInput.length > 0) commandString = "command=listIsos&page="+currentPage+"&keyword="+searchInput+"&isofilter="+type+"&response=json" else commandString = "command=listIsos&page="+currentPage+"&isofilter="+type+"&response=json"; } //listItems(submenuContent, commandString, jsonResponse1, jsonResponse2, template, fnJSONToTemplate); listItems(submenuContent, commandString, "listisosresponse", "iso", $("#vm_iso_template"), isoJSONToTemplate); } submenuContentEventBinder($("#submenu_content_iso"), listIsos); $("#iso_type").bind("change", function(event){ currentPage=1; event.preventDefault(); listIsos(); }); $("#submenu_iso").bind("click", function(event) { event.preventDefault(); $(this).toggleClass("submenu_links_on").toggleClass("submenu_links_off"); currentSubMenu.toggleClass("submenu_links_off").toggleClass("submenu_links_on"); currentSubMenu = $(this); var submenuContent = $("#submenu_content_iso").show(); $("#submenu_content_template").hide(); currentPage=1; listIsos(); }); // *** ISO (end) *** var currentSubMenu = $("#submenu_template"); currentSubMenu.click(); if(isAdmin()) $("#dialog_add_template #add_template_featured_container, #dialog_edit_template #edit_template_featured_container").show(); else $("#dialog_add_template #add_template_featured_container, #dialog_edit_template #edit_template_featured_container").hide(); }