Skip to content

Commit

Permalink
Different approach to updating.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuangzi committed Dec 4, 2010
1 parent faf65c8 commit e0ce623
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions wwwroot/genrei.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,16 @@ var Genrei = (function($){
// Display area
self.display = $('<div class="genrei-display"></div>');
self.textarea.after(self.display);
// Update the display when necessary
self.textarea.change(function(){ self.updateDisplay(); });
self.textarea.keydown(function(){ self.updateDisplay(); });
setInterval(function(){
if (self.textarea.val() != self.currentValue) {
self.currentValue = self.textarea.val();
self.updateDisplay(self.currentValue);
}
},50);
// Start query queuing process.
self.startQueue();
});
};

Genrei.prototype.updateDisplay = function(){
var self = this;
self.queuedQuery = { text: self.currentValue };
};

Genrei.prototype.startQueue = function(){
var self = this;
setInterval(function(){
if (!self.querying && self.queuedQuery != null) {
if (!self.querying && self.currentValue != self.textarea.val()) {
self.currentValue = self.textarea.val();
self.queryType = self.type;
self.querying = true;
$.ajax({
Expand Down

0 comments on commit e0ce623

Please sign in to comment.