var v = new Vue({ el: '#app', data:{ debug: true, static: null, user_data: [], active_page: "bundles", active_room: 0, active_bundle: 0, active_season: "spring", active_skill: "farming", save_mode: false, load_mode: false }, ready: function(){ this.fetchData(); new Clipboard('.copy'); storedUserData = localStorage.getItem('user_data'); if(storedUserData !== null && storedUserData !== ""){ this.loadData(storedUserData); } }, computed: { user_data_serialized: function(){ return btoa(JSON.stringify(this.user_data)); } }, methods: { fetchData: function(){ this.$http.get('bundles.json', function(data, status, response){ if(status == 200){ this.static = data; if(this.user_data.length <= 0){ for(i=0; i 0){ return true; } else{ return false; } }, getSeasonName: function(seasonId){ for(i = 0; i < this.static.seasons.length; i++){ if(this.static.seasons[i].id === seasonId){ return this.static.seasons[i].name; } } return ""; }, getSkillName: function(skillId){ for(i = 0; i < this.static.skills.length; i++){ if(this.static.skills[i].id === skillId){ return this.static.skills[i].name; } } return ""; }, getRoomItemsRequired: function(roomId) { return this.static.bundles.reduce(function(previousValue, nextValue){ if(nextValue.room === roomId){ return previousValue + nextValue.items_required; } else{ return previousValue; } }, 0) }, getRoomItemsChecked: function(roomId){ return this.static.bundles .filter(function(b){ return b.room === roomId; }) .reduce(function(p, c){ return p + Math.min(v.user_data[c.id].length, c.items_required); }, 0); } } }); Vue.filter('inBundle', function(value, id){ return value.filter(function(element){ if(element.bundles.indexOf(id) > -1){ return true; } else{ return false; } }); }); Vue.filter('filterByArray', function(array1, array2){ return array1.filter(function(element){ if(array2.indexOf(element.id) > -1){ return true; } else{ return false; } }); });