Skip to content

Instantly share code, notes, and snippets.

@amundo
Last active December 14, 2015 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amundo/5062195 to your computer and use it in GitHub Desktop.
Save amundo/5062195 to your computer and use it in GitHub Desktop.
i'm trying to load a json file with some metadata in it
var Metadata = function(){
this.files = [];
this.load = function(){
//console.log('this.load…');
$.getJSON(
"metadata.json",
this.store
)
};
this.store = function(json){
//console.log('Metadata' + show(Metadata));
//console.log('this…' + show(this));
//console.log('this…' + show(json));
console.log('this.store…' + json);
console.log('this.files…' + this.files);
this.files = json;
};
this.lookup = function(file_id){
return _.where(this.files, {file_id: file_id})[0];
};
this.load();
return {
files : this.files
}
}
// what i'm hoping to do with this thing (elsewhere in the app):
}
window.app = (function(){
var myapp = {};
myapp.metadata = new Metadata();
// then i'd be able to:
var hil001 = myapp.lookup('hil001');
// now i have the info about hil001…
})()
[
{
"comment": "really quiet",
"index": "001",
"analysis_status": "Handwritten phonetic transcription",
"language": "Hiligaynon (hil)",
"title": "Vocabulary 1",
"mediatype": "audio",
"format": "wav",
"equipment": "Edirol",
"sample_rate": 44100.0,
"access": "Open",
"filename": "hil001_2012-09-27_JDL_Class_NumbersOneToTen.wav",
"eaf_filename": "hil001_2012-09-27_JDL_Class_NumbersOneToTen.eaf",
"genre": "Elicited words",
"topic": "Numbers 1 to 10",
"setting": "FM Class",
"speaker": "Joshua de Leon",
"file_id": "hil001",
"date": "2012-09-27",
"place": "UCSB classroom",
"collector": "FM class"
},
{
"comment": "normal",
"index": "002",
"analysis_status": "",
"language": "Hiligaynon (hil)",
"title": "Diseases",
"mediatype": "audio",
"format": "wav",
"equipment": "Edirol",
"sample_rate": 44100.0,
"access": "",
"filename": "hil002_2012-10-01_JDL_DW_Diseases.wav",
"eaf_filename": "hil002_2012-10-01_JDL_DW_Diseases.eaf",
"genre": "",
"topic": "Diseases",
"setting": "Individual meeting",
"speaker": "Joshua de Leon",
"file_id": "hil002",
"date": "2012-10-01",
"place": "Field Methods room",
"collector": "Di"
},
{
"comment": "really quiet",
"index": "003",
"analysis_status": "",
"language": "Hiligaynon (hil)",
"title": "Animals",
"mediatype": "audio",
"format": "wav",
"equipment": "Edirol",
"sample_rate": 44100.0,
"access": "",
"filename": "hil003_2012-10-01_JDL_Class_Animals.wav",
"eaf_filename": "hil003_2012-10-01_JDL_Class_Animals.eaf",
"genre": "",
"topic": "Animals",
"setting": "FM Class",
"speaker": "Joshua de Leon",
"file_id": "hil003",
"date": "2012-10-01",
"place": "Field Methods room",
"collector": "FM Class"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment