Commits

Gregory Petukhov committed 569b1c6

Add iter count feature

Comments (0)

Files changed (3)

 *.swp
 *.swo
 *.orig
+update.sh
 
 # Project specific
 
 <div class="container">
     <div class="row">
         <div class="span2">
-            <button class="btn btn-info" onclick="createNewPage()">New page</button>
-            <br/>
-            <br/>
-            <button class="btn btn-success" onclick="calculatePageRank()">Calculate PR</button>
-            <br/>
-            <br/>
-            <button class="btn btn-warning" onclick="resetAll()">Reset All</button>
-            <br/><br/>
+            <button class="btn btn-small btn-info" onclick="createNewPage()">New page</button>
+            <button class="btn btn-small btn-warning" onclick="resetAll()">Reset All</button>
+            <hr>
             <form>
                 <label class="checkbox">
                     <input checked="checked" name="auto-calc" type="checkbox" /> Auto Calculation
                 </label>
+                <input class="input-mini" value="5" name="iteration-count" type="text" />
+                <span class="help-inline">Iterations</span>
             </form>
+            <button class="btn btn-small btn-success" onclick="calculatePageRank()">Calculate PR</button>
+            <hr>
             <h3>Links</h3>
             <ul id="page-link-list" class="unstyled">
             </ul>

static/js/util.js

         page.rank_new = 0;
     });
 
-    for(var x=0; x<5; x++) {
+    var iterationCount = parseInt($('input[name="iteration-count"]').val());
+    if (isNaN(iterationCount)) {
+        iterationCount = 5;
+    }
+    for(var x=0; x<iterationCount; x++) {
         $.each(pageRegistry, function(pid, page) {
             if (page.links.length) {
                 var rank_share = page.rank / page.links.length;
                     var dst = pageRegistry[link_id];
                     dst.rank_new += rank_share;
                 });
+            } else {
+                page.rank_new += page.rank;
             }
         });
         $.each(pageRegistry, function(pid, page) {