Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace('Models', function() {
- return this.Item = (function(_super) {
- __extends(Item, _super);
- function Item() {
- return Item.__super__.constructor.apply(this, arguments);
- }
- Item.prototype.model = {
- name: Item.name,
- parent: _super,
- table: Item.name.toLowerCase(),
- proto: Item
- /*
- */
- };
- Item.prototype.buy = function(cb, count) {
- var _this = this;
- if (cb == null) {
- cb = (function() {});
- }
- if (count == null) {
- count = 1;
- }
- return Server.post("items/" + (id()) + "/purchase.json", {
- 'count': count
- }, function(data) {
- return cb(data);
- });
- };
- Item.prototype.sell = function(cb, count) {
- var _this = this;
- if (cb == null) {
- cb = (function() {});
- }
- if (count == null) {
- count = 1;
- }
- return Server.post("items/" + (id()) + "/sale.json", {
- 'count': count
- }, function(data) {
- return cb(data);
- });
- };
- Item.getByLevel = function(level) {
- return this.findBy('level', level);
- };
- Item.getDocuments = function() {
- return this.getByType('d');
- };
- Item.getOrganizations = function() {
- return this.getByType('o');
- };
- Item.getPeople = function() {
- return this.getByType('p');
- };
- Item.types = {
- d: 'documents',
- o: 'organizations',
- p: 'people'
- };
- Item.getByType = function(type) {
- return this.where('type = %1', [this.types[type]]).get();
- };
- return Item;
- })(ArJs.Model);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement