Generated by Coffeescript 1.10.0var model, model, bind = function (fn, me) {return function () {return fn.apply (me, Argu ments); }; };model = null;$ (function () {var dropZone; Model = new Model (); Ko.applybindings (model); DropZone = document.getElementById (' drop-zone '); Dropzone.addeventlistener (' DragEnter ', model.stoppropagation); Dropzone.addeventlistener (' dragover ', model.stoppropagation); return dropzone.addeventlistener (' drop ', model.processdrop);}); Model = (function () {function Model () {this.instock = Bind (this.instock, this); This.processdrop = Bind (this.processdrop, this); } Model.prototype.racks = Ko.observablearray (); Model.prototype.cat = "; Model.prototype.stopPropagation = function (e) {e.stoppropagation (); return E.preventdefault (); }; Model.prototype.processDrop = function (e) {var file, reader; This.stoppropagation (e); File = e.datatransfer.files[0]; If (file.name.match (/^s\d{4}.*\.csv$/i)) {$ (' #fileInfo '). text (file.name); This.cat = file.name.substring (0, 5). touppercase (); reader = new FileReader (); Reader.onload = (function (_this) {return function () {var hasnoread, i, j, len, len1, plate, platerow, RA ck, ref; Rack = new Codelibrack (); Rack.loadfromcsv (reader.result); _this.racks.removeall (); _this.racks.push (rack); Hasnoread = false; ref = rack.plates; For (i = 0, len = ref.length; i < len; i++) {platerow = ref[i]; For (j = 0, len1 = platerow.length; J < len1; j + +) {plate = platerow[j]; If (' No Read ' = = = Plate.code) {hasnoread = true; }}} return $ (' #inStockButton '). prop (' disabled ', hasnoread); }; }) (this); return Reader.readastext (file); } else {$ (' #fileInfo '). text (' Invalid file '); $ (' #inStockButton '). prop (' disabled ', true); return This.racks.removeAll (); } }; Model.prototype.inStock = function () {var codes, i, j, len, len1, plate, platerow, racks, ref; codes = []; Racks = Ko.mapping.toJS (this.racks); If (racks.length) {ref = racks[0].plates; For (i = 0, len = ref.length; i < len; i++) {platerow = ref[i]; For (j = 0, len1 = platerow.length; J < len1; j + +) {plate = platerow[j]; If (plate.code.match (/^\d+$/)) {codes.push (plate.code); }}} return $.postjson (' doinstock.jhtml ', {cat:this.cat, codes:codes}). done ((func tion (_this) {return function (json) {if (json.error) {return alert (json.error); } else {return alert (' upload succeeded '); } }; }) (this)); } }; Return Model;}) ();
Selleck-molecular Library Warehousing Instock-js