Last active
January 20, 2018 10:50
-
-
Save wonderful123/eccf17dfcb18ee28c425659baafe1f48 to your computer and use it in GitHub Desktop.
Trade sim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Object.extend({ | |
description: "Gives the cheapest prices", | |
options: [ | |
{ | |
label: "Time period", | |
selection: "1d", | |
component: "trade-simulator/trigger-options/select-option", | |
options: ["1d", "3d", "5d", "30d"] | |
}, | |
{ | |
label: "Maximum price", | |
component: "trade-simulator/trigger-options/input-option", | |
selection: "10" | |
}, | |
], | |
priceData: {}, | |
validBuys: function(date) { | |
// return list of valid buys on date using priceData and options | |
// Just some test responses.... | |
if (date === "1") | |
return ["Wünsche", "sind", "Träume"]; | |
if (date === "2") | |
return ["Was", "geht", "Alter?"]; | |
if (date === "3") | |
return ["Hello", "my", "name", "is", "Doctor", "Greenthumb"]; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import CheapestPrice from './cheapest-price'; | |
export default Ember.Component.extend({ | |
triggers: [ | |
"Cheapest price", | |
"Highest price" | |
], | |
selection: "Cheapest price", //default | |
buyTrigger: Ember.computed('selection', function() { | |
let selection = this.get('selection') | |
var trigger; | |
if (selection === "Cheapest price") { | |
trigger = CheapestPrice.create(); | |
} else if (selection === "Highest price") { | |
return {description: "Would return HighestPrice object with option list"}; | |
} | |
this.sendAction('setTrigger', trigger); | |
return trigger; | |
}), | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
priceData: { | |
"abc": [5, 2, 3, 6, 2, 6], | |
"xyz": [8, 7, 6, 8, 5, 4] | |
}, | |
date: "1", | |
actions: { | |
calculate: function() { | |
let date = this.get('date'); | |
let buyTrigger = this.get('buyTrigger'); | |
buyTrigger.priceData = this.priceData; // set the object price data | |
let validBuys = buyTrigger.validBuys(date); | |
this.set('validBuys', `Cheapest buys on day ${this.get('date')}, max price of $${buyTrigger.options[1].selection} are: ${validBuys}`); | |
}, | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.13.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.16.2", | |
"ember-template-compiler": "2.16.2", | |
"ember-testing": "2.16.2" | |
}, | |
"addons": { | |
"ember-data": "2.16.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment