Skip to content

Commit d441f21

Browse files
author
Antonino Tramontana
committed
modificato: src/components/Activity.vue
1 parent f7b6ae7 commit d441f21

File tree

1 file changed

+29
-52
lines changed

1 file changed

+29
-52
lines changed

src/components/Activity.vue

Lines changed: 29 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -244,59 +244,36 @@
244244
import 'prismjs'
245245
import 'prismjs/components/prism-python.js'
246246
import sidebar from '../components/Sidebar'
247-
import musicpkg from '/home/n0rthw1nd/magisInfo/Progettazione/directories/vue-app/sounds/notes/music_package.json'
248-
249-
var prova = '{"userName": "Jaydeep Gondaliya"}' ;
250-
//var data = JSON.parse(musicpkg);
251-
252-
253-
new Vue ({
254-
el: '#liveapp',
255-
data: {
256-
json: null
257-
},
258-
created: function () {
259-
fetch("/home/n0rthw1nd/magisInfo/Progettazione/directories/vue-app/sounds/notes/music_package.json")
260-
.then(r => r.json())
261-
.then(json => {
262-
this.json=json;
263-
});
264-
},
247+
248+
249+
function readTextFile(file, callback) {
250+
var rawFile = new XMLHttpRequest();
251+
rawFile.overrideMimeType("application/json");
252+
rawFile.open("GET", file, true);
253+
rawFile.onreadystatechange = function() {
254+
if (rawFile.readyState === 4 && rawFile.status == "200") {
255+
callback(rawFile.responseText);
256+
}
257+
}
258+
rawFile.send(null);
259+
}
260+
261+
//usage:
262+
var data = readTextFile( "./static/music_package.json" , function(text){
263+
var datas = JSON.parse(text);
264+
console.log(datas)
265+
return datas;
265266
});
266-
//var instrumentlist = [];
267-
268-
269-
//new Vue jsondata: {
270-
271-
//}
272-
//new Vue ({
273-
// el: '#liveapp',
274-
// data: {
275-
// json: musicpkg
276-
// },
277-
// created: function () {
278-
// fetch("/data.json")
279-
// .then(r => r.json())
280-
// .then(json => {
281-
// this.json=json;
282-
// });
283-
// }
284-
// methods: {
285-
// readFromJson(input) {
286-
// console.log("inside readfromjson")
287-
// var json = JSON.parse(input)
288-
// console.log("parsed city.value is: " + json.city.value)
289-
// this.parsedJson = json
290-
// }
291-
//});
292-
293-
//for (p in data) {
294-
// var pkg = data['packages'][p]; // cat
295-
// var names = [pkg['name_IT'] , pkg['name_EN']];
296-
// instrumentlist[instrumentlist.length] = names;
297-
298-
//}
299-
var instrumentlist = [["piano","piano"], ["chitarra","guitar"], ["flauto","flute"]];
267+
268+
var instrumentlist = [];
269+
270+
for (p in data) {
271+
var pkg = data['packages'][p]; // cat
272+
var names = [pkg['name_IT'] , pkg['name_EN']];
273+
instrumentlist[instrumentlist.length] = names;
274+
275+
}
276+
var instrumentlist = [["pianoooo","piano"], ["chitarra","guitar"], ["flauto","flute"]];
300277
301278
export default {
302279
name: 'Blockly',

0 commit comments

Comments
 (0)