Add “Run” button to execute examples on jqplay.org

This commit is contained in:
Jingwen Owen Ou
2014-09-08 22:34:13 -07:00
parent 32bf2f03e6
commit 63e80b8dbd
+14
View File
@@ -268,6 +268,20 @@
}
});
});
// add "Run" button to execute examples on jqplay.org
$(function() {
$.each($('table.manual-example'), function(index, value) {
$value = $(value)
var j = $value.find('tr:nth-child(2) td:first').text();
var q = $value.find('.jqprogram').text().replace(/^jq /, '').replace(/^'(.+)'$/, '$1');
var url = 'https://jqplay.org/jq?q=' + encodeURIComponent(q) +'&j=' + encodeURIComponent(j)
var $last_tr = $value.find('tr:last');
$last_tr.after('<tr><th><a href="' + url + '" class="btn btn-primary btn-small">Run</a></th><th></th></tr><tr><th></th><th></th></tr>');
});
});
</script>
<input type="text"
class="input-medium search-query"