]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Subrotined fetchAutowords bug fixes.
authorMetabox <redacted>
Thu, 16 May 2019 10:36:26 +0000 (20:36 +1000)
committerMetabox <redacted>
Thu, 16 May 2019 10:36:26 +0000 (20:36 +1000)
13 files changed:
dbLifeLog/cgisess_2e753ef24d72c03527610d2b71321ecb [new file with mode: 0644]
dbLifeLog/cgisess_5786940189f56ba90775b375015031a0 [new file with mode: 0644]
dbLifeLog/cgisess_6cd3d053557d46298a1fbaa7d054b402 [new file with mode: 0644]
dbLifeLog/cgisess_6e1acbdb23deb67566251ee45a9d5904 [new file with mode: 0644]
dbLifeLog/cgisess_7dcd14aff3b905fd46843d20c85dc47c [new file with mode: 0644]
dbLifeLog/cgisess_ab26eaf0df06205e2e479dd9e73e2a5e [new file with mode: 0644]
dbLifeLog/cgisess_b03f7e44a56d832aca12b2d0d9885dc5 [new file with mode: 0644]
dbLifeLog/cgisess_e01dfa0dd28affb0d00b72bfff0ff303 [new file with mode: 0644]
dbLifeLog/cgisess_e0bd04e8964c3adabaa754ad2fc1a286 [new file with mode: 0644]
dbLifeLog/cgisess_e373ebf22622cc8b85b94edab5974e30 [new file with mode: 0644]
dbLifeLog/cgisess_e50018bbed297ea9dce239beac458c17 [new file with mode: 0644]
htdocs/cgi-bin/main.cgi
htdocs/cgi-bin/wsrc/main.js

