From: Metabox Date: Wed, 15 May 2019 07:09:50 +0000 (+1000) Subject: Autocomplete initial implenetation. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=1ba861423f48fc1a67c58f137a472681fbbcf0cd;p=LifeLog.git Autocomplete initial implenetation. --- diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index 7b619e7..ff09038 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -29,9 +29,10 @@ our $PRC_WIDTH = '60'; our $LOG_PATH = '../../dbLifeLog/'; our $SESSN_EXPR = '+30m'; our $DATE_UNI = '0'; -our $RELEASE_VER = '1.3'; +our $RELEASE_VER = '1.4'; our $AUTHORITY = ''; our $IMG_W_H = '210x120'; +our $AUTO_WRD_LMT= 200; #END OF SETTINGS my $cgi = CGI->new; @@ -389,6 +390,54 @@ while(my @row = $st->fetchrow_array()) { } } +#Fetch Keywords autocomplete we go by words larger then three. +# +$st = $db->prepare( 'select LOG from LOG;' ); +my $aw_cnt = 0; +my $autows = qq("gas","money","today"); +$rv = $st->execute() or die or die "

Error->"& $DBI::errstri &"

"; +if($rv < 0) { + print "

Error->"& $DBI::errstri &"

"; +} +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, "-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; +} +} #End of table? if($rs_prev && $tbl_rc < $REC_LIMIT){ @@ -428,7 +477,7 @@ $tbl .= '
Keywords: - +
'; @@ -506,18 +555,28 @@ $srh.='
'; #Page printout from here! # print qq(
\n +
\n$frm\n
\n
\n
$srh
\n$tbl\n

-
View Statistics

-
Configure Log

-
LOGOUT
+
View Statistics

+
Configure Log

+
LOGOUT
); print qq(
    $cat_descriptions -
- ); + + + + ); print $cgi->end_html; $st->finish; @@ -725,13 +784,14 @@ sub getConfiguration{ while (my @r=$st->fetchrow_array()){ switch ($r[1]) { - case "REC_LIMIT" {$REC_LIMIT=$r[2]} - case "TIME_ZONE" {$TIME_ZONE=$r[2]} - case "PRC_WIDTH" {$PRC_WIDTH=$r[2]} - case "SESSN_EXPR" {$SESSN_EXPR=$r[2]} - case "DATE_UNI" {$DATE_UNI=$r[2]} - case "LANGUAGE" {$LANGUAGE=$r[2]} - case "IMG_W_H" {$IMG_W_H=$r[2]} + case "REC_LIMIT" {$REC_LIMIT=$r[2]} + case "TIME_ZONE" {$TIME_ZONE=$r[2]} + case "PRC_WIDTH" {$PRC_WIDTH=$r[2]} + case "SESSN_EXPR" {$SESSN_EXPR=$r[2]} + case "DATE_UNI" {$DATE_UNI=$r[2]} + case "LANGUAGE" {$LANGUAGE=$r[2]} + case "IMG_W_H" {$IMG_W_H=$r[2]} + case "AUTO_WRD_LMT" {$AUTO_WRD_LMT=$r[2]} else {print "Unknow variable setting: ".$r[1]. " == ". $r[2]} } diff --git a/htdocs/cgi-bin/wsrc/main.css b/htdocs/cgi-bin/wsrc/main.css index dbde0b7..ef586c2 100644 --- a/htdocs/cgi-bin/wsrc/main.css +++ b/htdocs/cgi-bin/wsrc/main.css @@ -135,6 +135,16 @@ img { text-decoration-style: wavy; } +#floating_menu { + position: absolute; + float: right; + margin: 0; + border: 2px solid #94cde7; + padding: 5px; + text-align: center; + background: #ccffff; +} + #cat_lst { visibility: hidden; } @@ -147,4 +157,36 @@ img { .ui-button, .ui-button-text .ui-button { font-size: 12px !important; +} + +.ui-menu { + list-style: none; + padding: 10px; + margin: 0; + display: block; + width: 227px; + text-align: left; +} + +.ui-menu .ui-menu { + margin-top: -3px; +} + +.ui-menu .ui-menu-item { + margin: 0; + padding: 0; + width: 200px; +} + +.ui-menu .ui-menu-item a { + text-decoration: none; + display: block; + padding: .2em .4em; + line-height: 1.5; + zoom: 1; +} + +.ui-menu .ui-menu-item a.ui-state-hover, +.ui-menu .ui-menu-item a.ui-state-active { + margin: -1px; } \ No newline at end of file