chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1300885 - /chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html
Date Thu, 15 Mar 2012 10:30:30 GMT
Author: jens
Date: Thu Mar 15 10:30:29 2012
New Revision: 1300885

URL: http://svn.apache.org/viewvc?rev=1300885&view=rev
Log:
Improve paging support

Modified:
    chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html

Modified: chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html
URL: http://svn.apache.org/viewvc/chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html?rev=1300885&r1=1300884&r2=1300885&view=diff
==============================================================================
--- chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html (original)
+++ chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html Thu
Mar 15 10:30:29 2012
@@ -296,10 +296,18 @@
     
     function onClickQueryLast() {
         var pageCtx = session.getPagingContext("doquery");
-        pageCtx.skipCount = pageCtx.totalItems - session.opCtx.maxItems;
+        if (pageCtx.totalItems==null || pageCtx.totalItems==0) {
+            alert("Total number of items is unknown");
+            return;
+        }
+
+        var totalItems = pageCtx.totalItems;
+       	var totalPages = ((pageCtx.totalItems - (pageCtx.totalItems % session.opCtx.maxItems))
/ session.opCtx.maxItems);
+       	pageCtx.skipCount = totalPages * session.opCtx.maxItems;
+        
         doQueryWithOffset();
     }
-    
+
     function doQueryWithOffset() {
         checkSession("#queryresponsesection");
         $("#queryresponsesection *").remove();
@@ -307,17 +315,27 @@
        	session.doQueryPaged($('#queryfield').val(), "doquery", function(data) {
        	 	if (!checkError(data, "#queryresponsesection")) {
               	var tbl = createQueryTable(data);
-              	$("#queryresponsesection").append(tbl).append($("<br>"))
-              	    .append($("<button>").attr("onClick", "onClickQueryFirst()").append($("<img>").attr("src",
"images/first.png")))
-              		.append($("<button>").attr("onClick", "onClickQueryPrev()").append($("<img>").attr("src",
"images/prev.png")))
-              		.append($("<button>").attr("onClick", "onClickQueryNext()").append($("<img>").attr("src",
"images/next.png")))
-              		.append($("<button>").attr("onClick", "onClickQueryLast()").append($("<img>").attr("src",
"images/last.png")));
+                var pageCtx = session.getPagingContext("doquery");
+                var totalItems = pageCtx.totalItems==null || pageCtx.totalItems==0 ? 4294967295
: pageCtx.totalItems;
+                var page = Math.floor(pageCtx.skipCount / session.opCtx.maxItems) + 1;
+                var totalPages;
+                if (pageCtx.totalItems==null || pageCtx.totalItems==0)
+                    totalPages = "(unknown)";
+                else
+                	totalPages = ((totalItems - (totalItems % session.opCtx.maxItems)) / session.opCtx.maxItems)
+ 1;
+
+              	$("#queryresponsesection").append(tbl).append($("<table>").append($("<tr>").append($("<td>").css("border-width","0px")
+              	    .append($("<button>").attr("value", "first").click(function() {onClickQueryFirst();}).append($("<img>").attr("src",
"images/first.png")))
+              		.append($("<button>").attr("value", "prev").click(function() {onClickQueryPrev();}).append($("<img>").attr("src",
"images/prev.png")))
+              		.append($("<button>").attr("value", "next").click(function() {onClickQueryNext();}).append($("<img>").attr("src",
"images/next.png")))
+              		.append($("<button>").attr("value", "last").click(function() {onClickQueryLast();}).append($("<img>").attr("src",
"images/last.png"))))
+              		.append($("<td>").css("border-width","0px").text("Page " + page + "
of " + totalPages + " / Items total: " + (totalItems==4294967295?"unknown":totalItems)))));
        	 	}
        	});
     };
 
     $(document).ready(function() {
-        
+
         $(document).ajaxError(function(event, request, settings, excep){
             var cmisError = CmisSession.defaultErrorHandler(event, request, settings, excep);
             displayError(cmisError, '#errorsection');
@@ -474,6 +492,7 @@
 	    </table>
 	</form>
     <button id="repositories">Connect!</button> <br/>
+    
     <div id="repositoriessection">
     </div>
     <form >



Mime
View raw message