diff --git a/asset/style.css b/asset/style.css index a1572b9..a3bc43f 100644 --- a/asset/style.css +++ b/asset/style.css @@ -16,6 +16,7 @@ body { /* MENU */ .menu { + color: #fff; height: 100%; background:#000; position:fixed; @@ -23,7 +24,7 @@ body { top: 0px; z-index: 100; padding-top:20px; - font-size:1.5em; + width: 150px; /*-webkit-transition: width 0.05s ease-in-out; transition: width 0.05s ease-in-out;*/ } @@ -43,29 +44,62 @@ body { color: #eee; } .menu-item { + font-size:1.5em; height: 50px; - padding-top:10px; - margin-top: 5px; - margin-right: 20px; -} -.menu-item-space { - margin-top: 50px; -} -.menu-item i { - width: 50%; - float: left; - padding: 2px 0 0 25px; - text-align: center; + padding-top: 10px; + margin: 0px auto; } .menu-item .count { - width: 50%; float: left; - padding: 0 0 0 15px; + text-align: right; + width: 50%; + padding-right: 10px; +} +.menu-item i { + float: left; text-align: center; + width: 50px; + margin-top: 2px; } +.menu-tag-container { + display: table; + margin: 40px auto; +} +.menu-tag-container i { + display: table-row; + font-size:1.5em; + width: 100%; + text-align: center; + color: #333; + height: 30px; +} +.menu:hover .menu-tag-container i { + color: #999; +} +.menu-tag { + display: table-row; + font-size:0.8em; + height: 20px; + margin-top: 5px; + padding-top: 2px; + float: left; + clear: left; +} +.menu-tag-count { + float: left; + text-align: right; + padding-right: 10px; +} +.menu-tag-label { + float: left; + text-align: left; +} + + + .container { - margin-left: 120px; + margin-left: 150px; /* This should be the width of the menu */ } /*.menu:hover + .container{ transition: 0.05s -webkit-filter ease-in; diff --git a/logic/main.js b/logic/main.js index 53b44b8..99d8ab7 100644 --- a/logic/main.js +++ b/logic/main.js @@ -137,12 +137,9 @@ function Main() this.processDatabase = function() { - var tempDatabase = this.database; - var dbKeys = Object.keys(this.database); - - for (i = 0; i < dbKeys.length; i++) + for (i = 0; i < this.keys.length; i++) { - let value = this.database[dbKeys[i]]; + let value = this.database[this.keys[i]]; // TAGS if (typeof value.TAGS !== 'undefined') @@ -154,7 +151,7 @@ function Main() tags[t] = tags[t].trim().toLowerCase(); } - this.database[dbKeys[i]].TAGS = tags; + this.database[this.keys[i]].TAGS = tags; } // TERMS @@ -173,10 +170,10 @@ function Main() formattedTerms.push(term); } - this.database[dbKeys[i]].TERM = formattedTerms; + this.database[this.keys[i]].TERM = formattedTerms; } - this.database[dbKeys[i]].DIID = i; + this.database[this.keys[i]].DIID = i; } console.log(this.database); } @@ -206,6 +203,7 @@ function Main() // CALCULATE let dbKeys = Object.keys(db); let types = {}; + let tags = {}; let terms = 0; let i = 0; while (i < dbKeys.length) @@ -221,22 +219,57 @@ function Main() { types[db[dbKeys[i]].TYPE] = 1; } + } - if (typeof db[dbKeys[i]].TERM !== 'undefined') + // TAGS + if (typeof db[dbKeys[i]].TAGS !== 'undefined') + { + for (var t = 0; t < db[dbKeys[i]].TAGS.length; t++) { - terms += db[dbKeys[i]].TERM.length; + if (typeof tags[db[dbKeys[i]].TAGS[t]] !== 'undefined') + { + tags[db[dbKeys[i]].TAGS[t]] ++; + } + else + { + tags[db[dbKeys[i]].TAGS[t]] = 1; + } } } + + // TERM + if (typeof db[dbKeys[i]].TERM !== 'undefined') + { + terms += db[dbKeys[i]].TERM.length; + } + i++; } - console.log(types); + + // SORT TAGS, TAKE TOP 5 + // Create items array + var items = Object.keys(tags).map(function(key) { + return [key, tags[key]]; + }); + + // Sort the array based on the second element + items.sort(function(first, second) { + return second[1] - first[1]; + }); + + tags = items.slice(0, 5); + console.log(tags); + + // DISPLAY let menuContent = ``; - + + // TYPE menuContent += ``; menuContent += ``; @@ -244,7 +277,8 @@ function Main() { menuContent += ` `; menuContent += ``; menuContent += ``; } @@ -252,7 +286,8 @@ function Main() { menuContent += ` `; menuContent += ``; menuContent += ``; } @@ -260,7 +295,8 @@ function Main() { menuContent += ` `; menuContent += ``; menuContent += ``; } @@ -268,7 +304,8 @@ function Main() { menuContent += ` `; menuContent += ``; menuContent += ``; } @@ -276,7 +313,8 @@ function Main() { menuContent += ` `; menuContent += ``; menuContent += ``; } @@ -284,7 +322,8 @@ function Main() { menuContent += ` `; menuContent += ``; menuContent += ``; } @@ -292,7 +331,8 @@ function Main() { menuContent += ` `; menuContent += ``; menuContent += ``; } @@ -300,7 +340,8 @@ function Main() { menuContent += ` `; menuContent += ``; menuContent += ``; } @@ -308,7 +349,8 @@ function Main() { menuContent += ` `; menuContent += ``; menuContent += ``; } @@ -316,7 +358,8 @@ function Main() { menuContent += ` `; menuContent += ``; menuContent += ``; } @@ -324,21 +367,42 @@ function Main() { menuContent += ` `; menuContent += ``; menuContent += ``; } + // TERM if (terms > 0) { // menuContent += ` `; menuContent += `
`; menuContent += ``; menuContent += ` `; menuContent += ``; } + // TAGS + if (tags.length > 0) + { + menuContent += ` `; + } + this.menu.innerHTML = ``; this.menu.innerHTML += menuContent; }