chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1384639 [2/2] - in /chemistry/playground/chemistry-opencmis-javascript-relax/src/main/webapp: ./ css/ images/ js/
Date Fri, 14 Sep 2012 04:28:47 GMT
Added: chemistry/playground/chemistry-opencmis-javascript-relax/src/main/webapp/js/jquery.image-gallery.min.js
URL: http://svn.apache.org/viewvc/chemistry/playground/chemistry-opencmis-javascript-relax/src/main/webapp/js/jquery.image-gallery.min.js?rev=1384639&view=auto
==============================================================================
--- chemistry/playground/chemistry-opencmis-javascript-relax/src/main/webapp/js/jquery.image-gallery.min.js (added)
+++ chemistry/playground/chemistry-opencmis-javascript-relax/src/main/webapp/js/jquery.image-gallery.min.js Fri Sep 14 04:28:45 2012
@@ -0,0 +1 @@
+(function(a){"use strict",typeof define=="function"&&define.amd?define(["jquery","./load-image.js","jquery-ui"],a):a(window.jQuery,window.loadImage)})(function(a,b){"use strict",a.widget("blueimp.imagegallery",{options:{selector:'a[rel="gallery"]',namespace:"imagegallery",slideshow:0,offsetWidth:100,offsetHeight:100,fullscreen:!1,canvas:!1,imageClickDivision:.5,bodyClass:"gallery-body",loaderId:"gallery-loader",effects:["blind","clip","drop","explode","fade","fold","puff","slide","scale"],modal:!0,resizable:!1,width:"auto",height:"auto",show:"fade",hide:"fade",dialogClass:"gallery-dialog"},_getOverlay:function(){return a(document.body).children(".ui-widget-overlay").last()},_openSibling:function(a){var b=this,c=this._dialog;clearTimeout(this._slideShow),this._slideShow=null,a.href!==this._link.href?c.dialog("widget").hide(this.options.hide,function(){b._overlay=b._getOverlay().clone().appendTo(document.body),c.dialog("option","hide",null).dialog("close"),b._callback=function
 (){b._overlay.remove(),b._overlay=null},b._open(a)}):c.dialog("close")},_prev:function(){this._openSibling(this._prevLink)},_next:function(){this._openSibling(this._nextLink)},_keyHandler:function(a){var b=a.data.imagegallery;switch(a.which){case 37:case 38:return b._prev(),!1;case 39:case 40:return b._next(),!1}},_wheelHandler:function(a){var b=a.data.imagegallery;a=a.originalEvent,b._wheelCounter+=a.wheelDelta||a.detail||0;if(a.wheelDelta&&b._wheelCounter>=120||!a.wheelDelta&&b._wheelCounter<0)b._prev(),b._wheelCounter=0;else if(a.wheelDelta&&b._wheelCounter<=-120||!a.wheelDelta&&b._wheelCounter>0)b._next(),b._wheelCounter=0;return!1},_clickHandler:function(a){var b=a.data.imagegallery,c=b._dialog;(a.pageX-c.offset().left)/c.width()<b.options.imageClickDivision?b._prev():b._next()},_overlayClickHandler:function(b){var c=b.data.imagegallery;a(this).unbind("click."+c.options.namespace,c._overlayClickHandler),c._dialog.dialog("close")},_openHandler:function(b){var c=b.data.im
 agegallery,d=c.options;a(document.body).addClass(d.bodyClass),c._getOverlay().bind("click."+d.namespace,b.data,c._overlayClickHandler),c._callback&&(c._callback(),c._callback=null),d.slideshow&&(c._slideShow=setTimeout(function(){c._next()},d.slideshow))},_closeHandler:function(b){var c=b.data.imagegallery,d=c.options;a(document).unbind("keydown."+d.namespace,c._keyHandler).unbind("mousewheel."+d.namespace+", DOMMouseScroll."+d.namespace,c._wheelHandler),clearTimeout(c._slideShow),c._slideShow=null,c._overlay||(a(document.body).removeClass(d.bodyClass),c._position=null),c._dialog.remove(),c._dialog=null},_dragStopHandler:function(a,b){var c=a.data.imagegallery;c._position=b.position},_initDialogHandlers:function(){var b=this,c=this.options,d={imagegallery:this};a(document).bind("keydown."+c.namespace,d,this._keyHandler).bind("mousewheel."+c.namespace+", DOMMouseScroll."+c.namespace,d,this._wheelHandler),b._dialog.bind("click."+c.namespace,d,this._clickHandler).bind("dialogop
 en."+c.namespace,d,this._openHandler).bind("dialogclose."+c.namespace,d,this._closeHandler).bind("dialogdragstop."+c.namespace,d,this._dragStopHandler)},_loadHandler:function(b){var c=this.options,d=c.offsetWidth,e=c.offsetHeight;this._dialog=a("<div></div>"),this._loaded=!0,a(document).unbind("keydown."+c.namespace,this._escapeHandler).unbind("click."+c.namespace,this._documentClickHandler),this._img=null,this._loadingAnimation.hide(),this._initDialogHandlers(),this._position&&(c=a.extend({},c,{position:[this._position.left,this._position.top]})),this._dialog.append(b).appendTo(document.body).toggleClass("gallery-dialog-single",this._prevLink===this._link&&this._nextLink===this._link).dialog(c)},_abortLoading:function(){var b=this.options;this._img.unbind(),a(document).unbind("keydown."+b.namespace,this._escapeHandler).unbind("click."+b.namespace,this._documentClickHandler),this._getOverlay().remove(),this._loadingAnimation.hide(),a(document.body).removeClass(b.bodyClass)},
 _escapeHandler:function(a){a.keyCode===27&&a.data.imagegallery._abortLoading()},_documentClickHandler:function(b){var c=b.data.imagegallery;a(b.target).closest(c._link).length||c._abortLoading()},_loadImage:function(){var c=this,d=this.options,e={imagegallery:this},f=a(window).width(),g=a(window).height(),h;d.fullscreen?h={minWidth:f,minHeight:g,maxWidth:f,maxHeight:g,canvas:d.canvas}:h={maxWidth:f-d.offsetWidth,maxHeight:g-d.offsetHeight,canvas:d.canvas},a(document).bind("keydown."+d.namespace,e,this._escapeHandler).bind("click."+d.namespace,e,this._documentClickHandler),c._loaded=null,this._img=a(b(this._link.href,function(a){c._loadHandler(a)},h)),setTimeout(function(){c._loaded||c._loadingAnimation.show()},100)},_preloadSiblings:function(){a("<img>").prop("src",this._nextLink.href),a("<img>").prop("src",this._prevLink.href)},_initSiblings:function(){var a=this,b=this._link,c=this.element.find(this.options.selector);this._prevLink=null,this._nextLink=null,c.each(function(
 d){(c[d+1]===b||c[d+2]===b)&&this.href!==b.href&&(a._prevLink=this);if((c[d-1]===b||c[d-2]===b)&&this.href!==b.href)return a._nextLink=this,!1}),this._prevLink||(this._prevLink=c[c.length-1]),this._nextLink||(this._nextLink=c[0])},_getRandomEffect:function(){var a=this.options.effects;return a[Math.floor(Math.random()*a.length)]},_initEffects:function(){var a=this.options;if(a.show==="random"||this._show==="random")this._show="random",a.show=this._getRandomEffect();if(a.hide==="random"||this._hide==="random")this._hide="random",a.hide=this._getRandomEffect()},_open:function(b){if(this._dialog){var c=a.extend({},this);c._dialog=null,c._position=null,c._open(b);return}this.options.title=b.title||decodeURIComponent(b.href.split("/").pop()),this._link=b,this._initEffects(),this._loadImage(),this._initSiblings(),this._preloadSiblings()},_initFullscreenOptions:function(){var a=this.options;a.fullscreen?(/-fullscreen$/.test(a.dialogClass)||(a.dialogClass+="-fullscreen"),/-fullscree
 n$/.test(a.bodyClass)||(a.bodyClass+="-fullscreen")):(a.dialogClass=a.dialogClass.replace(/-fullscreen$/,""),a.bodyClass=a.bodyClass.replace(/-fullscreen$/,""))},_initLoadingAnimation:function(){this._loadingAnimation=a('<div id="'+this.options.loaderId+'"></div>').hide().appendTo(document.body)},_destroyLoadingAnimation:function(){this._loadingAnimation.remove(),this._loadingAnimation=null},_delegate:function(){var a=this,b=this.options;this.element.delegate(b.selector,"click."+b.namespace,function(b){b.preventDefault(),a._open(this)})},_undelegate:function(){this.element.undelegate(this.options.selector,"click."+this.options.namespace)},_setOption:function(b,c){this._show=this._hide=null;var d=b==="namespace"||b==="selector";d&&this._undelegate(),a.Widget.prototype._setOption.call(this,b,c),d&&this._delegate(),a.inArray(b,["fullscreen","dialogClass","bodyClass"])!==-1&&this._initFullscreenOptions()},_create:function(){this._wheelCounter=0,this._initLoadingAnimation(),this.
 _initFullscreenOptions(),this._delegate()},destroy:function(){clearTimeout(this._slideShow),this._slideShow=null,this._dialog&&this._dialog.dialog("close"),this._undelegate(),this._destroyLoadingAnimation(),a.Widget.prototype.destroy.call(this)},enable:function(){a.Widget.prototype.enable.call(this),this._delegate()},disable:function(){clearTimeout(this._slideShow),this._slideShow=null,this._undelegate(),a.Widget.prototype.disable.call(this)}})});
\ No newline at end of file

Added: chemistry/playground/chemistry-opencmis-javascript-relax/src/main/webapp/js/load-image.min.js
URL: http://svn.apache.org/viewvc/chemistry/playground/chemistry-opencmis-javascript-relax/src/main/webapp/js/load-image.min.js?rev=1384639&view=auto
==============================================================================
--- chemistry/playground/chemistry-opencmis-javascript-relax/src/main/webapp/js/load-image.min.js (added)
+++ chemistry/playground/chemistry-opencmis-javascript-relax/src/main/webapp/js/load-image.min.js Fri Sep 14 04:28:45 2012
@@ -0,0 +1 @@
+(function(a){"use strict";var b=function(a,c,d){var e=document.createElement("img"),f,g;return e.onerror=c,e.onload=function(){g&&(!d||!d.noRevoke)&&b.revokeObjectURL(g),c(b.scale(e,d))},window.Blob&&a instanceof Blob||window.File&&a instanceof File?f=g=b.createObjectURL(a):f=a,f?(e.src=f,e):b.readFile(a,function(a){e.src=a})},c=window.createObjectURL&&window||window.URL&&URL.revokeObjectURL&&URL||window.webkitURL&&webkitURL;b.scale=function(a,b){b=b||{};var c=document.createElement("canvas"),d=a.width,e=a.height,f=Math.max((b.minWidth||d)/d,(b.minHeight||e)/e);return f>1&&(d=parseInt(d*f,10),e=parseInt(e*f,10)),f=Math.min((b.maxWidth||d)/d,(b.maxHeight||e)/e),f<1&&(d=parseInt(d*f,10),e=parseInt(e*f,10)),a.getContext||b.canvas&&c.getContext?(c.width=d,c.height=e,c.getContext("2d").drawImage(a,0,0,d,e),c):(a.width=d,a.height=e,a)},b.createObjectURL=function(a){return c?c.createObjectURL(a):!1},b.revokeObjectURL=function(a){return c?c.revokeObjectURL(a):!1},b.readFile=function
 (a,b){if(window.FileReader&&FileReader.prototype.readAsDataURL){var c=new FileReader;return c.onload=function(a){b(a.target.result)},c.readAsDataURL(a),c}return!1},typeof define=="function"&&define.amd?define(function(){return b}):a.loadImage=b})(this);
\ No newline at end of file

Modified: chemistry/playground/chemistry-opencmis-javascript-relax/src/main/webapp/playerpage.js
URL: http://svn.apache.org/viewvc/chemistry/playground/chemistry-opencmis-javascript-relax/src/main/webapp/playerpage.js?rev=1384639&r1=1384638&r2=1384639&view=diff
==============================================================================
--- chemistry/playground/chemistry-opencmis-javascript-relax/src/main/webapp/playerpage.js (original)
+++ chemistry/playground/chemistry-opencmis-javascript-relax/src/main/webapp/playerpage.js Fri Sep 14 04:28:45 2012
@@ -2,9 +2,12 @@
     var session = null;
     var filter = null;
     var myPlaylist =null;
+    var map = null;
+    var markers = null;
+    var clickListener = null;
     
     function connect() {
-        var firstRepoId;        
+        var firstRepoId = null;        
         connectToRepo($("#reposfield").val(), $("#jsonpfield").attr("checked")=="checked", $("#userfield").val(),
                 $("#pwdfield").val(), function(repoInfos) {
             trace("getRepositories()");
@@ -34,7 +37,7 @@
               password: password
             });
          factory.getRepositories(cbFct, function(errorMessage) {
-             displayError(errorMessage, "#alertpane")
+             displayError(errorMessage, "#alertpane");
          });
     }
                 
@@ -75,11 +78,14 @@
     function displayError(cmisError, domId) {
         if (null == domId)
             domId = "#alertpane";
-        $(domId + " *").remove();
-        if (null != cmisError)
-            $(domId).html(cmisError.toString());         
+        $(domId).html(null);
+        if (null != cmisError) {
+        	var str = cmisError.toString();   
+        	if (null != str)
+        		$(domId).text(str);      
+        }
     }
-    
+        
     function checkError(jsonObj, domId) {
         if (jsonObj != null && jsonObj.exception) {
             var cmisError = session.createErrorFromErrorResponse(jsonObj);
@@ -89,11 +95,11 @@
             return null;
     }
     
-    function getMapSize(map) {
+    function getHashMapSize(map) {
         if (map ==null)
             return 0;
         
-        var size = 0, key;
+        var size = 0, key = null;
         for (key in map) {
             if (map.hasOwnProperty(key)) size++;
         }
@@ -103,6 +109,47 @@
     function createRandomString() {
         return Math.round(Math.random()*1000).toString();
     }
+    
+    function toRad(degree) {
+        return degree * Math.PI / 180;
+    }
+
+    function toDeg(rad) {
+        return rad * 180 / Math.PI;
+    }
+      
+    function getImageDisplayKind()
+    {
+    	for (var i=0; i < document.ImageDisplayForm.ImageDisplayKind.length; i++)
+    	{
+    		if (document.ImageDisplayForm.ImageDisplayKind[i].checked)
+    		{
+    			return document.ImageDisplayForm.ImageDisplayKind[i].value;
+    		}
+    	}
+    }
+    
+    function showMap(lat, lon, name, contentUrl) {
+    	var position = new google.maps.LatLng(lat, lon);
+    	var mapOptions = {
+    			center: position,
+    			zoom: 8,
+    			mapTypeId: google.maps.MapTypeId.ROADMAP
+    	};
+    	var canvas = document.getElementById("map_canvas");
+    	var map = new google.maps.Map(canvas,
+    			mapOptions);    	
+    	// display marker
+    	var marker = new google.maps.Marker({
+	      position: position,
+	      map: map,
+	      title: name
+	  });
+      
+       google.maps.event.addListener(marker, 'click', function(event) {
+    	   window.open(contentUrl,"_blank");
+       });
+    }
 
     function onClickQueryForPlaylistFirst() {
         var pageCtx = session.getPagingContext("doQueryForPlaylist");
@@ -140,6 +187,78 @@
         doQueryByArtist(pageCtx.query);
     }
 
+    function onClickQueryForOfficeFirst() {
+        var pageCtx = session.getPagingContext("doQueryForOffice");
+        pageCtx.setFirstPage();
+        doQueryForOffice(pageCtx.query);
+    }
+    
+    function onClickQueryForOfficePrev() {
+        var pageCtx = session.getPagingContext("doQueryForOffice");
+        pageCtx.setPreviousPage();
+        doQueryForOffice(pageCtx.query);
+    }
+    
+    function onClickQueryForOfficeNext() {
+        var pageCtx = session.getPagingContext("doQueryForOffice");
+        pageCtx.setNextPage();
+        doQueryForOffice(pageCtx.query);
+    }
+    
+    function onClickQueryForOfficeLast() {
+        var pageCtx = session.getPagingContext("doQueryForOffice");        
+        pageCtx.setLastPage();        
+        doQueryForOffice(pageCtx.query);
+    }
+    
+    function onClickQueryForPicturesFirst() {
+        var pageCtx = session.getPagingContext("doQueryForPictures");
+        pageCtx.setFirstPage();
+        doQueryForPictures(pageCtx.query);
+    }
+    
+    function onClickQueryForPicturesPrev() {
+        var pageCtx = session.getPagingContext("doQueryForPictures");
+        pageCtx.setPreviousPage();
+        doQueryForPictures(pageCtx.query);
+    }
+    
+    function onClickQueryForPicturesNext() {
+        var pageCtx = session.getPagingContext("doQueryForPictures");
+        pageCtx.setNextPage();
+        doQueryForPictures(pageCtx.query);
+    }
+    
+    function onClickQueryForPicturesLast() {
+        var pageCtx = session.getPagingContext("doQueryForPictures");        
+        pageCtx.setLastPage();        
+        doQueryForPictures(pageCtx.query);
+    }
+    
+    function onClickQueryForArtistListPicturesFirst() {
+        var pageCtx = session.getPagingContext("doQueryForArtistListPictures");
+        pageCtx.setFirstPage();
+        doQueryForPictures(pageCtx.query);
+    }
+    
+    function onClickQueryForArtistListPicturesPrev() {
+        var pageCtx = session.getPagingContext("doQueryForArtistListPictures");
+        pageCtx.setPreviousPage();
+        doQueryForPictures(pageCtx.query);
+    }
+    
+    function onClickQueryForArtistListPicturesNext() {
+        var pageCtx = session.getPagingContext("doQueryForArtistListPictures");
+        pageCtx.setNextPage();
+        doQueryForPictures(pageCtx.query);
+    }
+    
+    function onClickQueryForArtistListPicturesLast() {
+        var pageCtx = session.getPagingContext("doQueryForArtistListPictures");        
+        pageCtx.setLastPage();        
+        doQueryForPictures(pageCtx.query);
+    }
+    
     function getContentUrl(id) {
         return session.getRootUrl() + "?cmisselector=content&objectId=" + id;
     }
@@ -165,6 +284,14 @@
             return "";
     }
         
+    function getDirectPropertyValue(props, queryName) {
+        var prop = props[queryName];
+        if (null != prop && null != prop.value) {
+            return prop.value;
+        } else
+            return null;
+    }
+
     function filterByAlbum(filter) {
         session.deletePagingContext("doQueryByAlbum");
         if (filter)
@@ -180,7 +307,6 @@
             var props = queryResp.results[child].properties;
             var typeId = getPropertyValue(props, "cmis:objectTypeId");
             if (typeId != null && typeId === "audioFile") {
-                var playItem = {};
                 var album = getPropertyValue(props, "ALBUM");
                 var artist  = getPropertyValue(props, "ARTIST");
                 if (album && artist)
@@ -189,7 +315,7 @@
         }
         
         $("#filterresultlist").html(null);
-        if (getMapSize(albums) == 0)
+        if (getHashMapSize(albums) == 0)
             $("#filterresultlist").append("None found.");
         else            
             for (var album in albums) {
@@ -216,6 +342,14 @@
         });       
     }
     
+    function filterAlbumByArtist(filter) {
+        session.deletePagingContext("doQueryByArtist");
+        if (filter)
+            doQueryByArtist("SELECT * FROM AUDIO_FILE where ARTIST LIKE '" + filter + "%'");
+        else
+            doQueryByArtist("SELECT * FROM AUDIO_FILE");
+    }
+
     function filterAlbumByTitle(filter) {
         session.deletePagingContext("doQueryByAlbum");
         if (filter)
@@ -245,21 +379,21 @@
         session.deletePagingContext("doQueryByAlbum");
         var date1 = new Date();
         date1.setDate(date1.getDate()-7);
-        doQueryByAlbum("SELECT * FROM AUDIO_FILE where cmis:creationDate >='" + date1.toJSON() + "'");        
+        doQueryByAlbum("SELECT * FROM AUDIO_FILE where cmis:creationDate >= TIMESTAMP '" + date1.toJSON() + "'");        
     }
     
     function filterAlbumByUploadedDateLastMonth() {
         session.deletePagingContext("doQueryByAlbum");
         var date1 = new Date();
         date1.setMonth(date1.getMonth()-1);
-        doQueryByAlbum("SELECT * FROM AUDIO_FILE where cmis:creationDate >='" + date1.toJSON() + "'");        
+        doQueryByAlbum("SELECT * FROM AUDIO_FILE where cmis:creationDate >= TIMESTAMP '" + date1.toJSON() + "'");        
     }
     
     function filterAlbumByUploadedDateLastYear() {
         session.deletePagingContext("doQueryByAlbum");
         var date1 = new Date();
         date1.setYear(date1.getYear()-1);
-        doQueryByAlbum("SELECT * FROM AUDIO_FILE where cmis:creationDate >='" + date1.toJSON() + "'");        
+        doQueryByAlbum("SELECT * FROM AUDIO_FILE where cmis:creationDate >= TIMESTAMP '" + date1.toJSON() + "'");        
     }
     
     function filterAlbumByUploadedByMe() {
@@ -272,7 +406,287 @@
         doQueryByAlbum("SELECT * FROM AUDIO_FILE where cmis:createdBy <>'" + session.user + "'");        
     }  
 
-    function loadPlayer(domObj, cbFct) {
+    function filterByTitle(type, filter) {
+        session.deletePagingContext("doQueryByAlbum");
+        if (filter)
+            doQueryForPlaylist("SELECT * FROM " + type + " where TITLE LIKE '" + filter + "%'");
+        else
+            doQueryForPlaylist("SELECT * FROM " + type);
+    }
+    
+    function filterVideoByArtist(filter) {
+        session.deletePagingContext("doQueryForPlaylist");
+        if (filter)
+            doQueryForPlaylist("SELECT * FROM VIDEO_FILE  where ARTIST LIKE '" + filter + "%'");
+        else
+            doQueryForPlaylist("SELECT * FROM VIDEO_FILE");
+    }
+    
+    function filterVideoByGenre(filter) {
+        session.deletePagingContext("doQueryForPlaylist");
+        if (filter)
+            doQueryForPlaylist("SELECT * FROM VIDEO_FILE where GENRE = '" + filter + "'");
+        else
+            doQueryForPlaylist("SELECT * FROM VIDEO_FILE where GENRE IS NULL");
+    }
+    
+    function filterVideoByReleaseDate(year1, year2) {
+        session.deletePagingContext("doQueryByAlbum");
+        if (year2 == null)
+        	doQueryForPlaylist("SELECT * FROM VIDEO_FILE where YEAR='" + year1 + "'");
+        else
+        	doQueryForPlaylist("SELECT * FROM VIDEO_FILE where YEAR >='" + year1 + "' AND YEAR <= '" + year2 + "'");        
+    }
+
+    function filterOfficeDocumentsByApplication(filter) {
+        session.deletePagingContext("doQueryForOffice");
+        if (filter)
+            doQueryForOffice("SELECT * FROM OFFICE_DOCUMENT where cmis:contentStreamMimeType = '" + filter + "'");
+        else
+        	doQueryForOffice("SELECT * FROM OFFICE_DOCUMENT where cmis:contentStreamMimeType IS NULL");
+    }
+    
+    function filterOfficeDocumentsByAuthor(filter) {
+        session.deletePagingContext("doQueryForOffice");
+        if (filter)
+            doQueryForOffice("SELECT * FROM OFFICE_DOCUMENT where AUTHOR LIKE '" + filter + "%'");
+        else
+        	doQueryForOffice("SELECT * FROM OFFICE_DOCUMENT");
+    }
+    
+    function filterOfficeDocumentsByKeyword(filter) {
+        session.deletePagingContext("doQueryForOffice");
+        if (filter)
+            doQueryForOffice("SELECT * FROM OFFICE_DOCUMENT where KEYWORDS = '" + filter + "'");
+        else
+        	doQueryForOffice("SELECT * FROM OFFICE_DOCUMENT where KEYWORDS IS NULL");
+    }
+    
+    function filterOfficeDocumentsByLastSaveDate(date1, date2) {
+        session.deletePagingContext("doQueryForOffice");
+        if (date1 && date2)
+            doQueryForOffice("SELECT * FROM OFFICE_DOCUMENT where LAST_SAVE_DATE >= TIMESTAMP '" + date1.toJSON() + 
+            	"' AND LAST_SAVE_DATE < TIMESTAMP '" + date2.toJSON() + "'");
+        else
+        	doQueryForOffice("SELECT * FROM OFFICE_DOCUMENT");
+    }
+    
+    function filterOfficeDocumentsByLastSaveDateToday() {
+        var date1 = new Date();
+        var date2 = new Date();
+        date1.setDate(date1.getDate()-1);
+        filterOfficeDocumentsByLastSaveDate(date1, date2);
+    }
+    
+    function filterOfficeDocumentsByLastSaveDateLastWeek() {
+        var date1 = new Date();
+        var date2 = new Date();
+        date1.setDate(date1.getDate()-7);
+        filterOfficeDocumentsByLastSaveDate(date1, date2);
+    }
+
+    function filterOfficeDocumentsByLastSaveDateLastMonth() {
+        var date1 = new Date();
+        var date2 = new Date();
+        date1.setMonth(date1.getMonth()-1);
+        filterOfficeDocumentsByLastSaveDate(date1, date2);
+    }
+
+    function filterOfficeDocumentsByLastSaveDateLastYear() {
+        var date1 = new Date();
+        var date2 = new Date();
+        date1.setFullYear(date1.getFullYear()-1);
+        filterOfficeDocumentsByLastSaveDate(date1, date2);
+    }
+
+    function filterOfficeDocumentsByLastSaveDateOlderOneYear() {
+        var date1 = new Date();
+        var date2 = new Date();
+        date1.setDate(0);
+        date1.setMonth(0);
+        date1.setFullYear(0);
+        filterOfficeDocumentsByLastSaveDate(date1, date2);
+   }
+
+    function filterOfficeDocumentsByNoPages(from, to) {
+        session.deletePagingContext("doQueryForOffice");
+        if (from != null && to != null)
+            doQueryForOffice("SELECT * FROM OFFICE_DOCUMENT where PAGE_COUNT >= " + from + 
+                	" AND PAGE_COUNT < " + to);
+        else
+        	doQueryForOffice("SELECT * FROM OFFICE_DOCUMENT");    	
+    }
+
+    function filterOfficeDocumentsByNoSlides(from, to) {
+        session.deletePagingContext("doQueryForOffice");
+        if (from != null && to != null)
+            doQueryForOffice("SELECT * FROM OFFICE_DOCUMENT where SLIDE_COUNT >= " + from + 
+                	" AND SLIDE_COUNT < " + to);
+        else
+        	doQueryForOffice("SELECT * FROM OFFICE_DOCUMENT");    	
+    }
+    
+    function filterPicturesByDateTakenToday() {
+        var date1 = new Date();
+        var date2 = new Date();
+        date1.setDate(date1.getDate()-1);
+        filterPictureByDateTaken(date1, date2);
+   }
+    
+    function filterPicturesByDateTakenLastWeek() {
+        var date1 = new Date();
+        var date2 = new Date();
+        date1.setDate(date1.getDate()-7);
+        filterPictureByDateTaken(date1, date2);
+    }
+    
+    function filterPicturesByDateTakenLastMonth() {
+        var date1 = new Date();
+        var date2 = new Date();
+        date1.setMonth(date1.getMonth()-1);
+        filterPictureByDateTaken(date1, date2);
+   }
+
+    function filterPicturesByDateTakenLastYear() {
+        var date1 = new Date();
+        var date2 = new Date();
+        date1.setFullYear(date1.getFullYear()-1);
+        filterPictureByDateTaken(date1, date2);
+    }
+
+    function filterPicturesByDateTakenOlderOneYear() {
+        var date1 = new Date();
+        var date2 = new Date();
+        date1.setDate(0);
+        date1.setMonth(0);
+        date1.setFullYear(0);
+        filterPictureByDateTaken(date1, date2);
+    }
+
+    function filterPictureByCamera(brand) {
+        session.deletePagingContext("doQueryForPictures");
+        if (brand != null)
+        	doQueryForPictures("SELECT * FROM EXIF_IMAGE where MAKE = '" + brand +"'");
+        else
+        	doQueryForPictures("SELECT * FROM EXIF_IMAGE");    	    	
+    }
+    
+    function filterPictureByArtist(artist) {
+        session.deletePagingContext("doQueryForPictures");
+        if (artist != null)
+        	doQueryForPictures("SELECT * FROM EXIF_IMAGE where ARTIST LIKE '" + artist +"%'");
+        else
+        	doQueryForPictures("SELECT * FROM EXIF_IMAGE");    	    	
+    }
+    
+    function filterPictureByDateTaken(date1, date2) {
+        session.deletePagingContext("doQueryForPictures");
+        if (date1 && date2)
+            doQueryForPictures("SELECT * FROM EXIF_IMAGE where DATE_TIME_ORIGINAL >= TIMESTAMP '" + date1.toJSON() + 
+            	"' AND DATE_TIME_ORIGINAL < TIMESTAMP '" + date2.toJSON() + "'");
+        else
+        	doQueryForPictures("SELECT * FROM EXIF_IMAGE");
+    }
+    
+    function filterPictureByResolution(minRes, maxRes) {
+        session.deletePagingContext("doQueryForPictures");
+        if (minRes >= 0 && maxRes >= 0)
+            doQueryForPictures("SELECT * FROM EXIF_IMAGE where (IMAGE_WIDTH >= " + minRes + 
+            	" AND IMAGE_WIDTH < " + maxRes + " AND IMAGE_HEIGHT <= "+ maxRes + ") OR (IMAGE_HEIGHT >= " + minRes + 
+                " AND IMAGE_HEIGHT < " + maxRes + " AND IMAGE_WIDTH <= "+ maxRes + ")");
+        else
+        	doQueryForPictures("SELECT * FROM EXIF_IMAGE");
+    	
+    }
+    
+    function filterPictureByFocalLength(minLength, maxLength) {
+        session.deletePagingContext("doQueryForPictures");
+        if (minLength > 0.0 && maxLength > 0.0)
+            doQueryForPictures("SELECT * FROM EXIF_IMAGE where FOCAL_LENGTH >= " + minLength + 
+            	".0 AND FOCAL_LENGTH < " + maxLength + ".0");
+        else if (maxLength > 0.0)
+            doQueryForPictures("SELECT * FROM EXIF_IMAGE where FOCAL_LENGTH <= " + maxLength + ".0");
+        else if (minLength > 0.0)
+            doQueryForPictures("SELECT * FROM EXIF_IMAGE where FOCAL_LENGTH >= " + minLength + 
+            	".0");
+        else
+        	doQueryForPictures("SELECT * FROM EXIF_IMAGE");
+   }
+    
+    function filterPictureByGeoLocation(latSouth, lonWest, latNorth, lonEast) {
+        session.deletePagingContext("doQueryForPictures");
+        doQueryForPictures("SELECT * FROM EXIF_IMAGE where GPS_LATITUDE >= " + latSouth + 
+            	" AND GPS_LATITUDE < " + latNorth + " AND GPS_LONGITUDE >= " + lonWest + 
+            	" AND GPS_LONGITUDE < " + lonEast, "Map");
+        
+   }
+    
+   function filterArtistListForPictures(artist) {
+        session.deletePagingContext("doQueryForPictures");
+        
+        if (artist != null)
+        	doQueryForArtistListPictures("SELECT * FROM EXIF_IMAGE where ARTIST LIKE '" + artist +"%'");
+        else
+        	doQueryForArtistListPictures("SELECT * FROM EXIF_IMAGE");    	    	
+   }
+   
+   function filterPictureByLocation(distance) {
+    	trace("search by distance" + distance);
+   }
+    
+   function doQueryForArtistListPictures(cmisQuery) { 
+        session.doQueryPaged(cmisQuery, "filterArtistListForPictures", function(data) {
+	        if (!checkError(data, "#alertpane")) {
+	        	createArtistListPictures(data);
+	            // display buttons for paging and setup paging context
+	            var pageCtx = session.getPagingContext("filterArtistListForPictures");
+	            pageCtx.query = cmisQuery;
+	            var totalItems = pageCtx.totalItems==null ? 4294967295 : pageCtx.totalItems;
+	            var page = Math.floor(pageCtx.skipCount / session.opCtx.maxItems) + 1;
+	            var totalPages;
+	            if (pageCtx.totalItems==null)
+	                totalPages = "(unknown)";
+	            else
+	                totalPages = ((totalItems - (totalItems % session.opCtx.maxItems)) / session.opCtx.maxItems) + 1;
+	            
+	            if (data.results.length == 0)
+	                $("#pagingbuttons").html($("<p>").text("No items found."));
+	            else
+	                $("#pagingbuttons").html(null);
+	            
+	            if (pageCtx.getTotalPages() > 1) {
+	                $("#pagingbuttons")
+	                    .append($("<table>").append($("<tr>").append($("<td>")
+	                    .append($("<button>").attr("value", "first").click(function() {onClickQueryForArtistListPicturesFirst();}).append($("<img>").attr("src", "images/first.png")))
+	                    .append($("<button>").attr("value", "prev").click(function() {onClickQueryForArtistListPicturesPrev();}).append($("<img>").attr("src", "images/prev.png")))
+	                    .append($("<button>").attr("value", "next").click(function() {onClickQueryForArtistListPicturesNext();}).append($("<img>").attr("src", "images/next.png")))
+	                    .append($("<button>").attr("value", "last").click(function() {onClickQueryForArtistListPicturesLast();}).append($("<img>").attr("src", "images/last.png"))))
+	                    .append($("<td>").text("Page " + page + " of " + totalPages + " / Items total: " + (totalItems==4294967295?"unknown":totalItems)))))
+	                    .append($("<hr>"));
+	            }
+	         }
+	    });
+    }
+    
+    function createArtistListPictures(queryResp) {
+        var artists = {};
+        for (var child in queryResp.results) {
+            var props = queryResp.results[child].properties;
+            var typeId = getPropertyValue(props, "cmis:objectTypeId");
+            if (typeId != null && typeId === "exifImage") {
+                var artist  = getPropertyValue(props, "ARTIST");
+                if (artist)
+                	artists[artist] = artist;
+            }
+        }
+        
+        $("#filterresultlist").html(null);
+        for (var artist in artists) {
+            $("#filterresultlist").append($("<li>").append($("<a>").attr("href","javascript:filterPictureByArtist(\"" + artist + "\");").text(artist)));
+        }
+    }
+
+   function loadPlayer(domObj, cbFct) {
         domObj.load('jplayer.html', function() {
 
             myPlaylist = new jPlayerPlaylist({
@@ -291,7 +705,7 @@
                     enableRemoveControls: false
                 },
                 swfPath: "jplayer",
-                supplied: "webmv, mp3"
+                supplied: "m4v, mp3"
                 // supplied: "webmv, ogv, m4v, oga, mp3"
             });
 
@@ -299,7 +713,7 @@
         });        
     }
     
-    function getPlaylistForAlbum(albumName) {
+   function getPlaylistForAlbum(albumName) {
         var queryString; 
         
         if (albumName.lastIndexOf("no/unknown") >= 0)
@@ -317,14 +731,6 @@
             });
     }
     
-    function filterByArtist(filter) {
-        session.deletePagingContext("doQueryByArtist");
-        if (filter)
-            doQueryByArtist("SELECT * FROM AUDIO_FILE where ARTIST LIKE '" + filter + "%'");
-        else
-            doQueryByArtist("SELECT * FROM AUDIO_FILE");
-    }
-
     function doQueryByArtist(cmisQuery) {
         checkSession("#alertpane");
         $("#queryresponsesection *").remove();
@@ -349,7 +755,6 @@
             var props = queryResp.results[child].properties;
             var typeId = getPropertyValue(props, "cmis:objectTypeId");
             if (typeId != null && typeId === "audioFile") {
-                var playItem = {};
                 var album = getPropertyValue(props, "ALBUM");
                 var artist  = getPropertyValue(props, "ARTIST");
                 if (album && artist)
@@ -366,21 +771,13 @@
         }
     }
 
-    function filterByTitle(filter) {
-        session.deletePagingContext("doQueryByAlbum");
-        if (filter)
-            doQueryForPlaylist("SELECT * FROM AUDIO_FILE where TITLE LIKE '" + filter + "%'");
-        else
-            doQueryForPlaylist("SELECT * FROM AUDIO_FILE");
-    }
-    
     function doQueryForPlaylist(queryString) {
         checkSession("#alertpane");
         $("#queryresponsesection *").remove();
         trace("doing query: " + queryString);
         session.doQueryPaged(queryString, "doQueryForPlaylist", function(data) {
             if (!checkError(data, "#queryresponsesection")) {
-                var tbl = createPlaylist(data);
+                createPlaylist(data);
                 var pageCtx = session.getPagingContext("doQueryForPlaylist");
                 pageCtx.query = queryString;
                 var totalItems = pageCtx.totalItems==null ? 4294967295 : pageCtx.totalItems;
@@ -419,12 +816,17 @@
         for (var child in queryResp.results) {
             var props = queryResp.results[child].properties;
             var typeId = getPropertyValue(props, "cmis:objectTypeId");
-            if (typeId != null && typeId === "audioFile") {
+            if (typeId != null) {
                 var playItem = {};
                 playItem.artist = getPropertyValue(props, "ARTIST");
                 playItem.title = getPropertyValue(props, "TITLE");
-                playItem.mp3 = getContentUrl(getPropertyValue(props, "cmis:objectId"));
-                playItem.poster = "images/musical-notes.jpg";
+                var mimeType = getPropertyValue(props, "cmis:contentStreamMimeType");
+                if (mimeType.indexOf("audio/") == 0) {
+                	playItem.mp3 = getContentUrl(getPropertyValue(props, "cmis:objectId"));
+                    playItem.poster = "images/musical-notes.jpg";
+                } else if (mimeType.indexOf("video/") == 0) {
+                	playItem.m4v = getContentUrl(getPropertyValue(props, "cmis:objectId"));
+                }
                 trace("add track: " + playItem.mp3);
                 playList.push(playItem);
             }
@@ -432,6 +834,389 @@
         myPlaylist.setPlaylist(playList);
     }
 
+    function doQueryForOffice(cmisQuery) {
+        checkSession("#alertpane");
+        $("#queryresponsesection *").remove();
+        trace("doing query: " + cmisQuery);
+        session.doQueryPaged(cmisQuery, "doQueryForOffice", function(data) {
+            if (!checkError(data, "#alertpane")) {
+                createOfficeList(data);
+                // display buttons for paging and setup paging context
+                var pageCtx = session.getPagingContext("doQueryForOffice");
+                pageCtx.query = cmisQuery;
+                var totalItems = pageCtx.totalItems==null ? 4294967295 : pageCtx.totalItems;
+                var page = Math.floor(pageCtx.skipCount / session.opCtx.maxItems) + 1;
+                var totalPages;
+                if (pageCtx.totalItems==null)
+                    totalPages = "(unknown)";
+                else
+                    totalPages = ((totalItems - (totalItems % session.opCtx.maxItems)) / session.opCtx.maxItems) + 1;
+                
+                if (data.results.length == 0)
+                    $("#pagingbuttons").html($("<p>").text("No items found."));
+                else
+                    $("#pagingbuttons").html(null);
+                
+                if (pageCtx.getTotalPages() > 1) {
+                    $("#pagingbuttons")
+                        .append($("<table>").append($("<tr>").append($("<td>")
+                        .append($("<button>").attr("value", "first").click(function() {onClickQueryForOfficeFirst();}).append($("<img>").attr("src", "images/first.png")))
+                        .append($("<button>").attr("value", "prev").click(function() {onClickQueryForOfficePrev();}).append($("<img>").attr("src", "images/prev.png")))
+                        .append($("<button>").attr("value", "next").click(function() {onClickQueryForOfficeNext();}).append($("<img>").attr("src", "images/next.png")))
+                        .append($("<button>").attr("value", "last").click(function() {onClickQueryForOfficeLast();}).append($("<img>").attr("src", "images/last.png"))))
+                        .append($("<td>").text("Page " + page + " of " + totalPages + " / Items total: " + (totalItems==4294967295?"unknown":totalItems)))))
+                        .append($("<hr>"));
+                }
+             }
+        });       
+    }
+    
+    function createOfficeList(queryResp) {
+        var docs = [];
+        for (var child in queryResp.results) {
+            var props = queryResp.results[child].properties;
+            var typeId = getPropertyValue(props, "cmis:objectTypeId");
+            if (typeId != null) {
+                var docItem = {};
+                docItem.objectId = getPropertyValue(props, "cmis:objectId");
+                docItem.name = getPropertyValue(props, "cmis:name");
+                docItem.application  = getPropertyValue(props, "APPLICATION");
+                docItem.author  = getPropertyValue(props, "AUTHOR");
+                docItem.slideCount  = getPropertyValue(props, "SLIDE_COUNT");
+                docItem.pageCount  = getPropertyValue(props, "PAGE_COUNT");
+                docItem.lastSaveDate  = getPropertyValue(props, "LAST_SAVE_DATE");
+                docItem.keywords  = getPropertyValue(props, "KEYWORDS");
+                trace("add docs: " + docItem);
+                docs.push(docItem);
+            }
+        }
+        
+        displayOfficeResultTable(docs);
+    }
+    
+    function displayOfficeResultTable(docs) {
+        $("#resultpane").html(null);
+        var table = $("<table>");
+        var thead = $("<thead>");
+        var tbody = $("<tbody>");
+        $("#resultpane").append(table);
+        table.append(thead).append(tbody);
+        thead.append($("<th>").text("Name")).append($("<th>").text("Author")).append($("<th>").text("Save Date"))
+    		 .append($("<th>").text("Pages")).append($("<th>").text("Slides")).append($("<th>").text("Keywords"));
+                
+        for (var i in docs) {
+        	var doc = docs[i];
+            var trow = $("<tr>");
+            trow.append($("<a>").attr("href", getContentUrl(doc.objectId)).text(doc.name).attr("target", "_blank"))
+                .append($("<td>").text(doc.author))
+            	.append($("<td>").text(doc.lastSaveDate))
+            	.append($("<td>").text(doc.pageCount))
+            	.append($("<td>").text(doc.slideCount))
+            	.append($("<td>").text(doc.keywords));
+            tbody.append(trow);        	
+        }
+    }
+
+
+function doQueryForPictures(cmisQuery, displayKind) {
+    checkSession("#alertpane");
+    $("#queryresponsesection *").remove();
+    trace("doing query: " + cmisQuery);
+
+	if (null == displayKind)
+		displayKind = getImageDisplayKind();
+
+    session.doQueryPaged(cmisQuery, "doQueryForPictures", function(data) {
+        if (!checkError(data, "#alertpane")) {
+            createPictureList(data, displayKind);
+            // display buttons for paging and setup paging context
+            var pageCtx = session.getPagingContext("doQueryForPictures");
+            pageCtx.query = cmisQuery;
+            var totalItems = pageCtx.totalItems==null ? 4294967295 : pageCtx.totalItems;
+            var page = Math.floor(pageCtx.skipCount / session.opCtx.maxItems) + 1;
+            var totalPages;
+            if (pageCtx.totalItems==null)
+                totalPages = "(unknown)";
+            else
+                totalPages = ((totalItems - (totalItems % session.opCtx.maxItems)) / session.opCtx.maxItems) + 1;
+            
+            if (data.results.length == 0)
+                $("#pagingbuttons").html($("<p>").text("No items found."));
+            else
+                $("#pagingbuttons").html(null);
+            
+            if (pageCtx.getTotalPages() > 1) {
+                $("#pagingbuttons")
+                    .append($("<table>").append($("<tr>").append($("<td>")
+                    .append($("<button>").attr("value", "first").click(function() {onClickQueryForPicturesFirst();}).append($("<img>").attr("src", "images/first.png")))
+                    .append($("<button>").attr("value", "prev").click(function() {onClickQueryForPicturesPrev();}).append($("<img>").attr("src", "images/prev.png")))
+                    .append($("<button>").attr("value", "next").click(function() {onClickQueryForPicturesNext();}).append($("<img>").attr("src", "images/next.png")))
+                    .append($("<button>").attr("value", "last").click(function() {onClickQueryForPicturesLast();}).append($("<img>").attr("src", "images/last.png"))))
+                    .append($("<td>").text("Page " + page + " of " + totalPages + " / Items total: " + (totalItems==4294967295?"unknown":totalItems)))))
+                    .append($("<hr>"));
+            }
+         }
+    });       
+}
+
+function createPictureList(queryResp, displayKind) {
+    var docs = [];
+    for (var child in queryResp.results) {
+        var props = queryResp.results[child].properties;
+        var typeId = getPropertyValue(props, "cmis:objectTypeId");
+        if (typeId != null && typeId === "exifImage") {
+            var docItem = {};
+            docItem.objectId = getPropertyValue(props, "cmis:objectId");
+            docItem.name = getPropertyValue(props, "cmis:name");
+            docItem.make  = getPropertyValue(props, "MAKE");
+            docItem.artist  = getPropertyValue(props, "ARTIST");
+            docItem.focalLength  = getPropertyValue(props, "FOCAL_LENGTH");
+            docItem.model  = getPropertyValue(props, "MODEL");
+            docItem.dateTaken  = getPropertyValue(props, "CREATE_DATE");
+            docItem.width  = getPropertyValue(props, "IMAGE_WIDTH");
+            docItem.height  = getPropertyValue(props, "IMAGE_HEIGHT");
+            docItem.gpsLatitude = getDirectPropertyValue(props, "GPS_LATITUDE");
+            docItem.gpsLongitude = getDirectPropertyValue(props, "GPS_LONGITUDE");
+            docs.push(docItem);
+        }
+    }
+    
+    if (displayKind == "List")
+        displayPictureResultTable(docs);
+    else if (displayKind == "Map")
+    	displayPictureMap(docs);
+    else
+    	displayPictureGallery(docs);
+}
+
+function displayPictureGallery(docs) {
+	trace("display pictures as gallery");
+    $("#resultpane").html(null);
+    // Initialize the Image Gallery widget:
+//    $('#resultpane').imagegallery();
+    $('#resultpane').imagegallery( { show: "slide",
+        hide: "slide",
+        canvas: false }
+    );
+
+    // Create a buttonset out of the checkbox options:
+    $('#buttonset').html($("<input>").prop("type", "checkbox").prop("id", "option-fullscreen"))
+    	.append($("<label>").prop("for", "option-fullscreen").text("Fullscreen"))
+    	.append($("<input>").prop("type", "checkbox").prop("id", "option-slideshow"))
+    	.append($("<label>").prop("for", "option-slideshow").text("Slideshow"));
+    
+    // Create a buttonset out of the checkbox options:
+//    $('#buttonset').buttonset();
+
+    // Listen to options changes:
+    $('#buttonset input, #effect').change(function () {
+        $('#playerpane').imagegallery('option', {
+            show: 'fade',
+            hide: 'fade',
+            fullscreen: $('#option-fullscreen').is(':checked'),
+            slideshow: $('#option-slideshow').is(':checked') && 2000
+        });
+    });
+
+    // Enable real fullscreen mode:
+    $('#option-fullscreen').click(function () {
+        var checkbox = $(this),
+            root = document.documentElement;
+        if (checkbox.is(':checked')) {
+            if (root.webkitRequestFullScreen) {
+                root.webkitRequestFullScreen(
+                    window.Element.ALLOW_KEYBOARD_INPUT
+                );
+            } else if (root.mozRequestFullScreen) {
+                root.mozRequestFullScreen();
+            }
+        } else {
+            (document.webkitCancelFullScreen ||
+                document.mozCancelFullScreen ||
+                $.noop).apply(document);
+        }
+    });
+
+    // Load images from query response
+    var gallery = $('#resultpane');
+    
+    for (var i in docs) {
+    	var doc = docs[i];
+
+    	$('<a rel="gallery"/>')
+        .append($('<img>').prop('src', getContentUrl(doc.objectId)).prop('class', 'gallerylist'))
+        .prop('href', getContentUrl(doc.objectId))
+        .prop('title', doc.name)
+        .appendTo(gallery);
+    }
+}
+
+function displayPictureResultTable(docs) {
+    $("#resultpane").html(null);
+    var table = $("<table>");
+    var thead = $("<thead>");
+    var tbody = $("<tbody>");
+    $("#resultpane").append(table);
+    table.append(thead).append(tbody);
+    thead.append($("<th>").text("Name")).append($("<th>").text("Brand")).append($("<th>").text("Model"))
+		 .append($("<th>").text("Artist")).append($("<th>").text("Date Taken")).append($("<th>").text("Width"))
+		 .append($("<th>").text("Height")).append($("<th>").text("F-Length")).append($("<th>").text("Location"));
+            
+    for (var i in docs) {
+    	var doc = docs[i];
+        var trow = $("<tr>");
+        trow.append($("<td>").append($("<a>").attr("href", getContentUrl(doc.objectId)).text(doc.name).attr("target", "_blank")))
+            .append($("<td>").text(doc.make))
+        	.append($("<td>").text(doc.model))
+        	.append($("<td>").text(doc.artist))
+        	.append($("<td>").text(doc.dateTaken))
+        	.append($("<td>").text(doc.width))
+            .append($("<td>").text(doc.height))
+        	.append($("<td>").text(doc.focalLength));
+        if (doc.gpsLatitude != null && doc.gpsLongitude != null)
+            trow.append($("<td>").append($("<a>").attr("href", "javascript:showMap(" + doc.gpsLatitude + "," + doc.gpsLongitude + ",'" + doc.name + "', '" + getContentUrl(doc.objectId) + "')").text("Map")));
+        else
+        	trow.append($("<td>"));
+        tbody.append(trow);        	
+    }
+}
+
+function getBoundingRectFromPictures(docs) {
+	var west = null;
+	var east = null;
+	var north = null;
+	var south = null;
+	
+    for (var i in docs) {
+    	trace("bound rect, check pic " + i + ": " + docs[i].gpsLatitude + ", " + docs[i].gpsLongitude);
+    	if (west == null)
+    		west = docs[i].gpsLongitude;
+    	if (east == null)
+    		east = docs[i].gpsLongitude;
+    	if (north == null)
+    		north = docs[i].gpsLatitude;
+    	if (south == null)
+    		south = docs[i].gpsLatitude;
+    	
+    	if (docs[i].gpsLongitude < west)
+    		west = docs[i].gpsLongitude;
+    	if (docs[i].gpsLongitude > east)
+    		east = docs[i].gpsLongitude;
+        if (docs[i].gpsLatitude < south)
+    		south = docs[i].gpsLatitude;
+        if (docs[i].gpsLatitude > north)
+    		north = docs[i].gpsLatitude;
+    }
+	trace("bound rect, found (west, north, east, south): " + west + ", " + north + ", " + east + ", " + south);
+	return { "west": west, "north": north, "east": east, "south": south };
+}
+
+function displayPictureMap(docs) {
+	if (docs.length == 0)
+	    return;
+
+    $("#pagingbuttons").html($("<p>").text("Found " + docs.length + "picture(s). See map."));
+
+	var boundRect = getBoundingRectFromPictures(docs);
+	if (boundRect.west == null || boundRect.north == null || boundRect.east == null || boundRect.south == null) {
+		// This should never happen that query for location found a result but no location is available s
+		trace("No Geo location found in query, nothing to display");
+    	$('#hint').text("No Geo location found in query");
+		return;
+	}
+
+	// increase bounding rect by 10 %
+//    var width = boundRect.east - boundRect.west;
+//    var height = boundRect.north - boundRect.south;
+//    var north = boundRect.north + (0.05 * height);
+//    var south = boundRect.south - (0.05 * height);
+//    var west = boundRect.west - (0.05 * width);
+//    var east = boundRect.east + (0.05 * width);
+	var zoom = getZoomForBoundingRect(boundRect);
+	
+    var center = new google.maps.LatLng((boundRect.north + boundRect.south) / 2, (boundRect.west + boundRect.east) / 2);
+	map.panTo(center);
+	map.setZoom(zoom);
+	
+	markers = [];
+	for (var i in docs) {
+    	trace("display picture as markers on map " + docs[i].name);
+    	var marker = new google.maps.Marker({
+  	      position: new google.maps.LatLng(docs[i].gpsLatitude, docs[i].gpsLongitude),
+  	      map: map,
+  	      title: docs[i].name
+    	});
+        
+    	addClickHandlerToMarker(marker, getContentUrl(docs[i].objectId));
+    	    	
+    	markers.push(marker);
+    }
+}
+
+function addClickHandlerToMarker(marker, url) {
+	google.maps.event.addListener(marker, 'click', function(event) {
+ 	   window.open(url, "_blank");
+	});	
+}
+
+function clearMarkers() {
+	for (var i in markers) {
+		markers[i].setMap(null);
+	}
+}
+
+function getZoomForBoundingRect(rect) {
+	// http://stackoverflow.com/questions/6048975/google-maps-v3-how-to-calculate-the-zoom-level-for-a-given-bounds
+	var GLOBE_WIDTH = 256; // a constant in Google's map projection
+	var angleH = rect.east - rect.west;
+	var angleV = rect.north - rect.south;
+	var pixelWidth = document.getElementById("searchbylocmap").clientWidth;
+	var pixelHeight = document.getElementById("searchbylocmap").clientHeight;
+
+	if (angleH < 0) {
+	    angleH += 360;
+	} else if (angleH == 0) {
+		angleH = 0.01;
+	}
+	if (angleV < 0) {
+		angleV += 360;
+	} else if (angleV == 0) {
+		angleV = 0.01;
+	}
+	
+//	var zoomfactor = Math.round(Math.log(pixelWidth * 360 / angle / GLOBE_WIDTH) / Math.LN2);
+	var zoomFactorH = Math.floor(Math.log(pixelWidth * 360 / angleH / GLOBE_WIDTH) / Math.LN2)-1;
+	var zoomFactorV = Math.floor(Math.log(pixelHeight * 360 / angleV / GLOBE_WIDTH) / Math.LN2)-1;
+
+	var zoom = Math.min(zoomFactorH, zoomFactorV);
+	zoom = Math.min(zoom, 15); // limit to level 15
+	return zoom;
+}
+
+function moveMapToMyCurrentPosition() {
+    // Try HTML5 geolocation
+    if(navigator.geolocation) {
+      navigator.geolocation.getCurrentPosition(function(position) {
+        var pos = new google.maps.LatLng(position.coords.latitude,
+                                         position.coords.longitude);
+
+        map.setCenter(pos);
+        clearMarkers();
+        var marker = new google.maps.Marker({
+        	map: map,
+        	position: pos
+        });
+
+        markers.push(marker);
+      }, function() {
+          displayError("Determinining your current location failed.", '#alertpane');
+      });
+    } else {
+      // Browser doesn't support Geolocation
+        displayError("Your browser does not support getting your location.", '#alertpane');
+    }	
+}
+
     function onFilterByAlbum() {
         checkSession("#alertpane");
         $('#mainpane').load('filterbyalbum.html', function() {
@@ -476,6 +1261,258 @@
         });                
     }     
 
+    function onFilterVideoByTitle() {
+        checkSession("#alertpane");
+        $('#mainpane').load('filtervideobytitle.html', function() {
+            loadPlayer($('#playerpane'), function() {
+                });
+       });
+    }
+
+    function onFilterVideoByArtist() {
+        checkSession("#alertpane");
+        $('#mainpane').load('filtervideobyartist.html', function() {
+            loadPlayer($('#playerpane'), function() {
+                });
+       });
+    }
+
+    function onFilterVideoByReleaseDate() {
+        checkSession("#alertpane");
+        $('#mainpane').load('filtervideobyreleasedate.html', function() {
+            loadPlayer($('#playerpane'), function() {
+                });
+       });
+    }
+
+    function onFilterVideoByGenre() {
+        checkSession("#alertpane");
+        $('#mainpane').load('filtervideobygenre.html', function() {
+            loadPlayer($('#playerpane'), function() {
+                });
+       });
+    }
+
+    function onFilterOfficeByApplication() {
+        checkSession("#alertpane");
+        $('#mainpane').load('filterofficebyapplication.html', function() {
+      });
+    }
+    
+    function onFilterOfficeByAuthor() {
+        checkSession("#alertpane");
+        $('#mainpane').load('filterofficebyauthor.html', function() {
+       });
+    }
+
+    function onFilterOfficeByLastSaveDate() {
+        checkSession("#alertpane");
+        $('#mainpane').load('filterofficebylastsavedate.html', function() {
+       });
+    }
+
+    function onFilterOfficeByKeyword() {
+        checkSession("#alertpane");
+        $('#mainpane').load('filterofficebykeyword.html', function() {
+       });
+    }
+
+    function onFilterOfficeByNumberOfPages() {
+        checkSession("#alertpane");
+        $('#mainpane').load('filterofficebynopages.html', function() {
+       });
+    }
+
+    function onFilterOfficeByNumberOfSlides() {
+        checkSession("#alertpane");
+        $('#mainpane').load('filterofficebynoslides.html', function() {
+       });
+    }
+
+    function onFilterPictureByCamera() {
+        checkSession("#alertpane");
+        $('#mainpane').load('filterpicturebycamera.html', function() {
+       });
+    }
+    
+    function onFilterPictureByArtist() {
+        checkSession("#alertpane");
+        $('#mainpane').load('filterpicturebyartist.html', function() {
+       });
+    }
+    
+    function onFilterPictureByDateTaken() {
+        checkSession("#alertpane");
+        $('#mainpane').load('filterpicturebydatetaken.html', function() {
+       });
+    }
+    
+    function onFilterPictureyByFocalLength() {
+        checkSession("#alertpane");
+        $('#mainpane').load('filterpicturebyfocallength.html', function() {
+       });
+    }
+    
+    function onFilterPictureByResolution() {
+        checkSession("#alertpane");
+        $('#mainpane').load('filterpicturebyresolution.html', function() {
+       });
+    }
+    
+    function onFilterPictureByLocation() {
+        checkSession("#alertpane");
+        $('#mainpane').load('filterpicturebylocation.html', function() {
+            $( "input[name='MapTool']" ).bind( "click", activateLocationSearch );
+        	loadGoogleMap();
+       });
+    }
+
+    function onSubmitKeyword() {
+    	var keywordElement = document.getElementById('keyword_field');
+    	var keyword = keywordElement.value;
+    	filterOfficeDocumentsByKeyword(keyword);
+    }
+    
+    function onSubmitMapSearch() {
+    	var address = document.getElementById('map_search_field').value;
+    	trace("Search location on map: " + address);
+    	var geocoder = new google.maps.Geocoder();
+    	geocoder.geocode( { 'address': address}, function(results, status) {
+    	      if (status == google.maps.GeocoderStatus.OK) {
+    	        map.setCenter(results[0].geometry.location);
+//    	        var marker = new google.maps.Marker({
+//    	            map: map,
+//    	            position: results[0].geometry.location
+//    	        });
+    	      } else {
+    	        $("#resultpane").text("Cannot find location: " + status);
+    	      }
+    	    });
+    }
+    
+    function onSubmitMyLocation() {
+    	moveMapToMyCurrentPosition();
+    }
+    
+    
+    function getLatFromPointWithDistanceAndBearing(lat, lon, distance, bearing) {
+    	// see: http://www.movable-type.co.uk/scripts/latlong.html
+        // bearing is in radians, clockwise from north;
+    	// distance/radius is the angular distance (in radians), where d is the distance travelled 
+    	// and radius is the earthÕs radius
+
+    	var radius = 6371; // earth radius in km
+    	var dr = distance/radius;
+
+    	// convert lat, lon from degree to radians:
+    	lat = toRad(lat);
+    	lon = toRad(lon);
+    	
+    	var resLat = Math.asin( Math.sin(lat)*Math.cos(dr) + 
+                 Math.cos(lat)*Math.sin(dr)*Math.cos(bearing) );
+
+    	var resLon = lon + Math.atan2(Math.sin(bearing)*Math.sin(dr)*Math.cos(lat), 
+                 Math.cos(dr)-Math.sin(lat)*Math.sin(resLat));
+    	
+    	// convert back to degree
+    	resLat = toDeg(resLat);
+    	resLon = toDeg(resLon);
+    	
+    	trace("point with dist " + distance + " is: " + resLat + ", " + resLon);
+    	return new google.maps.LatLng(resLat, resLon);
+    }
+
+    function boundingRectFromPointWithDist(lat, lon, distance) {
+     	
+     	var hd = distance / 2.0;
+     	distanceToCorner = Math.sqrt(hd*hd*2);
+     	var bearing;
+     	
+     	bearing = Math.PI / 4; // 45¡ north-east
+     	var ptNE = getLatFromPointWithDistanceAndBearing(lat, lon, distance, bearing);
+     	
+     	bearing = 5.0 * Math.PI / 4; // 45¡ south-west
+     	var ptSW = getLatFromPointWithDistanceAndBearing(lat, lon, distance, bearing);
+
+     	var boundingRectangle = new google.maps.LatLngBounds(ptSW, ptNE);
+     	trace("bounding rect is: " + boundingRectangle.toString());
+     	return boundingRectangle;
+    }
+
+    function showRectOnMap(boundRect) {
+    	rect =  new google.maps.Rectangle();
+    	var rectOptions = {
+    		      strokeColor: "#FF0000",
+    		      strokeOpacity: 0.8,
+    		      strokeWeight: 2,
+    		      fillOpacity: 0.0,
+    		      map: map,
+    		      bounds: boundRect
+    		    };
+
+    	rect.setOptions(rectOptions);
+    }
+
+    // display map if location by map pane is loaded
+    function loadGoogleMap() {
+    	trace("Loading Google Map");
+    	var canvas = document.getElementById("searchbylocmap");
+    	var position = new google.maps.LatLng(35.509872,24.480286);
+       	var mapOptions = {
+    			center: position,
+    			zoom: 8,
+    			mapTypeId: google.maps.MapTypeId.ROADMAP
+    	};
+ 
+    	map = new google.maps.Map(canvas, mapOptions);
+    }
+    
+    function getPicturesByLocation() {
+		map.setOptions({ draggableCursor: 'crosshair' });		
+
+        clickListener = google.maps.event.addListener(map, 'click', function(event) {
+        	var distance = getDistance();
+    		trace("Clicked at position: (Lat: " + event.latLng.lat() + ", lon: " + event.latLng.lng() + ")");
+        	trace("Querying pictures from distance " + distance);
+            $("#pagingbuttons").html($("<p>").text("Querying for pictures, please wait..."));
+
+    		clearMarkers();
+    		var rect = boundingRectFromPointWithDist(event.latLng.lat(), event.latLng.lng(), distance);
+//    		showRectOnMap(rect);
+    		filterPictureByGeoLocation(rect.getSouthWest().lat(), rect.getSouthWest().lng(),
+    				rect.getNorthEast().lat(), rect.getNorthEast().lng());
+       });
+
+    }
+
+    function getDistance() {
+    	var distance = 3.0;
+    	
+    	for (var i=0; i < document.mapsearchformdistance.SearchByLocationDistance.length; i++)
+    	{
+    		if (document.mapsearchformdistance.SearchByLocationDistance[i].checked)
+    		{
+    			distance = document.mapsearchformdistance.SearchByLocationDistance[i].value;
+    		}
+    	}
+    	
+    	return distance;
+    }
+    
+    function activateLocationSearch() {
+    	trace("click in map to search");
+		if (document.mapsearchform.MapTool[0].checked)
+		{
+			map.setOptions({ draggableCursor: null }); // reset to default cursor
+			if (null != clickListener) {
+				google.maps.event.removeListener(clickListener);
+				clickListener = null;
+			}
+		} else	if (document.mapsearchform.MapTool[1].checked) {
+			getPicturesByLocation();
+		}
+    }
+
     $(document).ready(function() {
 
         $(document).ajaxError(function(event, request, settings, excep){
@@ -483,7 +1520,7 @@
             displayError(cmisError, '#alertpane');
          });
         
-        var myLayout = $('body').layout({
+        /*var myLayout = */ $('body').layout({
             west__size:         200 // "25%"
         ,   east__size:         0
             // RESIZE Accordion widget when panes resize
@@ -492,7 +1529,7 @@
 
         // ACCORDION - in the West pane
         $("#accordion1").accordion({ fillSpace: true,
-                                     active:     1
+                                     active:     3    //pictures
                                    });        
         connect();
         



Mime
View raw message