sketchucation logo sketchucation
    • Login
    1. Home
    2. tbleicher
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    T
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 0
    • Posts 2
    • Groups 1

    tbleicher

    @tbleicher

    0
    Reputation
    1
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    tbleicher Unfollow Follow
    registered-users

    Latest posts made by tbleicher

    • RE: Escape characters between ruby and javascript

      @pout said:

      i have a javascript like this:

      settings=x+","+y+","+z;
      > query = 'skp;_edit@'+settings;
      > window.location.href = query;
      

      in ruby:

      window.add_action_callback("_edit") {|window,p|
      > resultarray=p.split(",")
      

      Now the x, y or z value in javascript can contain commas.
      So this will cause problems for the resultarray in ruby.

      What is the best way to escape the comma's (or any problem characters in javascript) so they are comming to ruby in a usable way?

      If you know that you're going to have commas in the variable values then a comma as a separation character is probably not a good choice. That said, you could first use javascript's escape() on all your variables which will turn every "," in a "%2c" and then join them with your separating ",".

      On the Ruby side you can find a "URL-decode" functions in the CGI module:

      
      def urlDecode(string)
          ## URL-decode from Ruby;;CGI
          string.tr('+', ' ').gsub(/((?;%[0-9a-fA-F]{2})+)/n) do
              [$1.delete('%')].pack('H*')
          end
      end
      

      @pout said:

      Off course the other way arround is also a problem:
      ruby

      rubyarray=['blablabla,','boem,boem,boem','world']
      > #join the array to send to javascript
      > rubyarray=rubyarray.compact.join(",")
      > command = "_test('#{rubyarray}')"
      > window.execute_script(command)
      

      In javascriptI split up the string by comma

      function _test(x)
      > p = x.split(',');
      

      Same procedure only the other way around. These days I prefer to build a JSON string in Ruby and eval() that on the javascript side for anything that's a bit more complex. In your case that would take car of the the encoding because your rubyarray also works as javascript array.

      Cheers,
      Thomas

      posted in Developers' Forum
      T
      tbleicher
    • RE: WebDialogs - The Lost Manual — R1 09 November 2009

      @thomthom said:

      You won't be able to use HTML5 in webdialogs - not until IE adds support for it.

      I am using excanvas http://code.google.com/p/explorercanvas/ which provides a canvas object in IE.

      Thomas

      posted in Developers' Forum
      T
      tbleicher