Permalink
Browse files

Add UI demo

  • Loading branch information...
1 parent 962fc19 commit 643b10df66084d5c12dac2d30ec1e736197d6d38 Brian Moore committed Nov 24, 2010
Showing 407 changed files with 72,862 additions and 0 deletions.
View
@@ -0,0 +1,28 @@
+require 'yaml'
+
+unless File.exists? "build.yml"
+ puts "Cannot find build.yml"
+ exit 1
+end
+
+
+$app_config = YAML::load_file("build.yml")
+$app_path = File.expand_path(File.dirname(__FILE__))
+
+if ENV["RHO_HOME"].nil?
+ rakefilepath = "#{$app_config["sdk"]}/Rakefile"
+else
+ rakefilepath = "#{ENV["RHO_HOME"]}/Rakefile"
+end
+
+unless File.exists? rakefilepath
+ puts "\nCannot find your Rhodes gem or source path."
+ puts "\nIf you have the sdk on your path or have installed the gem this"
+ puts "can be resolved by running 'set-rhodes-sdk'"
+ puts "\nYou can also set this manually by modifying your build.yml or"
+ puts "setting the environment variable RHO_HOME"
+ exit 1
+end
+
+load rakefilepath
+
@@ -0,0 +1,10 @@
+# The model has already been created by the framework, and extends Rhom::RhomObject
+# You can add more methods here
+class Contact
+ include Rhom::PropertyBag
+
+ # Uncomment the following line to enable sync with Contact.
+ enable :sync
+
+ #add model specifc code here
+end
@@ -0,0 +1,103 @@
+require 'rho/rhocontroller'
+require 'helpers/browser_helper'
+require 'json'
+
+class RenderController < Rho::RhoController
+ include BrowserHelper
+
+ def alljson
+
+ if $UseRhosync == true
+
+ @contacts = Contact.find(:all)
+ temp = []
+ index = 1;
+ @contacts.each do |contact|
+ temp << {
+ :index => index,
+ :handle => contact.object,
+ :position => contact.jobTitle,
+ :firstName => contact.contactFirstName,
+ :lastName => contact.contactLastName,
+ :type => contact.contactType,
+ :workPhone => contact.workPhone,
+ :cellPhone => contact.cellularPhone,
+ :email => contact.contactEmail,
+ :address => contact.primaryAddress,
+ :city => contact.primaryCity,
+ :state => contact.primaryStateProvince,
+ :postalCode => contact.primaryZipCode,
+ #:lastVisted =>
+ :description => contact.description
+ }
+ index = index+1;
+ end
+
+ all = { :contacts => temp }
+ else
+ all = { :contacts => [
+ {:index => 1, :handle => 'JulioBenesh-Doctor', :position => 'Doctor', :firstName => 'Julio', :lastName => 'Benesh'},
+ {:index => 2, :handle => 'JulioMinich-Therapist', :position => 'Therapist', :firstName => 'Julio', :lastName => 'Minich'},
+ {:index => 3, :handle => 'TaniaRicco-Doctor', :position => 'Doctor', :firstName => 'Tania', :lastName => 'Ricco'},
+ {:index => 4, :handle => 'OdessaSteuck-Doctor', :position => 'Doctor', :firstName => 'Odessa', :lastName => 'Steuck'},
+ {:index => 5, :handle => 'NelsonRaber-Doctor', :position => 'Doctor', :firstName => 'Nelson', :lastName => 'Raber'},
+ {:index => 6, :handle => 'TyroneScannell-Doctor', :position => 'Doctor', :firstName => 'Tyrone', :lastName => 'Scannell'},
+ {:index => 7, :handle => 'AllanDisbrow-Doctor', :position => 'Doctor', :firstName => 'Allan', :lastName => 'Disbrow'},
+ {:index => 8, :handle => 'CodyHerrell-Specialist', :position => 'Specialist', :firstName => 'Cody', :lastName => 'Herrell'},
+ {:index => 9, :handle => 'JulioBurgoyne-Doctor', :position => 'Doctor', :firstName => 'Julio', :lastName => 'Burgoyne'},
+ {:index => 10, :handle => 'JessieBoedeker-Doctor', :position => 'Doctor', :firstName => 'Jessie', :lastName => 'Boedeker'},
+ {:index => 11, :handle => 'AllanLeyendecker-Doctor', :position => 'Doctor', :firstName => 'Allan', :lastName => 'Leyendecker'},
+ {:index => 12, :handle => 'JavierLockley-Doctor', :position => 'Doctor', :firstName => 'Javier', :lastName => 'Lockley'},
+ {:index => 13, :handle => 'GuyReasor-Doctor', :position => 'Doctor', :firstName => 'Guy', :lastName => 'Reasor'},
+ {:index => 14, :handle => 'JamieBrummer-Doctor', :position => 'Doctor', :firstName => 'Jamie', :lastName => 'Brummer'},
+ {:index => 15, :handle => 'JessieCasa-Doctor', :position => 'Doctor', :firstName => 'Jessie', :lastName => 'Casa'},
+ {:index => 16, :handle => 'MarcieRicca-Doctor', :position => 'Doctor', :firstName => 'Marcie', :lastName => 'Ricca'},
+ {:index => 17, :handle => 'GayLamoureaux-Doctor', :position => 'Doctor', :firstName => 'Gay', :lastName => 'Lamoureaux'},
+ {:index => 18, :handle => 'AltheaSturtz-Doctor', :position => 'Doctor', :firstName => 'Althea', :lastName => 'Sturtz'},
+ {:index => 19, :handle => 'KenyaMorocco-Doctor', :position => 'Doctor', :firstName => 'Kenya', :lastName => 'Morocco'},
+ {:index => 20, :handle => 'RaePasquariello-Doctor', :position => 'Doctor', :firstName => 'Rae', :lastName => 'Pasquariello'},
+ {:index => 21, :handle => 'TedAbundis-Doctor', :position => 'Doctor', :firstName => 'Ted', :lastName => 'Abundis'},
+ {:index => 22, :handle => 'JessieSchacherer-Doctor', :position => 'Doctor', :firstName => 'Jessie', :lastName => 'Schacherer'},
+ {:index => 23, :handle => 'JamieGleaves-Doctor', :position => 'Doctor', :firstName => 'Jamie', :lastName => 'Gleaves'},
+ {:index => 24, :handle => 'HillarySpiva-Doctor', :position => 'Doctor', :firstName => 'Hillary', :lastName => 'Spiva'},
+ {:index => 25, :handle => 'ElinorRockefeller-Doctor', :position => 'Doctor', :firstName => 'Elinor', :lastName => 'Rockefeller'},
+ {:index => 26, :handle => 'DonaClauss-Doctor', :position => 'Doctor', :firstName => 'Dona', :lastName => 'Clauss'},
+ {:index => 27, :handle => 'AshleeKennerly-Doctor', :position => 'Doctor', :firstName => 'Ashlee', :lastName => 'Kennerly'},
+ {:index => 28, :handle => 'AlanaWiersma-Doctor', :position => 'Doctor', :firstName => 'Alana', :lastName => 'Wiersma'},
+ {:index => 29, :handle => 'KellyHoldman-Doctor', :position => 'Doctor', :firstName => 'Kelly', :lastName => 'Holdman'},
+ {:index => 30, :handle => 'MathewLofthouse-Doctor', :position => 'Doctor', :firstName => 'Mathew', :lastName => 'Lofthouse'},
+ {:index => 31, :handle => 'DonaTatman-Doctor', :position => 'Doctor', :firstName => 'Dona', :lastName => 'Tatman'},
+ {:index => 32, :handle => 'ClaytonClear-Doctor', :position => 'Doctor', :firstName => 'Clayton', :lastName => 'Clear'},
+ {:index => 33, :handle => 'RosalindaUrman-Doctor', :position => 'Doctor', :firstName => 'Rosalinda', :lastName => 'Urman'},
+ {:index => 34, :handle => 'CodySayler-Doctor', :position => 'Doctor', :firstName => 'Cody', :lastName => 'Sayler'},
+ {:index => 35, :handle => 'OdessaAveritt-Doctor', :position => 'Doctor', :firstName => 'Odessa', :lastName => 'Averitt'},
+ {:index => 36, :handle => 'TedPoage-Doctor', :position => 'Doctor', :firstName => 'Ted', :lastName => 'Poage'},
+ {:index => 37, :handle => 'PenelopeGayer-Doctor', :position => 'Doctor', :firstName => 'Penelope', :lastName => 'Gayer'},
+ {:index => 38, :handle => 'KatyBluford-Doctor', :position => 'Doctor', :firstName => 'Katy', :lastName => 'Bluford'},
+ {:index => 39, :handle => 'KellyMchargue-Doctor', :position => 'Doctor', :firstName => 'Kelly', :lastName => 'Mchargue'},
+ {:index => 40, :handle => 'KathrineGustavson-Doctor', :position => 'Doctor', :firstName => 'Kathrine', :lastName => 'Gustavson'},
+ {:index => 41, :handle => 'KellyHartson-Doctor', :position => 'Doctor', :firstName => 'Kelly', :lastName => 'Hartson'},
+ {:index => 42, :handle => 'CarleneSummitt-Doctor', :position => 'Doctor', :firstName => 'Carlene', :lastName => 'Summitt'},
+ {:index => 43, :handle => 'KathrineVrabel-Doctor', :position => 'Doctor', :firstName => 'Kathrine', :lastName => 'Vrabel'},
+ {:index => 44, :handle => 'RoxieMcconn-Doctor', :position => 'Doctor', :firstName => 'Roxie', :lastName => 'Mcconn'},
+ {:index => 45, :handle => 'MargeryPullman-Doctor', :position => 'Doctor', :firstName => 'Margery', :lastName => 'Pullman'},
+ {:index => 46, :handle => 'AvisBueche-Doctor', :position => 'Doctor', :firstName => 'Avis', :lastName => 'Bueche'},
+ {:index => 47, :handle => 'EsmeraldaKatzer-Doctor', :position => 'Doctor', :firstName => 'Esmeralda', :lastName => 'Katzer'},
+ {:index => 48, :handle => 'TaniaBelmonte-Doctor', :position => 'Doctor', :firstName => 'Tania', :lastName => 'Belmonte'},
+ {:index => 49, :handle => 'MalindaKwak-Doctor', :position => 'Doctor', :firstName => 'Malinda', :lastName => 'Kwak'},
+ {:index => 50, :handle => 'TanishaJobin-Doctor', :position => 'Doctor', :firstName => 'Tanisha', :lastName => 'Jobin'},
+ {:index => 51, :handle => 'KellyDziedzic-Doctor', :position => 'Doctor', :firstName => 'Kelly', :lastName => 'Dziedzic'},
+ {:index => 52, :handle => 'DarrenDevalle-Doctor', :position => 'Doctor', :firstName => 'Darren', :lastName => 'Devalle'},
+ {:index => 53, :handle => 'JulioBuchannon-Doctor', :position => 'Doctor', :firstName => 'Julio', :lastName => 'Buchannon'},
+ {:index => 54, :handle => 'DarrenSchreier-Doctor', :position => 'Doctor', :firstName => 'Darren', :lastName => 'Schreier'},
+ {:index => 55, :handle => 'JamiePollman-Doctor', :position => 'Doctor', :firstName => 'Jamie', :lastName => 'Pollman'},
+ {:index => 56, :handle => 'KarinaPompey-Doctor', :position => 'Doctor', :firstName => 'Karina', :lastName => 'Pompey'},
+ {:index => 57, :handle => 'HughSnover-Doctor', :position => 'Doctor', :firstName => 'Hugh', :lastName => 'Snover'},
+ {:index => 58, :handle => 'ZebraEvilias-Doctor', :position => 'Doctor', :firstName => 'Zebra', :lastName => 'Evilias'}
+ ]}
+
+ end
+
+ render :string => ::JSON.generate(all)
+ end
+end
@@ -0,0 +1,60 @@
+require 'rho'
+require 'rho/rhocontroller'
+require 'rho/rhoerror'
+require 'helpers/browser_helper'
+
+class SettingsController < Rho::RhoController
+ include BrowserHelper
+
+ def rotation_callback
+ WebView.refresh
+ end
+
+ def my_login
+ System::set_screen_rotation_notification(url_for(:action => :rotation_callback),"")
+
+ if System.get_property('has_network') == true
+ $UseRhosync = true
+ SyncEngine.login(" "," ", (url_for :action => :my_login_callback) )
+ render :action => :wait
+ else
+ $UseRhosync = false
+ WebView.navigate("/public/ui/theoracle/index.html")
+ end
+ end
+
+ def my_sync
+ if System.get_property('has_network') == true
+ $UseRhosync = true
+ Contact.set_notification("/app/Settings/sync_notify",'')
+ SyncEngine.dosync
+ render :action => :wait
+ end
+ end
+
+ def my_login_callback
+ SyncEngine.dosync
+ end
+
+ def sync_notify
+ puts 'sync_notify: ' + @params.inspect
+ status = @params['status'] ? @params['status'] : ""
+
+ if status == "in_progress"
+ #do nothing
+ elsif status == "complete" || status == "ok"
+ WebView.navigate ("/public/ui/theoracle/index.html")
+ elsif status == "error"
+ err_code = @params['error_code'].to_i
+ rho_error = Rho::RhoError.new(err_code)
+
+ @msg = @params['error_message'] if err_code == Rho::RhoError::ERR_CUSTOMSYNCSERVER
+ @msg = rho_error.message() unless @msg && @msg.length > 0
+
+ if rho_error.unknown_client?(@params['error_message'])
+ Rhom::Rhom.database_client_reset
+ SyncEngine.dosync
+ end
+ end
+ end
+end
@@ -0,0 +1,3 @@
+ <div align="center">
+ <h1>Syncing...</h1>
+ </div>
@@ -0,0 +1,20 @@
+require 'rho/rhoapplication'
+
+class AppApplication < Rho::RhoApplication
+ $UseRhosync = false
+
+ def initialize
+ # Tab items are loaded left->right, @tabs[0] is leftmost tab in the tab-bar
+ # Super must be called *after* settings @tabs!
+ @tabs = nil
+ @@tabbar = nil
+ @@toolbar = nil
+
+ super
+
+ # Uncomment to set sync notification callback to /app/Settings/sync_notify.
+ # SyncEngine::set_objectnotify_url("/app/Settings/sync_notify")
+ # SyncEngine.set_notification(-1, "/app/Settings/sync_notify", '')
+ Contact.set_notification("/app/Settings/sync_notify",'')
+ end
+end
@@ -0,0 +1,126 @@
+require 'json'
+
+module ApplicationHelper
+ def strip_braces(str=nil)
+ str ? str.gsub(/\{/, "").gsub(/\}/, "") : nil
+ end
+
+ def strike_if(str, condition=true)
+ condition ? "<s>#{str}</s>" : str
+ end
+
+ def display_blanks(value)
+ if blank?(value)
+ "---"
+ else
+ value
+ end
+ end
+
+ def blank?(value)
+ value.nil? || value == "" || value.length==0
+ end
+
+ def display_blankstr(value)
+ if blank?(value)
+ " "
+ else
+ value
+ end
+ end
+
+ def display_newline()
+ "<br>"
+ end
+
+ def display_space()
+ " "
+ end
+
+ def display_dollars(value)
+ if blank?(value)
+ " "
+ else
+ number = "$" + sprintf("%.2f", value)
+
+ # use a commify algorithm -- http://snippets.dzone.com/tag/commify
+ number.reverse!
+ number.gsub!(/(\d\d\d)(?=\d)(?!\d*\.)/, '\1,')
+ number.reverse!
+ end
+ end
+
+ def display_number(value)
+ if blank?(value)
+ " "
+ else
+ sprintf("%.2f", value)
+ end
+ end
+
+ def both_items_present?(value1, value2)
+ !blank?(value1) && !blank?(value2)
+ end
+
+ def replace_newlines(value)
+ if blank?(value)
+ " "
+ else
+ value.gsub('\n', ' ')
+ end
+ end
+
+ def format_address_for_mapping(street, city, state, zip, tagforurl)
+ # handle case where fields could be nil
+ mystreet = !street.nil? ? street : ""
+ mycity = !city.nil? ? city : ""
+ mystate = !state.nil? ? state : ""
+ myzip = !zip.nil? ? zip : ""
+
+ result = ""
+ if !tagforurl
+ # build up address string
+ result += (mystreet + ", ") if mystreet.length > 0
+ result += (mycity + ", ") if mycity.length > 0
+ result += (mystate + " ") if mystate.length > 0
+ result += myzip if myzip.length > 0
+ else
+ # need to URL encode data too
+ result += ("&street=" + Rho::RhoSupport.url_encode(mystreet)) if mystreet.length > 0
+ result += ("&city=" + Rho::RhoSupport.url_encode(mycity)) if mycity.length > 0
+ result += ("&state=" + Rho::RhoSupport.url_encode(mystate)) if mystate.length > 0
+ result += ("&zip=" + Rho::RhoSupport.url_encode(myzip)) if myzip.length > 0
+ end
+ # remove any extraneous characters that could interfere with proper address matching
+ result = replace_newlines(result)
+ end
+
+ def has_valid_mapping_address(street, city, state, zip)
+ # at a minimum, an address must have a state or a zip
+ (!state.nil? && state.length > 0) || (!zip.nil? && zip.length > 0)
+ end
+
+ def format_latlon_for_mapping(latitude, longitude)
+ result = ""
+ result += ("&latitude=" + Rho::RhoSupport.url_encode(latitude)) if latitude.length > 0
+ result += ("&longitude=" + Rho::RhoSupport.url_encode(longitude)) if longitude.length > 0
+ result
+ end
+
+ def render_transition(params)
+ @params["rho_callback"] = nil
+ params[:layout] = false
+ # TODO: escape carriage returns instead of removing them altoegether
+ content = render(params).split('\'').join('\\\'').split(/[\r\n]/).join('')
+ WebView.execute_js("Rho.insertAsyncPage('<div>#{content}</div>')")
+ end
+
+ def caller_request_hash_to_query
+ 'caller_request=' + Rho::RhoSupport.url_encode(::JSON.generate(@request))
+ end
+
+ def caller_request_query_to_hash
+ @caller_request = Rho::JSON.parse(@params['caller_request']) if @params['caller_request']
+ end
+
+end
@@ -0,0 +1,18 @@
+module BrowserHelper
+
+ def placeholder(label=nil)
+ "placeholder='#{label}'" if platform == 'apple'
+ end
+
+ def platform
+ System::get_property('platform').downcase
+ end
+
+ def selected(option_value,object_value)
+ "selected=\"yes\"" if option_value == object_value
+ end
+
+ def checked(option_value,object_value)
+ "checked=\"yes\"" if option_value == object_value
+ end
+end
View
@@ -0,0 +1,19 @@
+<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">-->
+
+<!doctype html>
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<!-- <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>-->
+ <title>The Oracle</title>
+
+</head>
+
+<body>
+ <%= @content %>
+</body>
+
+
+</html>
Oops, something went wrong.

0 comments on commit 643b10d

Please sign in to comment.