Return to Snippet

Revision: 3557
at August 12, 2007 09:34 by charlesroper


Updated Code
#!/usr/bin/env ruby
require 'socket'

def escape_javascript(javascript)
  (javascript || '').gsub('\\','\0\0').gsub(/
|\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" }
end

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())}})();")

jssh_socket = TCPSocket::new("localhost", 9997);
jssh_socket.puts("getWindows()[0].getBrowser().loadURI('#{refresh}')")
jssh_socket.close

Revision: 3556
at August 12, 2007 09:34 by charlesroper


Updated Code
#!/usr/bin/env ruby

require 'socket'

def escape_javascript(javascript)
  (javascript || '').gsub('\\','\0\0').gsub(/
|\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" }
end

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())}})();")

$jssh_socket = TCPSocket::new("localhost", 9997);
$jssh_socket.puts("getWindows()[0].getBrowser().loadURI('#{refresh}')")
$jssh_socket.close

Revision: 3555
at August 12, 2007 09:30 by charlesroper


Updated Code
#!/usr/bin/env ruby

require 'socket'

def escape_javascript(javascript)
  (javascript || '').gsub('\\','\0\0').gsub(/
|\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" }
end

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())}})();")

$jssh_socket = TCPSocket::new("localhost", 9997);
$jssh_socket.puts("getWindows()[0].getBrowser().loadURI('#{refresh}')")
$jssh_socket.close;

Revision: 3554
at August 12, 2007 09:25 by charlesroper


Initial Code
def escape_javascript(javascript)
  (javascript || '').gsub('\\','\0\0').gsub(/
|\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" }
end

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())}})();")

$jssh_socket = TCPSocket::new("localhost", 9997)
$jssh_socket.puts("getWindows()[0].getBrowser().loadURI('#{refresh}')")
$jssh_socket.close

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

Initial Description
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.

Initial Title
Refresh Stylesheets for E Text Editor

Initial Tags
css, ruby

Initial Language
Ruby