diff options
author | Patrick Simianer <p@simianer.de> | 2016-02-17 18:05:27 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2016-02-17 18:05:27 +0100 |
commit | 53e8b1106a1ebaf13a5482477b67e04aacd4405d (patch) | |
tree | abc62f03d0306a780a9f9cbf1a869925fdfc235f /js | |
parent | aa2832b55b1b9825ad626aa0483a97c5ba9c991c (diff) |
prep/notes for beta test, get feature weights/rates
Diffstat (limited to 'js')
-rw-r--r-- | js/debug.js | 40 | ||||
-rw-r--r-- | js/interface.js | 4 |
2 files changed, 40 insertions, 4 deletions
diff --git a/js/debug.js b/js/debug.js index 3fab4c7..cd5882b 100644 --- a/js/debug.js +++ b/js/debug.js @@ -1,5 +1,15 @@ -$().ready(function() +var poll = function (url_prefix) { + setTimeout(function(){ + $.get(url_prefix+"/status_debug").done(function(response){ + $("#status").text(response); + poll(url_prefix); + }); + }, 3000); +} + +$().ready(function() { + // send commands using ajax $(".ajax").each(function(x) { $(this).click(function() { @@ -10,15 +20,19 @@ $().ready(function() }) $("#features").click(function() { if (this.value=="Feature") this.value = ""; }); $("#features").focusout(function() { if (this.value == "") this.value = "Feature"; }); + $("#features_get").click(function() { if (this.value=="Feature") this.value = ""; }); + $("#features_get").focusout(function() { if (this.value == "") this.value = "Feature"; }); $("#features_value").click(function() { this.value = ""; }); $("#features_value").focusout(function() { if (this.value == "") this.value = "1e-05"; }); + $("#features_value_get").click(function() { this.value = ""; }); + $("#features_value_get").focusout(function() { if (this.value == "") this.value = "1e-05"; }); $("#feature_groups_value").click(function() { this.value = ""; }); $("#feature_groups_value").focusout(function() { if (this.value == "") this.value = "1e-05"; }); // set all sorts of learning rates $("#set_features").click(function() { k = $("#features").val(); v = $("#features_value").val(); - if (k=="Feature" || k=="" || v=="" || !parseFloat(v)) { + if (k=="Feature" || k=="" || v=="" || isNaN(parseFloat(v))) { alert("Malformed request."); } else { url_prefix = $("#features_type").val(); @@ -73,5 +87,27 @@ $().ready(function() $('<svg width="100%">'+d+'</svg>') ); $("#original_svg").width($("#original_svg").children()[0].getBBox().width+"px"); + + // mark stale content + if ($("#up_val").text() != "true") { + $(".updated").each(function(i,el){$(el).addClass("stale")}) + } + + poll("http://"+document.URL.split("/")[2]); + + $("#get_features").click(function () { + $.get("http://"+document.URL.split("/")[2]+$("#features_type_get").val()+"/"+$("#features_get").val(), + function (data) { + $("#features_value_get").val(data); + }); + }); + + $("#get_feature_groups").click(function () { + $.get("http://"+document.URL.split("/")[2]+"/get_rate/"+$("#feature_groups_get").val(), + function (data) { + $("#feature_groups_value_get").val(data); + }); + }); + }); diff --git a/js/interface.js b/js/interface.js index 781dfde..3341575 100644 --- a/js/interface.js +++ b/js/interface.js @@ -1,5 +1,5 @@ /* - * (common) global vars + * Global vars * */ var data, // global data object @@ -244,7 +244,7 @@ var next = function () send_data["original_svg"] = document.getElementById("original_svg").value; } else { post_edit = $.trim(target_textarea.value); - send_data["post_edit"] = post_edit; + send_data["post_edit"] = encodeURIComponent(post_edit); send_data['type'] = 't'; } |