on master help sign in
*
edbec08Devine Lu Linvega
scripts/hallway.js+13−2
@@ -27,6 +27,16 @@ function Hallway (sites) {
27
27
28 // Entries
28 // Entries
29
29
30+ function compare( a, b ) {
31+ if ( a.date < b.date ){
32+ return -1;
33+ }
34+ if ( a.date > b.date ){
35+ return 1;
36+ }
37+ return 0;
38+ }
39+
30 this.sortEntries = function () {
40 this.sortEntries = function () {
31 const a = []
41 const a = []
32 for (const id in feeds) {
42 for (const id in feeds) {
@@ -36,7 +46,7 @@ function Hallway (sites) {
36 a.push(entry)
46 a.push(entry)
37 }
47 }
38 }
48 }
39− return a
49+ return a.sort( compare );
40 }
50 }
41
51
42 this.templateEntry = function (entry) {
52 this.templateEntry = function (entry) {
@@ -92,7 +102,8 @@ function Hallway (sites) {
92 const lines = feed.split('\n')
102 const lines = feed.split('\n')
93 const entries = []
103 const entries = []
94 for (const id in lines) {
104 for (const id in lines) {
95− const line = lines[id]
105+ const line = lines[id].trim()
106+ if(line === ''){ continue }
96 const date = line.substr(0, 25).trim()
107 const date = line.substr(0, 25).trim()
97 const body = line.substr(26).trim()
108 const body = line.substr(26).trim()
98 entries.push({ date, body, author })
109 entries.push({ date, body, author })