]> granicus.if.org Git - jq/commitdiff
Add “Run” button to execute examples on jqplay.org 573/head
authorJingwen Owen Ou <jingweno@gmail.com>
Tue, 9 Sep 2014 05:34:13 +0000 (22:34 -0700)
committerJingwen Owen Ou <jingweno@gmail.com>
Tue, 9 Sep 2014 05:41:54 +0000 (22:41 -0700)
manual/index.html

index 4df3598fa1b5ed2e3e778baa0be4aa7809eb410d..99f9cb1b32a0e52978b3f2de20b0de6cbd232673 100644 (file)
                   }
                 });
               });
+
+            // 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"