diff --git a/dbLifeLog/cgisess_2e753ef24d72c03527610d2b71321ecb b/dbLifeLog/cgisess_2e753ef24d72c03527610d2b71321ecb
new file mode 100644 (file)
index 0000000..e9db19b
--- /dev/null
@@ -0,0 +1 @@
+$D = {'_SESSION_REMOTE_ADDR' => '127.0.0.1','_SESSION_ID' => '2e753ef24d72c03527610d2b71321ecb','_SESSION_CTIME' => 1557983572,'_SESSION_ATIME' => 1557983572};;$D
\ No newline at end of file
diff --git a/dbLifeLog/cgisess_5786940189f56ba90775b375015031a0 b/dbLifeLog/cgisess_5786940189f56ba90775b375015031a0
new file mode 100644 (file)
index 0000000..dc3bf48
--- /dev/null
@@ -0,0 +1 @@
+$D = {'_SESSION_ID' => '5786940189f56ba90775b375015031a0','_SESSION_REMOTE_ADDR' => '127.0.0.1','_SESSION_CTIME' => 1557987147,'_SESSION_ATIME' => 1557987147};;$D
\ No newline at end of file
diff --git a/dbLifeLog/cgisess_6cd3d053557d46298a1fbaa7d054b402 b/dbLifeLog/cgisess_6cd3d053557d46298a1fbaa7d054b402
new file mode 100644 (file)
index 0000000..5df0ddb
--- /dev/null
@@ -0,0 +1 @@
+$D = {'_SESSION_REMOTE_ADDR' => '127.0.0.1','_SESSION_ATIME' => 1557981471,'_SESSION_ID' => '6cd3d053557d46298a1fbaa7d054b402','_SESSION_CTIME' => 1557981471};;$D
\ No newline at end of file
diff --git a/dbLifeLog/cgisess_6e1acbdb23deb67566251ee45a9d5904 b/dbLifeLog/cgisess_6e1acbdb23deb67566251ee45a9d5904
new file mode 100644 (file)
index 0000000..440fec4
--- /dev/null
@@ -0,0 +1 @@
+$D = {'_SESSION_ATIME' => 1557960216,'_SESSION_REMOTE_ADDR' => '127.0.0.1','_SESSION_ID' => '6e1acbdb23deb67566251ee45a9d5904','_SESSION_CTIME' => 1557960216,'_SESSION_ETIME' => 1800};;$D
\ No newline at end of file
diff --git a/dbLifeLog/cgisess_7dcd14aff3b905fd46843d20c85dc47c b/dbLifeLog/cgisess_7dcd14aff3b905fd46843d20c85dc47c
new file mode 100644 (file)
index 0000000..190bbd2
--- /dev/null
@@ -0,0 +1 @@
+$D = {'_SESSION_REMOTE_ADDR' => '127.0.0.1','_SESSION_CTIME' => 1557974481,'_SESSION_ID' => '7dcd14aff3b905fd46843d20c85dc47c','_SESSION_ATIME' => 1557974481};;$D
\ No newline at end of file
diff --git a/dbLifeLog/cgisess_ab26eaf0df06205e2e479dd9e73e2a5e b/dbLifeLog/cgisess_ab26eaf0df06205e2e479dd9e73e2a5e
new file mode 100644 (file)
index 0000000..b94b8ec
--- /dev/null
@@ -0,0 +1 @@
+$D = {'passw' => '42FAP5H0JUSZM','alias' => 'admin','_SESSION_CTIME' => 1558001039,'_SESSION_ETIME' => 1800,'_SESSION_ID' => 'ab26eaf0df06205e2e479dd9e73e2a5e','_SESSION_ATIME' => 1558002630,'database' => 'data_admin_log.db','_SESSION_REMOTE_ADDR' => '127.0.0.1'};;$D
\ No newline at end of file
diff --git a/dbLifeLog/cgisess_b03f7e44a56d832aca12b2d0d9885dc5 b/dbLifeLog/cgisess_b03f7e44a56d832aca12b2d0d9885dc5
new file mode 100644 (file)
index 0000000..afca6e1
--- /dev/null
@@ -0,0 +1 @@
+$D = {'_SESSION_ATIME' => 1557965056,'_SESSION_CTIME' => 1557965056,'_SESSION_ID' => 'b03f7e44a56d832aca12b2d0d9885dc5','_SESSION_REMOTE_ADDR' => '127.0.0.1'};;$D
\ No newline at end of file
diff --git a/dbLifeLog/cgisess_e01dfa0dd28affb0d00b72bfff0ff303 b/dbLifeLog/cgisess_e01dfa0dd28affb0d00b72bfff0ff303
new file mode 100644 (file)
index 0000000..cbff52f
--- /dev/null
@@ -0,0 +1 @@
+$D = {'_SESSION_CTIME' => 1557995553,'_SESSION_ATIME' => 1557995553,'_SESSION_ID' => 'e01dfa0dd28affb0d00b72bfff0ff303','_SESSION_REMOTE_ADDR' => '127.0.0.1'};;$D
\ No newline at end of file
diff --git a/dbLifeLog/cgisess_e0bd04e8964c3adabaa754ad2fc1a286 b/dbLifeLog/cgisess_e0bd04e8964c3adabaa754ad2fc1a286
new file mode 100644 (file)
index 0000000..d687593
--- /dev/null
@@ -0,0 +1 @@
+$D = {'_SESSION_ID' => 'e0bd04e8964c3adabaa754ad2fc1a286','_SESSION_ATIME' => 1557983463,'_SESSION_REMOTE_ADDR' => '127.0.0.1','_SESSION_CTIME' => 1557983463};;$D
\ No newline at end of file
diff --git a/dbLifeLog/cgisess_e373ebf22622cc8b85b94edab5974e30 b/dbLifeLog/cgisess_e373ebf22622cc8b85b94edab5974e30
new file mode 100644 (file)
index 0000000..a9e4bd7
--- /dev/null
@@ -0,0 +1 @@
+$D = {'_SESSION_CTIME' => 1557960412,'_SESSION_ATIME' => 1557960412,'_SESSION_ETIME' => 1800,'_SESSION_REMOTE_ADDR' => '127.0.0.1','_SESSION_ID' => 'e373ebf22622cc8b85b94edab5974e30'};;$D
\ No newline at end of file
diff --git a/dbLifeLog/cgisess_e50018bbed297ea9dce239beac458c17 b/dbLifeLog/cgisess_e50018bbed297ea9dce239beac458c17
new file mode 100644 (file)
index 0000000..5c293df
--- /dev/null
@@ -0,0 +1 @@
+$D = {'_SESSION_ID' => 'e50018bbed297ea9dce239beac458c17','_SESSION_REMOTE_ADDR' => '127.0.0.1','_SESSION_CTIME' => 1557986965,'_SESSION_ATIME' => 1557986965};;$D
\ No newline at end of file
index 88c064f061c689236093a0ae27d1c6ba3ed7c6fe..ab45a6792e809866cdf285a529e20bfd253b624d 100755 (executable)
@@ -65,10 +65,12 @@ my $tbl_rc_prev = 0;
 my $tbl_cur_id;
 my $rs_keys = $cgi->param('keywords');
 my $rs_cat_idx = $cgi->param('category');
+my $prm_vc = $cgi->param("vc");
 my $rs_dat_from = $cgi->param('v_from');
 my $rs_dat_to = $cgi->param('v_to');
