Share Pastebin
Guest
Public paste!

jirkap

By: a guest | Jan 19th, 2010 | Syntax: None | Size: 1.08 KB | Hits: 203 | Expires: Never
Copy text to clipboard
  1. Global.js
  2. ---------
  3. function onStart(){
  4.     HopObject.wrapFunction(HopObject);
  5. }
  6.  
  7. Global.skin
  8. -----------
  9. <% response.a %>
  10. <div style="position: absolute; width: 200px; height: 200px; background-color: #c0c0c0; z-index: 1000; right: 20px; bottom: 20px">
  11.     <% param.user %>
  12.         <% param.obj %>
  13. </div>
  14. <% response.b %>
  15.  
  16. HopObject.js
  17. ------------
  18. HopObject.wrapFunction = function(obj){
  19.     if (!obj.prototype.onResponse) {
  20.         obj.prototype.onResponse = function(){
  21.             // XXX Can this be empty?
  22.         }
  23.     }
  24.     var old = obj.prototype.onResponse;
  25.     obj.prototype.onResponse = function(){
  26.         function modifyResponse(){
  27.             var a = res.getBuffer();
  28.             a = a.split(/<body\s.*>|<body>/);
  29.            
  30.             res.reset();
  31.             res.data.a = a[0];
  32.             res.data.b = a[1];
  33.            
  34.             var table = {
  35.                 user: !session.user ? 'No users in.' : session.user,
  36.                                 obj: this
  37.                         };
  38.             renderSkin('Tinker', table);
  39.         }
  40.         old.call(obj, modifyResponse()); // Modify
  41.     }
  42. }