w2v-server: improve self-links in tsne-map and som
diff --git a/templates/index.html.ep b/templates/index.html.ep
index 0a2a408..3f4de00 100644
--- a/templates/index.html.ep
+++ b/templates/index.html.ep
@@ -62,7 +62,6 @@
}
% use Mojo::ByteStream 'b';
- % my $urlprefix = url_with->query([word=>'']);
var paraResults = <%= b(Mojo::JSON::to_json($lists)) %>;
var urlprefix = new URLSearchParams(window.location.search);
if (paraResults.length > 0 && paraResults[0] != null) {
@@ -76,7 +75,7 @@
nranks = nranks.concat(paraResults[i].map(function(a){return a.rank;}));
nmarked = nmarked.concat(paraResults[i].map(function(a){return a.marked;}));
}
- showMap({target: " "+urlParams.get('word')+" ", mergedEnd: 0, words: nwords, vecs: nvecs, ranks: nranks, marked: nmarked, urlprefix: "?"+urlprefix} );
+ showMap({target: " "+urlParams.get('word')+" ", mergedEnd: 0, words: nwords, vecs: nvecs, ranks: nranks, marked: nmarked} );
var t = $('#firsttable').DataTable({
data: paraResults[0],
"sScrollY": "780px",
@@ -500,8 +499,8 @@
T.Y[i][0] = (d.x - mapWidth/2 - tx)/ss/20;
T.Y[i][1] = (d.y - mapHeight/2 - ty)/ss/20;
return "translate(" +
- (d.x) + "," +
- (d.y) + ")";
+ (d.x) + "," +
+ (d.y) + ")";
});
}
@@ -511,8 +510,8 @@
.data(data.words)
.attr("transform", function(d, i) {
return "translate(" +
- ((Y[i][0]*20*ss + tx) + mapWidth/2) + "," +
- ((Y[i][1]*20*ss + ty) + mapHeight/2) + ")"; });
+ ((Y[i][0]*20*ss + tx) + mapWidth/2) + "," +
+ ((Y[i][1]*20*ss + ty) + mapHeight/2) + ")"; });
}
var svg;
@@ -522,6 +521,9 @@
function drawEmbedding() {
var urlprefix = new URLSearchParams(window.location.search);
+ urlprefix.delete("word");
+ urlprefix.append("word","");
+
$("#embed").empty();
var div = d3.select("#embed");
@@ -539,7 +541,7 @@
g.append("a")
.attr("xlink:href", function(word) {
- urlprefix.set("word", word); return "?"+urlprefix; })
+ return "?"+urlprefix+word; })
.attr("class", function(d, i) {
var res="";
if(data.marked[i]) {
@@ -616,12 +618,12 @@
// setTimeout(updateEmbedding, 1);
// setTimeout(
- labeler = d3.labeler()
- .label(labels)
- .anchor(anchor_array)
- .width(mapWidth)
- .height(mapHeight)
- .update(applyJitter);
+ labeler = d3.labeler()
+ .label(labels)
+ .anchor(anchor_array)
+ .width(mapWidth)
+ .height(mapHeight)
+ .update(applyJitter);
// .start(1000);
iter_id = setInterval(jitterStep, 1);