-my $rs_prev = $cgi->param('rs_prev'); 
+my $rs_prev = $cgi->param('rs_prev');
 my $rs_cur = $cgi->param('rs_cur');
+my $rs_page = $cgi->param('rs_page');
 my $stmS = "SELECT rowid, ID_CAT, DATE, LOG, AMMOUNT from LOG WHERE";
 my $stmE = " ORDER BY DATE DESC;";
 my $stmD = "";
@@ -133,12 +135,13 @@ my $cats = qq(<select   class="ui-widget-content" id="ec" name="ec"
  onBlur="toggleVisibility('cat_desc')" 
  onScroll="helpSelCategory(this);updateSelCategory(this)" 
  onChange="updateSelCategory(this)">
-                                                       <option value="0">---</option>\n);
-
-
+ <option value="0">---</option>\n);
 my %hshCats;
 my %desc = {};
-my $c_sel = 1;
+my $c_sel = 0;
+my $cats_v = $cats;
+$cats_v =~ s/\"ec\"/\"vc\"/g;
+
  while(my @row = $st->fetchrow_array()) {
        if($row[0]==$c_sel){
                $cats = $cats. '<option selected value="'.$row[0].'">'.$row[1].'</option>\n';
@@ -146,12 +149,21 @@ my $c_sel = 1;
        else{   
                $cats = $cats. '<option value="'.$row[0].'">'.$row[1].'</option>\n';
        }       
+       if($row[0]==$prm_vc){
+               $cats_v = $cats_v. '<option selected value="'.$row[0].'">'.$row[1].'</option>\n';
+       }
+       else{   
+               $cats_v = $cats_v. '<option value="'.$row[0].'">'.$row[1].'</option>\n';
+       }       
        $hshCats{$row[0]} = $row[1];
        $desc{$row[0]} = $row[2];
  }
  
 $cats = $cats.'</select>';
 
+
+
+
 my $cat_descriptions = "";
 for my $key (keys %desc){
           my $kv = $desc{$key};
@@ -170,9 +182,13 @@ my $tbl = qq(<form id="frm_log" action="remove.cgi" onSubmit="return formDelVali
        <th class="tbl">Category</th><th>Edit</th>
 </tr>);
 
+if($prm_vc){#view category form selection
+       $rs_cat_idx = $prm_vc;
+}
+
 if($rs_keys){
        
-       my @keywords = split / /, $rs_keys;
+       my @keywords = split / /, $rs_keys;     
        if($rs_cat_idx){
                $stmS = $stmS ." ID_CAT='".$rs_cat_idx."' AND";
        }else{
@@ -195,12 +211,12 @@ if($rs_keys){
 }
 elsif($rs_cat_idx){
 
-       if($stmD){
-             $stmt = $stmS.$stmD. " AND ID_CAT='".$rs_cat_idx."'" .$stmE;
-       }
-       else{
-         $stmt = $stmS." ID_CAT='".$rs_cat_idx."'" .$stmE;
-    }
+                               if($stmD){
+                                                       $stmt = $stmS.$stmD. " AND ID_CAT='".$rs_cat_idx."'" .$stmE;
+                               }
+                               else{
+                                                               $stmt = $stmS." ID_CAT='".$rs_cat_idx."'" .$stmE;
+                                       }
 }
 else{
       if($stmD){
@@ -214,16 +230,16 @@ else{
        &processSubmit;
 ###############
  #
- # Enable to see main query statement issued!
- #print $cgi->pre("### -> ".$stmt);
+ # Uncomment bellow to see main query statement issued!
+# print $cgi->pre("### -> ".$stmt);
+ #
 my $tfId = 0;
 my $id = 0;
 my $tbl_start = index $stmt, "<=";
 my $re_a_tag = qr/<a\s+.*?>.*<\/a>/si ;
 
 if($tbl_start>0){
-       #check if we are at the beggining of the LOG table?
-       
+       #check if we are at the beggining of the LOG table?     
        my $stc = $db->prepare('select rowid from LOG order by rowid DESC LIMIT 1;');
           $stc->execute();
        my @row =$stc->fetchrow_array();
@@ -384,12 +400,13 @@ while(my @row = $st->fetchrow_array()) {
        $tbl_rc += 1;
 
        if($REC_LIMIT>0 && $tbl_rc==$REC_LIMIT){
-
                &buildNavigationButtons;
                last;
        }
-}
 
+}#while end
+
+##
 #Fetch Keywords autocomplete we go by words larger then three.
 #
 $st = $db->prepare( 'select LOG from LOG;' );
@@ -399,45 +416,7 @@ $rv = $st->execute() or die or die "<p>Error->"& $DBI::errstri &"</p>";
 if($rv < 0) {
                        print "<p>Error->"& $DBI::errstri &"</p>";
 }
-while(my @row = $st->fetchrow_array()) {
-                 my $log = $row[0];
-                       #Decode escaped \\n
-                       $log =~ s/\\n/\n/gs;
-                       $log =~ s/''/'/g;
-                       #Replace link to empty string
-                       my @words = split(/($re_a_tag)/si , $log) ;  
-                       foreach my $ch_i ( @words ) {
-                                       next if $ch_i =~ /$re_a_tag/;
-                                       next if index($ch_i, "<img")>-1;
-                                       $ch_i =~ s/https//gsi;
-                                       $ch_i =~ s/($RE{URI}{HTTP})//gsi;
-                       }       
-                       $log = join(' ' , @words);
-                       @words = split(' ', $log) ;  
-                       foreach my $word (@words)  {
-                                 #remove all non alphanumerics
-                                 $word =~ s/[^a-zA-Z]//gs;                                     
-                                       if(length($word)>2){
-                                                $word = lc $word;
-                                                #parse for already placed words, instead of using an hash.
-                                                my $idx = index($autows, $word,0);
-                                                if($idx>0){
-                                                         my $end = index($autows,'"', $idx);
-                                                         my $existing = substr($autows, $idx, $end - $idx);
-                                                               next if $word eq $existing;                                                             
-                                                }
-                                                 
-                                                                               $autows .= qq(,"$word");
-                                                                               if($aw_cnt++>$AUTO_WRD_LMT){
-                                                                                       last;
-                                                                               }
-                                       }                                       
-                       }               
-
-if($aw_cnt>$AUTO_WRD_LMT){
-                                               last;
-}
-}
+&fetchAutocomplete;
 
 #End of table?
 if($rs_prev && $tbl_rc < $REC_LIMIT){
@@ -518,6 +497,7 @@ $cats
        <input type="hidden" name="rs_all" value="0"/>
        <input type="hidden" name="rs_cur" value="0"/>
        <input type="hidden" name="rs_prev" value="$tbl_rc_prev"/>
+       <input type="hidden" name="rs_page" value="$rs_page"/>
        <input type="hidden" name="CGISESSID" value="$sid"/>
        $tags</form>
        );
@@ -529,8 +509,8 @@ my  $srh = qq(
                                        <tr class="r0"><td colspan="4"><b>Search/View By</b></td></tr>
                );
 
-$cats =~ s/selected//g;
-$srh .= qq(<tr><td align="right"><b>View by Category:</b></td><td>$cats</td><td></td>
+
+$srh .= qq(<tr><td align="right"><b>View by Category:</b></td><td>$cats_v</td><td></td>
        <td colspan="1" align="left">
        <button id="btn_cat" onclick="viewByCategory(this);" style="float:left">View</button>
        <input id="idx_cat" name="category" type="hidden" value="0"></td></tr>
@@ -630,13 +610,22 @@ try{
                $REC_LIMIT = 0;
        }
 
-       if($view_mode && $view_mode == "1"){
+       if($view_mode == "1"){
 
                if($rs_cur){
-                        $stmt = 'SELECT rowid, ID_CAT, DATE, LOG, AMMOUNT from LOG 
-                                 where rowid <= "'.$rs_cur.'" ORDER BY DATE DESC;';
-                        return;
-               }
+                       
+                       if($rs_cur==$rs_prev){#Mid page back button if id ordinal.                         
+                                $rs_cur += $REC_LIMIT;
+                                $rs_prev =$rs_cur;
+                                $rs_page--;                             
+                       }
+                       else{
+                               $rs_page++;
+                       }
+                       
+                               $stmt = 'SELECT rowid, ID_CAT, DATE, LOG, AMMOUNT from LOG where rowid <= "'.$rs_cur.'" ORDER BY DATE DESC;;;'.$rs_page;
+                       return;
+         }
        }
 
        if($log && $date && $cat){
@@ -666,8 +655,7 @@ try{
                        print $cgi->p('<b>Insert is in the past!</b>');
                        #Renumerate directly (not proper SQL but faster);
                        $st = $db->prepare('select rowid from LOG ORDER BY DATE;');
-                       $st->execute();
-                       my @row = $st->fetchrow_array();
+                       $st->execute();                 
                        my $cnt = 1;
                        while(my @row = $st->fetchrow_array()) {
                        my $st_upd = $db->prepare("UPDATE LOG SET rowid=".$cnt.
@@ -701,7 +689,7 @@ sub buildNavigationButtons{
 
        $tbl .=  qq!<tr class="r$tfId"><td></td>!;
 
-       if($rs_prev && $rs_prev>0 && $tbl_start>0){
+       if($rs_prev && $rs_prev>0 && $tbl_start>0 && $rs_page>0){
 
         $tbl = $tbl . qq!<td><input type="hidden" value="$rs_prev"/>
         <input type="button" onclick="submitPrev($rs_prev);return false;"
@@ -774,6 +762,56 @@ try  {
 }
 }
 
+sub fetchAutocomplete{
+  try  {
+
+                                       while(my @row = $st->fetchrow_array()) {
+                                                               my $log = $row[0];
+                                                               #Decode escaped \\n
+                                                               $log =~ s/\\n/\n/gs;
+                                                               $log =~ s/''/'/g;
+                                                               #Replace link to empty string
+                                                               my @words = split(/($re_a_tag)/si , $log) ;  
+                                                               foreach my $ch_i ( @words ) {
+                                                                               next if $ch_i =~ /$re_a_tag/;
+                                                                               next if index($ch_i, "<img")>-1;
+                                                                               $ch_i =~ s/https//gsi;
+                                                                               $ch_i =~ s/($RE{URI}{HTTP})//gsi;
+                                                               }       
+                                                               $log = join(' ' , @words);
+                                                               @words = split(' ', $log) ;  
+                                                               foreach my $word (@words)  {
+                                                                               #remove all non alphanumerics
+                                                                               $word =~ s/[^a-zA-Z]//gs;                                       
+                                                                               if(length($word)>2){
+                                                                                       $word = lc $word;
+                                                                                       #parse for already placed words, instead of using an hash.
+                                                                                       my $idx = index($autows, $word,0);
+                                                                                       if($idx>0){
+                                                                                                       my $end = index($autows,'"', $idx);
+                                                                                                       my $existing = substr($autows, $idx, $end - $idx);
+                                                                                                       next if $word eq $existing;                                                             
+                                                                                       }
+                                                                                               
+                                                                                                                       $autows .= qq(,"$word");
+                                                                                                                       if($aw_cnt++>$AUTO_WRD_LMT){
+                                                                                                                               last;
+                                                                                                                       }
+                                                                               }                                       
+                                                               }               
+
+                                       if($aw_cnt>$AUTO_WRD_LMT){
+                                                                                       last;
+                                       }
+                                       }
+
+
+
+       }
+       catch{
+               print "<font color=red><b>SERVER ERROR</b></font>:".$_;
+       }
+}
 
 sub getConfiguration{
        my $db = shift;
index 4b14eef1318ca2ac81c1b5d7e224746318659ba3..532b038a48e8b122d647498c3b81dd90f5309e53 100644 (file)
@@ -42,7 +42,7 @@ function loadedBody(toggle) {
         allowTipHover: false
     });
     $('#el').poshytip({
-        content: "This is your log entry can't be empty.",
+        content: "This is the log entry, can't be left empty.",
         className: 'tip-yellowsimple',
         showOn: 'focus',
         alignTo: 'target',
@@ -77,7 +77,7 @@ function loadedBody(toggle) {
         _MAP.set(children[i].id, children[i].innerHTML);
     }
 
-
+    helpSelCategory($('#ec'));
 
 }
 
@@ -276,28 +276,31 @@ function resetView() {
 }
 
 function updateSelCategory(sel) {
-    var cat = document.getElementById("idx_cat");
-    cat.value = sel.options[sel.selectedIndex].value;
+    if (sel.id == "ec") {
+        var cat = document.getElementById("idx_cat");
+        cat.value = sel.options[sel.selectedIndex].value;
+    }
 }
 
 function toggleVisibility(target, ensureOff) {
-    var d = document.getElementById(target);
-    if (d.style.display === "none" || d.style.display === "" && !ensureOff) {
-        d.style.display = "block";
+    if (!ensureOff) {
+        $(target).toggle();
     } else {
-        d.style.display = "none";
+        $(target).hide();
     }
 }
 
 
 
 function helpSelCategory(sel) {
-    var el = document.getElementById("cat_desc");
+
     var desc = _MAP.get(sel.options[sel.selectedIndex].value);
     if (!desc) {
         desc = "<font color='red'>Please select a Category!</font>";
     }
-    el.innerHTML = desc;
+    document.getElementById("cat_desc").innerHTML = desc;
+    $('#cat_desc').show();
+    $('#cat_desc').fadeOut(5000);
 }
 
 function viewByCategory(btn) {