Permalink
Browse files

load file list from external file

  • Loading branch information...
1 parent 61fe64f commit a7053eb48553154cbd415e348e54d5c7d46bfe56 @takeshe12 committed Jan 26, 2017
Showing with 35 additions and 8 deletions.
  1. +15 −0 getfile.sh
  2. +17 −8 index.html
  3. +3 −0 infolist
View
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# check file exists
+if [ -e infolist ]; then
+ rm infolist
+fi
+
+# get early 3 files
+files=`ls info | sort -r | head -n 3`
+
+# except extention(.html)
+for filepath in $files; do
+ basename $filepath .html >> infolist
+done
+
View
@@ -20,7 +20,7 @@
var path = 'info/'+ this + '.html';
$("#" + this).load(path);
});
-})
+ })
</script>
<!-- Mobile Specific Metas
@@ -56,14 +56,23 @@ <h2 class="info">Information</h2>
<p id="infomation"></p>
<script>
-// get information iterative
-var hoge = ""
-var id = ["170125","170122","170110","161231","161204","161203"];
-$.each(id,function(i,value){
- hoge += "<section class='sec'><div id=\'" + value + "\'</div></section>";
+
+// get early 3 file from info file list.
+var arr = [];
+$.ajax({
+ url: 'infolist',
+ async:false, //wait to finish ajax connection
+ success: function(data){
+ arr = data.split(/\r\n|\r|\n/);
+ arr.pop(); //delete end value
+ var infotag = ""
+ $.each(arr,function(i,value){
+ infotag += "<section class='sec'><div id=\'" + value + "\'></div></section>";
+ });
+ var elem = document.getElementById("infomation");
+ elem.innerHTML = infotag
+ }
});
-var elem = document.getElementById("infomation");
-elem.innerHTML = hoge
</script>
</div>
View
@@ -0,0 +1,3 @@
+170125
+170122
+170110

0 comments on commit a7053eb

Please sign in to comment.