I need to modify my code to accommodate new json file
This is my html:
- $(document).ready(function() {
- $('#sounds').click(function(e) {
- console.log("got this far");
- e.preventDefault();
- $.getJSON('soundsData.json', function(data) {
- var html = '';
- $.each(data, function(key, val) {
- html += '<li>' + key + '<audio class="sound"><source src="./Miscellaneous/' + val[0] + '" type="audio/ogg"><source src="./Miscellaneous/' + val[1] + '" type="audio/mpeg"></audio></li>';
- $('#list').html(html);
- });
- });
- $('#list').on('click', 'li', function(e) {
- e.stopPropagation();
- $('audio').each(function() { this.pause(); }); //Stop all
- $('audio', this)[0].play(); // Play this one
- });
- });
- });
my css:
- li:hover {
- cursor: pointer;
- }
- li {
- font-size: 1.3em;
- font-weight: bold;
- padding: 5px 0;
- }
my current json file:
- {
- "angry cat" : ["angryCat.ogg","angryCat.mp3"],
- "anymore" : ["anymore.ogg","anymore.mp3"],
- "dark side" : ["darkside.ogg","darkside.mp3"],
- "failure to communicate" : ["comm.ogg","comm.mp3"],
- "count" : ["count.ogg","count.mp3"],
- "doh" : ["doh.ogg","doh.mp3"],
- "dumb asshole" : ["dumbasshole.ogg","dumbasshole.mp3"],
- "electric" : ["electric.ogg","electric.mp3"],
- "Good Bad and Ugly" : ["gbu.ogg","gbu.mp3"],
- "gdday" : ["gdday.ogg","gdday.mp3"]
- }
the json I want to use:
- {
- "Miscellaneous" : {
- "angry cat" : ["angryCat.ogg","angryCat.mp3"],
- "anymore" : ["anymore.ogg","anymore.mp3"],
- "dark side" : ["darkside.ogg","darkside.mp3"],
- "failure to communicate" : ["comm.ogg","comm.mp3"],
- "count" : ["count.ogg","count.mp3"],
- "doh" : ["doh.ogg","doh.mp3"],
- "dumb asshole" : ["dumbasshole.ogg","dumbasshole.mp3"],
- "electric" : ["electric.ogg","electric.mp3"],
- "Good Bad and Ugly" : ["gbu.ogg","gbu.mp3"],
- "gdday" : ["gdday.ogg","gdday.mp3"]
- },
- "Napoleon Dynamite" : {
- "Bow to your Sensi" : ["bow2sensi.ogg","bow2sensi.mp3"],
- "Cage Fighter" : ["cagefighter.ogg","cagefighter.mp3"],
- "Neck Meat" : ["neckmeat.ogg","neckmeat.mp3"],
- "Skills" : ["skills.ogg","skills.mp3"]
- }
- }
The json I'm using currently takes data from one folder named
Miscellaneous.
The jason I want to use takes data from two folders
Miscellaneous
and
Napoleon Dynamite.
these folders are contained in the
movieWaves folder. All the folders as well as the page files are contained within
movieWaves at the same level.