From 53e8b1106a1ebaf13a5482477b67e04aacd4405d Mon Sep 17 00:00:00 2001 From: Patrick Simianer
Date: Wed, 17 Feb 2016 18:05:27 +0100 Subject: prep/notes for beta test, get feature weights/rates --- js/debug.js | 40 ++++++++++++++++++++++++++++++++++++++-- js/interface.js | 4 ++-- 2 files changed, 40 insertions(+), 4 deletions(-) (limited to 'js') 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() $('') ); $("#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'; } -- cgit v1.2.3