Refresh Stylesheets for E Text Editor


/ Published in: Ruby
Save to your folder(s)

The escape_javascript funtion is taken from Rails (http://rails.rubyonrails.com/classes/ActionView/Helpers/JavaScriptHelper.html#M000633). Most of the work on this was done by pnomolos and n00ge on the E Text Editor forums.


Copy this code and paste it in your HTML
  1. #!/usr/bin/env ruby
  2. require 'socket'
  3.  
  4. def escape_javascript(javascript)
  5. (javascript || '').gsub('\\','\0\0').gsub(/
  6. |\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" }
  7. end
  8.  
  9. refresh = escape_javascript("javascript:void(function(){var i,a,s;a=document.getElementsByTagName('link');for(i=0;i<a.length;i++){s=a[i]; if(!s.href){continue;}var h=s.href.replace(/(&|%5C?)forceReload=\d+/,'');s.href=h+(h.indexOf('?')>=0?'&':'?')+'forceReload='+(new Date().valueOf())}})();")
  10.  
  11. jssh_socket = TCPSocket::new("localhost", 9997);
  12. jssh_socket.puts("getWindows()[0].getBrowser().loadURI('#{refresh}')")
  13. jssh_socket.close

URL: http://www.e-texteditor.com/forum/viewtopic.php?p=6358

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.