Demo Discussion
Forum Config Examples Contributions Vulnerabilities
  Discussion forum about ELOG  Not logged in ELOG logo
Message ID: 68971     Entry time: Tue May 14 09:40:58 2019
Icon: Idea  Author: Xuan Wu  Author Email: wux@ihep.ac.cn 
Category: Comment  OS: Linux  ELOG Version: 3.1.3 
Subject: add a little function--go to the specified page number 

Hi all,

I added an input widget for pagination. I'd like to share it here, maybe someone needs. If there are many pages,  specifying the page number will be useful. 

The picture and patch code are in the attachment

Regards,

Xuan

Attachment 1: pagination.png  2 kB  Uploaded Tue May 14 11:07:17 2019  | Hide | Hide all
pagination.png
Attachment 2: goto.patch  1 kB  Uploaded Tue May 14 11:07:30 2019  | Hide | Hide all
--- elogd.c.org	2019-05-14 10:12:01.891558950 +0800
+++ elogd.c	2019-05-14 10:44:38.165898395 +0800
@@ -19407,6 +19407,26 @@ void show_page_navigation(LOGBOOK * lbs,
       rsprintf("<a href=\"%s\">%s</a>\n", ref, loc("All"));
    }
 
+   sprintf(ref, "");
+   build_ref(ref, sizeof(ref), "", "", "", "");
+
+   rsprintf("<input id=\"setPage\" title=\"Goto\" type=number size=\"6\" onChange=\'getPage(\"%d\");\'>", num_pages);
+   rsprintf("<script language=\"JavaScript\" type=\"text/javascript\">\n");
+   rsprintf("<!--\n");
+   rsprintf("function getPage(max)\n");
+   rsprintf("  {\n");
+   rsprintf("   var value = document.getElementById('setPage').value;\n");
+   rsprintf("   value = parseInt(value);\n");
+   rsprintf("   if(value > max)\n");
+   rsprintf("      value = max;\n");
+   rsprintf("   if(value < 1)\n");
+   rsprintf("      value = 1;\n");
+   rsprintf("   var url = 'page' + value + \"%s\";\n", ref);
+   rsprintf("   window.location.href = url;\n");
+   rsprintf("  }\n");
+   rsprintf("//-->\n");
+   rsprintf("</script>\n");
+
    rsprintf("</span></td></tr>\n");
 }
 
ELOG V3.1.5-fe60aaf