[Virus] Make webservice output values accessible by css selectors in the API console
Review Request #205 — Created Oct. 25, 2013 and submitted
Information | |
---|---|
pprkut | |
Virus | |
pprkut:trait_fixes | |
Reviewers | |
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.
-
-
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.
-
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.
-
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.
Change Summary:
freshen up HTML output generation a bit. Inspired by Leo's comments :)
Diff: |
Revision 3 (+41 -13) |
---|