Mercurial > hg > Members > e105711
view webGL/ruby/directoryReader.rb @ 16:b322a8557f93 draft
draw text
author | e105711 <yomitan.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 03 Jul 2012 23:20:21 +0900 |
parents | 80789d11de5c |
children | 1e8fa3c370ab |
line wrap: on
line source
#!/user/bin/ruby dir = Dir.open("../music/"); file = File.open("../src/loadMusicFiles.js","w"); file.print "function loadMusicFiles(){\n"; file.print "\tvar jsonArray=[];\n"; dir.each{|list| if list.match(".json") && !(list.match("~")) then file.print "\tjsonArray.push(\"music/" + list + "\");\n"; end } file.print "\tcursor.setMAX(jsonArray.length);\n"; file.print "\tfor(var i=0;i<jsonArray.length;i++){\n"; file.print "\t\tvar httpObj = jQuery.get(jsonArray[i],null,function(){\n"; file.print "\t\t\tvar JSONObj = JSON.parse(httpObj.responseText);\n"; file.print "\t\t\tmusicsArray.push(new MusicInformation(JSONObj.title,JSONObj.path));\n"; file.print "\t\t});"; file.print "\t}\n"; file.print "}\n"; dir.close(); file.close();