function ProcessWidget(div) { this._div = div; this._timerID = null; this._processCount = 0; this._updateOptions = {}; this._onDones = []; this._latestHistoryEntry = null; var self = this; $(window).keypress(function(evt) { if (evt.charCode == 26 || (evt.charCode == 122 && (evt.ctrlKey || evt.metaKey))) { // ctrl-z or meta-z var t = evt.target; if (t) { var tagName = t.tagName.toLowerCase(); if (tagName == "textarea" || tagName == "input") { return; } } self.undo(); } }); this.update({}); } ProcessWidget.prototype.resize = function() { }; ProcessWidget.prototype.update = function(updateOptions, onDone) { this._latestHistoryEntry = null; for (var n in updateOptions) { if (updateOptions.hasOwnProperty(n)) { this._updateOptions[n] = updateOptions[n]; } } if (onDone) { this._onDones.push(onDone); } if (this._timerID !== null) { return; } var self = this; Ajax.chainGetJSON( "/command/get-processes?" + $.param({ project: theProject.id }), null, function(data) { self._latestHistoryEntry = null; self._render(data); } ); }; ProcessWidget.prototype.showUndo = function(historyEntry) { var self = this; this._latestHistoryEntry = historyEntry; this._div.stop(true,false).empty().html( '
' ).slideDown(200).delay(5000).slideUp(150); var elmts = DOM.bind(this._div); elmts.description.text(historyEntry.description); elmts.undo.click(function() { self.undo(); }); elmts.close.click(function() { $(".process-panel-inner").stop(true,false).slideUp(150); }); }; ProcessWidget.prototype.undo = function() { if (this._latestHistoryEntry !== null) { Gridworks.postProcess( "undo-redo", { undoID: this._latestHistoryEntry.id }, null, { everythingChanged: true } ); } }; ProcessWidget.prototype._cancelAll = function() { var self = this; $.post( "/command/cancel-processes?" + $.param({ project: theProject.id }), null, function(o) { self._data = null; self._runOnDones(); }, "json" ); }; ProcessWidget.prototype._render = function(newData) { var self = this; var newProcessMap = {}; this._div.stop(true, false).empty(); if (!newData.processes.length) { Gridworks.setTitle(); this._div.hide(); } else { this._div.show(); var innerDiv = $('').addClass("process-panel-inner").appendTo(this._div); var headDiv = $('').addClass("process-panel-head").appendTo(innerDiv); $('