stocked
Daniel Asher Resnick 3 years ago
parent 0df9eb8bca
commit 050c71e872
  1. 38
      src/public/js/stocked.js
  2. 31
      src/views/partials/stocked.erb

@ -1,3 +1,28 @@
class TimeLogger {
constructor() {
this.logs = [];
this.unlabelled_id = 0;
this.start = this.previous = Date.now();
this.log('start');
}
log(label) {
var now = Date.now();
var log = {
'when': now,
'label': label,
'elapsed': now - this.previous,
'total': now - this.start
};
this.logs.push(log);
this.previous = now;
return log;
}
}
const timelogger = new TimeLogger;
console.log(timelogger.logs[0]);
var test_data = { var test_data = {
"Chattel Setting": { "Chattel Setting": {
"Born Chattel": { "Born Chattel": {
@ -1594,6 +1619,8 @@ var test_data = {
} }
}; };
console.log(timelogger.log("post-data"));
function StockedSetting(name, settingData) { function StockedSetting(name, settingData) {
this.isSubsetting = false; this.isSubsetting = false;
if(result = name.match(/(.*) setting/i)) { if(result = name.match(/(.*) setting/i)) {
@ -1709,6 +1736,13 @@ function StockedCtrl($scope, burningData) {
$scope.StockedUtil = StockedUtil; $scope.StockedUtil = StockedUtil;
/* testing */ /* testing */
$scope.general = {
'Name': '',
'Stride': 7,
'CommonTraits': ['foo', 'baz'],
'selectedTrait': 'bar'
};
$scope.parseStock = function (stockData){ $scope.parseStock = function (stockData){
let settings = []; let settings = [];
for (let name in stockData) { for (let name in stockData) {
@ -1720,6 +1754,10 @@ function StockedCtrl($scope, burningData) {
$scope.settings = $scope.parseStock(test_data); $scope.settings = $scope.parseStock(test_data);
/* end testing */ /* end testing */
$scope.addSetting = function (){
this.settings.push(new StockedSetting(this.newSettingName, {}));
}
$scope.collapseBody = function(data_target, $event) { $scope.collapseBody = function(data_target, $event) {
$(data_target).collapse("toggle"); $(data_target).collapse("toggle");
if($event) { $event.stopPropagation(); } if($event) { $event.stopPropagation(); }

@ -55,7 +55,29 @@
</div> </div>
<div class='panel-collapse collapse in' id='collapse_general'> <div class='panel-collapse collapse in' id='collapse_general'>
<div class='panel-body'> <div class='panel-body'>
TODO: Name, common traits, stride, etc. <label for='stock-name'>Name:</label>
<input class='form-control input-lg not-editing editable-name' name='stock-name' id='stock-name'
ng-model="general.Name" ng-click="$event.stopPropagation()"
ng-focus='editField($event, true)' ng-blur='editField($event, false)' />
<label for='stock-stride'>Stride:</label>
<input type="number" class='not-editing editable-num' name='stock-stride' id='stock-stride'
ng-model="general.Stride" ng-click="$event.stopPropagation()"
ng-focus='editField($event, true)' ng-blur='editField($event, false)' />
<br />
TODO: common traits
<div>
<span>{{general.CommonTraits}}</span>
<select class='form-control' ng-model='general.selectedTrait' ng-options='t for t in charredTraits'></select>
</div>
<div>
<a href='' ng-click='general.CommonTraits.push(general.selectedTrait)'>Add trait</a>
</div>
<div>
<a href='' ng-click=''>TODO: Add new trait</a>
</div>
<br />
TODO: other things in General section?
</div> </div>
</div> </div>
<div class='panel-heading'> <div class='panel-heading'>
@ -237,7 +259,12 @@
</div> </div>
</div> </div>
<div class='panel panel-default'> <div class='panel panel-default'>
<a href='/#/stocked'>+ TODO: Add new setting</a> <label for='stock-name'>Name:</label>
<input class='form-control input-lg not-editing editable-name'
name='new-setting-name' id='new-setting-name'
ng-model="newSettingName" ng-click="$event.stopPropagation()"
ng-focus='editField($event, true)' ng-blur='editField($event, false)' />
<a href='' ng-click='addSetting()'>+ TODO: Add new setting</a>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save