mirror of
https://gitlab.com/Deukhoofd/BattleSim.git
synced 2025-10-27 18:00:03 +00:00
Added sort by tier and filter to current tier
This commit is contained in:
@@ -454,6 +454,7 @@ h1{font-family:"PT Sans Narrow","Helvetica Neue",sans-serif;font-size:2em;font-w
|
||||
.teambuilder .selectize-input input{height:18px}
|
||||
.teambuilder{position:absolute;top:0;bottom:0;left:0;right:0;}
|
||||
.teambuilder select,.teambuilder input{margin-bottom:0 !important;width:100%}
|
||||
.teambuilder .filter-tier-box{width:25px}
|
||||
.teambuilder .meta-info{max-width:1368px}
|
||||
.teambuilder .meta-info .left-side,.teambuilder .meta-info .right-side{float:left;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}
|
||||
.teambuilder .navigation{position:absolute;top:50px;bottom:0;background-color:rgba(223,231,232,0.5);width:160px;}
|
||||
|
||||
114
public/js/app.js
114
public/js/app.js
@@ -5538,6 +5538,9 @@
|
||||
this.setGeneration = __bind(this.setGeneration, this);
|
||||
this.sortSpecieslist = __bind(this.sortSpecieslist, this);
|
||||
this.changeSort = __bind(this.changeSort, this);
|
||||
this.arrToObject = __bind(this.arrToObject, this);
|
||||
this.objectToArr = __bind(this.objectToArr, this);
|
||||
this.filterTier = __bind(this.filterTier, this);
|
||||
this.setFormat = __bind(this.setFormat, this);
|
||||
this.initialize = __bind(this.initialize, this);
|
||||
return PokemonEditView.__super__.constructor.apply(this, arguments);
|
||||
@@ -5551,8 +5554,11 @@
|
||||
|
||||
PokemonEditView.prototype.movesTemplate = JST['teambuilder/moves'];
|
||||
|
||||
PokemonEditView.prototype.tierFilterBool = true;
|
||||
|
||||
PokemonEditView.prototype.events = {
|
||||
'change .sortSpecies': 'changeSort',
|
||||
'change .filter-tier': 'filterTier',
|
||||
'change .species_list': 'changeSpecies',
|
||||
'change .selected_nickname': 'changeNickname',
|
||||
'click .selected_shininess': 'changeShiny',
|
||||
@@ -5591,11 +5597,72 @@
|
||||
return this.setGeneration(format.generation);
|
||||
};
|
||||
|
||||
PokemonEditView.prototype.filterTier = function(e) {
|
||||
var FormeData, SpeciesData, arr, data, obj, species, thistier, _i, _len, _ref;
|
||||
thistier = this.pokemon.getTeam().getTier().tierRank;
|
||||
_ref = this.generation, SpeciesData = _ref.SpeciesData, FormeData = _ref.FormeData;
|
||||
if (e.target.checked) {
|
||||
arr = this.objectToArr(SpeciesData);
|
||||
console.log(thistier);
|
||||
for (_i = 0, _len = arr.length; _i < _len; _i++) {
|
||||
obj = arr[_i];
|
||||
obj.tier = window.PokeBattle.Tier.Tiers[FormeData[obj.pokename]["default"].tier[0]].tierRank;
|
||||
}
|
||||
console.log(arr);
|
||||
arr = _.filter(arr, function(thing) {
|
||||
return thing.tier === thistier;
|
||||
});
|
||||
obj = this.arrToObject(arr);
|
||||
this.speciesList = (function() {
|
||||
var _results;
|
||||
_results = [];
|
||||
for (species in obj) {
|
||||
data = obj[species];
|
||||
_results.push(species);
|
||||
}
|
||||
return _results;
|
||||
})();
|
||||
return this.render();
|
||||
} else {
|
||||
this.speciesList = (function() {
|
||||
var _results;
|
||||
_results = [];
|
||||
for (species in SpeciesData) {
|
||||
data = SpeciesData[species];
|
||||
_results.push(species);
|
||||
}
|
||||
return _results;
|
||||
})();
|
||||
return this.render();
|
||||
}
|
||||
};
|
||||
|
||||
PokemonEditView.prototype.objectToArr = function(data) {
|
||||
var arr, key, val;
|
||||
arr = [];
|
||||
for (key in data) {
|
||||
val = data[key];
|
||||
val.pokename = key;
|
||||
arr.push(val);
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
PokemonEditView.prototype.arrToObject = function(arr) {
|
||||
var obj, thing, _i, _len;
|
||||
obj = {};
|
||||
for (_i = 0, _len = arr.length; _i < _len; _i++) {
|
||||
thing = arr[_i];
|
||||
obj[thing.pokename] = thing;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
PokemonEditView.prototype.changeSort = function(e) {
|
||||
var sort;
|
||||
sort = $(e.currentTarget).val();
|
||||
if (sort === "Default Sort") {
|
||||
return this.sortSpecieslist("Default");
|
||||
if (sort === "Sort") {
|
||||
return this.sortSpecieslist("tier", false);
|
||||
} else if (sort === "Sort by Dexnumber") {
|
||||
return this.sortSpecieslist("id", false);
|
||||
} else if (sort === "Invert by Dexnumber") {
|
||||
@@ -5604,6 +5671,10 @@
|
||||
return this.sortSpecieslist("pokename", false);
|
||||
} else if (sort === "Invert Alphabetically") {
|
||||
return this.sortSpecieslist("pokename", true);
|
||||
} else if (sort === "Sort by Tier") {
|
||||
return this.sortSpecieslist("tier", false);
|
||||
} else if (sort === "Invert by Tier") {
|
||||
return this.sortSpecieslist("tier", true);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5628,23 +5699,23 @@
|
||||
};
|
||||
|
||||
PokemonEditView.prototype.sortObject = function(data, option, reverse) {
|
||||
var arr, finished, key, newobj, thing, val, _i, _len;
|
||||
arr = [];
|
||||
for (key in data) {
|
||||
val = data[key];
|
||||
val.pokename = key;
|
||||
arr.push(val);
|
||||
var FormeData, arr, finished, obj, _i, _len;
|
||||
arr = this.objectToArr(data);
|
||||
if (option !== 'tier') {
|
||||
arr = _.sortBy(arr, option);
|
||||
} else {
|
||||
FormeData = this.generation.FormeData;
|
||||
for (_i = 0, _len = arr.length; _i < _len; _i++) {
|
||||
obj = arr[_i];
|
||||
obj.tier = window.PokeBattle.Tier.Tiers[FormeData[obj.pokename]["default"].tier[0]].tierRank;
|
||||
arr = _.sortBy(arr, 'tier');
|
||||
}
|
||||
}
|
||||
arr = _.sortBy(arr, option);
|
||||
if (reverse === true) {
|
||||
arr.reverse();
|
||||
}
|
||||
newobj = {};
|
||||
for (_i = 0, _len = arr.length; _i < _len; _i++) {
|
||||
thing = arr[_i];
|
||||
newobj[thing.pokename] = thing;
|
||||
}
|
||||
return finished = newobj;
|
||||
obj = this.arrToObject(arr);
|
||||
return finished = obj;
|
||||
};
|
||||
|
||||
PokemonEditView.prototype.setGeneration = function(generation) {
|
||||
@@ -6026,6 +6097,7 @@
|
||||
};
|
||||
|
||||
PokemonEditView.prototype.render = function() {
|
||||
var filtertierbox;
|
||||
this.$el.html(this.editTemplate({
|
||||
window: window,
|
||||
speciesList: this.speciesList,
|
||||
@@ -6053,6 +6125,18 @@
|
||||
}
|
||||
});
|
||||
attachSelectize(this.$el.find(".selected_item"));
|
||||
filtertierbox = this.$el.find(".filter-tier-box")[0];
|
||||
console.log(filtertierbox);
|
||||
console.log(this.tierFilterBool);
|
||||
if (this.tierFilterBool === false) {
|
||||
console.log("false");
|
||||
filtertierbox.checked = true;
|
||||
this.tierFilterBool = true;
|
||||
} else if (this.tierFilterBool === true) {
|
||||
console.log("true");
|
||||
filtertierbox.checked = false;
|
||||
this.tierFilterBool = false;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
@@ -865,7 +865,7 @@ var locals_ = (locals || {}),speciesList = locals_.speciesList,itemList = locals
|
||||
var block = this.block, attributes = this.attributes || {}, escaped = this.escaped || {};
|
||||
buf.push("<tr><td class=\"stat-label\"><strong>" + (jade.escape((jade.interp = statName) == null ? '' : jade.interp)) + ":</strong></td><td class=\"ev-range-cell\"><input" + (jade.attrs({ 'type':("range"), 'min':("0"), 'max':("252"), 'step':("4"), 'data-stat':(keyName), "class": [('ev-entry')] }, {"type":true,"min":true,"max":true,"step":true,"data-stat":true})) + "/></td><td class=\"ev-cell\"><input" + (jade.attrs({ 'type':("text"), 'data-stat':(keyName), "class": [('ev-entry')] }, {"type":true,"data-stat":true})) + "/></td><td class=\"iv-cell\"><input" + (jade.attrs({ 'type':("text"), 'data-stat':(keyName), "class": [('iv-entry')] }, {"type":true,"data-stat":true})) + "/></td><td" + (jade.attrs({ 'data-stat':(keyName), "class": [('base-stat')] }, {"data-stat":true})) + "></td><td" + (jade.attrs({ 'data-stat':(keyName), "class": [('stat-total')] }, {"data-stat":true})) + "></td></tr>");
|
||||
};
|
||||
buf.push("<div class=\"meta-info clearfix\"><div class=\"left-side\"><div class=\"species\"><select class=\"sortSpecies\"><option>" + (jade.escape(null == (jade.interp = "") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Sort by Dexnumber") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Invert by Dexnumber") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Sort Alphabetically") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Invert Alphabetically") ? "" : jade.interp)) + "</option></select><select class=\"species_list\"><option></option>");
|
||||
buf.push("<div class=\"meta-info clearfix\"><div class=\"left-side\"><div class=\"species\"><label class=\"filter-tier\"><input type=\"checkbox\" class=\"filter-tier-box\"/>Filter to Current Tier</label><select class=\"sortSpecies\"><option>" + (jade.escape(null == (jade.interp = "Sort") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Sort by Dexnumber") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Invert by Dexnumber") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Sort Alphabetically") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Invert Alphabetically") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Sort by Tier") ? "" : jade.interp)) + "</option><option>" + (jade.escape(null == (jade.interp = "Invert by Tier") ? "" : jade.interp)) + "</option></select><select class=\"species_list\"><option></option>");
|
||||
// iterate speciesList
|
||||
;(function(){
|
||||
var $$obj = speciesList;
|
||||
|
||||
Reference in New Issue
Block a user