w2v-server: improve self-links in tsne-map and som
diff --git a/js/som.js b/js/som.js
index ca16d28..e496d36 100644
--- a/js/som.js
+++ b/js/som.js
@@ -135,7 +135,10 @@
// var avg, avgsim1, avgsim2, minsim;
var refIndex;
var colorScale;
-
+ var urlprefix = new URLSearchParams(window.location.search);
+ urlprefix.delete("word");
+ urlprefix.append("word","");
+
if(no_targets > 1) {
refIndex=1;
colorScale = d3.scale.linear()
@@ -192,7 +195,7 @@
.enter().append("g")
.attr("class", "u");
g.append("a")
- .attr("xlink:href", function(word) {return data.urlprefix+word;})
+ .attr("xlink:href", function(word) {return "?"+urlprefix+word;})
.attr("title", function(d, i) {
return "rank: "+i +" "+"freq. rank: "+data.ranks[i].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
})
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);