You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jspwiki.apache.org by Janne Jalkanen <ja...@ecyrd.com> on 2009/02/03 22:20:40 UTC

Re: svn commit: r740438 - in /incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH: ChangeLog src/com/ecyrd/jspwiki/Release.java src/webdocs/scripts/jspwiki-common.js src/webdocs/templates/default/AttachmentTab.jsp src/webdocs/templates/default/InfoContent.jsp

Excellent.  Could we also get this documented wherever "sortable" is  
documented?  It might be very useful knowledge for e.g. plugin writers.

/Janne

On Feb 3, 2009, at 23:00 , brushed@apache.org wrote:

> Author: brushed
> Date: Tue Feb  3 21:00:03 2009
> New Revision: 740438
>
> URL: http://svn.apache.org/viewvc?rev=740438&view=rev
> Log:
> 2.8.2-svn-8
>     * JSPWIKI-480, fix sorting on timestamps (modified date) in the  
> Attachement and Info tab
>
> Modified:
> incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog
> incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/ 
> Release.java
> incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/scripts/ 
> jspwiki-common.js
> incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/templates/ 
> default/AttachmentTab.jsp
> incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/templates/ 
> default/InfoContent.jsp
>
> Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog
> URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog?rev=740438&r1=740437&r2=740438&view=diff
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog (original)
> +++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog Tue Feb   
> 3 21:00:03 2009
> @@ -1,3 +1,15 @@
> +2009-02-03  Dirk Frederickx <di...@gmail.org>
> +
> +        * 2.8.2-svn-8
> +
> +        * JSPWIKI-480, sorting on timestamps (modified date) in
> +        the Attachement tab and the Info tab was not always working,
> +        as timeformats are depending on the user-preferences.
> +        An invisible javascript parsable timeformat attribute is now
> +        added to the tables, independent of the user-preferred  
> timeformat.
> +        This attribute is used by the js sorting routines.
> +
> +
> 2009-02-02  Dirk Frederickx <di...@gmail.org>
>
>      * 2.8.2-svn-7
>
> Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ 
> ecyrd/jspwiki/Release.java
> URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java?rev=740438&r1=740437&r2=740438&view=diff
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/ 
> jspwiki/Release.java (original)
> +++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/ 
> jspwiki/Release.java Tue Feb  3 21:00:03 2009
> @@ -77,7 +77,7 @@
>   *  <p>
>   *  If the build identifier is empty, it is not added.
>   */
> -    public static final String     BUILD         = "7";
> +    public static final String     BUILD         = "8";
>
>  /**
>   *  This is the generic version string you should use
>
> Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/ 
> scripts/jspwiki-common.js
> URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/scripts/jspwiki-common.js?rev=740438&r1=740437&r2=740438&view=diff
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/ 
> scripts/jspwiki-common.js (original)
> +++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/ 
> scripts/jspwiki-common.js Tue Feb  3 21:00:03 2009
> @@ -1318,7 +1318,7 @@
> 		this.DescendingTitle = "sort.descending".localize();
> 		
> 		$ES('.sortable table',page).each(function(table){
> -			if( table.rows.length < 2 ) return;
> +			if( table.rows.length <= 2 ) return;
>
> 			$A(table.rows[0].cells).each(function(th){
> 				th=$(th);
> @@ -1375,42 +1375,70 @@
> 	},
>
> 	guessDataType: function(rows, colidx){
> +
> 		var num=date=ip4=euro=kmgt=true;
> +
> 		rows.each(function(r,i){
> -			var v = $getText(r.cells[colidx]).clean().toLowerCase();
> +
> +			var v = r.cells[colidx];
> +			v = v.getAttribute('sortvalue') || $getText(v);
> +			v = v.clean().toLowerCase();
> +
> 			if(num)  num  = !isNaN(parseFloat(v));
> 			if(date) date = !isNaN(Date.parse(v));
> 			if(ip4)  ip4  = v.test(/(?:\\d{1,3}\\.){3}\\d{1,3}/); //169.169.0.1
> 			if(euro) euro = v.test(/^[£$€][0-9.,]+/);
> 			if(kmgt) kmgt = v.test(/(?:[0-9.,]+)\s*(?:[kmgt])b/);  //2 MB,  
> 4GB, 1.2kb, 8Tb
> +
> 		});
> +
> 		return (kmgt) ? 'kmgt': (euro) ? 'euro': (ip4) ? 'ip4': (date) ?  
> 'date': (num) ? 'num': 'string';
> +
> 	},
>
> 	convert: function(val, datatype){
> -		switch(datatype){
> -			case "num" : return  
> parseFloat( val.match( Number.REparsefloat ) );
> -			case "euro": return parseFloat( val.replace(/[^0-9.,]/g,'') );
> -			case "date": return new Date( Date.parse( val ) );
> +
> +		switch( datatype ){
> +
> +			case "num" :
> +				return parseFloat( val.match( Number.REparsefloat ) );
> +				
> +			case "euro":
> +				return parseFloat( val.replace(/[^0-9.,]/g,'') );
> +				
> +			case "date":
> +				return new Date( Date.parse( val ) );
> +				
> 			case "ip4" :
> 				var octet = val.split( "." );
> 				return parseInt(octet[0]) * 1000000000 + parseInt(octet[1]) *  
> 1000000 + parseInt(octet[2]) * 1000 + parseInt(octet[3]);
> +
> 			case "kmgt":
> 				var v = val.toString().toLowerCase().match(/([0-9.,]+) 
> \s*([kmgt])b/);
> 				if(!v) return 0;
> 				var z=v[2];
> 				z = (z=='m') ? 3 : (z=='g') ? 6 : (z=='t') ? 9 : 0;
> 				return v[1].toFloat()*Math.pow(10,z);
> -			default: return val.toString().toLowerCase();
> +
> +			default:
> +				return val.toString().toLowerCase();
> +
> 		}
> +
> 	},
>
> -	createCompare: function(i, datatype) {
> -		return function(row1, row2) {
> -			var val1 = Sortable.convert( $getText(row1.cells[i]), datatype );
> -			var val2 = Sortable.convert( $getText(row2.cells[i]), datatype );
> +	createCompare: function( i, datatype ){
> +
> +		return function( row1, row2 ){
>
> -			if(val1<val2){ return -1 } else if(val1>val2){ return 1 } else  
> return 0;
> +			//fixme: should cache the converted sortable values
> +			var v1 = row1.cells[i],
> +				v2 = row2.cells[i],
> +				val1 = Sortable.convert( v1.getAttribute('sortvalue') ||  
> $getText(v1), datatype ),
> +				val2 = Sortable.convert( v2.getAttribute('sortvalue') ||  
> $getText(v2), datatype );
> +
> +			return val1 - val2;
> +			
> 		}
> 	}
> }
>
> Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/ 
> templates/default/AttachmentTab.jsp
> URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/templates/default/AttachmentTab.jsp?rev=740438&r1=740437&r2=740438&view=diff
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/ 
> templates/default/AttachmentTab.jsp (original)
> +++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/ 
> templates/default/AttachmentTab.jsp Tue Feb  3 21:00:03 2009
> @@ -48,7 +48,9 @@
>
>  </table>
> </form>
> +
> <wiki:Messages div="error" />
> +
> </wiki:Permission>
> <wiki:Permission permission="!upload">
> <div class="formhelp"><fmt:message key="attach.add.permission"/></div>
> @@ -105,7 +107,9 @@
>    <td style="text-align:center;">
>      <a href="<wiki:PageInfoLink format='url' />"  
> title="<fmt:message key='attach.moreinfo.title'/ 
> >"><wiki:PageVersion /></a>
>    </td>
> -	  <td style="white-space:nowrap;"><fmt:formatDate value="<%=  
> att.getLastModified() %>" pattern="${prefs.DateFormat}" timeZone="$ 
> {prefs.TimeZone}" /></td>
> +	  <td style="white-space:nowrap;" sortvalue="<fmt:formatDate  
> value='<%= att.getLastModified() %>' pattern='EEE, d MMM yyyy  
> hh:mm:ss' />">
> +	  <fmt:formatDate value="<%= att.getLastModified() %>" pattern="$ 
> {prefs.DateFormat}" timeZone="${prefs.TimeZone}" />
> +	  </td>
>    <td><wiki:Author /></td>
>    <wiki:Permission permission="delete">
>    <td>
>
> Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/ 
> templates/default/InfoContent.jsp
> URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/templates/default/InfoContent.jsp?rev=740438&r1=740437&r2=740438&view=diff
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/ 
> templates/default/InfoContent.jsp (original)
> +++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/ 
> templates/default/InfoContent.jsp Tue Feb  3 21:00:03 2009
> @@ -199,7 +199,9 @@
>        </wiki:LinkTo>
>      </td>
>
> -        <td><fmt:formatDate value="<%=  
> currentPage.getLastModified() %>" pattern="${prefs.DateFormat}"  
> timeZone="${prefs.TimeZone}" /></td>
> +	    <td style="white-space:nowrap;" sortvalue="<fmt:formatDate  
> value='<%= currentPage.getLastModified() %>' pattern='EEE, d MMM  
> yyyy hh:mm:ss' />">
> +        <fmt:formatDate value="<%= currentPage.getLastModified()  
> %>" pattern="${prefs.DateFormat}" timeZone="${prefs.TimeZone}" />
> +        </td>
>      <td style="white-space:nowrap;text-align:right;">
>        <c:set var="ff"><wiki:PageSize /></c:set>
>        <fmt:formatNumber value='${ff/1000}' maxFractionDigits='3'  
> minFractionDigits='1'/>&nbsp;<fmt:message key="info.kilobytes"/>
> @@ -358,7 +360,9 @@
>    <td style="white-space:nowrap;text-align:right;">
>      <fmt:formatNumber value='<%=Double.toString(att.getSize()/ 
> 1000.0) %>' groupingUsed='false' maxFractionDigits='1'  
> minFractionDigits='1'/>&nbsp;<fmt:message key="info.kilobytes"/>
>    </td>
> -	  <td style="white-space:nowrap;"><fmt:formatDate value="<%=  
> att.getLastModified() %>" pattern="${prefs.DateFormat}" timeZone="$ 
> {prefs.TimeZone}" /></td>
> +	  <td style="white-space:nowrap;" sortvalue="<fmt:formatDate  
> value='<%= att.getLastModified() %>' pattern='EEE, d MMM yyyy  
> hh:mm:ss' />">
> +	  <fmt:formatDate value="<%= att.getLastModified() %>" pattern="$ 
> {prefs.DateFormat}" timeZone="${prefs.TimeZone}" />
> +	  </td>
>    <td><wiki:Author /></td>
>    <%--
>    // FIXME: This needs to be added, once we figure out what is  
> going on.
>