Forum: Ruby Re: Ruby in Browsers?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6087a044557d6b59ab52e7dd20f94da8?d=identicon&s=25 Peña, Botp (Guest)
on 2006-02-08 07:24
(Received via mailing list)
petermichaux@yahoo.com [mailto:petermichaux@yahoo.com]

#Any moves out there to get Ruby imbeded in browsers?
#
#How about Ruby as a client-side scripting web standard? (Maybe it would
#have to be Ruby Light with the file accessors removed.)

maybe you can take a look at activescriptruby. though i can run it only
on win ie, it may help you. it needs only one or two dll. The ff html eg
runs great (i just tried it).

<html>
<head>
 <title>Yo-Ko-So ! Active Ruby World !</title>
 <script language="RubyScript">
  ActiveScriptRuby.settrace false

  @ctbl = ["red", "firebrick", "deeppink", "hotpink", "lightpink",
           "darksalmon", "darkorange", "coral", "crimson" ]
  @ftbl = ["Times New Roman", "Modern", "Tahoma", "Arial", "Century",
           "Courier New"]
  @stbl = ["x-small", "small", "medium", "large", "x-large", "xx-large"]

  def changeColor(s)
   @window.document.all(s).style.color = @ctbl[rand(@ctbl.length)]
   @window.setTimeout("changeColor(\"#{s}\")", rand(8000) + 1,
"RubyScript")
  end

  def changeFont(s)
   @window.document.all(s).style.fontFamily = @ftbl[rand(@ftbl.length)]
   @window.setTimeout("changeFont(\"#{s}\")", rand(8000) + 1,
"RubyScript")
  end

  def changeSize(s)
   @window.document.all(s).style.fontSize = @stbl[rand(@stbl.length)]
   @window.setTimeout("changeSize(\"#{s}\")", rand(8000) + 1,
"RubyScript")
  end

  def changePos(s)
   @window.document.all(s).style.posTop =
rand(@window.screen.availHeight)
   @window.document.all(s).style.posLeft =
rand(@window.screen.availWidth)
   @window.setTimeout("changePos(\"#{s}\")", rand(8000) + 1,
"RubyScript")
  end

  def run()
    bdy = ""
    ["ruby1", "ruby2", "ruby3", "ruby4", "ruby5", "ruby6", "ruby7"].each
do |s|
      bdy += "<SPAN ID=#{s} style='position:absolute'>Ruby</SPAN>"
      @window.setTimeout("changeColor(\"#{s}\")", rand(8000) + 1,
"RubyScript")
      @window.setTimeout("changeFont(\"#{s}\")", rand(8000) + 1,
"RubyScript")
      @window.setTimeout("changeSize(\"#{s}\")", rand(8000) + 1,
"RubyScript")
      @window.setTimeout("changePos(\"#{s}\")", rand(8000) + 1,
"RubyScript")
    end
    @window.document.body.innerHTML = bdy
  end
 </script>
</head>
<body language="RubyScript" onload="run" bgcolor="black">
</body>
</html>

kind regards -botp
This topic is locked and can not be replied to.