Skip to content

Commit 018a6fa

Browse files
committed
apps sort by edit date. console.log patch for old browsers
1 parent 9241b76 commit 018a6fa

File tree

5 files changed

+39
-14
lines changed

5 files changed

+39
-14
lines changed

coder-base/apps/coder/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"created": "2013-03-05",
3-
"modified": "2013-06-14",
3+
"modified": "2013-06-26",
44
"color": "#bdc3c7",
55
"author": "Jason Striegel",
66
"name": "Coder",

coder-base/apps/coderlib/app.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ exports.listApps = function() {
8585
var info = fs.statSync( appdir + filename );
8686
if ( info.isDirectory() ) {
8787
var appinfo = null;
88+
var metastat = null;
8889
try {
89-
appinfo = fs.statSync( appdir + filename + "/app.js" );
90+
appinfo = fs.statSync( appdir + filename + "/app.js" );
91+
metastat = fs.statSync( appdir + filename + "/meta.json" );
9092
} catch ( e ) {
9193
}
9294
if ( typeof appinfo !== 'undefined' && appinfo && appinfo.isFile() ) {
@@ -108,7 +110,7 @@ exports.listApps = function() {
108110
metainfo.hidden = (typeof metafile.hidden !== 'undefined') ? metafile.hidden : metainfo.hidden;
109111
} catch( e ) {
110112
}
111-
apps[filename] = { appname: filename, metadata: metainfo };
113+
apps[filename] = { appname: filename, metadata: metainfo, ctime: metastat.ctime.getTime() };
112114
}
113115
}
114116
}

coder-base/apps/coderlib/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"created": "2013-03-05",
3-
"modified": "2013-03-13",
3+
"modified": "2013-06-26",
44
"color": "#3e3e3e",
55
"author": "Jason Striegel",
66
"name": "CoderLib",

coder-base/static/apps/coder/js/index.js

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ var handleFileImport = function( ev ) {
9595
if ( files && files.length > 0 ) {
9696
var importfile = files[0];
9797

98-
console.log( importfile );
98+
//console.log( importfile );
9999
if (!importfile.type.match('application/zip')) {
100100
alert('This doesn\'t appear to be a Coder project zip file');
101101
return false;
@@ -114,8 +114,8 @@ var handleFileImport = function( ev ) {
114114
cache: false,
115115
data: fdata,
116116
success: function( data ) {
117-
console.log('upload returned');
118-
console.log(data);
117+
//console.log('upload returned');
118+
//console.log(data);
119119
if ( data.status === 'success' ) {
120120
var newappid = data.appname;
121121
window.location.href = '/app/editor/edit/' + encodeURIComponent(newappid);
@@ -218,7 +218,7 @@ var saveSettings = function() {
218218
$.post('/app/auth/api/devicename/set',
219219
{ 'device_name': $('#coder_name').val() },
220220
function(d) {
221-
console.log( d );
221+
//console.log( d );
222222
if ( d.status === 'success' ) {
223223
device_name = d.device_name;
224224
$("#coder_logo").text( device_name );
@@ -236,7 +236,7 @@ var saveSettings = function() {
236236
$.post('/app/auth/api/coderowner/set',
237237
{ 'coder_owner': $('#coder_ownername').val() },
238238
function(d) {
239-
console.log( d );
239+
//console.log( d );
240240
if ( d.status === 'success' ) {
241241
coder_owner = d.coder_owner;
242242
}
@@ -261,7 +261,7 @@ var saveSettings = function() {
261261
$.post('/app/auth/api/codercolor/set',
262262
{ 'coder_color': hexcolor },
263263
function(d) {
264-
console.log( d );
264+
//console.log( d );
265265
if ( d.status === 'success' ) {
266266
coder_color = d.coder_color;
267267
$("#coder_nav").css('background-color', coder_color);
@@ -283,6 +283,8 @@ var saveSettings = function() {
283283

284284
var buildAppList = function(apps){
285285

286+
287+
//get the app color from our own app (appname is set globally in template)
286288
metadata = apps[appname].metadata;
287289
$('.userbgcolor').css('background-color', metadata.color);
288290

@@ -304,9 +306,25 @@ var buildAppList = function(apps){
304306
};
305307
};
306308

307-
//console.log( apps );
308-
for ( var x in apps ) {
309-
var app = apps[x];
309+
310+
311+
//Sort the apps by more recently modified
312+
var sortedapps = [];
313+
for ( var k in apps ) {
314+
sortedapps.push( apps[k] );
315+
}
316+
sortedapps.sort( function(a,b) {
317+
if ( a.ctime < b.ctime ) {
318+
return 1;
319+
} else if ( b.ctime < a.ctime ) {
320+
return -1;
321+
} else {
322+
return 0;
323+
}
324+
});
325+
326+
for ( var x=0; x<sortedapps.length; x++ ) {
327+
var app = sortedapps[x];
310328

311329
//don't show hidden apps
312330
//console.log( app.metadata );
@@ -373,7 +391,7 @@ var createAppClicked = function() {
373391
app_color: rgb2hex( $("#createform .colorchit.active").first().css('background-color') )
374392
},
375393
function(d) {
376-
console.log( d );
394+
//console.log( d );
377395
var newappid = d.appname;
378396
window.location.href = '/app/editor/edit/' + encodeURIComponent(newappid);
379397
}

coder-base/static/apps/coderlib/js/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
* limitations under the License.
1919
*/
2020

21+
if (typeof console === "undefined" || typeof console.log === "undefined") {
22+
console = {};
23+
console.log = function() {};
24+
}
25+
2126
var Coder = {
2227
coderlib_url: "/app/coderlib",
2328
appname: '',

0 commit comments

Comments
 (0)