diff --git a/www/js/views/SearchViews.js b/www/js/views/SearchViews.js index c5c321ae..eabb5923 100644 --- a/www/js/views/SearchViews.js +++ b/www/js/views/SearchViews.js @@ -33,13 +33,14 @@ define(function (require) { addNewRS = function (model, strTarget) { var refstrings = model.get("refstring"), selectedIndex = 0, + i = 0, curDate = new Date(), timestamp = (curDate.getFullYear() + "-" + (curDate.getMonth() + 1) + "-" + curDate.getDay() + "T" + curDate.getUTCHours() + ":" + curDate.getUTCMinutes() + ":" + curDate.getUTCSeconds() + "z"), found = false; console.log("addNewRS - attempting to add: " + strTarget); // sanity check -- is this refstring already there? // add or increment the new value - for (var i = 0; i < refstrings.length; i++) { + for (i = 0; i < refstrings.length; i++) { if (refstrings[i].target === strTarget) { // This RefString already exists in the KB - no work to do found = true; @@ -65,6 +66,35 @@ define(function (require) { // model.update(); model.save(); console.log("addNewRS - saving model"); + $("#RefStrings").html(theRefStrings(refstrings)); + // set the frequency meters for each refstring + for (i = 0; i < refstrings.length; i++) { + if (strTarget.length > 0) { + // looking to select a refstring after redrawing + if (refstrings[i].target === strTarget) { + selectedIndex = i; // found it + } + } + if (refstrings[i].n > 0) { + // normal refstring instance + $("#pct-" + i).width((Math.round(refstrings[i].n / refstrings[0].n * 90) + 10) + "%"); + } else { + // deleted refstring + $("#pct-" + i).width("0%"); + $("#rs-" + i).addClass("deleted"); + } + } + if (strTarget.length > 0) { + // now select the index we found + $("#rs-" + selectedIndex).click(); + } + // // add the new item to the UI + // // (the _full_ refstring list is templated; see RefStringList.html) + // var liRS = "