Changeset 3432

Show
Ignore:
Timestamp:
08/14/08 17:01:25 (5 years ago)
Author:
rcarvalho
Message:

Javascript is almost working under internet explorer

Location:
branch/UmitWeb
Files:
44 added
22 modified

Legend:

Unmodified
Added
Removed
  • branch/UmitWeb/share/umit/templates/compare_results.html

    r1466 r3432  
    4040                <a class="expander" href="javascript:void(null)"><h4 id="scan1-switch" class="sw-collapsed">Scan 1</h4></a> 
    4141                <div class="frame-div hide code diff-text" id="scan1-detail"></div> 
    42                 <span id="scan1-xml" class="hide"/> 
     42                <span id="scan1-xml" class="hide"></span> 
    4343            </div> 
    4444            <div id="result-right"> 
     
    5757                <a class="expander" href="javascript:void(null)"><h4 id="scan2-switch" class="sw-collapsed">Scan 2</h4></a> 
    5858                <div class="frame-div hide code diff-text" id="scan2-detail"></div> 
    59                 <span id="scan2-xml" class="hide"/> 
     59                <span id="scan2-xml" class="hide"></span> 
    6060            </div> 
    6161            <div id="result-main"> 
     
    8686                </div> 
    8787            </div> 
    88             <div id="footer">Copyright (C) 2005 Insecure.Com LLC. Sponsored by<a target="_blank" href="http://code.google.com/soc/"><img title="Sponsored by Google" alt="Sponsored by Google" src="/media/images/google-small-logo.png"/></a></div> 
     88            <div id="footer">Copyright (C) 2007 Adriano Monteiro Marques.</div> 
    8989        </div> 
    9090    </body> 
  • branch/UmitWeb/share/umit/templates/html/index.html

    r1212 r3432  
    55    <body> 
    66        <script type="text/javascript"> 
    7         if(window.gecko){ 
     7        if(window.gecko || window.khtml || window.opera || window.ie){ 
    88            document.write("redirecting the page...") 
    99            document.close() 
  • branch/UmitWeb/share/umit/templates/index.html

    r2871 r3432  
    1010        <link rel="stylesheet" href="/media/css/tabber.css"/> 
    1111        <link rel="icon" href="/favicon.ico" type="image/vnd.microsoft.icon"/> 
    12         <script type="text/javascript" src="/media/js/mootools.v1.11.js"></script> 
     12        <!-- <script type='text/javascript'  
     13                src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script> --> 
     14        <script type="text/javascript" src="/media/js/mootools.v1.11-old.js"></script> 
    1315        <script type="text/javascript" src="/media/js/common.js"></script> 
    1416        <script type="text/javascript" src="/media/js/dialog.js"></script> 
     
    145147            </div> 
    146148        </div> 
    147             <div id="footer">Copyright (C) 2007 Adriano Monteiro Marques.</a></div> 
     149            <div id="footer">Copyright (C) 2007 Adriano Monteiro Marques.</div> 
    148150        </div> 
    149151    </body> 
  • branch/UmitWeb/share/umit/umitweb_media/css/layout.css

    r1466 r3432  
    120120    height:350px; 
    121121} 
     122 
     123.dialog{ 
     124    z-index: 500; 
     125} 
  • branch/UmitWeb/share/umit/umitweb_media/js/command-wizard.js

    r1256 r3432  
    1111        this.options.content.empty(); 
    1212 
    13         self = this; 
    14         title = new Element("h3"); 
    15         commandConstructorDiv = new Element("div"); 
    16         lbl = new Element("label"); 
     13        var self = this; 
     14        var title = new Element("h3"); 
     15        var commandConstructorDiv = new Element("div"); 
     16        var lbl = new Element("label"); 
    1717        lbl.setHTML("<strong>Command: </strong>"); 
    18         divCommandConstructor = new Element("input", {"id": "divCommandConstructor", 
     18        var divCommandConstructor = new Element("input", {"id": "divCommandConstructor", 
    1919                                            "style": "border:1px #DDD solid;margin: 5px;padding:4px; width: 95%;", "type": "text"}); 
    2020        divCommandConstructor.value = "nmap <target>"; 
     
    2323         
    2424        title.setText("UMIT Command Constructor Wizard"); 
    25         tabber = new Element("div", {"class": "tabber", "id": "tabberCommand"}); 
    26          
    27          
    28         tabBegin = new Element("div", {class: "tabbertab", style: "height: 285px"}); 
     25        var tabber = new Element("div", {"class": "tabber", "id": "tabberCommand"}); 
     26         
     27         
     28        var tabBegin = new Element("div", {"class": "tabbertab", "style": "height: 285px"}); 
    2929        tabBegin.setHTML("UMIT Allow user to construct powerful commands in two distinct ways:<p/>" + 
    3030                         "<input type='radio' id='novice' name='novice_expert' checked='checked'/><label for='novice'>Novice</label><p/>"+ 
     
    3232        tabber.adopt(tabBegin); 
    3333         
    34         tabSelectType = new Element("div", {class: "tabbertab", style: "height: 285px"}); 
    35         htext = "You wish to create a new profile, or just want to quickly create a command and run it once?<p/>"; 
     34        var tabSelectType = new Element("div", {"class": "tabbertab", "style": "height: 285px"}); 
     35        var htext = "You wish to create a new profile, or just want to quickly create a command and run it once?<p/>"; 
    3636        htext += "<input type='radio' name='type' id='type_profile' checked='checked'/><label for='type_profile'>Profile</label><p/>"; 
    3737        htext += "<input type='radio' name='type' id='type_command'/><label for='type_command'>Command</label><br/>"; 
     
    4141        tabber.adopt(tabSelectType); 
    4242         
    43         tabProfileDetails = new Element("div", {class: "tabbertab", style: "height: 285px;"}); 
     43        var tabProfileDetails = new Element("div", {"class": "tabbertab", "style": "height: 285px;"}); 
    4444        tabProfileDetails.setText("Please, enter the profile name, " + 
    4545                                  "and optionally, enter a hint, description and annotation for this " + 
    4646                                   "new profile:"); 
    47         spnProfile = new Element("table"); 
    48         spnProfile.setHTML("<tr><td valign='top'><label for='pprofile_name'><strong>Profile Name:</strong>&nbsp;&nbsp;</label></td>" + 
    49                            "<td><input type='text' id='pprofile_name' size='40'/></td></tr>" + 
     47        var spnProfile = new Element("table"); 
     48        tabProfileDetails.adopt(spnProfile); 
     49        addTableRow(spnProfile, [{'valign': 'top',  
     50                                  'value': "<label for='pprofile_name'><strong>Profile Name:</strong>&nbsp;&nbsp;</label>"}, 
     51                                  "<input type='text' id='pprofile_name' size='40'/>"]); 
     52                                   
     53        addTableRow(spnProfile, [{'valign': 'top', 
     54                                  'value': "<label for='pprofile_name'><strong>Profile Name:</strong>&nbsp;&nbsp;</label>"}, 
     55                                  "<input type='text' id='profile_hint' size='40'/>"]); 
     56        addTableRow(spnProfile, [{'valign': 'top', 
     57                                  'value': "<label for='profile_description'>Description:&nbsp;&nbsp;</label>"}, 
     58                                  "<textarea id='profile_description' rows='4' cols='37'></textarea>"]); 
     59                                   
     60        addTableRow(spnProfile, [{'valign': 'top', 
     61                                  'value': "<label for='profile_annotation'>Annotation:&nbsp;&nbsp;</label>"}, 
     62                                  "<textarea id='profile_annotation' rows='4' cols='37'></textarea>"]); 
     63         
     64                                 
     65        /*spnProfile.setHTML("<tbody><tr><td valign='top'><label for='pprofile_name'><strong>Profile Name:</strong>&nbsp;&nbsp;</label></td>" + 
     66                           "<td><input type='text' id='pprofile_name' size='40'/></td></tr>" +                            
    5067                           "<tr><td valign='top'><label for='profile_int'>Hint:&nbsp;&nbsp;</label></td>" + 
    51                            "<td><input type='text' id='profile_hint' size='40'/></td></tr>" + 
     68                           "<td><input type='text' id='profile_hint' size='40'/></td></tr>" +                           
    5269                           "<tr><td valign='top'><label for='profile_description'>Description:&nbsp;&nbsp;</label></td>"+ 
    5370                           "<td><textarea id='profile_description' rows='4' cols='37'></textarea></td></tr>" + 
     71                            
    5472                           "<tr><td valign='top'><label for='profile_annotation'>Annotation:&nbsp;&nbsp;</label></td>" + 
    55                            "<td><textarea id='profile_annotation' rows='4' cols='37'></textarea></td></tr>"); 
    56         tabProfileDetails.adopt(spnProfile); 
     73                           "<td><textarea id='profile_annotation' rows='4' cols='37'></textarea></td></tr></tbody>");*/ 
     74         
    5775        tabber.adopt(tabProfileDetails); 
    5876         
    5977        new Json.Remote("/wizard/", {onComplete: function(sections){ 
    6078            varData = sections; 
    61             for(k in sections){ 
    62                 s = sections[k] 
    63                 tab = new Element("div", {class: "tabbertab", style: "height: 285px;"}); 
     79            for(var k in sections){ 
     80                var s = sections[k]; 
     81                var tab = new Element("div", {"class": "tabbertab", "style": "height: 285px;"}); 
    6482                tab.setHTML("<b>" + s.label + "</b>"); 
    65                 table = new Element("table", {width: "100%"}); 
    66                 tableContent = "<tr>"; 
     83                var table = new Element("table", {"width": "100%"}); 
     84                 
    6785                s.options.each(function(op){ 
     86                    var row = []; 
    6887                    if(op.type == "list"){ 
    69                         tableContent += "<tr><td width='0'></td>" 
    70                         tableContent += "<td><label for='" + op.label + "'>" + op.label + "</label></td>" 
    71                         tableContent += "<td><select id='" + op.label + "'>" 
    72                         for(y=0; y < op.options.length; y++){ 
    73                             lbl = op.options[y]; 
    74                             tableContent += "<option value='" + lbl.command + "'>" + ((lbl.name == "None")? "": lbl.name) + "</option>" 
    75                         } 
    76                         tableContent += "</select></td></tr>" 
     88                        row.push({"width": "0", "value": ""}); 
     89                        row.push("<label for='" + op.label + "'>" + op.label + "</label>"); 
     90                         
     91                        var selectTag = new Element("select", {"id": op.label}); 
     92                        for(var y=0; y < op.options.length; y++){ 
     93                            var lbl = op.options[y]; 
     94                            var opt = new Element("option", {"value": lbl.command}); 
     95                            opt.text = (lbl.name == "None")? "": lbl.name; 
     96                            try{ 
     97                                selectTag.add(opt, null); 
     98                            }catch(e){ 
     99                                // IE only 
     100                                selectTag.add(opt); 
     101                            } 
     102                        } 
     103                        row.push({"value": selectTag}); 
     104                        addTableRow(table, row); 
     105 
    77106                    }else if(op.type == "check"){ 
    78                         tableContent += "<tr><td width='0'><input type='checkbox' id='" + op.label + "' value='" + op.command + "'/></td>" 
    79                         tableContent += "<td><label for='" + op.label + "'>" + op.label + "</label></td>" 
     107                        row.push({"width": "0", "value": "input type='checkbox' id='" + op.label + "' value='" + op.command + "'/>"}); 
     108                        row.push("<label for='" + op.label + "'>" + op.label + "</label>"); 
    80109                        if(op.arg_type){ 
    81                             tableContent += "<td><input type='text' size='15' id='txt-" + op.label + "' class='wiz-input'/></td>" 
    82                         } 
    83                         tableContent += "</tr>" 
     110                            row.push("<input type='text' size='15' id='txt-" + op.label + "' class='wiz-input'/>"); 
     111                        } 
     112                        addTableRow(table, row); 
    84113                    } 
    85114                }); 
    86                 tableContent += "</tr>"; 
    87                 table.setHTML(tableContent); 
     115 
    88116                tab.adopt(table); 
    89117                tabber.adopt(tab); 
     
    92120                tabber.getElements("select").each(function(el){ 
    93121                    el.addEvent("change", function(e){ 
    94                         for(i = 0; i < this.length; i++){ 
    95                             v = this[i].value; 
     122                        for(var i = 0; i < this.length; i++){ 
     123                            var v = this[i].value; 
    96124                            if(i != this.selectedIndex){ 
    97125                                removeCommand(v); 
    98126                            } 
    99127                        } 
    100                         v = this[this.selectedIndex].value; 
     128                        var v = this[this.selectedIndex].value; 
    101129                        updateCommand(v); 
    102130                    }); 
     
    106134                tabber.getElements("input[type=checkbox]").each(function(el){ 
    107135                    el.addEvent("change", function(e){ 
    108                         v = this.value; 
    109                         cmpl = ($defined($("txt-" + v.id)))? $("txt-" + v.id).value: ""; 
     136                        var v = this.value; 
     137                        var cmpl = ($defined($("txt-" + v.id)))? $("txt-" + v.id).value: ""; 
    110138                        if(this.checked){ 
    111139                            updateCommand(v, cmpl); 
     
    119147                    el.addEvent("focus", function(e){ 
    120148                        $(this.id.substring("txt-".length)).checked = true; 
    121                         v = $(this.id.substring("txt-".length)).value 
    122                         cmpl = this.value; 
     149                        var v = $(this.id.substring("txt-".length)).value; 
     150                        var cmpl = this.value; 
    123151                        updateCommand(v, cmpl); 
    124152                    }); 
    125153                     
    126154                    el.addEvent("keyup", function(e){ 
    127                         v = $(this.id.substring("txt-".length)).value 
    128                         cmpl = this.value; 
     155                        var v = $(this.id.substring("txt-".length)).value; 
     156                        var cmpl = this.value; 
    129157                        updateCommand(v, cmpl); 
    130158                    }); 
     
    132160            } 
    133161             
    134             tabFinish = new Element("div", {class: "tabbertab", style: "height: 285px;"}); 
     162            var tabFinish = new Element("div", {"class": "tabbertab", "style": "height: 285px;"}); 
    135163            tabFinish.setHTML("UMIT generated the nmap command. Click Apply to finish this wizard."); 
    136164            tabber.adopt(tabFinish); 
     
    146174        }}).send(); 
    147175        this.options.content.addClass("hide"); 
    148         to = tabberOptions; 
     176        var to = tabberOptions; 
    149177        this.options.content.adopt(title); 
    150178        this.options.content.adopt(commandConstructorDiv); 
     
    152180        this.options.content.setStyle("padding", "10px;"); 
    153181         
    154         actionDiv = new Element("div", {style: "text-align: right"}); 
    155         btnNext = new Element("input", {type: "button", value:"Next"}); 
    156         btnPrevious = new Element("input", {type: "button", value:"Previous", style: "margin-right: 6px"}); 
    157         btnCancel = new Element("input", {type: "button", value:"Cancel", style: "margin-right: 20px"}); 
     182        var actionDiv = new Element("div", {"style": "text-align: right"}); 
     183        var btnNext = new Element("input", {"type": "button", "value":"Next"}); 
     184        var btnPrevious = new Element("input", {"type": "button", "value":"Previous", "style": "margin-right: 6px"}); 
     185        var btnCancel = new Element("input", {"type": "button", "value":"Cancel", "style": "margin-right: 20px"}); 
    158186     
    159187        actionDiv.adopt(btnCancel); 
     
    176204         
    177205        btnNext.addEvent("click", function(e){ 
    178             size = tabber.tabber.tabs.length-2; 
     206            var size = tabber.tabber.tabs.length-2; 
    179207            switch(tabber.tabberCount){ 
    180208                case 0: 
     
    184212                     
    185213                        self.close(); 
    186                         rs = new ProfileEditorDialog(); 
     214                        var rs = new ProfileEditorDialog(); 
    187215                        rs.run(); 
    188216                        return; 
     
    205233                case 2: 
    206234                    if($("pprofile_name").value.trim().length == 0){ 
    207                         alert("Unnamed profile!\nou must provide a name for this profile."); 
     235                        alert("Unnamed profile!\nYou must provide a name for this profile."); 
    208236                        return; 
    209237                    } 
     
    216244                    if($("type_command").checked){ 
    217245                        $("target").value = $("command_target").value; 
    218                         lastHost = $("target").value; 
     246                        var lastHost = $("target").value; 
    219247                        runScan(e); 
    220248                        self.close(); 
    221249                    }else if($("type_profile").checked){ 
    222                         args = { 
     250                        var args = { 
    223251                            name: $("pprofile_name").value, 
    224252                            command: divCommandConstructor.value, 
     
    228256                        } 
    229257                         
    230                         xhr = new XHR({method: "post", 
     258                        var xhr = new XHR({method: "post", 
    231259                                      onSuccess: function(req){ 
    232260                                        alert("Profile saved succefull!"); 
     
    247275         
    248276        btnPrevious.addEvent("click", function(e){ 
    249             size = tabber.tabber.tabs.length-2; 
     277            var size = tabber.tabber.tabs.length-2; 
    250278            switch(tabber.tabberCount){ 
    251279                default: 
     
    264292            btnNext.disabled = false; 
    265293        }); 
    266         divLoading = new Element("div", {class: 'ajax-loading', style: "float: left; width: 100%"}); 
     294        divLoading = new Element("div", {"class": 'ajax-loading', "style": "float: left; width: 100%"}); 
    267295        this.window.adopt(divLoading); 
    268296    } 
     
    271299 
    272300function updateCommand(value, complement){ 
    273         commandLine = $("divCommandConstructor"); 
     301        var commandLine = $("divCommandConstructor"); 
     302        var target = ""; 
    274303        if($("type_command").checked){ 
    275                 target = $("command_target").value.trim() 
     304                target = $("command_target").value.trim(); 
    276305        }else{ 
    277                 target = "<target>" 
     306                target = "<target>"; 
    278307        } 
    279308         
    280309        commandLine.value = commandLine.value.replace(" " + target, ""); 
    281         oldValue = commandLine.value; 
    282  
    283         regex = new RegExp(value.replace(" ", "[ ]+").replace("%s", "[^ ^$]*")); 
    284          
     310        var oldValue = commandLine.value; 
     311 
     312        var regex = new RegExp(value.replace(" ", "[ ]+").replace("%s", "[^ ^$]*")); 
     313        var newValue = ""; 
    285314        if($defined(complement)){ 
    286315                newValue = value.replace("%s", complement); 
  • branch/UmitWeb/share/umit/umitweb_media/js/common.js

    r1466 r3432  
    1 last_host_scanned = "<target>" 
    2 var slides = {} 
     1var last_host_scanned = "<target>"; 
     2var slides = {}; 
    33 
    44fillCommand = function(value){ 
    5     $('command').value = $('command').value.replace(last_host_scanned, value) 
    6     last_host_scanned = value 
     5    $('command').value = $('command').value.replace(last_host_scanned, value); 
     6    last_host_scanned = value; 
    77} 
    88 
     
    1717 
    1818function toggle(target){ 
    19     tgDiv = $(target + "-detail") 
     19    var tgDiv = $(target + "-detail") 
    2020     
    21     tgSwitcher = $(target + "-switch") 
     21    var tgSwitcher = $(target + "-switch") 
    2222     
    2323    tgDiv.toggleClass("hide"); 
     
    7474 
    7575function addTableRow(table, row, lineAttrs){ 
    76         tr = new Element("tr"); 
     76        var tr = new Element("tr"); 
    7777        if(lineAttrs){ 
    78                 for(attr in lineAttrs){ 
     78                for(var attr in lineAttrs){ 
    7979                    tr[attr] = lineAttrs[attr]; 
    8080                } 
    8181        } 
    82         for(i = 0; i < row.length; i++){ 
    83                 td = new Element("td") 
     82        for(var i = 0; i < row.length; i++){ 
     83                var td = new Element("td") 
    8484                if($type(row[i]) == "string"){ 
    8585                    td.setHTML(row[i]); 
     
    8787                    td.adopt(row[i]); 
    8888                }else{ 
    89                     for(attr in row[i].attrs){ 
    90                         td[attr] = row[i].attrs[attr] 
    91                     } 
    92                     if($type(row[i].value) == "string"){ 
    93                         td.setHTML(row[i].value); 
    94                     }else{ 
    95                         td.adopt(row[i].value); 
    96                     } 
     89            for(var attr in row[i].attrs){ 
     90                td[attr] = row[i].attrs[attr] 
     91            } 
     92            if($type(row[i].value) == "string"){ 
     93                td.setHTML(row[i].value); 
     94            }else{ 
     95                td.adopt(row[i].value); 
     96            } 
    9797                } 
    9898                tr.adopt(td) 
    9999        } 
    100100        table.adopt(tr) 
    101         return tr; 
     101    return tr; 
    102102} 
    103103 
    104104function showError(req, target){ 
    105         messages = { 
     105        var messages = { 
    106106                403: {"title": "Access Denied", 
    107107                      "description": "Your access has been " + 
     
    112112                                "access to access this page."} 
    113113        } 
    114         div = new Element("div", {'class': "error"}) 
     114        var div = new Element("div", {'class': "error"}) 
    115115        if(messages[req.status]){ 
    116116                div.setHTML(messages[req.status]["description"]); 
    117                 header = new Element("h3", {styles: {"display": "block", "color": "red"}}); 
     117                var header = new Element("h3", {styles: {"display": "block", "color": "red"}}); 
    118118                header.setText(messages[req.status]['title']); 
    119119                $(target).empty().adopt(div); 
    120120                header.injectBefore(div); 
    121121        }else{ 
    122                 regexp = /.*Message:((.*[\r]?[\n]?)*)/g 
    123                 txt = req.responseText.match(regexp)[0] 
     122                var regexp = /.*Message:((.*[\r]?[\n]?)*)/g 
     123                var txt = req.responseText.match(regexp)[0] 
    124124                //txt = req.responseText 
    125                 header = new Element("h3", {styles: {"display": "block", "color": "red"}}); 
     125                var header = new Element("h3", {styles: {"display": "block", "color": "red"}}); 
    126126                header.setText("Response Code:" + req.status) 
    127127                $(target).empty().adopt(div); 
     
    133133function removeCommand(value){ 
    134134        commandLine = $("divCommandConstructor"); 
    135         oldValue = commandLine.value; 
    136         regex = new RegExp(value.replace(" ", "[ ]+").replace("%s", "[^ ^$]*")); 
     135        var oldValue = commandLine.value; 
     136        var regex = new RegExp(value.replace(" ", "[ ]+").replace("%s", "[^ ^$]*")); 
    137137         
    138138        if(oldValue.match(regex)){ 
     
    143143 
    144144function updateProfiles(){ 
    145         new Json.Remote("/scan/profiles/", {onComplete: function(result){ 
    146                 $("profiles").empty(); 
    147                 for(i = 0; i < result.length; i++){ 
    148                         opt = new Element("option", {"value": result[i][1]}) 
     145    new Json.Remote("/scan/profiles/", {onComplete: function(result){ 
     146        $("profiles").empty(); 
     147                for(var i = 0; i < result.length; i++){ 
     148                        var opt = new Element("option", {"value": result[i][1]}) 
    149149                        opt.setText(result[i][0]); 
    150150                        $("profiles").adopt(opt); 
    151151                } 
    152                 cmd = $("profiles").options[0].value; 
     152                var cmd = $("profiles").options[0].value; 
    153153                if($("target").value != ""){ 
    154154                        cmd = cmd.replace("<target>", $("target").value); 
     
    158158} 
    159159 
     160function emptyTBody(tbody){ 
     161    for(var i = 0; i < tbody.rows.length; i++){ 
     162        tbody.deleteRow(0); 
     163    } 
     164} 
     165 
    160166window.addEvent("domready", function(){ 
    161167    setInputStyles(); 
    162     size = getViewportSize(); 
     168    var size = getViewportSize(); 
    163169    $$("div[class='tab-placeholder']").each(function(div){ 
    164         div.style.height = (size[1]-271) + "px"; 
     170            div.style.height = (size[1]-271) + "px"; 
    165171    }); 
    166172         
    167173    if($defined($("hosts"))) 
    168         $("hosts").style.height = (size[1]-220) + "px" 
     174            $("hosts").style.height = (size[1]-220) + "px"; 
    169175    if($defined($("services"))) 
    170         $("services").style.height = (size[1]-220) + "px" 
     176            $("services").style.height = (size[1]-220) + "px"; 
    171177         
    172178    if($defined($("body"))){ 
    173         $("body").setStyle("width", (size[0]) + "px"); 
     179            $("body").setStyle("width", (size[0]) + "px"); 
    174180        $("umit-title").setStyle("width", size[0]-60 + "px"); 
    175181    } 
  • branch/UmitWeb/share/umit/umitweb_media/js/compare_results.js

    r1476 r3432  
    11var varData = null; 
     2var handler = null; 
    23 
    34DiffHandler = new Class({ 
    45    "color": function(){ 
    56        if(diff_text != null){ 
    6             last_tag = null; 
    7             new_text = []; 
    8             removed = /^-.*/; 
    9             styles = { 
     7            var last_tag = null; 
     8            var new_text = []; 
     9            var removed = /^-.*/; 
     10            var styles = { 
    1011                added: {"style": "background-color:" + diff_colors.added, 
    1112                        "regex": /^\+.*/}, 
     
    1314                          "regex": /^-.*/} 
    1415            }; 
    15             new_lines = []; 
    16             for(i = 0; i < diff_text.length; i++){ 
    17                 found = false; 
    18                 line = diff_text[i]; 
     16            var new_lines = []; 
     17            for(var i = 0; i < diff_text.length; i++){ 
     18                var found = false; 
     19                var line = diff_text[i]; 
    1920                for(k in styles){ 
    2021                    if(line.match(styles[k].regex)){ 
     
    3637    }, 
    3738    "showCompareTable": function(childs, color, spaces, classLine){ 
    38         tbl = $("compare-table").getElement("tbody"); 
    39         self = this; 
     39        var tbl = $("compare-table").getElement("tbody"); 
     40        var self = this; 
    4041         
    4142        if(spaces == null){ 
     
    4445         
    4546        childs.each(function(c){ 
    46             spn1rstCell = new Element("span"); 
     47            var spn1rstCell = new Element("span"); 
    4748            spn1rstCell.setHTML("<span>" + spaces + "</span>"); 
    48             lnk = new Element("a", {"href": "javascript:void(null)", "styles": {"display": "inline"}}); 
     49            var lnk = new Element("a", {"href": "javascript:void(null)", "styles": {"display": "inline"}}); 
    4950            lnk.adopt(new Element("img", {"src": "/media/images/plus.png", "styles": {"display": "inline"}})); 
    5051            spn1rstCell.appendText(c.state); 
    5152            spn1rstCell.setStyle("margin:0"); 
    5253            spn1rstCell.setStyle("padding:0"); 
    53             tr = addTableRow(tbl, [{"value": spn1rstCell, "attrs": {"padding": "0"}},  
     54            var tr = addTableRow(tbl, [{"value": spn1rstCell, "attrs": {"padding": "0"}},  
    5455                                  {"value": c.section, "attrs": {"styles": {"white-space": "nowrap", "padding": "0"}}},  
    5556                                  {"value": c.property, "attrs": {"styles": {"white-space": "nowrap", "padding": "0"}}},  
     
    140141    new Json.Remote("/scans/", { 
    141142        onComplete: function(scans){ 
    142             D = scans; 
     143            var D = scans; 
    143144            scans.each(function(scan){ 
    144145                $$($("s1-result"), $("s2-result")).each(function(el){ 
     
    182183function makeDiff(){ 
    183184    if($("scan1-detail").getText().length > 0 && $("scan2-detail").getText().length > 0){ 
    184         args = { 
     185        var args = { 
    185186            "scan1": $("scan1-detail").getText(), 
    186187            "scan2": $("scan2-detail").getText(), 
     
    191192            method: "post", 
    192193            onSuccess: function(response){ 
    193                 result = Json.evaluate(response); 
     194                var result = Json.evaluate(response); 
    194195                diff_text = result.text; 
    195196                diff_compare = result.compare; 
     
    205206 
    206207function viewHTMLDiff(){ 
    207     args = { 
     208    var args = { 
    208209        scan1: $("scan1-detail").getText(), 
    209210        scan2: $("scan2-detail").getText() 
     
    214215        onSuccess: function(response){ 
    215216            w = window.open("", "_blank"); 
    216             w.document.write(response); 
    217             w.document.close(); 
     217            if(w == null){ 
     218                alert("Oops! UmitWeb has encountered a pop-pup blocker! please, allow UmitWeb to open pop-up windows."); 
     219            }else{ 
     220                w.document.write(response); 
     221                w.document.close(); 
     222            } 
    218223        } 
    219224    }).send("make_html_diff/", Object.toQueryString(args)); 
  • branch/UmitWeb/share/umit/umitweb_media/js/dialog.js

    r1263 r3432  
    88    }, 
    99    initialize: function(options){ 
    10         self = this; 
     10        var self = this; 
    1111        this.options = $merge(this.options, options || {}); 
    1212        this.window = new Element("div", {"class": "dialog"}); 
    13         header = new Element("h2"); 
    14         d = new Drag.Move(this.window, {handle: header}); 
    15         lblTitle = new Element("label"); 
     13        var thisHeader = new Element("h2"); 
     14        var lblTitle = new Element("label"); 
    1615        lblTitle.setText(this.options.title); 
    17         header.adopt(lblTitle); 
    18         lnk = new Element("a", {"href": "javascript: void(null)"}); 
     16        thisHeader.adopt(lblTitle); 
     17        var lnk = new Element("a", {"href": "javascript: void(null)"}); 
    1918        lnk.setText("X"); 
    2019        lnk.setStyle("position", "absolute"); 
     
    2524            self.close(); 
    2625        }); 
    27         header.adopt(lnk); 
     26        thisHeader.adopt(lnk); 
    2827         
    2928        this.window.setStyle("position", "absolute"); 
     
    3231        this.window.setStyle("width", this.options.width); 
    3332        this.window.setStyle("height", this.options.height); 
     33        this.window.setStyle("zIndex", "101") 
    3434         
    35         this.window.adopt(header); 
     35        this.window.adopt(thisHeader); 
    3636        this.window.adopt(this.options.content); 
     37        var d = new Drag.Move(this.window, {'handle': thisHeader}); 
     38         
     39        if(window.ie){ 
     40            var iFrame = new Element("iframe"); 
     41            iFrame.src = "javascript:false"; 
     42            iFrame.scrolling = "no"; 
     43            iFrame.frameBorder = "0"; 
     44            iFrame.setStyle("width", this.options.width); 
     45            iFrame.setStyle("height", this.options.height); 
     46            iFrame.style.zIndex = "-1"; 
     47            iFrame.setStyle("position", "absolute"); 
     48            iFrame.injectBefore(thisHeader); 
     49        } 
    3750    }, 
    3851     
  • branch/UmitWeb/share/umit/umitweb_media/js/index.js

    r1257 r3432  
    1 var varData = "" 
     1var varData = ""; 
    22 
    3 scanLock = false; 
     3var scanLock = false; 
    44 
    5 lastHost = null; 
    6 lastService = null; 
     5var lastHost = null; 
     6var lastService = null; 
    77var scanEvent = null; 
    88var scanId = null; 
     
    1111var sSlide; 
    1212var hSlide; 
     13var rs; // Instance of a Dialog 
    1314 
    1415function openScan(){ 
    15         isToRun = true; 
     16        var isToRun = true; 
    1617        if(saved == false && scanId != null){ 
    1718                text = "The given scan has unsaved changes!\n" + 
     
    5657window.addEvent("domready", function(){ 
    5758    if($defined($("frmScan"))){ 
    58         $("frmScan").addEvent("submit", runScan); 
     59        $("frmScan").addEvent("submit", runScan); 
    5960         
    60         $("toggleHosts").addEvent("click", function(e){ 
    61                 if(!this.hasClass("active")){ 
    62                     ts = $("toggleServices"); 
    63                     this.addClass("active"); 
    64                     ts.removeClass("active"); 
    65                     $("hosts").setStyle("display", "block"); 
    66                     $("services").setStyle("display", "none"); 
    67                 } 
    68                 new Event(e).stop(); 
    69         }); 
     61            $("toggleHosts").addEvent("click", function(e){ 
     62                    if(!this.hasClass("active")){ 
     63                    var ts = $("toggleServices"); 
     64                    this.addClass("active"); 
     65                    ts.removeClass("active"); 
     66                    $("hosts").setStyle("display", "block"); 
     67                    $("services").setStyle("display", "none"); 
     68                } 
     69                new Event(e).stop(); 
     70        }); 
    7071         
    71         $("toggleServices").addEvent("click", function(e){ 
    72                 if(!this.hasClass("active")){ 
    73                     th = $("toggleHosts"); 
    74                     this.addClass("active"); 
    75                     th.removeClass("active"); 
    76                     $("hosts").setStyle("display", "none"); 
    77                     $("services").setStyle("display", "block"); 
    78                 } 
    79                 new Event(e).stop(); 
    80         }); 
     72            $("toggleServices").addEvent("click", function(e){ 
     73            if(!this.hasClass("active")){ 
     74                    var th = $("toggleHosts"); 
     75                    this.addClass("active"); 
     76                    th.removeClass("active"); 
     77                    $("hosts").setStyle("display", "none"); 
     78                    $("services").setStyle("display", "block"); 
     79                } 
     80                new Event(e).stop(); 
     81        }); 
     82 
     83        $("toggleHosts").addClass("active"); 
     84        $("services").setStyle("display", "none"); 
    8185         
    82         $("toggleHosts").addClass("active"); 
    83         $("services").setStyle("display", "none"); 
     86        updateProfiles(); 
    8487         
    85         updateProfiles(); 
    86          
    87         $("profiles").addEvent("change", function(event){ 
    88                 cmd = this.options[this.selectedIndex].value; 
    89                 if($("target").value != ""){ 
    90                         cmd = cmd.replace("<target>", $("target").value); 
    91                 } 
    92                 $("command").value = cmd; 
    93                 new Event(event).stop(); 
    94         }); 
     88            $("profiles").addEvent("change", function(event){ 
     89                var cmd = this.options[this.selectedIndex].value; 
     90                if($("target").value != ""){ 
     91                        cmd = cmd.replace("<target>", $("target").value); 
     92                } 
     93                $("command").value = cmd; 
     94                new Event(event).stop(); 
     95        }); 
    9596        $("divSpinner").addClass("hide"); 
    9697        $("body").removeClass("hide"); 
     
    9899 
    99100   $("highlight_out").addEvent("change", function(e){ 
    100         new Event(e).stop(); 
    101         if(!nmapOutput || nmapOutput.trim().length == 0){ return } 
    102         if(this.checked){ 
    103                 $("nmap-output").setHTML(formatNmapOutput(nmapOutput)); 
    104         }else{ 
    105                 $("nmap-output").setText(nmapOutput); 
    106         } 
     101            new Event(e).stop(); 
     102        if(!nmapOutput || nmapOutput.trim().length == 0){ return } 
     103        if(this.checked){ 
     104                $("nmap-output").setHTML(formatNmapOutput(nmapOutput)); 
     105        }else{ 
     106                $("nmap-output").setText(nmapOutput); 
     107        } 
    107108   }); 
    108109}); 
  • branch/UmitWeb/share/umit/umitweb_media/js/login.js

    r1299 r3432  
    11doLogin = function(e){ 
     2    try{ 
    23    new Event(e).stop(); 
    34    $("spinner").removeClass("hide"); 
     
    56    $("spacer").addClass("hide"); 
    67    processResult = function(result){ 
    7         if(result == "OK"){ 
    8             location.href = "/" 
    9         }else{ 
     8            if(result == "OK"){ 
     9            location.href = "/" 
     10        }else{ 
    1011            $("spinner").addClass("hide"); 
    11             $("error").empty().removeClass("hide").setText("Incorrect username or password") 
    12         } 
     12            $("error").empty().removeClass("hide").setText("Incorrect username or password") 
     13        } 
    1314    } 
    1415    this.send({onComplete: processResult}); 
     16    }catch(e){ 
     17        alert(e); 
     18    } 
    1519    return false; 
    1620} 
  • branch/UmitWeb/share/umit/umitweb_media/js/mootools.v1.11-old.js

    r907 r3432  
    24502450 
    24512451        setHTML: function(){ 
    2452                 this.innerHTML = $A(arguments).join(''); 
     2452            if($A(arguments)){ 
     2453                    this.innerHTML = $A(arguments).join(''); 
     2454            } 
    24532455                return this; 
    24542456        }, 
  • branch/UmitWeb/share/umit/umitweb_media/js/permissions.js

    r1466 r3432  
     1currentConstraints = []; 
     2 
    13PermissionDialog = Dialog.extend({ 
    24    options: { 
     
    1012        this.options.content.empty(); 
    1113 
    12         self = this; 
    13         tabber = new Element("div", {"class": "tabber", "id": "tabberPermission"}); 
    14          
    15         tabMain = new Element("div", {class: "tabbertab", style: "height: 175px;", title: "Main Information"}); 
     14        var self = this; 
     15        var tabber = new Element("div", {"class": "tabber", "id": "tabberPermission"}); 
     16         
     17        var tabMain = new Element("div", {class: "tabbertab", style: "height: 175px;", title: "Main Information"}); 
    1618        tabber.adopt(tabMain); 
    17         tabConstraints = new Element("div", {class: "tabbertab", style: "height: 175px;", title: "Constraints"}); 
     19        var tabConstraints = new Element("div", {class: "tabbertab", style: "height: 175px;", title: "Constraints"}); 
    1820        tabber.adopt(tabConstraints); 
    1921         
    20         tbl = new Element("table"); 
     22        var tbl = new Element("table"); 
    2123        tabMain.adopt(tbl); 
    22         divType = new Element("span"); 
     24        var divType = new Element("span"); 
    2325        divType.setText("Base Type:* "); 
    24         selectPermType = new Element("select"); 
    25         opt1 = new Element("option", {"value": "allow"}); 
     26        var selectPermType = new Element("select"); 
     27        var opt1 = new Element("option", {"value": "allow"}); 
    2628        opt1.setText("Allow"); 
    27         opt2 = new Element("option", {"value": "deny"}); 
     29        var opt2 = new Element("option", {"value": "deny"}); 
    2830        opt2.setText("Deny"); 
    2931        selectPermType.adopt(opt1); 
    3032        selectPermType.adopt(opt2); 
    3133        divType.adopt(selectPermType); 
    32         inputId = new Element("input", {"size": "30", "type": "text", "style": "margin-right:10px;"}); 
    33         txtDescription = new Element("textarea", {"style": "width: 435px; height: 115px;"}); 
    34         fsDescription = new Element("fieldset", {"style": "padding:0;margin:0"}); 
    35         legend = new Element("legend"); 
     34        var inputId = new Element("input", {"size": "30", "type": "text", "style": "margin-right:10px;"}); 
     35        var txtDescription = new Element("textarea", {"style": "width: 435px; height: 115px;"}); 
     36        var fsDescription = new Element("fieldset", {"style": "padding:0;margin:0"}); 
     37        var legend = new Element("legend"); 
    3638        legend.setText("Description"); 
    3739        fsDescription.adopt(legend); 
     
    4042        currentConstraints = []; 
    4143         
    42         tblContents = new Element("table"); 
    43         dvConstraints = new Element("div", {"styles": {"height": "167px", "width": "415px", "border": "#CCC 1px solid", "overflow": "auto"}}); 
    44         tblConstraints = new Element("table", {"id": "constraints_table", "class": "std_table"}); 
     44        var tblContents = new Element("table"); 
     45        var dvConstraints = new Element("div", {"styles": {"height": "167px", "width": "415px", "border": "#CCC 1px solid", "overflow": "auto"}}); 
     46        var tblConstraints = new Element("table", {"id": "constraints_table", "class": "std_table"}); 
    4547        dvConstraints.adopt(tblConstraints); 
    4648         
    47         lnkMoveUp = new Element("a", {"href": "javascript:void(null)"}); 
    48         imgMoveUp = new Element("img", {"src": "/media/images/up.png", "alt":"Move constraint up", "title":"Move constraint up"}); 
     49        var lnkMoveUp = new Element("a", {"href": "javascript:void(null)"}); 
     50        var imgMoveUp = new Element("img", {"src": "/media/images/up.png", "alt":"Move constraint up", "title":"Move constraint up"}); 
    4951        lnkMoveUp.adopt(imgMoveUp); 
    5052        lnkMoveUp.addEvent("click", function(e){ 
    51             for(j = 1; j < currentConstraints.length; j++){ 
     53            for(var j = 1; j < currentConstraints.length; j++){ 
    5254                if(currentConstraints[j]["check"].checked){ 
    53                     aux = currentConstraints[j-1]; 
     55                    var aux = currentConstraints[j-1]; 
    5456                    currentConstraints[j-1] = currentConstraints[j]; 
    5557                    currentConstraints[j] = aux; 
     
    6062        }); 
    6163         
    62         lnkMoveDown = new Element("a", {"href": "javascript:void(null)"}); 
    63         imgMoveDown = new Element("img", {"src": "/media/images/down.png", "alt":"Move constraint down", "title":"Move constraint down"}); 
     64        var lnkMoveDown = new Element("a", {"href": "javascript:void(null)"}); 
     65        var imgMoveDown = new Element("img", {"src": "/media/images/down.png", "alt":"Move constraint down", "title":"Move constraint down"}); 
    6466        lnkMoveDown.adopt(imgMoveDown); 
    6567        lnkMoveDown.addEvent("click", function(e){ 
    66             for(j = currentConstraints.length - 2; j >= 0; j--){ 
     68            for(var j = currentConstraints.length - 2; j >= 0; j--){ 
    6769                if(currentConstraints[j]["check"].checked){ 
    68                     aux = currentConstraints[j+1]; 
     70                    var aux = currentConstraints[j+1]; 
    6971                    currentConstraints[j+1] = currentConstraints[j]; 
    7072                    currentConstraints[j] = aux; 
     
    7577        }); 
    7678         
    77         lnkAdd = new Element("a", {"href": "javascript:void(null)"}); 
    78         imgAdd = new Element("img", {"src": "/media/images/plus.png", "alt":"Add new constraint", "title":"Add new constraint"}); 
     79        var lnkAdd = new Element("a", {"href": "javascript:void(null)"}); 
     80        var imgAdd = new Element("img", {"src": "/media/images/plus.png", "alt":"Add new constraint", "title":"Add new constraint"}); 
    7981        lnkAdd.adopt(imgAdd); 
    8082        lnkAdd.addEvent("click", function(e){ 
     
    8284        }); 
    8385         
    84         lnkRemove = new Element("a", {"href": "javascript:void(null)"}); 
    85         imgRemove = new Element("img", {"src": "/media/images/minus.png", "alt":"Remove constraint", "title":"Remove constraint"}); 
     86        var lnkRemove = new Element("a", {"href": "javascript:void(null)"}); 
     87        var imgRemove = new Element("img", {"src": "/media/images/minus.png", "alt":"Remove constraint", "title":"Remove constraint"}); 
    8688        lnkRemove.adopt(imgRemove); 
    8789        lnkRemove.addEvent("click", function(e){ 
    88             for(j = 0; j < currentConstraints.length; j++){ 
     90            for(var j = 0; j < currentConstraints.length; j++){ 
    8991                if(currentConstraints[j]["check"].checked){ 
    9092                    if(j > 0){ 
     
    9597                } 
    9698            } 
    97             cc = []; 
     99            var cc = []; 
    98100            currentConstraints.each(function(c){ 
    99101                if(typeof c != "undefined"){ 
     
    113115         
    114116        if(self.options.data){ 
    115             d = self.options.data; 
     117            var d = self.options.data; 
    116118            inputId.value = d.id; 
    117119            txtDescription.value = d.description; 
     
    142144         
    143145        btnOK.addEvent("click", function(e){ 
    144             reqFields = [inputId] 
    145             saveURL = "add/" 
     146            var reqFields = [inputId] 
     147            var saveURL = "add/" 
    146148            if(self.options.data){ 
    147149                saveURL = "edit/" + self.options.data.id + "/" 
    148150            } 
    149151             
    150             for(k = 0; k < reqFields.length; k++){ 
     152            for(var k = 0; k < reqFields.length; k++){ 
    151153                if(reqFields[k].value.trim().length == 0){ 
    152154                    alert("Please, fill all the entries marked with a '*'."); 
     
    156158            } 
    157159             
    158             constraint_types = [] 
    159             constraints = [] 
     160            var constraint_types = [] 
     161            var constraints = [] 
    160162            currentConstraints.each(function(c){ 
    161163                constraint_types.extend([c["type"].value]); 
     
    169171            } 
    170172             
    171             args = { 
     173            var args = { 
    172174                id: inputId.value, 
    173175                type: selectPermType[selectPermType.selectedIndex].value, 
     
    177179            } 
    178180                         
    179             xhr = new XHR({method: "post", 
     181            var xhr = new XHR({method: "post", 
    180182                            onSuccess: function(req){ 
    181183                                try{ 
    182                                     response = null; 
     184                                    var response = null; 
    183185                                    eval('response = ' + req); 
    184186                                    varData = req 
     
    206208        this.options.content.adopt(tabber); 
    207209        this.options.content.adopt(actionDiv); 
    208         to = { 
     210        var to = { 
    209211            "div": tabber 
    210212        } 
    211213        tabber.tabber = new tabberObj(to); 
    212214        if(self.options.data){ 
    213             d = self.options.data; 
     215            var d = self.options.data; 
    214216            d.constraints.each(function(constraint){ 
    215217                addPermissionRow(constraint.type, constraint.content, constraint, tblConstraints); 
     
    219221}); 
    220222 
     223 
     224// Helper functions 
    221225function fillTableData(permissions){ 
    222     t = $("permissions_table").getElement("tbody").empty(); 
    223  
    224     for(index = 0; index < permissions.length; index++){ 
    225         p = permissions[index]; 
     226    var t = $("permissions_table").getElement("tbody").empty(); 
     227 
     228    for(var index = 0; index < permissions.length; index++){ 
     229        var p = permissions[index]; 
    226230        if(p.id != "allow-all" && p.id != "deny-all"){ 
    227             ch = new Element("input", {"type": "checkbox", "id": "chk-" + p.id}); 
    228             lnkEdit = new Element("a", {"href": "javascript:void(null)", "id": "" + p.id}); 
     231            var ch = new Element("input", {"type": "checkbox", "id": "chk-" + p.id}); 
     232            var lnkEdit = new Element("a", {"href": "javascript:void(null)", "id": "" + p.id}); 
    229233            lnkEdit.setText(p.id); 
    230234            lnkEdit.addEvent("click", function(e){ 
     
    233237            }); 
    234238             
    235             constraints = []; 
    236             for(j = 0; j < p.constraints.length; j++){ 
    237                 c = p.constraints[j]; 
     239            var constraints = []; 
     240            for(var j = 0; j < p.constraints.length; j++){ 
     241                var c = p.constraints[j]; 
    238242                constraints.include(c["content"] + " <span style='color:#505050'><i>(" + c["type"] + ")</i></span>"); 
    239243            } 
    240             imgType = new Element("img", {"src": "/media/images/" + (p.type=="allow"? "open": "closed") + ".png", 
     244            var imgType = new Element("img", {"src": "/media/images/" + (p.type=="allow"? "open": "closed") + ".png", 
    241245                                          "title": p.type, "alt": p.type}); 
    242             line = [ch, lnkEdit, {"value": imgType, "attrs": {"align": "center"}}, p.description, constraints.join("<br/>")] 
    243             className = (index % 2 == 0)? "light": "dark"; 
     246            var line = [ch, lnkEdit, {"value": imgType, "attrs": {"align": "center"}}, p.description, constraints.join("<br/>")] 
     247            var className = (index % 2 == 0)? "light": "dark"; 
    244248            tr = addTableRow(t, line); 
    245249            tr.addClass(className); 
     
    248252} 
    249253 
    250 var currentConstraints = []; 
     254 
    251255 
    252256function fillConstraintTable(tbl){ 
    253     t = tbl==null? $("constraints_table").empty(): tbl; 
    254     for(j = 0; j < currentConstraints.length; j++){ 
    255         c =  currentConstraints[j]; 
    256         args = {}; 
     257    var t = tbl==null? $("constraints_table").empty(): tbl; 
     258    for(var j = 0; j < currentConstraints.length; j++){ 
     259        var c =  currentConstraints[j]; 
     260        var args = {}; 
    257261        addTableRow(t, [c["check"], "Type: ", c["type"], "Content: ", c["content"]]); 
    258262         
     
    280284    type = (type)? type: ""; 
    281285    content = (content)? content: ""; 
    282     inputCheck = new Element("input", {"type": "radio", "name": "current"}); 
     286    var inputCheck = new Element("input", {"type": "radio", "name": "current"}); 
    283287    inputCheck.checked = true; 
    284     selectType = new Element("select"); 
    285     optCommand = new Element("option"); 
     288    var selectType = new Element("select"); 
     289    var optCommand = new Element("option"); 
    286290    optCommand.setText("command"); 
    287291    selectType.add(optCommand, null); 
    288     inputContent = new Element("input", {"type": "text"}); 
     292    var inputContent = new Element("input", {"type": "text"}); 
    289293    if(data){ 
    290294        inputContent.value = data["content"]; 
     
    303307        onComplete: fillTableData, 
    304308        onFailure: function(req){ 
    305             t = $("permissions_table").getElement("tbody").empty(); 
     309            var t = $("permissions_table").getElement("tbody").empty(); 
    306310            addTableRow(t, [{"value": "Error loading data. Please see umitweb.log for details.", "attrs": {"colSpan": "4"}}], {"class": "error"}); 
    307311        } 
     
    365369        }, 
    366370        onFailure: function(req){ 
    367             t = $("permissions_table").getElement("tbody").empty(); 
     371            var t = $("permissions_table").getElement("tbody").empty(); 
    368372            addTableRow(t, [{"value": "Error loading data. Please see umitweb.log for details.", "attrs": {"colSpan": "5"}} ], {"class": "error"}); 
    369373        }}); 
  • branch/UmitWeb/share/umit/umitweb_media/js/profile-editor.js

    r1256 r3432  
    1010        this.options.content.empty(); 
    1111 
    12         self = this; 
    13         title = new Element("h3"); 
    14         commandConstructorDiv = new Element("div"); 
    15         lbl = new Element("label"); 
     12        var self = this; 
     13        var title = new Element("h3"); 
     14        var commandConstructorDiv = new Element("div"); 
     15        var lbl = new Element("label"); 
    1616        lbl.setHTML("<strong>Command: </strong>"); 
    1717        divCommandConstructor = new Element("input", {"id": "divCommandConstructor", 
     
    2222         
    2323        title.setText("UMIT Profile Editor"); 
    24         tabber = new Element("div", {"class": "tabber", "id": "tabberCommand"}); 
    25          
    26         tabProfileDetails = new Element("div", {class: "tabbertab", style: "height: 305px;", title: "Profile"}); 
     24        var tabber = new Element("div", {"class": "tabber", "id": "tabberCommand"}); 
     25         
     26        var tabProfileDetails = new Element("div", {'class': "tabbertab", 'style': "height: 305px;", 'title': "Profile"}); 
     27         
    2728        tabProfileDetails.setHTML("<b>Profile Information</b><p/>Please, enter the profile name, " + 
    2829                                  "and optionally, enter a hint, description and annotation for this " + 
    2930                                   "new profile:"); 
    30         spnProfile = new Element("table"); 
     31        var spnProfile = new Element("table"); 
    3132        spnProfile.setHTML("<tr><td valign='top'><label for='pprofile_name'><strong>Profile Name:</strong>&nbsp;&nbsp;</label></td>" + 
    3233                           "<td><input type='text' id='pprofile_name' size='40'/></td></tr>" + 
     
    4243        new Json.Remote("/profile_editor/", {onComplete: function(sections){ 
    4344            varData = sections; 
    44             for(k in sections){ 
    45                 s = sections[k] 
    46                 tab = new Element("div", {class: "tabbertab", title: k, styles: {"overflow": "auto", "height": "305px"}}); 
    47                 tab.setHTML("<b>" + s.label + "</b>"); 
    48                 table = new Element("table", {width: "100%"}); 
    49                 tableContent = "<tr>"; 
     45             
     46            for(var k in sections){ 
     47                var s = sections[k]; 
     48                var tab = new Element("div"); 
     49                tab.addClass("tabbertab"); 
     50                tab.title = k; 
     51                tab.setStyle({"overflow": "auto", "height": "305px"}); 
     52                 
     53                //tab.setHTML("<b>" + s.label + "</b>"); 
     54                 
     55                var table = new Element("table", {width: "100%"}); 
     56                var tableContent = "<tr>"; 
    5057                s.options.each(function(op){ 
    5158                    if(op.type == "list"){ 
     
    7582                tabber.getElements("select").each(function(el){ 
    7683                    el.addEvent("change", function(e){ 
    77                         for(i = 0; i < this.length; i++){ 
    78                             v = this[i].value; 
     84                        for(var i = 0; i < this.length; i++){ 
     85                            var v = this[i].value; 
    7986                            if(i != this.selectedIndex){ 
    8087                                removeCommand(v); 
    8188                            } 
    8289                        } 
    83                         v = this[this.selectedIndex].value; 
     90                        var v = this[this.selectedIndex].value; 
    8491                        updateProfile(v); 
    8592                    }); 
     
    8996                tabber.getElements("input[type=checkbox]").each(function(el){ 
    9097                    el.addEvent("change", function(e){ 
    91                         v = this.value; 
    92                         cmpl = ($defined($("txt-" + v.id)))? $("txt-" + v.id).value: ""; 
     98                        var v = this.value; 
     99                        var cmpl = ($defined($("txt-" + v.id)))? $("txt-" + v.id).value: ""; 
    93100                        if(this.checked){ 
    94101                            updateProfile(v, cmpl); 
     
    102109                    el.addEvent("focus", function(e){ 
    103110                        $(this.id.substring("txt-".length)).checked = true; 
    104                         v = $(this.id.substring("txt-".length)).value 
    105                         cmpl = this.value; 
     111                        var v = $(this.id.substring("txt-".length)).value 
     112                        var cmpl = this.value; 
    106113                        updateProfile(v, cmpl); 
    107114                    }); 
    108115                     
    109116                    el.addEvent("keyup", function(e){ 
    110                         v = $(this.id.substring("txt-".length)).value 
    111                         cmpl = this.value; 
     117                        var v = $(this.id.substring("txt-".length)).value 
     118                        var cmpl = this.value; 
    112119                        updateProfile(v, cmpl); 
    113120                    }); 
     
    116123             
    117124            self.options.content.removeClass("hide"); 
    118             to = {}; 
     125            var to = {}; 
    119126            to.div = tabber; 
    120127            tabber.tabber = new tabberObj(to); 
     
    133140        this.options.content.setStyle("padding", "10px;"); 
    134141         
    135         actionDiv = new Element("div", {style: "text-align: right"}); 
    136         btnOK = new Element("input", {type: "button", value:"OK", styles: {"width": "80px;"}}); 
    137         btnCancel = new Element("input", {type: "button", value:"Cancel", style: "margin-right: 20px"}); 
     142        var actionDiv = new Element("div", {style: "text-align: right"}); 
     143        var btnOK = new Element("input", {type: "button", value:"OK", styles: {"width": "80px;"}}); 
     144        var btnCancel = new Element("input", {type: "button", value:"Cancel", style: "margin-right: 20px"}); 
    138145     
    139146        actionDiv.adopt(btnCancel); 
     
    149156                return; 
    150157            } 
    151             args = { 
     158            var args = { 
    152159                name: $("pprofile_name").value, 
    153160                command: divCommandConstructor.value, 
     
    157164            } 
    158165                         
    159             xhr = new XHR({method: "post", 
     166            var xhr = new XHR({method: "post", 
    160167                           onSuccess: function(req){ 
    161168                           alert("Profile saved succefully!"); 
     
    171178        this.options.content.adopt(tabber); 
    172179        this.options.content.adopt(actionDiv); 
    173         divLoading = new Element("div", {class: 'ajax-loading', style: "float: left; width: 100%"}); 
     180        var divLoading = new Element("div"); 
     181        divLoading.addClass('ajax-loading'); 
     182        divLoading.setStyle({"float": "left", "width": "100%"}); 
    174183        this.window.adopt(divLoading); 
    175184         
     
    178187 
    179188function updateProfile(value, complement){ 
    180         commandLine = $("divCommandConstructor"); 
    181          
    182         target = "<target>" 
     189        var commandLine = $("divCommandConstructor"); 
     190         
     191        var target = "<target>" 
    183192         
    184193        commandLine.value = commandLine.value.replace(" " + target, ""); 
    185         oldValue = commandLine.value; 
     194        var oldValue = commandLine.value; 
    186195 
    187         regex = new RegExp(value.replace(" ", "[ ]+").replace("%s", "[^ ^$]*")); 
    188          
     196        var regex = new RegExp(value.replace(" ", "[ ]+").replace("%s", "[^ ^$]*")); 
     197         
     198        var newValue = null; 
    189199        if($defined(complement)){ 
    190200                newValue = value.replace("%s", complement); 
  • branch/UmitWeb/share/umit/umitweb_media/js/roles.js

    r1276 r3432  
    1010        this.options.content.empty(); 
    1111 
    12         self = this; 
    13         tabber = new Element("div", {"class": "tabber", "id": "tabberRole"}); 
    14          
    15         tabMain = new Element("div", {class: "tabbertab", style: "height: 175px;", title: "Main Information"}); 
     12        var self = this; 
     13        var tabber = new Element("div", {"class": "tabber", "id": "tabberRole"}); 
     14         
     15        var tabMain = new Element("div", {class: "tabbertab", style: "height: 175px;", title: "Main Information"}); 
    1616        tabber.adopt(tabMain); 
    1717        tabPermissions = new Element("div", {class: "tabbertab", style: "height: 175px;", title: "Permissions"}); 
    1818        tabber.adopt(tabPermissions); 
    1919         
    20         tbl = new Element("table"); 
     20        var tbl = new Element("table"); 
    2121        tabMain.adopt(tbl); 
    22         inputId = new Element("input", {"size": "30", "type": "text"}); 
    23         txtDescription = new Element("textarea", {"style": "width: 385px; height: 110px;"}); 
    24         fsDescription = new Element("fieldset", {"style": "padding:0;margin:0"}); 
    25         legend = new Element("legend"); 
     22        var inputId = new Element("input", {"size": "30", "type": "text"}); 
     23        var txtDescription = new Element("textarea", {"style": "width: 385px; height: 110px;"}); 
     24        var fsDescription = new Element("fieldset", {"style": "padding:0;margin:0"}); 
     25        var legend = new Element("legend"); 
    2626        legend.setText("Description"); 
    2727        fsDescription.adopt(legend); 
     
    2929         
    3030        if(self.options.data){ 
    31             d = self.options.data; 
     31            var d = self.options.data; 
    3232            inputId.value = d.id; 
    3333            txtDescription.value = d.description; 
     
    4949            lbl.addClass("hint"); 
    5050             
    51             for(k=0; k < permissions.length; k++){ 
    52                 p = permissions[k]; 
     51            for(var k=0; k < permissions.length; k++){ 
     52                var p = permissions[k]; 
    5353                if(p != "allow-all" && p != "deny-all"){ 
    54                     opt = new Element("option", {"value": p}); 
     54                    var opt = new Element("option", {"value": p}); 
    5555                    opt.setText(p); 
    5656                    selectPermissions.add(opt, null); 
     
    5858            } 
    5959             
    60             imgBtnMoveUp = new Element("img", {"src": "/media/images/up.png"}); 
    61             btnMoveUp = new Element("a", {"href": "javascript:void(null)"}); 
     60            var imgBtnMoveUp = new Element("img", {"src": "/media/images/up.png"}); 
     61            var btnMoveUp = new Element("a", {"href": "javascript:void(null)"}); 
    6262            btnMoveUp.adopt(imgBtnMoveUp); 
    6363            btnMoveUp.addEvent("click", function(e){ 
    64                 for(j = 1; j < selectedPermissions.length; j++){ 
     64                for(var j = 1; j < selectedPermissions.length; j++){ 
    6565                    if(selectedPermissions[j].selected){ 
    66                         opt = selectedPermissions[j]; 
    67                         optBefore = selectedPermissions[j-1]; 
     66                        var opt = selectedPermissions[j]; 
     67                        var optBefore = selectedPermissions[j-1]; 
    6868                        selectedPermissions.add(opt, optBefore); 
    6969                    } 
     
    7171            }); 
    7272             
    73             imgBtnMoveDown = new Element("img", {"src": "/media/images/down.png"}); 
    74             btnMoveDown = new Element("a", {"href": "javascript:void(null)"}); 
     73            var imgBtnMoveDown = new Element("img", {"src": "/media/images/down.png"}); 
     74            var btnMoveDown = new Element("a", {"href": "javascript:void(null)"}); 
    7575            btnMoveDown.adopt(imgBtnMoveDown); 
    7676            btnMoveDown.addEvent("click", function(e){ 
    77                 for(j = selectedPermissions.length-2; j >=0; j--){ 
     77                for(var j = selectedPermissions.length-2; j >=0; j--){ 
    7878                    if(selectedPermissions[j].selected){ 
    79                         opt = selectedPermissions[j]; 
    80                         optBefore = selectedPermissions[j+1]; 
     79                        var opt = selectedPermissions[j]; 
     80                        var optBefore = selectedPermissions[j+1]; 
    8181                        opt.injectAfter(optBefore); 
    8282                    } 
     
    8484            }); 
    8585             
    86             imgBtnIn = new Element("img", {"src": "/media/images/right.png"}); 
    87             btnIn = new Element("a", {"href": "javascript:void(null)"}); 
     86            var imgBtnIn = new Element("img", {"src": "/media/images/right.png"}); 
     87            var btnIn = new Element("a", {"href": "javascript:void(null)"}); 
    8888            btnIn.adopt(imgBtnIn); 
    8989            btnIn.addEvent("click", function(e){ 
    90                 options = [] 
    91                 for(j = 0; j < selectPermissions.length; j++){ 
     90                var options = [] 
     91                for(var j = 0; j < selectPermissions.length; j++){ 
    9292                    if(selectPermissions[j].selected){ 
    9393                        options.include(selectPermissions[j]); 
    9494                    } 
    9595                } 
    96                 for(j = 0; j < options.length; j++){ 
     96                for(var j = 0; j < options.length; j++){ 
    9797                    selectedPermissions.add(options[j], null); 
    9898                } 
    9999            }); 
    100100             
    101             imgBtnOut = new Element("img", {"src": "/media/images/left.png"}); 
    102             btnOut = new Element("a", {"href": "javascript:void(null)"}); 
     101            var imgBtnOut = new Element("img", {"src": "/media/images/left.png"}); 
     102            var btnOut = new Element("a", {"href": "javascript:void(null)"}); 
    103103            btnOut.adopt(imgBtnOut); 
    104104            btnOut.addEvent("click", function(e){ 
    105                 options = [] 
    106                 for(j = 0; j < selectedPermissions.length; j++){ 
     105                var options = [] 
     106                for(var j = 0; j < selectedPermissions.length; j++){ 
    107107                    if(selectedPermissions[j].selected){ 
    108108                        options.include(selectedPermissions[j]); 
    109109                    } 
    110110                } 
    111                 for(j = 0; j < options.length; j++){ 
     111                for(var j = 0; j < options.length; j++){ 
    112112                    selectPermissions.add(options[j], null); 
    113113                } 
    114114            }); 
    115115             
    116             fsSelectPermissions = new Element("fieldset", {"style": "padding: 0"}); 
     116            var fsSelectPermissions = new Element("fieldset", {"style": "padding: 0"}); 
    117117            fsSelectPermissions.setHTML("<legend>Available Permissions</legend>"); 
    118             fsSelectedPermissions = new Element("fieldset", {"style": "padding: 0"}); 
     118            var fsSelectedPermissions = new Element("fieldset", {"style": "padding: 0"}); 
    119119            fsSelectedPermissions.setHTML("<legend>Selected Permissions</legend>"); 
    120120             
     
    122122            fsSelectedPermissions.adopt(selectedPermissions); 
    123123             
    124             selectPermissionsTable = new Element("table"); 
    125             lines = [ 
     124            var selectPermissionsTable = new Element("table"); 
     125            var lines = [ 
    126126                {"value": fsSelectPermissions, "attrs": {"rowSpan": "2"}}, 
    127127                {"value": btnIn, "attrs": {"valign": "bottom"}}, 
     
    132132            addTableRow(selectPermissionsTable, [{"value": btnOut, "attrs": {"valign": "top"}}, 
    133133                                                 {"value": btnMoveDown, "attrs": {"valign": "top"}}]); 
    134             lblLast = new Element("label"); 
     134            var lblLast = new Element("label"); 
    135135            lblLast.setText("Last Rule:"); 
    136             selectLast = new Element("select"); 
    137             optDeny = new Element("option", {"value": "deny-all"}); 
    138             optAllow = new Element("option", {"value": "allow-all"}); 
     136            var selectLast = new Element("select"); 
     137            var optDeny = new Element("option", {"value": "deny-all"}); 
     138            var optAllow = new Element("option", {"value": "allow-all"}); 
    139139            optDeny.setText("Deny all commands"); 
    140140            optAllow.setText("Allow all commands"); 
     
    147147             
    148148            self.options.content.removeClass("hide"); 
    149             to = {}; 
     149            var to = {}; 
    150150            to.div = tabber; 
    151151            tabber.tabber = new tabberObj(to); 
     
    155155            setInputStyles(); 
    156156            if(self.options.data){ 
    157                 for(j = 0; j < self.options.data.permissions.length - 1; j++){ 
    158                     opt = $$("option[value=" + self.options.data.permissions[j] + "]")[0]; 
     157                for(var j = 0; j < self.options.data.permissions.length - 1; j++){ 
     158                    var opt = $$("option[value=" + self.options.data.permissions[j] + "]")[0]; 
    159159                    selectedPermissions.add(opt, null); 
    160160                } 
     
    174174        this.options.content.setStyle("padding", "10px;"); 
    175175         
    176         actionDiv = new Element("div", {style: "text-align: right"}); 
    177         btnOK = new Element("input", {type: "button", value:"OK", styles: {"width": "80px;"}}); 
    178         btnCancel = new Element("input", {type: "button", value:"Cancel", style: "margin-right: 20px"}); 
     176        var actionDiv = new Element("div", {style: "text-align: right"}); 
     177        var btnOK = new Element("input", {type: "button", value:"OK", styles: {"width": "80px;"}}); 
     178        var btnCancel = new Element("input", {type: "button", value:"Cancel", style: "margin-right: 20px"}); 
    179179     
    180180        actionDiv.adopt(btnCancel); 
     
    186186         
    187187        btnOK.addEvent("click", function(e){ 
    188             reqFields = [inputId] 
    189             saveURL = "add/" 
     188            var reqFields = [inputId] 
     189            var saveURL = "add/" 
    190190            if(self.options.data){ 
    191191                saveURL = "edit/" + self.options.data.id + "/" 
    192192            } 
    193193             
    194             for(k = 0; k < reqFields.length; k++){ 
     194            for(var k = 0; k < reqFields.length; k++){ 
    195195                if(reqFields[k].value.trim().length == 0){ 
    196196                    alert("Please, fill all the entries marked with a '*'."); 
     
    201201             
    202202             
    203             selectedOptions = [] 
    204             for(k = 0; k < selectedPermissions.length; k++){ 
    205                 opt = selectedPermissions[k]; 
     203            var selectedOptions = [] 
     204            for(var k = 0; k < selectedPermissions.length; k++){ 
     205                var opt = selectedPermissions[k]; 
    206206                selectedOptions.include(opt.value); 
    207207            } 
     
    214214            } 
    215215             
    216             args = { 
     216            var args = { 
    217217                id: inputId.value, 
    218218                description: txtDescription.value.trim(), 
     
    220220            } 
    221221                         
    222             xhr = new XHR({method: "post", 
     222            var xhr = new XHR({method: "post", 
    223223                            onSuccess: function(req){ 
    224224                                try{ 
     
    256256 
    257257function fillTableData(roles){ 
    258     t = $("roles_table").getElement("tbody").empty(); 
    259  
    260     for(index = 0; index < roles.length; index++){ 
    261         r = roles[index]; 
    262         ch = new Element("input", {"type": "checkbox", "id": "chk-" + r.id}); 
    263         lnkEdit = new Element("a", {"href": "javascript:void(null)", "id": "" + r.id}); 
     258    var t = $("roles_table").getElement("tbody").empty(); 
     259 
     260    for(var index = 0; index < roles.length; index++){ 
     261        var r = roles[index]; 
     262        var ch = new Element("input", {"type": "checkbox", "id": "chk-" + r.id}); 
     263        var lnkEdit = new Element("a", {"href": "javascript:void(null)", "id": "" + r.id}); 
    264264        lnkEdit.setText(r.id); 
    265265        lnkEdit.addEvent("click", function(e){ 
     
    267267            openRoleDialog(this.id); 
    268268        }); 
    269         line = [ch, lnkEdit, r.description, r.permissions.join(", ")] 
    270         className = (index % 2 == 0)? "light": "dark"; 
    271         tr = addTableRow(t, line); 
     269        var line = [ch, lnkEdit, r.description, r.permissions.join(", ")] 
     270        var className = (index % 2 == 0)? "light": "dark"; 
     271        var tr = addTableRow(t, line); 
    272272        tr.addClass(className); 
    273273    } 
     
    278278        onComplete: fillTableData, 
    279279        onFailure: function(req){ 
    280             t = $("roles_table").getElement("tbody").empty(); 
     280            var t = $("roles_table").getElement("tbody"); 
     281            emptyTBody(t); 
    281282            addTableRow(t, [{"value": "Error loading data. Please see umitweb.log for details.", "attrs": {"colSpan": "4"}}], {"class": "error"}); 
    282283        } 
     
    311312    $("delete-role").addEvent("click", function(e){ 
    312313        new Event(e).stop(); 
    313         ids = []; 
     314        var ids = []; 
    314315        $$("input[type=checkbox]").each(function(inp){ 
    315316            if(inp.checked){ 
     
    331332        new Event(e).stop(); 
    332333        this.send({onComplete: function(req){ 
    333             roles = null; 
     334            var roles = null; 
    334335            eval("roles = " + req); 
    335336            if(roles.length == 0){ 
     
    340341        }, 
    341342        onFailure: function(req){ 
    342             t = $("roles_table").getElement("tbody").empty(); 
     343            var t = $("roles_table").getElement("tbody").empty(); 
    343344            addTableRow(t, [{"value": "Error loading data. Please see umitweb.log for details.", "attrs": {"colSpan": "5"}} ], {"class": "error"}); 
    344345        }}); 
  • branch/UmitWeb/share/umit/umitweb_media/js/scan-dialog.js

    r1408 r3432  
    3030        selectScan = new Element("select", {"name": "scanId"}); 
    3131        selectScan.setStyle("width", "60px"); 
    32         opt = new Element("option"); 
    33         opt.setText("--- Select a saved scan ---"); 
    34         opt.value = "0"; 
    35         selectScan.add(opt, null); 
    36         selectScan.setStyle("width", "300px;"); 
     32        opt = new Element("option", {"value": "0"}); 
     33        opt.text = "--- Select a saved scan ---"; 
     34        try{ 
     35            selectScan.add(opt, null); 
     36        }catch(e){ 
     37            //IE only 
     38            selectScan.add(opt); 
     39        } 
     40        try{ 
     41            selectScan.setStyle("width", "300px;"); 
     42        }catch(e){ 
     43            // IE doesn't support <select> resizing 
     44        } 
    3745        selectScan.addEvent("focus", function(e){ 
    3846            rdDatabase.checked = true; 
     
    4250                scans.each(function(s){ 
    4351                    opt = new Element("option", {"value": s.id}); 
    44                     opt.setText(s.name + " (" + s.date + ")"); 
    45                     selectScan.add(opt, null); 
     52                    opt.text = s.name + " (" + s.date + ")"; 
     53                    try{ 
     54                        selectScan.add(opt, null); 
     55                    }catch(e){ 
     56                        selectScan.add(opt); 
     57                    } 
    4658                }); 
    4759            } 
     
    6072        frm.adopt(fieldSetDatabase); 
    6173        frm.adopt(btnSubmit); 
    62         self = this 
     74        var thisDialog = this; 
    6375        frm.addEvent("submit", function(e){ 
    6476            iFrame.addEvent("load", function(e2){ 
     77                var txt = null; 
     78                 
     79                if(window.ie){ 
     80                    txt = this.contentWindow.document.getElementsByTagName("pre")[0].innerText; 
     81                }else{ 
     82                    txt = this.contentDocument.getElementsByTagName("pre")[0].textContent; 
     83                } 
     84                 
    6585                try{ 
    66                     result = Json.evaluate(this.contentDocument.getElementsByTagName("pre")[0].textContent); 
     86                    result = Json.evaluate(txt); 
    6787                    if(result.result == "OK" && $defined(result.output.full)){ 
    6888                        varData = result.output.full; 
     
    80100                    } 
    81101                }catch(e){ 
    82                     $("nmap-output").setText(this.contentDocument.getElementsByTagName("pre")[0].textContent); 
     102                    $("nmap-output").setText(txt); 
    83103                } 
    84104            }); 
     
    143163        this.options.content.adopt(iFrame); 
    144164        this.options.content.adopt(frm); 
    145         self = this; 
     165        var thisDialog = this; 
    146166        frm.addEvent("submit", function(e){ 
    147167             
     
    165185                            if(response.result == "OK"){ 
    166186                                alert("Scan saved succefully!"); 
    167                                 self.close(); 
     187                                thisDialog.close(); 
    168188                            }else{ 
    169189                                alert("Error loading data. Check umitweb.log for details."); 
  • branch/UmitWeb/share/umit/umitweb_media/js/scan.js

    r3191 r3432  
     1var h; 
     2 
    13function loadHosts(hosts){ 
    2         tbHosts = $("hosts_table").getElement("tbody").empty(); 
    3         for(iH = 0; iH < hosts.length; iH++){ 
    4                 h = hosts[iH] 
     4        var tbHosts = $("hosts_table").getElement("tbody"); 
     5        emptyTBody(tbHosts); 
     6        for(var iH = 0; iH < hosts.length; iH++){ 
     7                h = hosts[iH]; 
     8                var txt = ""; 
    59                if(h.hostnames.length > 0){ 
    6                         txt = h.hostnames[0].hostname 
     10                        txt = h.hostnames[0].hostname; 
    711                }else{ 
    8                         txt = h.ip.addr 
    9                 } 
    10                  
    11                 img_src = '/media/images/unknown_24.png'; 
     12                        txt = h.ip.addr; 
     13                } 
     14                 
     15                var img_src = '/media/images/unknown_24.png'; 
    1216                if($defined(h.osmatch.name) && h.osmatch.name != ""){ 
    13                         oses = {"irix": "irix", 
     17                        var oses = {"irix": "irix", 
    1418                                "solaris": "solaris", 
    1519                                "linux": "linux", 
    1620                                "freebsd": "freebsd", 
    17                                 "macos x": "macosx", 
     21                                "mac os x": "macosx", 
    1822                                "openbsd": "openbsd", 
    1923                                "windows": "win", 
     
    2125                                "red hat": "redhat"} 
    2226                        img_src = "/media/images/default_24.png" 
    23                         for(k in oses){ 
     27                        for(var k in oses){ 
    2428                                if(h.osmatch.name.toLowerCase().contains(k)){ 
    25                                         img_src = "/media/images/" + oses[k] + "_24.png" 
     29                                        img_src = "/media/images/" + oses[k] + "_24.png"; 
     30                                        break; 
    2631                                } 
    2732                        } 
    2833                } 
    29                 img = new Element("img", {'src': img_src}); 
    30                  
    31                 lnk = new Element("a", {'href': 'javascript:void(null)'}); 
    32                 vX = iH 
     34                var img = new Element("img", {'src': img_src}); 
     35                 
     36                var lnk = new Element("a", {'href': 'javascript:void(null)'}); 
     37                var vX = iH 
    3338                lnk.addEvent("click", function(e){ 
    3439                        e = new Event(e); 
    35                         pId = this.parentNode.parentNode.getAttribute("id").substr("host-".length); 
     40                        var pId = this.parentNode.parentNode.getAttribute("id").substr("host-".length); 
    3641                        selectHost(e, hosts, pId); 
    3742                }); 
     
    115120 
    116121function loadPortsTab(pHosts){ 
    117         tbody = $("ports_table").getElement("tbody").empty(); 
    118         lines = new Array(); 
    119         count = 0; 
    120         for(k = 0; k < pHosts.length; k++){ 
    121                 for(i = 0; i < pHosts[k].ports.length; i++){ 
    122                         for(j = 0; j < pHosts[k].ports[i].port.length; j++){ 
    123                                 port = pHosts[k].ports[i].port[j]; 
    124                                 img = new Element("img"); 
     122        var tbody = $("ports_table").getElement("tbody"); 
     123        emptyTBody(tbody); 
     124        var lines = new Array(); 
     125        var count = 0; 
     126        for(var k = 0; k < pHosts.length; k++){ 
     127                for(var i = 0; i < pHosts[k].ports.length; i++){ 
     128                        for(var j = 0; j < pHosts[k].ports[i].port.length; j++){ 
     129                                var port = pHosts[k].ports[i].port[j]; 
     130                                var img = new Element("img"); 
    125131                                img.src = "/media/images/" + ((port.port_state == "open")? "open": "closed") + ".png"; 
    126132                                if(port.port_state == "open"){ 
    127133                                        img.src = "/media/images/open.png"; 
    128134                                }else{ 
    129                                         img 
     135                                         
    130136                                } 
    131                                 found = false; 
     137                                var found = false; 
    132138                                for(m = 0; m < lines.length; m++){ 
    133139                                        if(lines[m][1] == port.portid){ 
     
    145151        } 
    146152        for(k = 0; k < lines.length; k++){ 
    147                 addTableRow(tbody, lines[k]) 
     153                addTableRow(tbody, lines[k]); 
    148154        } 
    149155} 
     
    196202                tbl = new Element("table"); 
    197203                 
    198                 img_src = "/media/images/unknown_48.png" 
     204                var img_src = "/media/images/unknown_48.png"; 
    199205                if($defined(h.osmatch.name) && h.osmatch.name != ""){ 
    200206                        oses = {"irix": "irix", 
     
    208214                                "red hat": "redhat"} 
    209215                        img_src = "/media/images/default_48.png"; 
    210                         for(k in oses){ 
     216                        for(var k in oses){ 
    211217                                if(h.osmatch.name.toLowerCase().contains(k)){ 
    212218                                        img_src = "/media/images/" + oses[k] + "_48.png" 
     219                                        break; 
    213220                                } 
    214221                        } 
     
    548555        }); 
    549556         
    550         st = $("hosts_s_table").getElement("tbody").empty(); 
     557        st = $("hosts_s_table").getElement("tbody") 
     558        emptyTBody(st); 
    551559        $("hosts_s_table_placeholder").setStyle("display", "block"); 
    552560        $("ports_table_placeholder").setStyle("display", "none"); 
     
    575583    ports = scan.list_port; 
    576584    if(ports){ 
    577         services = new Array(); 
     585         
     586            resultServices = []; 
    578587        ports.each(function(port){ 
    579             st = $("services_table").getElement("tbody"); 
    580             lnk = new Element("a", {"href": "javascript:void(null)"}); 
     588            var st = $("services_table").getElement("tbody"); 
     589             
     590            var lnk = new Element("a", {"href": "javascript:void(null)"}); 
    581591            lnk.setText(port.service_name); 
    582592            lnk.addEvent("click", function(e){ 
     
    584594                selectService(scan, port.service_name, e); 
    585595            }); 
    586             if(!services.contains(port.service_name)){ 
    587                 services.include(port.service_name); 
    588                 addTableRow(st, [lnk], {"id": "service-" + port.service_name}); 
    589             } 
    590         }) 
     596                if(!resultServices.contains(port.service_name)){ 
     597                    resultServices.include(port.service_name); 
     598                    addTableRow(st, [lnk], {"id": "service-" + port.service_name}); 
     599            } 
     600        }); 
    591601    } 
    592602} 
     
    704714                              onFailure: function(req){ 
    705715                                $("nmap-output").removeClass("ajax-loading"); 
    706                                 $("hosts_table").getElement("tbody").empty(); 
     716                                emptyTBody($("hosts_table").getElement("tbody")); 
     717                                 
    707718                                if(req.status == 200){ 
    708719                                        $("nmap-output").setHTML(req.responseText); 
     
    732743                result_box.empty().addClass("ajax-loading"); 
    733744                tbHosts = $("hosts_table").getElement("tbody"); 
    734                 tbHosts.empty(); 
     745                emptyTBody(tbHosts); 
    735746                tr = new Element("tr"); 
    736747                td1 = new Element("td"); 
     
    743754                //tr2 = tr.cloneNode(); 
    744755                 
    745                 $("ports_table").getElement("tbody").empty(); 
     756                emptyTBody($("ports_table").getElement("tbody")); 
    746757                $("hosts_tab").empty(); 
    747758                $("scan_details").empty(); 
    748759                $("tabber-result").tabber.tabShow(1); 
    749                 $("services_table").getElement("tbody").empty(); 
    750                 $("profile_name").value = $("profiles")[$("profiles").selectedIndex].textContent 
    751          
    752                 /*reqObj = $("frmScan").send({onComplete: function(tResult){ 
    753                                 result = Json.evaluate(tResult); 
    754                                 if(result.result == "OK"){ 
    755                                             checkScanStatus(result.id) 
    756                                 }else{ 
    757                                             result_box.removeClass("ajax-loading").addClass("ajax-error"); 
    758                                             result_box.setText(result.status); 
    759                                 } 
    760                           }, 
    761                           onFailure: function(req){ 
    762                             result_box.removeClass("ajax-loading"); 
    763                             $("hosts_table").getElement("tbody").empty(); 
    764                             if(req.status == 200){ 
    765                                 $("nmap-output").setHTML(req.responseText); 
    766                             }else{ 
    767                                 showError(req, "nmap-output"); 
    768                             } 
    769                             scanLock = false; 
    770                           } 
    771                 }); 
    772                 reqObj.$events.onStateChange = [function(req){ 
    773                         alert(req.readyState); 
    774                         request = req; 
    775                         if(req.readyState == 3){ 
    776                                 checkIfFinished(); 
    777                         } 
    778                 }]*/ 
     760                emptyTBody($("services_table").getElement("tbody")); 
     761                var txtContent = $("profiles")[$("profiles").selectedIndex].textContent; 
     762                $("profile_name").value = txtContent; 
    779763         
    780764                args = { 
  • branch/UmitWeb/tests/browser_compability.txt

    r989 r3432  
    55| output highlight  |           *          |          *          |   *   |   *     |   *    | 
    66|-------------------|----------------------|---------------------|-------|---------|--------|   
    7 | hosts panel       |           *          |          *          |   *   |   *     |        | 
     7| hosts panel       |           *          |          *          |   *   |   *     |   x    | 
    88|-------------------|----------------------|---------------------|-------|---------|--------| 
    9 | services panel    |           *          |          *          |   *   |   *     |        | 
     9| services panel    |           *          |          *          |   *   |   *     |   x    | 
    1010|-------------------|----------------------|---------------------|-------|---------|--------| 
    11 | sw hosts/services |                      |          *          |   *   |   *     |        | 
     11| sw hosts/services |           x          |          *          |   *   |   *     |   x    | 
    1212|-------------------|----------------------|---------------------|-------|---------|--------| 
    13 | foldings          |                      |                     |   *   |   *     |   *    | 
     13| foldings          |           x          |          x          |   *   |   *     |   *    | 
     14|-------------------|----------------------|---------------------|-------|---------|--------| 
     15| dialogs           |           x          |          x          |   -   |   *     |   *    | 
     16|-------------------|----------------------|---------------------|-------|---------|--------| 
    1417|___________________|______________________|_____________________|_______|_________|________| 
     18 
     19* working 
     20x not working 
     21- partially working 
     22 
     23Notes: 
     24 
     25Opera: 
     26  - Dialog opens, but it closes the whole browser window when you click on the 'X' button 
  • branch/UmitWeb/umitCore/Paths.py

    r3232 r3432  
    2424from os.path import exists, join, split, abspath 
    2525import sys 
     26 
     27from types import StringTypes 
    2628 
    2729from umitCore.UmitLogging import log 
     
    3335from umitCore.BasePaths import ICONS_DIR, PIXMAPS_DIR, DOCS_DIR 
    3436 
    35 UMIT_ICON = join(main_dir, "share", "icons", "umit_48.ico") 
     37UMIT_ICON = join("share", "icons", "umit_48.ico") 
    3638 
    3739 
  • branch/UmitWeb/umitWeb/WebConf.py

    r3191 r3432  
    2323from umitWeb.WebLogger import getLogger 
    2424 
    25 class JsOutputHighlight(NmapOutputHighlight, object): 
     25class JsOutputHighlight(NmapOutputHighlight): 
    2626    logger  = getLogger("JsOutputHighlight") 
    2727     
    2828    def __init__(self, *args): 
    2929        NmapOutputHighlight.__init__(self, *args) 
    30         self.read(Path.webconfig_file) 
     30        self.parser.read(Path.webconfig_file) 
  • branch/UmitWeb/umitWeb/views/compare_results.py

    r2779 r3432  
    6464    data.append("'modified': '#%s%s%s'" % tuple(map(toHex, dc.modified))) 
    6565    data.append("'not_present': '#%s%s%s'" % tuple(map(toHex, dc.not_present))) 
    66     response.write("diff_colors = {%s}" % ",".join(data)) 
     66    response.write("var diff_colors = {%s}" % ",".join(data)) 
    6767    return response 
    6868 
  • branch/UmitWeb/umitWeb/views/scan.py

    r3191 r3432  
    136136                parser.set_xml_file(req.FILES['scan_result']['temp_file']) 
    137137                parser.parse() 
    138                 parsed_scan = __scan_to_json(parser) 
     138                parsed_scan = ScanJsonParser(parser).parse() 
    139139                junk = r"odpojfsdkjfpisudŕij208u-0w9rsdnfkdfçwrtwqr/fsasd~/???çds" 
    140140                key = md5.new(str(random.randint(0, sys.maxint-1)) \ 
     
    143143                req.session['scan_result_' + key] = open(req.FILES['scan_result']['temp_name'], 'r').read() 
    144144                text_out = parser.nmap_output.replace("'", "\\'").replace("\r", "").replace("\n", "\\n' + \n'") 
    145                 parsed_scan = str(parsed_scan).replace("\n", "\\n' + \n'") 
     145                parsed_scan = parsed_scan.replace("\n", "\\n' + \n'") 
    146146                return HttpResponse(("{'result': 'OK', 'id': '%s', 'output': " + \ 
    147147                                    "{'plain': '%s', 'full': %s}}") % \ 
     
    164164                                (parser.get_nmap_output().replace("'", "\\'").\ 
    165165                                replace("\r", "").replace("\n", "\\n' + \n'"), 
    166                                 str(__scan_to_json(parser))),  
     166                                ScanJsonParser(parser).parse()),  
    167167                                "text/plain") 
    168168    else: 
     
    171171@authenticate(ERROR) 
    172172def save_result(req, scan_id): 
    173     print req.POST 
    174173    if req.POST: 
    175174        scan = req.session.get("scan_result_" + scan_id, None) 
  • branch/UmitWeb/umitweb.py

    r1513 r3432  
    4040 
    4141def main(): 
    42     if sys.platform.startswith("linux"): 
     42    if sys.platform in ["linux" "darwin"]: 
    4343        if os.getuid() != 0: 
    4444            raise Exception, "Server MUST run as root."