Reduce lines of code
- by coffeeaddict
I'm not a JavaScript guru (yet). I am trying to figure out a way to cut down the number of lines below...are there any shortcuts for lets say the if statements?
function showDialog(divID)
{
var dialogDiv = $("#" + divID);
var height = 500;
var width = 400;
var resizable = false;
if (dialogDiv.attr("height") != "")
{
height = parseInt(dialogDiv.attr("height"));
}
if (dialogDiv.attr("width") != "")
{
width = parseInt(dialogDiv.attr("width"));
}
if (dialogDiv.attr("resizable") != "")
{
resizable = dialogDiv.attr("resizable");
}
dialogDiv.dialog
(
{
resizable: resizable,
width: width,
height: height,
bgiframe: true,
modal: true,
autoOpen: false,
show: 'blind'
}
)
dialogDiv.dialog("open");
}