You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@community.apache.org by hu...@apache.org on 2016/02/14 10:40:55 UTC

svn commit: r1730304 - /comdev/helpwanted.apache.org/site/js/hw.js

Author: humbedooh
Date: Sun Feb 14 09:40:55 2016
New Revision: 1730304

URL: http://svn.apache.org/viewvc?rev=1730304&view=rev
Log:
support sorting by columns

Modified:
    comdev/helpwanted.apache.org/site/js/hw.js

Modified: comdev/helpwanted.apache.org/site/js/hw.js
URL: http://svn.apache.org/viewvc/comdev/helpwanted.apache.org/site/js/hw.js?rev=1730304&r1=1730303&r2=1730304&view=diff
==============================================================================
--- comdev/helpwanted.apache.org/site/js/hw.js (original)
+++ comdev/helpwanted.apache.org/site/js/hw.js Sun Feb 14 09:40:55 2016
@@ -15,6 +15,7 @@
  limitations under the License.
 */
 
+var hw_oldstate
 
 var hw_weburl = new RegExp(
   "(" +
@@ -182,7 +183,7 @@ function wizard(step, arg) {
             obj.appendChild(document.createElement('br'))
         }
         obj.innerHTML += '<br/><div style="width: 100%; margin-top: 40px;"><input type="button" class="finishbutton" onclick="doForm()" value="Find me something to do!"/>' +
-        '<a onclick="wizard(1)" href="javascript:void(0);">Back to start</a></div>'
+        '<a onclick="wizard(1)" href="javascript:void(0);"><img src="/images/back.png" style="margin-left: 20px;"></a></div>'
     }
 }
 
@@ -315,6 +316,7 @@ function populateAdminForm() {
 }
 
 function displayItems(json, state) {
+    json = json ? json : cjson
     cjson = json
     var numItems = 0
     for (var i in json) {
@@ -324,6 +326,18 @@ function displayItems(json, state) {
         }
         numItems++
     }
+    
+    if (state && typeof(state) === "string") {
+        if (hw_oldstate == state) {
+            json.sort(function(a,b) { return a[state] < b[state] })
+            hw_oldstate = ""
+        } else {
+            json.sort(function(a,b) { return a[state] > b[state] })
+            hw_oldstate = state
+        }
+        
+    }
+    
     var obj = document.getElementById('hwitems')
     
     if (typeof(numItems) === 'undefined') {
@@ -332,7 +346,12 @@ function displayItems(json, state) {
     }
     
     obj.innerHTML = "<p id='hwrtable'>Found " + numItems + " item" + (numItems != 1 ? "s" : "") + " you might be interested in:</p>"
-    var tbl = "<table style='text-align: left;'><tr><th></th><th>Project</th><th>Title</th><th>Languages</th><th>Difficulty</th><th>Created</th></tr>"
+    var tbl = "<table style='text-align: left;'>" +
+    "<tr style='cursor: pointer' title='Click on a column to sort'><th>&nbsp;</th><th onclick='displayItems(null, \"project\");'>Project</th>" +
+    "<th onclick='displayItems(null, \"title\");'>Title</th>" +
+    "<th onclick='displayItems(null, \"languages\");'>Languages</th>" +
+    "<th onclick='displayItems(null, \"difficulty\");'>Difficulty</th>" +
+    "<th onclick='displayItems(null, \"created\");'>Created</th></tr>"
     for (var i in json) {
         var item = json[i]
         if (item.closed) {