[Virus] Make webservice output values accessible by css selectors in the API console

Review Request #205 — Created Oct. 25, 2013 and submitted

pprkut
Virus
pprkut:trait_fixes
Make the webservice output values accessible by CSS selectors in the API console, so we can easier build behaviour tests around them.
Cleanup display of output values a bit in the process.
Local test requests.
pprkut
leo
  1. I'm just proposing some solutions which are a bit more "modern", it's your choice if you want to follow them.
    
    Overall it looks fine.
  2. src/Virus/Core/Html/apiconsole.php (Diff revision 2)
     
     
     
     
     
     
     
     
     
     
     
    I'd do this in the following way:
    
    <?php if ($output !== NULL):
        foreach ($output as $key => $value): ?>
            <tr>
                <td class="json json_key">
                    <?php ehco $key . ':'; ?>
                </td>
                <td class="json" id="<?php echo 'json_display_' . $key; ?>">
                    <?php echo $value; ?>
                </td>
            </tr>
        <?php endforeach;
    endif: ?>
    
    Basically keeping the html out of php.
  3. statics/js/apiconsole.js (Diff revision 2)
     
     
    I think the event needs to be passed as a parameter to the anonymous function in order for the preventDefault() to work.
    1. Might be browser specific. I tested it in Chromium and it works there. And it seems to work fine in phantomjs too, which is the important one.
  4. statics/js/apiconsole.js (Diff revision 2)
     
     
     
     
     
     
     
     
    I'd do this in the following way:
    
    $.each(json, function(key, value) {
        var row = $('<tr></tr>');
        var td1 = $('<td></td>').attr({ class: ["json", "json_key"].join(' ') }).text(key + ':').appendTo(row);
        var td2 = $('<td></td>').attr('class', 'json').attr({ 'id': 'json_display_' + key, 'class': 'json' }).text(value).appendTo(row);
    
        row.appendTo($('#json_display'));
    });
    
    Basically making use of all the jQuery functions which do the job for you, instead of writing HTML in JS strings and using arrays to hold your HTML elements.
  5. 
      
pprkut
dinos
  1. Ship It!
  2. 
      
pprkut
Review request changed

Status: Closed (submitted)

Change Summary:

Merged into master
Loading...