Diff
Not logged in

Differences From:

File src/timeline.c part of check-in [a028affcf2] - Fix a bug in the javascript generator of the previous check-in. by drh on 2007-08-27 04:09:07. [view]

To:

File src/timeline.c part of check-in [53416550852e] - Fix a bug in the javascript. Only versions that are independent of the mouse-over version are grayed out now. by drh on 2007-08-27 05:02:17. [view]

@@ -166,9 +166,9 @@
 static int save_parentage_javascript(int rid, Blob *pOut){
   const char *zSep;
   Stmt q;
 
-  db_prepare(&q, "SELECT pid FROM plink WHERE cid=%d AND isprim!=0", rid);
+  db_prepare(&q, "SELECT pid FROM plink WHERE cid=%d", rid);
   zSep = "";
   blob_appendf(pOut, "parentof[\"m%d\"] = [", rid);
   while( db_step(&q)==SQLITE_ROW ){
     int pid = db_column_int(&q, 0);
@@ -176,9 +176,9 @@
     zSep = ",";
   }
   db_finalize(&q);
   blob_appendf(pOut, "];\n");
-  db_prepare(&q, "SELECT cid FROM plink WHERE pid=%d AND isprim!=0", rid);
+  db_prepare(&q, "SELECT cid FROM plink WHERE pid=%d", rid);
   zSep = "";
   blob_appendf(pOut, "childof[\"m%d\"] = [", rid);
   while( db_step(&q)==SQLITE_ROW ){
     int pid = db_column_int(&q, 0);
@@ -249,13 +249,16 @@
   @     setone(x,value);
   @   }
   @ }
   @ function setone(id, onoff){
+  @   if( parentof[id]==null ) return 0;
   @   var w = document.getElementById(id);
-  @   if( onoff==1 ){
-  @     w.style.color = "#000000";
+  @   var clr = onoff==1 ? "#000000" : "#a0a0a0";
+  @   if( w.style.color==clr ){
+  @     return 0
   @   }else{
-  @     w.style.color = "#a0a0a0";
+  @     w.style.color = clr
+  @     return 1
   @   }
   @ }
   @ function xin(id) {
   @   setall(0);
@@ -266,21 +269,25 @@
   @ function xout(id) {
   @   setall(1);
   @ }
   @ function set_parents(id){
-  @   if( parentof[id]==null ) return;
-  @   for(var x in parentof[id]){
-  @     var pid = parentof[id][x];
-  @     setone(pid,1);
-  @     set_parents(pid);
+  @   var plist = parentof[id];
+  @   if( plist==null ) return;
+  @   for(var x in plist){
+  @     var pid = plist[x];
+  @     if( setone(pid,1)==1 ){
+  @       set_parents(pid);
+  @     }
   @   }
   @ }
   @ function set_children(id){
-  @   if( childof[id]==null ) return;
-  @   for(var x in childof[id]){
-  @     var cid = childof[id][x];
-  @     setone(cid,1);
-  @     set_children(cid);
+  @   var clist = childof[id];
+  @   if( clist==null ) return;
+  @   for(var x in clist){
+  @     var cid = clist[x];
+  @     if( setone(cid,1)==1 ){
+  @       set_children(cid);
+  @     }
   @   }
   @ }
   @ function hilite(id) {
   @   var x = document.getElementById(id);