Permalink
Browse files

Switch if/else to switch structure

- reducing lines
  • Loading branch information...
1 parent 720754d commit d82ead46215a687f8320b0103ecbc529d558ee7b julmis committed Jul 26, 2004
Showing with 12 additions and 27 deletions.
  1. +12 −27 lib/editor/dialog.js
View
@@ -39,33 +39,18 @@ Dialog._arguments = null;
Dialog._geckoOpenModal = function(url, action, init) {
- if(url.lastIndexOf("insert_image.php") != -1) {
- var x = 730;
- var y = 540;
- } else if (url.lastIndexOf("link_std.php") != -1) {
- var x = 400;
- var y = 180;
- } else if (url.lastIndexOf("dlg_ins_smile.php") != -1) {
- var x = 330;
- var y = 360;
- } else if (url.lastIndexOf("dlg_ins_char.php") != -1) {
- var x = 450;
- var y = 270;
- } else if (url.lastIndexOf("select_color.php") != -1) {
- var x = 238;
- var y = 188;
- } else if (url.lastIndexOf("insert_table.php") != -1) {
- var x = 410;
- var y = 240;
- } else if (url.lastIndexOf("link_std.php") != -1) {
- var x = 420;
- var y = 210;
- } else if (url.lastIndexOf("insert_image_std.php") != -1) {
- var x = 450;
- var y = 230;
- } else {
- var x = 10;
- var y = 10;
+ var file = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));
+ var x,y;
+ switch(file) {
+ case "insert_image": x = 730; y = 540; break;
+ case "link_std": x = 400; y = 180; break;
+ case "dlg_ins_smile": x = 330; y = 360; break;
+ case "dlg_ins_char": x = 450; y = 270; break;
+ case "select_color": x = 238; y = 188; break;
+ case "insert_table": x = 410; y = 240; break;
+ case "link_std": x = 420; y = 210; break;
+ case "insert_image_std": x = 450; y = 230; break;
+ default: x = 50; y = 50;
}
var lx = (screen.width - x) / 2;

0 comments on commit d82ead4

Please sign in to comment.