Changeset 2761 for package_branches/invirt-web/ajaxterm-rebased/code
- Timestamp:
- Dec 21, 2009, 1:12:05 AM (15 years ago)
- Location:
- package_branches/invirt-web/ajaxterm-rebased/code
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
package_branches/invirt-web/ajaxterm-rebased/code/ajaxterm.py
r2753 r2761 3 3 """ Ajaxterm """ 4 4 5 import array,cgi,fcntl,glob, mimetypes,optparse,os,pty,random,re,signal,select,sys,threading,time,termios,struct,pwd5 import array,cgi,fcntl,glob,hashlib,mimetypes,optparse,os,pty,random,re,signal,select,sys,threading,time,termios,struct,pwd 6 6 7 7 os.chdir(os.path.normpath(os.path.dirname(__file__))) … … 101 101 self.buf="" 102 102 self.outbuf="" 103 self.last_html=""104 103 def peek(self,y1,x1,y2,x2): 105 104 return self.scr[self.width*y1+x1:self.width*y2+x2] … … 321 320 def dumplatin1(self): 322 321 return self.dump().translate(self.trl1) 323 def dumphtml(self,color=1, force=False):322 def dumphtml(self,color=1,last_hash=None): 324 323 h=self.height 325 324 w=self.width … … 343 342 if i%w==w-1: 344 343 span+='\n' 345 r='<?xml version="1.0" encoding="ISO-8859-1"?><pre class="term">%s</pre>'%r 346 if self.last_html==r and not force: 344 hash = hashlib.md5(r).hexdigest() 345 r='<?xml version="1.0" encoding="ISO-8859-1"?><pre class="term" id="%s">%s</pre>'% (hash,r) 346 if last_hash == hash: 347 347 return '<?xml version="1.0"?><idem></idem>' 348 348 else: 349 self.last_html=r350 # print self351 349 return r 352 350 def __repr__(self): … … 437 435 except (IOError,OSError): 438 436 self.proc_kill(fd) 439 def dump(self,fd,color=1, force=False):437 def dump(self,fd,color=1,last_hash=None): 440 438 try: 441 return self.proc[fd]['term'].dumphtml(color, force)439 return self.proc[fd]['term'].dumphtml(color, last_hash) 442 440 except KeyError: 443 441 return False -
package_branches/invirt-web/ajaxterm-rebased/code/main.py
r2759 r2761 414 414 @cherrypy.tools.require_POST() 415 415 @cherrypy.tools.gzip() 416 def at(self, machine_id, k=None, c=0, force=0):416 def at(self, machine_id, k=None, c=0, h=None): 417 417 machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine 418 418 with self.atsessions_lock: … … 432 432 self.atmulti.proc_write(term,k) 433 433 time.sleep(0.002) 434 dump=self.atmulti.dump(term,c, int(force))434 dump=self.atmulti.dump(term,c,h) 435 435 cherrypy.response.headers['Content-Type']='text/xml' 436 436 if isinstance(dump,str): -
package_branches/invirt-web/ajaxterm-rebased/code/static/ajaxterm/ajaxterm.js
r2760 r2761 13 13 var sending=0; 14 14 var rmax=1; 15 var force=true;16 15 17 16 var div=document.getElementById(id); … … 99 98 } 100 99 var query=query1+send; 101 if (force) { 102 query=query+"&force=1"; 103 force=false; 100 if (dterm.firstChild && dterm.firstChild.id) { 101 query=query+"&h="+dterm.firstChild.id; 104 102 } 105 103 r.open("POST",base_path,true); … … 263 261 focus_element.onkeypress=keypress; 264 262 focus_element.onkeydown=keydown; 265 force=true;266 263 timeout=window.setTimeout(update,100); 267 264 }
Note: See TracChangeset
for help on using the changeset viewer.