w2v-server.pl: fix cost info, stop when cost stays constant for 250 iterations
diff --git a/w2v-server.pl b/w2v-server.pl
index e37ef3b..c92400b 100644
--- a/w2v-server.pl
+++ b/w2v-server.pl
@@ -324,14 +324,13 @@
 }
 
 svg > .ui-tooltip-content {
-	font-size: 7pt;
+	font-size: 8pt;
 	colour: #222222;
 }
 
 svg {
-//  border: 1px solid #333;
-  margin-right: 10px;
-  margin-bottom:10px;
+    margin-right: 10px;
+    margin-bottom: 10px;
 }
 #wrapper {
     width: 100%;
@@ -339,21 +338,18 @@
     overflow: hidden; /* will contain if #first is longer than #second */
 }
 #first {
- margin-right: 20px;
-    float:left; /* add this */
-//    border: 1px solid green;
+    margin-right: 20px;
+    float: left;
+ //    border: 1px solid green;
 }
 #second {
     border: 1px solid #333;
-	  height: 850px;
     overflow: hidden; /* if you don't want #second to wrap below #first */
 }
 #cost {
-	z-index: 1;
-	position: fixed;
-	font-size: 10px;
-	color: #222222;
-  margin-bottom: 10px;
+	  font-size: 8pt;
+	  color: #222222;
+    margin-top: 4px;
 }
 </style>
 <script>
@@ -496,15 +492,23 @@
 	      applyJitter();
     }
 }
- 
+
+var last_cost=1000;
+
  function step() {
    var i = T.iter;
+   
    if(i > <%= $no_iterations %>) {
 		 stopStep();
    } else {
-     var cost = Math.round(T.step() *1000) / 1000; // do a few steps
-     $("#cost").html("tsne iteration " + i + ", cost: " + cost.toFixed(3));
-     updateEmbedding();
+     var cost = Math.round(T.step() *100000) / 100000; // do a few steps
+     $("#cost").html("tsne iteration " + i + ", cost: " + cost.toFixed(5));
+       if(i % 250 == 0 && cost >= last_cost) {
+		       stopStep();
+       } else {
+           last_cost = cost;
+           updateEmbedding();
+       }
    }
  }
 
@@ -582,8 +586,8 @@
 		<div id="second" style="width:800px; height:800px; font-family: arial;">
 			<div id="embed">
 			</div>
-			<div id="cost"></div>
 		</div>
+    <div id="cost"></div>
   </div>
 	<p>
 		Word vector model based on  DeReKo-2015-II. Trained with <a href="https://code.google.com/p/word2vec/">word2vec</a> using the following parameters:</p>