module Eve::JavascriptHelper

In addition to the helpers listed below, this library also exposes the “igb” method as described in Eve::Trust.

Public Instance Methods

request_trust(trust_url = "http:// click to toggle source

This will generate a method call that produces a pop-up a trust prompt in the client, allowing the user to either grant the trust request, ignore it, or always ignore trust requests from your site.

trust_url (String)
  This is a fully-qualified domain name and path (e.g. http://wiki.eveonline.com/w/) to which your site would
  like the user to grant trust.

The page will not be automatically refreshed if the user grants the trust request. Trust will take effect the next time the user refreshes the page, or navigates within the site.

Note that trust_url is processed and only the protocol, domain and path will be used from it. If you supply a query string or anchor, they will be discarded. It is recommended that you primarily pass in only fully-qualified domain names without paths (e.g. wiki.eveonline.com instead of wiki.eveonline.com/w/index.php), as this avoids pestering the user for trust on every page.

# File lib/eve/javascript_helper.rb, line 149
def request_trust(trust_url = "http://#{request.host}/", *args)
  trust_url = url_for(trust_url.merge(:only_path => false)) if trust_url.kind_of?(Hash)
  javascript_tag "CCPEVE.requestTrust(#{trust_url.inspect});", *args
end
type_id(which) click to toggle source

Returns the numeric type ID for a string, so you don’t have to manage “magic numbers” in your application. The argument can be a string or a symbol, and is case insensitive. Underscores will be converted to spaces.

Examples:

type_id('alliance')       # => 16159
type_id('character')      # => 1377
type_id('corporation')    # => 2
type_id('constellation')  # => 4
type_id('region')         # => 3
type_id('Solar System')   # => 5
type_id(:solar_system)    # => 5
type_id(:station)         # => 3867
# File lib/eve/javascript_helper.rb, line 18
def type_id(which)
  which = which.to_s.humanize unless which.kind_of?(String)
  which.downcase!
  case which
    when 'alliance' then 16159
    when 'character' then 1377
    when 'corporation' then 2
    when 'constellation' then 4
    when 'region' then 3
    when 'solar system', 'solarsystem' then 5
    when 'station' then 3867
    else raise ArgumentError, "Unknown type: #{which}"
  end
end