Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: jnewland/god_web
base: master
...
head fork: mathieuravaux/god_web
compare: master
Checking mergeability… Don't worry, you can still create the pull request.
  • 9 commits
  • 35 files changed
  • 0 commit comments
  • 3 contributors
Showing with 787 additions and 431 deletions.
  1. +50 −0 Rakefile
  2. +1 −0  VERSION
  3. +6 −52 bin/god_web
  4. +93 −42 god_web.gemspec
  5. +55 −0 lib/app.rb
  6. +4 −2 lib/environment.rb
  7. +50 −23 lib/god_web.rb
  8. +26 −0 public/app.css
  9. BIN  public/icons/databases.png
  10. BIN  public/icons/gear.png
  11. BIN  public/icons/groups.png
  12. BIN  public/icons/key.png
  13. BIN  public/icons/monitor.png
  14. BIN  public/icons/restart.png
  15. BIN  public/icons/ruby.png
  16. BIN  public/icons/server.png
  17. BIN  public/icons/start.png
  18. BIN  public/icons/stop.png
  19. BIN  public/icons/terminal.png
  20. BIN  public/icons/unmonitor.png
  21. BIN  public/icons/unmonitored.png
  22. BIN  public/icons/unmonitored_old.png
  23. BIN  public/icons/up.png
  24. BIN  public/icons/warn.png
  25. BIN  public/icons/wrench.png
  26. BIN  public/iui/iui-logo-touch-icon.png
  27. +27 −3 public/iui/iui.css
  28. +418 −291 public/iui/iui.js
  29. +1 −1  public/iui/iuix.css
  30. +1 −1  public/iui/iuix.js
  31. BIN  public/iui/redButton.png
  32. +20 −0 spec/god_web_spec.rb
  33. +11 −0 spec/spec_helper.rb
  34. +17 −14 views/status.erb
  35. +7 −2 views/watch.erb
View
50 Rakefile
@@ -0,0 +1,50 @@
+require 'rubygems'
+require 'rake'
+
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |gem|
+ gem.name = "god_web"
+ gem.summary = "iPhone friendly web UI for God"
+ gem.description = "iPhone friendly sinatra web UI for God"
+ gem.email = "see@github.com"
+ gem.homepage = "http://github.com/nofxx/god_web"
+ gem.authors = ["Jesse Newland", "Marcos Piccinini"]
+ gem.add_dependency "god"
+ gem.add_dependency "sinatra"
+ gem.add_development_dependency "rspec"
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
+ end
+rescue LoadError
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
+end
+
+require 'spec/rake/spectask'
+Spec::Rake::SpecTask.new(:spec) do |spec|
+ spec.libs << 'lib' << 'spec'
+ spec.spec_files = FileList['spec/**/*_spec.rb']
+end
+
+Spec::Rake::SpecTask.new(:rcov) do |spec|
+ spec.libs << 'lib' << 'spec'
+ spec.pattern = 'spec/**/*_spec.rb'
+ spec.rcov = true
+end
+
+task :spec => :check_dependencies
+
+task :default => :spec
+
+require 'rake/rdoctask'
+Rake::RDocTask.new do |rdoc|
+ if File.exist?('VERSION')
+ version = File.read('VERSION')
+ else
+ version = ""
+ end
+
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "god_web #{version}"
+ rdoc.rdoc_files.include('README*')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
View
1  VERSION
@@ -0,0 +1 @@
+0.2.0
View
58 bin/god_web 100644 → 100755
@@ -2,56 +2,10 @@
require File.dirname(__FILE__) + '/../lib/environment'
-before do
- unless (GODWEB_CONFIG['username'].nil? && GODWEB_CONFIG['password'].nil?) || self.request.path_info == '/heartbeat'
- authenticate_or_request_with_http_basic "GodWeb" do
- |user, pass| user == GODWEB_CONFIG['username'] && pass == GODWEB_CONFIG['password']
- end
- end
- GODWEB.ping
-end
+OptionParser.new { |op|
+ op.on('-e env') { |val| set :environment, val.to_sym }
+ op.on('-s server') { |val| set :server, val }
+ op.on('-p port') { |val| set :port, val.to_i }
+}.parse!(ARGV.dup)
-get '/' do
- @statuses = GODWEB.status
- @watches = []
- @statuses.each do |watch, status|
- @watches << watch.to_s
- end
- @watches.sort!
- @groups = GODWEB.groups
- show(:status)
-end
-
-get '/w/:watch' do
- @watch = params["watch"]
- @status = GODWEB.status[@watch][:state]
- @commands = GodWeb.possible_statuses(@status)
- show(:watch, "#{@watch} [#{@status}]")
-end
-
-get '/g/:group' do
- @watch = @group = params["group"]
- @status = nil
- @commands = GodWeb.possible_statuses(@status)
- show(:watch, "#{@group} [group]")
-end
-
-get '/w/:watch/:command' do
- @watch = params["watch"]
- @command = params["command"]
- @success = GODWEB.send(@command, @watch)
- @success = false if @success == []
- show(:command, "#{@command}ing #{@watch}")
-end
-
-get '/heartbeat' do
- @statuses = GODWEB.status
- 'OK'
-end
-
-private
-
- def show(template, title = 'GodWeb')
- @title = title
- erb(template)
- end
+set :run, true
View
135 god_web.gemspec
@@ -1,54 +1,105 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE
+# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
+# -*- encoding: utf-8 -*-
+
Gem::Specification.new do |s|
s.name = %q{god_web}
- s.version = "0.1.4"
-
- s.specification_version = 2 if s.respond_to? :specification_version=
+ s.version = "0.2.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Jesse Newland"]
- s.date = %q{2008-05-19}
+ s.authors = ["Jesse Newland", "Marcos Piccinini"]
+ s.date = %q{2009-09-08}
s.default_executable = %q{god_web}
- s.description = %q{iPhone friendly web UI for God}
- s.email = %q{jnewland@gmail.com}
+ s.description = %q{iPhone friendly sinatra web UI for God}
+ s.email = %q{see@github.com}
s.executables = ["god_web"]
- s.extra_rdoc_files = ["Readme.textile"]
s.files = [
- "bin/god_web",
- "lib/environment.rb",
- "lib/god_web.rb",
- "lib/sinatra_http_auth.rb",
- "views/command.erb",
- "views/status.erb",
- "views/watch.erb",
- "public/iui/backButton.png",
- "public/iui/blueButton.png",
- "public/iui/cancel.png",
- "public/iui/grayButton.png",
- "public/iui/iui.css",
- "public/iui/iui.js",
- "public/iui/iuix.css",
- "public/iui/iuix.js",
- "public/iui/listArrow.png",
- "public/iui/listArrowSel.png",
- "public/iui/listGroup.png",
- "public/iui/loading.gif",
- "public/iui/pinstripes.png",
- "public/iui/selection.png",
- "public/iui/thumb.png",
- "public/iui/toggle.png",
- "public/iui/toggleOn.png",
- "public/iui/toolButton.png",
- "public/iui/toolbar.png",
- "public/iui/whiteButton.png",
- "Readme.textile"
+ ".gitignore",
+ "Readme.textile",
+ "bin/god_web",
+ "bugs/issue-28789de6ef59a981f26031fdf68030a1474251e8.yaml",
+ "bugs/issue-949b87d1535bd55950daf2ec197a25ce2a0de13f.yaml",
+ "bugs/issue-9579e138eec0aee906895eefa1cc546bd7d54b0d.yaml",
+ "bugs/issue-b13b98759d3cf194cfee1bc00f0245f4b19f6cd2.yaml",
+ "bugs/issue-cf27fa73c85d2b7a389cbdcfe669b9703380667c.yaml",
+ "bugs/project.yaml",
+ "god_web.gemspec",
+ "lib/app.rb",
+ "lib/environment.rb",
+ "lib/god_web.rb",
+ "lib/sinatra_http_auth.rb",
+ "public/.DS_Store",
+ "public/app.css",
+ "public/icons/databases.png",
+ "public/icons/gear.png",
+ "public/icons/groups.png",
+ "public/icons/key.png",
+ "public/icons/monitor.png",
+ "public/icons/restart.png",
+ "public/icons/ruby.png",
+ "public/icons/server.png",
+ "public/icons/start.png",
+ "public/icons/stop.png",
+ "public/icons/terminal.png",
+ "public/icons/unmonitor.png",
+ "public/icons/unmonitored.png",
+ "public/icons/unmonitored_old.png",
+ "public/icons/up.png",
+ "public/icons/warn.png",
+ "public/icons/wrench.png",
+ "public/iui/backButton.png",
+ "public/iui/blueButton.png",
+ "public/iui/cancel.png",
+ "public/iui/grayButton.png",
+ "public/iui/iui-logo-touch-icon.png",
+ "public/iui/iui.css",
+ "public/iui/iui.js",
+ "public/iui/iuix.css",
+ "public/iui/iuix.js",
+ "public/iui/listArrow.png",
+ "public/iui/listArrowSel.png",
+ "public/iui/listGroup.png",
+ "public/iui/loading.gif",
+ "public/iui/pinstripes.png",
+ "public/iui/redButton.png",
+ "public/iui/selection.png",
+ "public/iui/thumb.png",
+ "public/iui/toggle.png",
+ "public/iui/toggleOn.png",
+ "public/iui/toolButton.png",
+ "public/iui/toolbar.png",
+ "public/iui/whiteButton.png",
+ "views/command.erb",
+ "views/status.erb",
+ "views/watch.erb"
]
- s.has_rdoc = false
- s.homepage = %q{http://github.com/jnewland/god_web}
+ s.homepage = %q{http://github.com/nofxx/god_web}
+ s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
- s.rubyforge_project = %q{god_web}
- s.rubygems_version = %q{1.1.0}
+ s.rubygems_version = %q{1.3.5}
s.summary = %q{iPhone friendly web UI for God}
+ s.test_files = [
+ "spec/spec_helper.rb",
+ "spec/god_web_spec.rb"
+ ]
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
- s.add_dependency(%q<god>, [">= 0.7.3"])
- s.add_dependency(%q<sinatra>, [">= 0.2.2"])
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ s.add_runtime_dependency(%q<god>, [">= 0"])
+ s.add_runtime_dependency(%q<sinatra>, [">= 0"])
+ s.add_development_dependency(%q<rspec>, [">= 0"])
+ else
+ s.add_dependency(%q<god>, [">= 0"])
+ s.add_dependency(%q<sinatra>, [">= 0"])
+ s.add_dependency(%q<rspec>, [">= 0"])
+ end
+ else
+ s.add_dependency(%q<god>, [">= 0"])
+ s.add_dependency(%q<sinatra>, [">= 0"])
+ s.add_dependency(%q<rspec>, [">= 0"])
+ end
end
View
55 lib/app.rb
@@ -0,0 +1,55 @@
+
+before do
+ unless (GODWEB_CONFIG['username'].nil? && GODWEB_CONFIG['password'].nil?) || self.request.path_info == '/heartbeat'
+ authenticate_or_request_with_http_basic "GodWeb" do
+ |user, pass| user == GODWEB_CONFIG['username'] && pass == GODWEB_CONFIG['password']
+ end
+ end
+ GODWEB.ping
+end
+
+get '/' do
+ @statuses = GODWEB.status
+ @watches = []
+ @statuses.each do |watch, status|
+ @watches << watch.to_s
+ end
+ @watches.sort!
+ @groups = GODWEB.groups
+ show(:status)
+end
+
+get '/w/:watch' do
+ @watch = params["watch"]
+ @status = GODWEB.status[@watch][:state]
+ @commands = GodWeb.possible_statuses(@status)
+ @log = GODWEB.last_log(@watch)
+ show(:watch, @watch)
+end
+
+get '/g/:group' do
+ @watch = @group = params["group"]
+ @status = nil
+ @commands = GodWeb.possible_statuses(@status)
+ show(:watch, "#{@group} [group]")
+end
+
+get '/w/:watch/:command' do
+ @watch = params["watch"]
+ @command = params["command"]
+ @success = GODWEB.send(@command, @watch)
+ @success = false if @success == []
+ show(:command, "#{@command}ing #{@watch}")
+end
+
+get '/heartbeat' do
+ @statuses = GODWEB.status
+ 'OK'
+end
+
+private
+
+def show(template, title = 'GodWeb')
+ @title = title
+ erb(template)
+end
View
6 lib/environment.rb
@@ -4,7 +4,9 @@
require 'stringio'
require 'yaml'
require 'erb'
+require 'optparse'
#included until http://sinatra.lighthouseapp.com/projects/9779/tickets/16-patch-http-authentication is in a released version
+require File.dirname(__FILE__) + '/app'
require File.dirname(__FILE__) + '/sinatra_http_auth'
require File.dirname(__FILE__) + '/god_web'
@@ -22,5 +24,5 @@
GODWEB = GodWeb.new(config)
-Sinatra.application.options.public = File.dirname(__FILE__) + "/../public"
-Sinatra.application.options.views = File.dirname(__FILE__) + "/../views"
+Sinatra::Application.public = File.dirname(__FILE__) + "/../public"
+Sinatra::Application.views = File.dirname(__FILE__) + "/../views"
View
73 lib/god_web.rb
@@ -66,6 +66,10 @@ def ping
end
end
+ def last_log(watch)
+ format_log(log_command(watch, true))
+ end
+
def self.possible_statuses(status)
case status
when :up
@@ -77,6 +81,7 @@ def self.possible_statuses(status)
end
end
+
private
def method_missing(meth,*args)
@@ -103,29 +108,51 @@ def status_command
@server.status
end
+ #
+ # To make it look good (no horiz scrollbars) in the iphone
+ #
+ def format_log(raw)
+ raw.split("\n").map do |l|
+ # clean stuff we don't need
+ l.gsub!(/I\s+|\(\w*\)|within bounds/, "") # gsub(/\(\w*\)/, """)
+ # if ok, span is green
+ ok = l =~ /\[ok\]/
+ # get some data we want...
+ l.gsub(/\[\S*\s(\S*)\]\W+INFO: (\w*-?\w*)\s\[(\w*)\]/, "<span class='gray'>\\1</span> | <span class='#{ok ? 'green' : 'red'}'>\\3</span> |").
+ # take only the integer from cpu
+ gsub(/cpu/, "cpu %").gsub(/(\d{1,3})\.\d*%/, "\\1").
+ # show mem usage in mb
+ gsub(/memory/, "memory mb").gsub(/(\d*kb)/) { ($1.to_i / 1000).to_s }
+ end.join("</br>")
+ end
+
#TODO
- # def log_command
- # begin
- # Signal.trap('INT') { exit }
- # name = @args[1]
- #
- # unless name
- # puts "You must specify a Task or Group name"
- # exit!
- # end
- #
- # t = Time.at(0)
- # loop do
- # print @server.running_log(name, t)
- # t = Time.now
- # sleep 1
- # end
- # rescue God::NoSuchWatchError
- # puts "No such watch"
- # rescue DRb::DRbConnError
- # puts "The server went away"
- # end
- # end
+ def log_command(name, sample=false)
+ begin
+ Signal.trap('INT') { exit }
+ # name = @args[1]
+
+ unless name
+ puts "You must specify a Task or Group name"
+ exit!
+ end
+
+ t = Time.at(0)
+ if sample
+ @server.running_log(name, t)
+ else
+ loop do
+ @server.running_log(name, t)
+ t = Time.now
+ sleep 1
+ end
+ end
+ rescue God::NoSuchWatchError
+ puts "No such watch"
+ rescue DRb::DRbConnError
+ puts "The server went away"
+ end
+ end
def quit_command
begin
@@ -162,4 +189,4 @@ def lifecycle_command(*args)
watches.empty? ? [] : watches
end
-end
+end
View
26 public/app.css
@@ -0,0 +1,26 @@
+body > ul > li {
+ padding-left: 30px;
+}
+li.up { background: transparent url(../icons/up.png) no-repeat scroll 8px 12px;}
+li.unmonitored { background: transparent url(../icons/unmonitored.png) no-repeat scroll 8px 12px;}
+li.monitor { background: transparent url(../icons/monitor.png) no-repeat scroll 8px 12px;}
+li.start { background: transparent url(../icons/start.png) no-repeat scroll 8px 12px;}
+li.stop { background: transparent url(../icons/stop.png) no-repeat scroll 8px 12px; }
+li.restart { background: transparent url(../icons/restart.png) no-repeat scroll 8px 12px;}
+li.unmonitor { background: transparent url(../icons/unmonitor.png) no-repeat scroll 8px 12px;}
+li.groups { background: transparent url(../icons/groups.png) no-repeat scroll 8px 12px;}
+
+.info {
+ font-size: 0.8em;
+}
+
+.gray { color: #aaa; }
+
+.green {
+ color: #00aa00;
+ font-weight: bold;
+}
+.red {
+ color: #aa0000;
+ font-weight: bold;
+}
View
BIN  public/icons/databases.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/icons/gear.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/icons/groups.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/icons/key.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/icons/monitor.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/icons/restart.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/icons/ruby.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/icons/server.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/icons/start.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/icons/stop.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/icons/terminal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/icons/unmonitor.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/icons/unmonitored.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/icons/unmonitored_old.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/icons/up.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/icons/warn.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/icons/wrench.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/iui/iui-logo-touch-icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
30 public/iui/iui.css
@@ -1,4 +1,4 @@
-/* iui.css (c) 2007 by iUI Project Members, see LICENSE.txt for license */
+/* iui.css (c) 2007-9 by iUI Project Members, see LICENSE.txt for license */
body {
margin: 0;
font-family: Helvetica;
@@ -18,6 +18,9 @@ body > *:not(.toolbar) {
top: 45px;
width: 100%;
min-height: 372px;
+ -webkit-transition-duration: 300ms;
+ -webkit-transition-property: -webkit-transform;
+ -webkit-transform: translateX(0%);
}
body[orient="landscape"] > *:not(.toolbar) {
@@ -118,6 +121,7 @@ body[orient="landscape"] > .toolbar > h1 {
}
.whiteButton,
+.redButton,
.grayButton {
display: block;
border-width: 0 12px;
@@ -134,6 +138,12 @@ body[orient="landscape"] > .toolbar > h1 {
text-shadow: rgba(255, 255, 255, 0.7) 0 1px 0;
}
+.redButton {
+ -webkit-border-image: url(redButton.png) 0 12 0 12;
+ color:#fff;
+ text-shadow: #7a0001 0 -1px 0;
+}
+
.grayButton {
-webkit-border-image: url(grayButton.png) 0 12 0 12;
color: #FFFFFF;
@@ -230,7 +240,7 @@ body > .dialog {
color: #999999;
}
-input {
+input:not(input[type|=radio]):not(input[type|=checkbox]) {
box-sizing: border-box;
-webkit-box-sizing: border-box;
width: 100%;
@@ -244,6 +254,7 @@ input {
body > .panel {
box-sizing: border-box;
+ -moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
padding: 10px;
background: #c8c8c8 url(pinstripes.png);
@@ -255,6 +266,7 @@ body > .panel {
padding: 0;
background: #FFFFFF;
-webkit-border-radius: 10px;
+ -moz-border-radius: 10px;
border: 1px solid #999999;
text-align: right;
font-size: 16px;
@@ -272,8 +284,9 @@ fieldset > .row:last-child {
border-bottom: none !important;
}
-.row > input {
+.row > input:not(input[type|=radio]):not(input[type|=checkbox]) {
box-sizing: border-box;
+ -moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
margin: 0;
border: none;
@@ -281,6 +294,11 @@ fieldset > .row:last-child {
height: 42px;
background: none;
}
+.row > input[type|=radio], .row > input[type|=checkbox] {
+ margin: 7px 7px 0 0;
+ height: 25px;
+ width: 25px;
+}
.row > label {
position: absolute;
@@ -289,6 +307,12 @@ fieldset > .row:last-child {
font-weight: bold;
}
+.row > span {
+ position: absolute;
+ padding: 12px 10px 0 110px;
+ margin: 0;
+}
+
.row > .toggle {
position: absolute;
top: 6px;
View
709 public/iui/iui.js
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2007, iUI Project Members
- See LICENSE.txt for licensing terms
+ Copyright (c) 2007-9, iUI Project Members
+ See LICENSE.txt for licensing terms
*/
@@ -17,364 +17,491 @@ var hashPrefix = "#_";
var pageHistory = [];
var newPageCount = 0;
var checkTimer;
+var hasOrientationEvent = false;
+var portraitVal = "portrait";
+var landscapeVal = "landscape";
// *************************************************************************************************
window.iui =
{
- showPage: function(page, backwards)
- {
- if (page)
- {
- if (currentDialog)
- {
- currentDialog.removeAttribute("selected");
- currentDialog = null;
- }
-
- if (hasClass(page, "dialog"))
- showDialog(page);
- else
- {
- var fromPage = currentPage;
- currentPage = page;
-
- if (fromPage)
- setTimeout(slidePages, 0, fromPage, page, backwards);
- else
- updatePage(page, fromPage);
- }
- }
- },
-
- showPageById: function(pageId)
- {
- var page = $(pageId);
- if (page)
- {
- var index = pageHistory.indexOf(pageId);
- var backwards = index != -1;
- if (backwards)
- pageHistory.splice(index, pageHistory.length);
-
- iui.showPage(page, backwards);
- }
- },
-
- showPageByHref: function(href, args, method, replace, cb)
- {
- var req = new XMLHttpRequest();
- req.onerror = function()
- {
- if (cb)
- cb(false);
- };
-
- req.onreadystatechange = function()
- {
- if (req.readyState == 4)
- {
- if (replace)
- replaceElementWithSource(replace, req.responseText);
- else
- {
- var frag = document.createElement("div");
- frag.innerHTML = req.responseText;
- iui.insertPages(frag.childNodes);
- }
- if (cb)
- setTimeout(cb, 1000, true);
- }
- };
-
- if (args)
- {
- req.open(method || "GET", href, true);
- req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- req.setRequestHeader("Content-Length", args.length);
- req.send(args.join("&"));
- }
- else
- {
- req.open(method || "GET", href, true);
- req.send(null);
- }
- },
-
- insertPages: function(nodes)
- {
- var targetPage;
- for (var i = 0; i < nodes.length; ++i)
- {
- var child = nodes[i];
- if (child.nodeType == 1)
- {
- if (!child.id)
- child.id = "__" + (++newPageCount) + "__";
-
- var clone = $(child.id);
- if (clone)
- clone.parentNode.replaceChild(child, clone);
- else
- document.body.appendChild(child);
-
- if (child.getAttribute("selected") == "true" || !targetPage)
- targetPage = child;
-
- --i;
- }
- }
-
- if (targetPage)
- iui.showPage(targetPage);
- },
-
- getSelectedPage: function()
- {
- for (var child = document.body.firstChild; child; child = child.nextSibling)
- {
- if (child.nodeType == 1 && child.getAttribute("selected") == "true")
- return child;
- }
- }
+ animOn: false, // Experimental slide animation with CSS transition disabled by default
+
+ showPage: function(page, backwards)
+ {
+ if (page)
+ {
+ if (currentDialog)
+ {
+ currentDialog.removeAttribute("selected");
+ currentDialog = null;
+ }
+
+ if (hasClass(page, "dialog"))
+ showDialog(page);
+ else
+ {
+ var fromPage = currentPage;
+ currentPage = page;
+
+ if (fromPage)
+ setTimeout(slidePages, 0, fromPage, page, backwards);
+ else
+ updatePage(page, fromPage);
+ }
+ }
+ },
+
+ showPageById: function(pageId)
+ {
+ var page = $(pageId);
+ if (page)
+ {
+ var index = pageHistory.indexOf(pageId);
+ var backwards = index != -1;
+ if (backwards)
+ pageHistory.splice(index, pageHistory.length);
+
+ iui.showPage(page, backwards);
+ }
+ },
+
+ showPageByHref: function(href, args, method, replace, cb)
+ {
+ var req = new XMLHttpRequest();
+ req.onerror = function()
+ {
+ if (cb)
+ cb(false);
+ };
+
+ req.onreadystatechange = function()
+ {
+ if (req.readyState == 4)
+ {
+ if (replace)
+ replaceElementWithSource(replace, req.responseText);
+ else
+ {
+ var frag = document.createElement("div");
+ frag.innerHTML = req.responseText;
+ iui.insertPages(frag.childNodes);
+ }
+ if (cb)
+ setTimeout(cb, 1000, true);
+ }
+ };
+
+ if (args)
+ {
+ req.open(method || "GET", href, true);
+ req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ req.setRequestHeader("Content-Length", args.length);
+ req.send(args.join("&"));
+ }
+ else
+ {
+ req.open(method || "GET", href, true);
+ req.send(null);
+ }
+ },
+
+ insertPages: function(nodes)
+ {
+ var targetPage;
+ for (var i = 0; i < nodes.length; ++i)
+ {
+ var child = nodes[i];
+ if (child.nodeType == 1)
+ {
+ if (!child.id)
+ child.id = "__" + (++newPageCount) + "__";
+
+ var clone = $(child.id);
+ if (clone)
+ clone.parentNode.replaceChild(child, clone);
+ else
+ document.body.appendChild(child);
+
+ if (child.getAttribute("selected") == "true" || !targetPage)
+ targetPage = child;
+
+ --i;
+ }
+ }
+
+ if (targetPage)
+ iui.showPage(targetPage);
+ },
+
+ getSelectedPage: function()
+ {
+ for (var child = document.body.firstChild; child; child = child.nextSibling)
+ {
+ if (child.nodeType == 1 && child.getAttribute("selected") == "true")
+ return child;
+ }
+ },
+ isNativeUrl: function(href)
+ {
+ for(var i = 0; i < iui.nativeUrlPatterns.length; i++)
+ {
+ if(href.match(iui.nativeUrlPatterns[i])) return true;
+ }
+ return false;
+ },
+ nativeUrlPatterns: [
+ new RegExp("^http:\/\/maps.google.com\/maps\?"),
+ new RegExp("^mailto:"),
+ new RegExp("^tel:"),
+ new RegExp("^http:\/\/www.youtube.com\/watch\\?v="),
+ new RegExp("^http:\/\/www.youtube.com\/v\/"),
+ new RegExp("^javascript:"),
+
+ ]
};
// *************************************************************************************************
addEventListener("load", function(event)
{
- var page = iui.getSelectedPage();
- if (page)
- iui.showPage(page);
+ var page = iui.getSelectedPage();
+ var locPage = getPageFromLoc();
+
+ if (page)
+ iui.showPage(page);
+
+ if (locPage && (locPage != page))
+ iui.showPage(locPage);
+
+ setTimeout(preloadImages, 0);
+ if (typeof window.onorientationchange == "object")
+ {
+ window.onorientationchange=orientChangeHandler;
+ hasOrientationEvent = true;
+ setTimeout(orientChangeHandler, 0);
+ }
+ setTimeout(checkOrientAndLocation, 0);
+ checkTimer = setInterval(checkOrientAndLocation, 300);
+}, false);
- setTimeout(preloadImages, 0);
- setTimeout(checkOrientAndLocation, 0);
- checkTimer = setInterval(checkOrientAndLocation, 300);
+addEventListener("unload", function(event)
+{
+ return;
}, false);
-
+
addEventListener("click", function(event)
{
- var link = findParent(event.target, "a");
- if (link)
- {
- function unselect() { link.removeAttribute("selected"); }
-
- if (link.href && link.hash && link.hash != "#")
- {
- link.setAttribute("selected", "true");
- iui.showPage($(link.hash.substr(1)));
- setTimeout(unselect, 500);
- }
- else if (link == $("backButton"))
- history.back();
- else if (link.getAttribute("type") == "submit")
- submitForm(findParent(link, "form"));
- else if (link.getAttribute("type") == "cancel")
- cancelDialog(findParent(link, "form"));
- else if (link.target == "_replace")
- {
- link.setAttribute("selected", "progress");
- iui.showPageByHref(link.href, null, null, link, unselect);
- }
- else if (!link.target)
- {
- link.setAttribute("selected", "progress");
- iui.showPageByHref(link.href, null, null, null, unselect);
- }
- else
- return;
-
- event.preventDefault();
- }
+ var link = findParent(event.target, "a");
+ if (link)
+ {
+ function unselect() { link.removeAttribute("selected"); }
+
+ if (link.href && link.hash && link.hash != "#" && !link.target)
+ {
+ link.setAttribute("selected", "true");
+ iui.showPage($(link.hash.substr(1)));
+ setTimeout(unselect, 500);
+ }
+ else if (link == $("backButton"))
+ history.back();
+ else if (link.getAttribute("type") == "submit")
+ submitForm(findParent(link, "form"));
+ else if (link.getAttribute("type") == "cancel")
+ cancelDialog(findParent(link, "form"));
+ else if (link.target == "_replace")
+ {
+ link.setAttribute("selected", "progress");
+ iui.showPageByHref(link.href, null, null, link, unselect);
+ }
+ else if (iui.isNativeUrl(link.href))
+ {
+ return;
+ }
+ else if (link.target == "_webapp")
+ {
+ location.href = link.href;
+ }
+ else if (!link.target)
+ {
+ link.setAttribute("selected", "progress");
+ iui.showPageByHref(link.href, null, null, null, unselect);
+ }
+ else
+ return;
+
+ event.preventDefault();
+ }
}, true);
addEventListener("click", function(event)
{
- var div = findParent(event.target, "div");
- if (div && hasClass(div, "toggle"))
- {
- div.setAttribute("toggled", div.getAttribute("toggled") != "true");
- event.preventDefault();
- }
+ var div = findParent(event.target, "div");
+ if (div && hasClass(div, "toggle"))
+ {
+ div.setAttribute("toggled", div.getAttribute("toggled") != "true");
+ event.preventDefault();
+ }
}, true);
+function getPageFromLoc()
+{
+ var page;
+ var result = location.hash.match(/#_([^\?_]+)/);
+ if (result)
+ page = result[1];
+ if (page)
+ page = $(page);
+ return page;
+}
+
+function orientChangeHandler()
+{
+ var orientation=window.orientation;
+ switch(orientation)
+ {
+ case 0:
+ setOrientation(portraitVal);
+ break;
+
+ case 90:
+ case -90:
+ setOrientation(landscapeVal);
+ break;
+ }
+}
+
+
function checkOrientAndLocation()
{
- if (window.innerWidth != currentWidth)
- {
- currentWidth = window.innerWidth;
- var orient = currentWidth == 320 ? "profile" : "landscape";
- document.body.setAttribute("orient", orient);
- setTimeout(scrollTo, 100, 0, 1);
- }
-
- if (location.hash != currentHash)
- {
- var pageId = location.hash.substr(hashPrefix.length)
- iui.showPageById(pageId);
- }
+ if (!hasOrientationEvent)
+ {
+ if (window.innerWidth != currentWidth)
+ {
+ currentWidth = window.innerWidth;
+ var orient = currentWidth == 320 ? portraitVal : landscapeVal;
+ setOrientation(orient);
+ }
+ }
+
+ if (location.hash != currentHash)
+ {
+ var pageId = location.hash.substr(hashPrefix.length);
+ iui.showPageById(pageId);
+ }
+}
+
+function setOrientation(orient)
+{
+ document.body.setAttribute("orient", orient);
+ setTimeout(scrollTo, 100, 0, 1);
}
function showDialog(page)
{
- currentDialog = page;
- page.setAttribute("selected", "true");
-
- if (hasClass(page, "dialog") && !page.target)
- showForm(page);
+ currentDialog = page;
+ page.setAttribute("selected", "true");
+
+ if (hasClass(page, "dialog") && !page.target)
+ showForm(page);
}
function showForm(form)
{
- form.onsubmit = function(event)
- {
- event.preventDefault();
- submitForm(form);
- };
-
- form.onclick = function(event)
- {
- if (event.target == form && hasClass(form, "dialog"))
- cancelDialog(form);
- };
+ form.onsubmit = function(event)
+ {
+ event.preventDefault();
+ submitForm(form);
+ };
+
+ form.onclick = function(event)
+ {
+ if (event.target == form && hasClass(form, "dialog"))
+ cancelDialog(form);
+ };
}
function cancelDialog(form)
{
- form.removeAttribute("selected");
+ form.removeAttribute("selected");
}
function updatePage(page, fromPage)
{
- if (!page.id)
- page.id = "__" + (++newPageCount) + "__";
-
- location.href = currentHash = hashPrefix + page.id;
- pageHistory.push(page.id);
-
- var pageTitle = $("pageTitle");
- if (page.title)
- pageTitle.innerHTML = page.title;
-
- if (page.localName.toLowerCase() == "form" && !page.target)
- showForm(page);
-
- var backButton = $("backButton");
- if (backButton)
- {
- var prevPage = $(pageHistory[pageHistory.length-2]);
- if (prevPage && !page.getAttribute("hideBackButton"))
- {
- backButton.style.display = "inline";
- backButton.innerHTML = prevPage.title ? prevPage.title : "Back";
- }
- else
- backButton.style.display = "none";
- }
+ if (!page.id)
+ page.id = "__" + (++newPageCount) + "__";
+
+ location.hash = currentHash = hashPrefix + page.id;
+ pageHistory.push(page.id);
+
+ var pageTitle = $("pageTitle");
+ if (page.title)
+ pageTitle.innerHTML = page.title;
+
+ if (page.localName.toLowerCase() == "form" && !page.target)
+ showForm(page);
+
+ var backButton = $("backButton");
+ if (backButton)
+ {
+ var prevPage = $(pageHistory[pageHistory.length-2]);
+ if (prevPage && !page.getAttribute("hideBackButton"))
+ {
+ backButton.style.display = "inline";
+ backButton.innerHTML = prevPage.title ? prevPage.title : "Back";
+ }
+ else
+ backButton.style.display = "none";
+ }
}
function slidePages(fromPage, toPage, backwards)
-{
- var axis = (backwards ? fromPage : toPage).getAttribute("axis");
- if (axis == "y")
- (backwards ? fromPage : toPage).style.top = "100%";
- else
- toPage.style.left = "100%";
-
- toPage.setAttribute("selected", "true");
- scrollTo(0, 1);
- clearInterval(checkTimer);
-
- var percent = 100;
- slide();
- var timer = setInterval(slide, slideInterval);
-
- function slide()
- {
- percent -= slideSpeed;
- if (percent <= 0)
- {
- percent = 0;
- if (!hasClass(toPage, "dialog"))
- fromPage.removeAttribute("selected");
- clearInterval(timer);
- checkTimer = setInterval(checkOrientAndLocation, 300);
- setTimeout(updatePage, 0, toPage, fromPage);
- }
-
- if (axis == "y")
- {
- backwards
- ? fromPage.style.top = (100-percent) + "%"
- : toPage.style.top = percent + "%";
- }
- else
- {
- fromPage.style.left = (backwards ? (100-percent) : (percent-100)) + "%";
- toPage.style.left = (backwards ? -percent : percent) + "%";
- }
- }
+{
+ var axis = (backwards ? fromPage : toPage).getAttribute("axis");
+
+ clearInterval(checkTimer);
+
+ if (canDoSlideAnim() && axis != 'y')
+ {
+ slide2(fromPage, toPage, backwards, slideDone);
+ }
+ else
+ {
+ slide1(fromPage, toPage, backwards, axis, slideDone);
+ }
+
+ function slideDone()
+ {
+ if (!hasClass(toPage, "dialog"))
+ fromPage.removeAttribute("selected");
+ checkTimer = setInterval(checkOrientAndLocation, 300);
+ setTimeout(updatePage, 0, toPage, fromPage);
+ fromPage.removeEventListener('webkitTransitionEnd', slideDone, false);
+ }
+}
+
+function canDoSlideAnim()
+{
+ return (iui.animOn) && (typeof WebKitCSSMatrix == "object");
+}
+
+function slide1(fromPage, toPage, backwards, axis, cb)
+{
+ if (axis == "y")
+ (backwards ? fromPage : toPage).style.top = "100%";
+ else
+ toPage.style.left = "100%";
+
+ scrollTo(0, 1);
+ toPage.setAttribute("selected", "true");
+ var percent = 100;
+ slide();
+ var timer = setInterval(slide, slideInterval);
+
+ function slide()
+ {
+ percent -= slideSpeed;
+ if (percent <= 0)
+ {
+ percent = 0;
+ clearInterval(timer);
+ cb();
+ }
+
+ if (axis == "y")
+ {
+ backwards
+ ? fromPage.style.top = (100-percent) + "%"
+ : toPage.style.top = percent + "%";
+ }
+ else
+ {
+ fromPage.style.left = (backwards ? (100-percent) : (percent-100)) + "%";
+ toPage.style.left = (backwards ? -percent : percent) + "%";
+ }
+ }
+}
+
+
+function slide2(fromPage, toPage, backwards, cb)
+{
+ toPage.style.webkitTransitionDuration = '0ms'; // Turn off transitions to set toPage start offset
+ // fromStart is always 0% and toEnd is always 0%
+ // iPhone won't take % width on toPage
+ var toStart = 'translateX(' + (backwards ? '-' : '') + window.innerWidth + 'px)';
+ var fromEnd = 'translateX(' + (backwards ? '100%' : '-100%') + ')';
+ toPage.style.webkitTransform = toStart;
+ toPage.setAttribute("selected", "true");
+ toPage.style.webkitTransitionDuration = ''; // Turn transitions back on
+ function startTrans()
+ {
+ fromPage.style.webkitTransform = fromEnd;
+ toPage.style.webkitTransform = 'translateX(0%)'; //toEnd
+ }
+ fromPage.addEventListener('webkitTransitionEnd', cb, false);
+ setTimeout(startTrans, 0);
}
function preloadImages()
{
- var preloader = document.createElement("div");
- preloader.id = "preloader";
- document.body.appendChild(preloader);
+ var preloader = document.createElement("div");
+ preloader.id = "preloader";
+ document.body.appendChild(preloader);
}
function submitForm(form)
{
- iui.showPageByHref(form.action || "POST", encodeForm(form), form.method);
+ iui.showPageByHref(form.action || "POST", encodeForm(form), form.method);
}
function encodeForm(form)
{
- function encode(inputs)
- {
- for (var i = 0; i < inputs.length; ++i)
- {
- if (inputs[i].name)
- args.push(inputs[i].name + "=" + escape(inputs[i].value));
- }
- }
-
- var args = [];
- encode(form.getElementsByTagName("input"));
- encode(form.getElementsByTagName("select"));
- return args;
+ function encode(inputs)
+ {
+ for (var i = 0; i < inputs.length; ++i)
+ {
+ if (inputs[i].name)
+ args.push(inputs[i].name + "=" + escape(inputs[i].value));
+ }
+ }
+
+ var args = [];
+ encode(form.getElementsByTagName("input"));
+ encode(form.getElementsByTagName("textarea"));
+ encode(form.getElementsByTagName("select"));
+ return args;
}
function findParent(node, localName)
{
- while (node && (node.nodeType != 1 || node.localName.toLowerCase() != localName))
- node = node.parentNode;
- return node;
+ while (node && (node.nodeType != 1 || node.localName.toLowerCase() != localName))
+ node = node.parentNode;
+ return node;
}
function hasClass(self, name)
{
- var re = new RegExp("(^|\\s)"+name+"($|\\s)");
- return re.exec(self.getAttribute("class")) != null;
+ var re = new RegExp("(^|\\s)"+name+"($|\\s)");
+ return re.exec(self.getAttribute("class")) != null;
}
function replaceElementWithSource(replace, source)
{
- var page = replace.parentNode;
- var parent = replace;
- while (page.parentNode != document.body)
- {
- page = page.parentNode;
- parent = parent.parentNode;
- }
+ var page = replace.parentNode;
+ var parent = replace;
+ while (page.parentNode != document.body)
+ {
+ page = page.parentNode;
+ parent = parent.parentNode;
+ }
- var frag = document.createElement(parent.localName);
- frag.innerHTML = source;
+ var frag = document.createElement(parent.localName);
+ frag.innerHTML = source;
- page.removeChild(parent);
+ page.removeChild(parent);
- while (frag.firstChild)
- page.appendChild(frag.firstChild);
+ while (frag.firstChild)
+ page.appendChild(frag.firstChild);
}
function $(id) { return document.getElementById(id); }
View
2  public/iui/iuix.css
@@ -1 +1 @@
-body{margin:0;font-family:Helvetica;background:#FFF;color:#000;overflow-x:hidden;-webkit-user-select:none;-webkit-text-size-adjust:none;}body>*:not(.toolbar){display:none;position:absolute;margin:0;padding:0;left:0;top:45px;width:100%;min-height:372px;}body[orient="landscape"]>*:not(.toolbar){min-height:268px;}body>*[selected="true"]{display:block;}a[selected],a:active{background-color:#194fdb!important;background-image:url(listArrowSel.png),url(selection.png)!important;background-repeat:no-repeat,repeat-x;background-position:right center,left top;color:#FFF!important;}a[selected="progress"]{background-image:url(loading.gif),url(selection.png)!important;}body>.toolbar{box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;border-bottom:1px solid #2d3642;border-top:1px solid #6d84a2;padding:10px;height:45px;background:url(toolbar.png) #6d84a2 repeat-x;}.toolbar>h1{position:absolute;overflow:hidden;left:50%;margin:1px 0 0 -75px;height:45px;font-size:20px;width:150px;font-weight:bold;text-shadow:rgba(0,0,0,0.4) 0 -1px 0;text-align:center;text-overflow:ellipsis;white-space:nowrap;color:#FFF;}body[orient="landscape"]>.toolbar>h1{margin-left:-125px;width:250px;}.button{position:absolute;overflow:hidden;top:8px;right:6px;margin:0;border-width:0 5px;padding:0 3px;width:auto;height:30px;line-height:30px;font-family:inherit;font-size:12px;font-weight:bold;color:#FFF;text-shadow:rgba(0,0,0,0.6) 0 -1px 0;text-overflow:ellipsis;text-decoration:none;white-space:nowrap;background:none;-webkit-border-image:url(toolButton.png) 0 5 0 5;}.blueButton{-webkit-border-image:url(blueButton.png) 0 5 0 5;border-width:0 5px;}.leftButton{left:6px;right:auto;}#backButton{display:none;left:6px;right:auto;padding:0;max-width:55px;border-width:0 8px 0 14px;-webkit-border-image:url(backButton.png) 0 8 0 14;}.whiteButton,.grayButton{display:block;border-width:0 12px;padding:10px;text-align:center;font-size:20px;font-weight:bold;text-decoration:inherit;color:inherit;}.whiteButton{-webkit-border-image:url(whiteButton.png) 0 12 0 12;text-shadow:rgba(255,255,255,0.7) 0 1px 0;}.grayButton{-webkit-border-image:url(grayButton.png) 0 12 0 12;color:#FFF;}body>ul>li{position:relative;margin:0;border-bottom:1px solid #E0E0E0;padding:8px 0 8px 10px;font-size:20px;font-weight:bold;list-style:none;}body>ul>li.group{position:relative;top:-1px;margin-bottom:-2px;border-top:1px solid #7d7d7d;border-bottom:1px solid #999;padding:1px 10px;background:url(listGroup.png) repeat-x;font-size:17px;font-weight:bold;text-shadow:rgba(0,0,0,0.4) 0 1px 0;color:#FFF;}body>ul>li.group:first-child{top:0;border-top:none;}body>ul>li>a{display:block;margin:-8px 0 -8px -10px;padding:8px 32px 8px 10px;text-decoration:none;color:inherit;background:url(listArrow.png) no-repeat right center;}a[target="_replace"]{box-sizing:border-box;-webkit-box-sizing:border-box;padding-top:25px;padding-bottom:25px;font-size:18px;color:cornflowerblue;background-color:#FFF;background-image:none;}body>.dialog{top:0;width:100%;min-height:417px;z-index:2;background:rgba(0,0,0,0.8);padding:0;text-align:right;}.dialog>fieldset{box-sizing:border-box;-webkit-box-sizing:border-box;width:100%;margin:0;border:none;border-top:1px solid #6d84a2;padding:10px 6px;background:url(toolbar.png) #7388a5 repeat-x;}.dialog>fieldset>h1{margin:0 10px 0 10px;padding:0;font-size:20px;font-weight:bold;color:#FFF;text-shadow:rgba(0,0,0,0.4) 0 -1px 0;text-align:center;}.dialog>fieldset>label{position:absolute;margin:16px 0 0 6px;font-size:14px;color:#999;}input{box-sizing:border-box;-webkit-box-sizing:border-box;width:100%;margin:8px 0 0 0;padding:6px 6px 6px 44px;font-size:16px;font-weight:normal;}body>.panel{box-sizing:border-box;-webkit-box-sizing:border-box;padding:10px;background:#c8c8c8 url(pinstripes.png);}.panel>fieldset{position:relative;margin:0 0 20px 0;padding:0;background:#FFF;-webkit-border-radius:10px;border:1px solid #999;text-align:right;font-size:16px;}.row{position:relative;min-height:42px;border-bottom:1px solid #999;-webkit-border-radius:0;text-align:right;}fieldset>.row:last-child{border-bottom:none!important;}.row>input{box-sizing:border-box;-webkit-box-sizing:border-box;margin:0;border:none;padding:12px 10px 0 110px;height:42px;background:none;}.row>label{position:absolute;margin:0 0 0 14px;line-height:42px;font-weight:bold;}.row>.toggle{position:absolute;top:6px;right:6px;width:100px;height:28px;}.toggle{border:1px solid #888;-webkit-border-radius:6px;background:#FFF url(toggle.png) repeat-x;font-size:19px;font-weight:bold;line-height:30px;}.toggle[toggled="true"]{border:1px solid #143fae;background:#194fdb url(toggleOn.png) repeat-x;}.toggleOn{display:none;position:absolute;width:60px;text-align:center;left:0;top:0;color:#FFF;text-shadow:rgba(0,0,0,0.4) 0 -1px 0;}.toggleOff{position:absolute;width:60px;text-align:center;right:0;top:0;color:#666;}.toggle[toggled="true"]>.toggleOn{display:block;}.toggle[toggled="true"]>.toggleOff{display:none;}.thumb{position:absolute;top:-1px;left:-1px;width:40px;height:28px;border:1px solid #888;-webkit-border-radius:6px;background:#fff url(thumb.png) repeat-x;}.toggle[toggled="true"]>.thumb{left:auto;right:-1px;}.panel>h2{margin:0 0 8px 14px;font-size:inherit;font-weight:bold;color:#4d4d70;text-shadow:rgba(255,255,255,0.75) 2px 2px 0;}#preloader{display:none;background-image:url(loading.gif),url(selection.png),url(blueButton.png),url(listArrowSel.png),url(listGroup.png);}
+body{margin:0;font-family:Helvetica;background:#FFF;color:#000;overflow-x:hidden;-webkit-user-select:none;-webkit-text-size-adjust:none;}body>*:not(.toolbar){display:none;position:absolute;margin:0;padding:0;left:0;top:45px;width:100%;min-height:372px;-webkit-transition-duration:300ms;-webkit-transition-property:-webkit-transform;-webkit-transform:translateX(0%);}body[orient="landscape"]>*:not(.toolbar){min-height:268px;}body>*[selected="true"]{display:block;}a[selected],a:active{background-color:#194fdb!important;background-image:url(listArrowSel.png),url(selection.png)!important;background-repeat:no-repeat,repeat-x;background-position:right center,left top;color:#FFF!important;}a[selected="progress"]{background-image:url(loading.gif),url(selection.png)!important;}body>.toolbar{box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;border-bottom:1px solid #2d3642;border-top:1px solid #6d84a2;padding:10px;height:45px;background:url(toolbar.png) #6d84a2 repeat-x;}.toolbar>h1{position:absolute;overflow:hidden;left:50%;margin:1px 0 0 -75px;height:45px;font-size:20px;width:150px;font-weight:bold;text-shadow:rgba(0,0,0,0.4) 0 -1px 0;text-align:center;text-overflow:ellipsis;white-space:nowrap;color:#FFF;}body[orient="landscape"]>.toolbar>h1{margin-left:-125px;width:250px;}.button{position:absolute;overflow:hidden;top:8px;right:6px;margin:0;border-width:0 5px;padding:0 3px;width:auto;height:30px;line-height:30px;font-family:inherit;font-size:12px;font-weight:bold;color:#FFF;text-shadow:rgba(0,0,0,0.6) 0 -1px 0;text-overflow:ellipsis;text-decoration:none;white-space:nowrap;background:none;-webkit-border-image:url(toolButton.png) 0 5 0 5;}.blueButton{-webkit-border-image:url(blueButton.png) 0 5 0 5;border-width:0 5px;}.leftButton{left:6px;right:auto;}#backButton{display:none;left:6px;right:auto;padding:0;max-width:55px;border-width:0 8px 0 14px;-webkit-border-image:url(backButton.png) 0 8 0 14;}.whiteButton,.redButton,.grayButton{display:block;border-width:0 12px;padding:10px;text-align:center;font-size:20px;font-weight:bold;text-decoration:inherit;color:inherit;}.whiteButton{-webkit-border-image:url(whiteButton.png) 0 12 0 12;text-shadow:rgba(255,255,255,0.7) 0 1px 0;}.redButton{-webkit-border-image:url(redButton.png) 0 12 0 12;color:#fff;text-shadow:#7a0001 0 -1px 0;}.grayButton{-webkit-border-image:url(grayButton.png) 0 12 0 12;color:#FFF;}body>ul>li{position:relative;margin:0;border-bottom:1px solid #E0E0E0;padding:8px 0 8px 10px;font-size:20px;font-weight:bold;list-style:none;}body>ul>li.group{position:relative;top:-1px;margin-bottom:-2px;border-top:1px solid #7d7d7d;border-bottom:1px solid #999;padding:1px 10px;background:url(listGroup.png) repeat-x;font-size:17px;font-weight:bold;text-shadow:rgba(0,0,0,0.4) 0 1px 0;color:#FFF;}body>ul>li.group:first-child{top:0;border-top:none;}body>ul>li>a{display:block;margin:-8px 0 -8px -10px;padding:8px 32px 8px 10px;text-decoration:none;color:inherit;background:url(listArrow.png) no-repeat right center;}a[target="_replace"]{box-sizing:border-box;-webkit-box-sizing:border-box;padding-top:25px;padding-bottom:25px;font-size:18px;color:cornflowerblue;background-color:#FFF;background-image:none;}body>.dialog{top:0;width:100%;min-height:417px;z-index:2;background:rgba(0,0,0,0.8);padding:0;text-align:right;}.dialog>fieldset{box-sizing:border-box;-webkit-box-sizing:border-box;width:100%;margin:0;border:none;border-top:1px solid #6d84a2;padding:10px 6px;background:url(toolbar.png) #7388a5 repeat-x;}.dialog>fieldset>h1{margin:0 10px 0 10px;padding:0;font-size:20px;font-weight:bold;color:#FFF;text-shadow:rgba(0,0,0,0.4) 0 -1px 0;text-align:center;}.dialog>fieldset>label{position:absolute;margin:16px 0 0 6px;font-size:14px;color:#999;}input:not(input[type|=radio]):not(input[type|=checkbox]){box-sizing:border-box;-webkit-box-sizing:border-box;width:100%;margin:8px 0 0 0;padding:6px 6px 6px 44px;font-size:16px;font-weight:normal;}body>.panel{box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:10px;background:#c8c8c8 url(pinstripes.png);}.panel>fieldset{position:relative;margin:0 0 20px 0;padding:0;background:#FFF;-webkit-border-radius:10px;-moz-border-radius:10px;border:1px solid #999;text-align:right;font-size:16px;}.row{position:relative;min-height:42px;border-bottom:1px solid #999;-webkit-border-radius:0;text-align:right;}fieldset>.row:last-child{border-bottom:none!important;}.row>input:not(input[type|=radio]):not(input[type|=checkbox]){box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;margin:0;border:none;padding:12px 10px 0 110px;height:42px;background:none;}.row>input[type|=radio],.row>input[type|=checkbox]{margin:7px 7px 0 0;height:25px;width:25px;}.row>label{position:absolute;margin:0 0 0 14px;line-height:42px;font-weight:bold;}.row>span{position:absolute;padding:12px 10px 0 110px;margin:0;}.row>.toggle{position:absolute;top:6px;right:6px;width:100px;height:28px;}.toggle{border:1px solid #888;-webkit-border-radius:6px;background:#FFF url(toggle.png) repeat-x;font-size:19px;font-weight:bold;line-height:30px;}.toggle[toggled="true"]{border:1px solid #143fae;background:#194fdb url(toggleOn.png) repeat-x;}.toggleOn{display:none;position:absolute;width:60px;text-align:center;left:0;top:0;color:#FFF;text-shadow:rgba(0,0,0,0.4) 0 -1px 0;}.toggleOff{position:absolute;width:60px;text-align:center;right:0;top:0;color:#666;}.toggle[toggled="true"]>.toggleOn{display:block;}.toggle[toggled="true"]>.toggleOff{display:none;}.thumb{position:absolute;top:-1px;left:-1px;width:40px;height:28px;border:1px solid #888;-webkit-border-radius:6px;background:#fff url(thumb.png) repeat-x;}.toggle[toggled="true"]>.thumb{left:auto;right:-1px;}.panel>h2{margin:0 0 8px 14px;font-size:inherit;font-weight:bold;color:#4d4d70;text-shadow:rgba(255,255,255,0.75) 2px 2px 0;}#preloader{display:none;background-image:url(loading.gif),url(selection.png),url(blueButton.png),url(listArrowSel.png),url(listGroup.png);}
View
2  public/iui/iuix.js
@@ -1 +1 @@
-(function(){var _1=20;var _2=0;var _3=null;var _4=null;var _5=0;var _6=location.hash;var _7="#_";var _8=[];var _9=0;var _a;window.iui={showPage:function(_b,_c){if(_b){if(_4){_4.removeAttribute("selected");_4=null;}if(hasClass(_b,"dialog")){showDialog(_b);}else{var _d=_3;_3=_b;if(_d){setTimeout(slidePages,0,_d,_b,_c);}else{updatePage(_b,_d);}}}},showPageById:function(_e){var _f=$(_e);if(_f){var _10=_8.indexOf(_e);var _11=_10!=-1;if(_11){_8.splice(_10,_8.length);}iui.showPage(_f,_11);}},showPageByHref:function(_12,_13,_14,_15,cb){var req=new XMLHttpRequest();req.onerror=function(){if(cb){cb(false);}};req.onreadystatechange=function(){if(req.readyState==4){if(_15){replaceElementWithSource(_15,req.responseText);}else{var _18=document.createElement("div");_18.innerHTML=req.responseText;iui.insertPages(_18.childNodes);}if(cb){setTimeout(cb,1000,true);}}};if(_13){req.open(_14||"GET",_12,true);req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");req.setRequestHeader("Content-Length",_13.length);req.send(_13.join("&"));}else{req.open(_14||"GET",_12,true);req.send(null);}},insertPages:function(_19){var _1a;for(var i=0;i<_19.length;++i){var _1c=_19[i];if(_1c.nodeType==1){if(!_1c.id){_1c.id="__"+(++_9)+"__";}var _1d=$(_1c.id);if(_1d){_1d.parentNode.replaceChild(_1c,_1d);}else{document.body.appendChild(_1c);}if(_1c.getAttribute("selected")=="true"||!_1a){_1a=_1c;}--i;}}if(_1a){iui.showPage(_1a);}},getSelectedPage:function(){for(var _1e=document.body.firstChild;_1e;_1e=_1e.nextSibling){if(_1e.nodeType==1&&_1e.getAttribute("selected")=="true"){return _1e;}}}};addEventListener("load",function(_1f){var _20=iui.getSelectedPage();if(_20){iui.showPage(_20);}setTimeout(preloadImages,0);setTimeout(checkOrientAndLocation,0);_a=setInterval(checkOrientAndLocation,300);},false);addEventListener("click",function(_21){var _22=findParent(_21.target,"a");if(_22){function unselect(){_22.removeAttribute("selected");}if(_22.href&&_22.hash&&_22.hash!="#"){_22.setAttribute("selected","true");iui.showPage($(_22.hash.substr(1)));setTimeout(unselect,500);}else{if(_22==$("backButton")){history.back();}else{if(_22.getAttribute("type")=="submit"){submitForm(findParent(_22,"form"));}else{if(_22.getAttribute("type")=="cancel"){cancelDialog(findParent(_22,"form"));}else{if(_22.target=="_replace"){_22.setAttribute("selected","progress");iui.showPageByHref(_22.href,null,null,_22,unselect);}else{if(!_22.target){_22.setAttribute("selected","progress");iui.showPageByHref(_22.href,null,null,null,unselect);}else{return;}}}}}}_21.preventDefault();}},true);addEventListener("click",function(_23){var div=findParent(_23.target,"div");if(div&&hasClass(div,"toggle")){div.setAttribute("toggled",div.getAttribute("toggled")!="true");_23.preventDefault();}},true);function checkOrientAndLocation(){if(window.innerWidth!=_5){_5=window.innerWidth;var _25=_5==320?"profile":"landscape";document.body.setAttribute("orient",_25);setTimeout(scrollTo,100,0,1);}if(location.hash!=_6){var _26=location.hash.substr(_7.length);iui.showPageById(_26);}}function showDialog(_27){_4=_27;_27.setAttribute("selected","true");if(hasClass(_27,"dialog")&&!_27.target){showForm(_27);}}function showForm(_28){_28.onsubmit=function(_29){_29.preventDefault();submitForm(_28);};_28.onclick=function(_2a){if(_2a.target==_28&&hasClass(_28,"dialog")){cancelDialog(_28);}};}function cancelDialog(_2b){_2b.removeAttribute("selected");}function updatePage(_2c,_2d){if(!_2c.id){_2c.id="__"+(++_9)+"__";}location.href=_6=_7+_2c.id;_8.push(_2c.id);var _2e=$("pageTitle");if(_2c.title){_2e.innerHTML=_2c.title;}if(_2c.localName.toLowerCase()=="form"&&!_2c.target){showForm(_2c);}var _2f=$("backButton");if(_2f){var _30=$(_8[_8.length-2]);if(_30&&!_2c.getAttribute("hideBackButton")){_2f.style.display="inline";_2f.innerHTML=_30.title?_30.title:"Back";}else{_2f.style.display="none";}}}function slidePages(_31,_32,_33){var _34=(_33?_31:_32).getAttribute("axis");if(_34=="y"){(_33?_31:_32).style.top="100%";}else{_32.style.left="100%";}_32.setAttribute("selected","true");scrollTo(0,1);clearInterval(_a);var _35=100;slide();var _36=setInterval(slide,_2);function slide(){_35-=_1;if(_35<=0){_35=0;if(!hasClass(_32,"dialog")){_31.removeAttribute("selected");}clearInterval(_36);_a=setInterval(checkOrientAndLocation,300);setTimeout(updatePage,0,_32,_31);}if(_34=="y"){_33?_31.style.top=(100-_35)+"%":_32.style.top=_35+"%";}else{_31.style.left=(_33?(100-_35):(_35-100))+"%";_32.style.left=(_33?-_35:_35)+"%";}}}function preloadImages(){var _37=document.createElement("div");_37.id="preloader";document.body.appendChild(_37);}function submitForm(_38){iui.showPageByHref(_38.action||"POST",encodeForm(_38),_38.method);}function encodeForm(_39){function encode(_3a){for(var i=0;i<_3a.length;++i){if(_3a[i].name){args.push(_3a[i].name+"="+escape(_3a[i].value));}}}var _3c=[];encode(_39.getElementsByTagName("input"));encode(_39.getElementsByTagName("select"));return _3c;}function findParent(_3d,_3e){while(_3d&&(_3d.nodeType!=1||_3d.localName.toLowerCase()!=_3e)){_3d=_3d.parentNode;}return _3d;}function hasClass(_3f,_40){var re=new RegExp("(^|\\s)"+_40+"($|\\s)");return re.exec(_3f.getAttribute("class"))!=null;}function replaceElementWithSource(_42,_43){var _44=_42.parentNode;var _45=_42;while(_44.parentNode!=document.body){_44=_44.parentNode;_45=_45.parentNode;}var _46=document.createElement(_45.localName);_46.innerHTML=_43;_44.removeChild(_45);while(_46.firstChild){_44.appendChild(_46.firstChild);}}function $(id){return document.getElementById(id);}function ddd(){console.log.apply(console,arguments);}})();
+(function(){var _1=20;var _2=0;var _3=null;var _4=null;var _5=0;var _6=location.hash;var _7="#_";var _8=[];var _9=0;var _a;var _b=false;var _c="portrait";var _d="landscape";window.iui={animOn:false,showPage:function(_e,_f){if(_e){if(_4){_4.removeAttribute("selected");_4=null;}if(hasClass(_e,"dialog")){showDialog(_e);}else{var _10=_3;_3=_e;if(_10){setTimeout(slidePages,0,_10,_e,_f);}else{updatePage(_e,_10);}}}},showPageById:function(_11){var _12=$(_11);if(_12){var _13=_8.indexOf(_11);var _14=_13!=-1;if(_14){_8.splice(_13,_8.length);}iui.showPage(_12,_14);}},showPageByHref:function(_15,_16,_17,_18,cb){var req=new XMLHttpRequest();req.onerror=function(){if(cb){cb(false);}};req.onreadystatechange=function(){if(req.readyState==4){if(_18){replaceElementWithSource(_18,req.responseText);}else{var _1b=document.createElement("div");_1b.innerHTML=req.responseText;iui.insertPages(_1b.childNodes);}if(cb){setTimeout(cb,1000,true);}}};if(_16){req.open(_17||"GET",_15,true);req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");req.setRequestHeader("Content-Length",_16.length);req.send(_16.join("&"));}else{req.open(_17||"GET",_15,true);req.send(null);}},insertPages:function(_1c){var _1d;for(var i=0;i<_1c.length;++i){var _1f=_1c[i];if(_1f.nodeType==1){if(!_1f.id){_1f.id="__"+(++_9)+"__";}var _20=$(_1f.id);if(_20){_20.parentNode.replaceChild(_1f,_20);}else{document.body.appendChild(_1f);}if(_1f.getAttribute("selected")=="true"||!_1d){_1d=_1f;}--i;}}if(_1d){iui.showPage(_1d);}},getSelectedPage:function(){for(var _21=document.body.firstChild;_21;_21=_21.nextSibling){if(_21.nodeType==1&&_21.getAttribute("selected")=="true"){return _21;}}},isNativeUrl:function(_22){for(var i=0;i<iui.nativeUrlPatterns.length;i++){if(_22.match(iui.nativeUrlPatterns[i])){return true;}}return false;},nativeUrlPatterns:[new RegExp("^http://maps.google.com/maps?"),new RegExp("^mailto:"),new RegExp("^tel:"),new RegExp("^http://www.youtube.com/watch\\?v="),new RegExp("^http://www.youtube.com/v/"),new RegExp("^javascript:"),]};addEventListener("load",function(_24){var _25=iui.getSelectedPage();var _26=getPageFromLoc();if(_25){iui.showPage(_25);}if(_26&&(_26!=_25)){iui.showPage(_26);}setTimeout(preloadImages,0);if(typeof window.onorientationchange=="object"){window.onorientationchange=orientChangeHandler;_b=true;setTimeout(orientChangeHandler,0);}setTimeout(checkOrientAndLocation,0);_a=setInterval(checkOrientAndLocation,300);},false);addEventListener("unload",function(_27){return;},false);addEventListener("click",function(_28){var _29=findParent(_28.target,"a");if(_29){function unselect(){_29.removeAttribute("selected");}if(_29.href&&_29.hash&&_29.hash!="#"&&!_29.target){_29.setAttribute("selected","true");iui.showPage($(_29.hash.substr(1)));setTimeout(unselect,500);}else{if(_29==$("backButton")){history.back();}else{if(_29.getAttribute("type")=="submit"){submitForm(findParent(_29,"form"));}else{if(_29.getAttribute("type")=="cancel"){cancelDialog(findParent(_29,"form"));}else{if(_29.target=="_replace"){_29.setAttribute("selected","progress");iui.showPageByHref(_29.href,null,null,_29,unselect);}else{if(iui.isNativeUrl(_29.href)){return;}else{if(_29.target=="_webapp"){location.href=_29.href;}else{if(!_29.target){_29.setAttribute("selected","progress");iui.showPageByHref(_29.href,null,null,null,unselect);}else{return;}}}}}}}}_28.preventDefault();}},true);addEventListener("click",function(_2a){var div=findParent(_2a.target,"div");if(div&&hasClass(div,"toggle")){div.setAttribute("toggled",div.getAttribute("toggled")!="true");_2a.preventDefault();}},true);function getPageFromLoc(){var _2c;var _2d=location.hash.match(/#_([^\?_]+)/);if(_2d){_2c=_2d[1];}if(_2c){_2c=$(_2c);}return _2c;}function orientChangeHandler(){var _2e=window.orientation;switch(_2e){case 0:setOrientation(_c);break;case 90:case -90:setOrientation(_d);break;}}function checkOrientAndLocation(){if(!_b){if(window.innerWidth!=_5){_5=window.innerWidth;var _2f=_5==320?_c:_d;setOrientation(_2f);}}if(location.hash!=_6){var _30=location.hash.substr(_7.length);iui.showPageById(_30);}}function setOrientation(_31){document.body.setAttribute("orient",_31);setTimeout(scrollTo,100,0,1);}function showDialog(_32){_4=_32;_32.setAttribute("selected","true");if(hasClass(_32,"dialog")&&!_32.target){showForm(_32);}}function showForm(_33){_33.onsubmit=function(_34){_34.preventDefault();submitForm(_33);};_33.onclick=function(_35){if(_35.target==_33&&hasClass(_33,"dialog")){cancelDialog(_33);}};}function cancelDialog(_36){_36.removeAttribute("selected");}function updatePage(_37,_38){if(!_37.id){_37.id="__"+(++_9)+"__";}location.hash=_6=_7+_37.id;_8.push(_37.id);var _39=$("pageTitle");if(_37.title){_39.innerHTML=_37.title;}if(_37.localName.toLowerCase()=="form"&&!_37.target){showForm(_37);}var _3a=$("backButton");if(_3a){var _3b=$(_8[_8.length-2]);if(_3b&&!_37.getAttribute("hideBackButton")){_3a.style.display="inline";_3a.innerHTML=_3b.title?_3b.title:"Back";}else{_3a.style.display="none";}}}function slidePages(_3c,_3d,_3e){var _3f=(_3e?_3c:_3d).getAttribute("axis");clearInterval(_a);if(canDoSlideAnim()&&_3f!="y"){slide2(_3c,_3d,_3e,slideDone);}else{slide1(_3c,_3d,_3e,_3f,slideDone);}function slideDone(){if(!hasClass(_3d,"dialog")){_3c.removeAttribute("selected");}_a=setInterval(checkOrientAndLocation,300);setTimeout(updatePage,0,_3d,_3c);_3c.removeEventListener("webkitTransitionEnd",slideDone,false);}}function canDoSlideAnim(){return (iui.animOn)&&(typeof WebKitCSSMatrix=="object");}function slide1(_40,_41,_42,_43,cb){if(_43=="y"){(_42?_40:_41).style.top="100%";}else{_41.style.left="100%";}scrollTo(0,1);_41.setAttribute("selected","true");var _45=100;slide();var _46=setInterval(slide,_2);function slide(){_45-=_1;if(_45<=0){_45=0;clearInterval(_46);cb();}if(_43=="y"){_42?_40.style.top=(100-_45)+"%":_41.style.top=_45+"%";}else{_40.style.left=(_42?(100-_45):(_45-100))+"%";_41.style.left=(_42?-_45:_45)+"%";}}}function slide2(_47,_48,_49,cb){_48.style.webkitTransitionDuration="0ms";var _4b="translateX("+(_49?"-":"")+window.innerWidth+"px)";var _4c="translateX("+(_49?"100%":"-100%")+")";_48.style.webkitTransform=_4b;_48.setAttribute("selected","true");_48.style.webkitTransitionDuration="";function startTrans(){_47.style.webkitTransform=_4c;_48.style.webkitTransform="translateX(0%)";}_47.addEventListener("webkitTransitionEnd",cb,false);setTimeout(startTrans,0);}function preloadImages(){var _4d=document.createElement("div");_4d.id="preloader";document.body.appendChild(_4d);}function submitForm(_4e){iui.showPageByHref(_4e.action||"POST",encodeForm(_4e),_4e.method);}function encodeForm(_4f){function encode(_50){for(var i=0;i<_50.length;++i){if(_50[i].name){args.push(_50[i].name+"="+escape(_50[i].value));}}}var _52=[];encode(_4f.getElementsByTagName("input"));encode(_4f.getElementsByTagName("textarea"));encode(_4f.getElementsByTagName("select"));return _52;}function findParent(_53,_54){while(_53&&(_53.nodeType!=1||_53.localName.toLowerCase()!=_54)){_53=_53.parentNode;}return _53;}function hasClass(_55,_56){var re=new RegExp("(^|\\s)"+_56+"($|\\s)");return re.exec(_55.getAttribute("class"))!=null;}function replaceElementWithSource(_58,_59){var _5a=_58.parentNode;var _5b=_58;while(_5a.parentNode!=document.body){_5a=_5a.parentNode;_5b=_5b.parentNode;}var _5c=document.createElement(_5b.localName);_5c.innerHTML=_59;_5a.removeChild(_5b);while(_5c.firstChild){_5a.appendChild(_5c.firstChild);}}function $(id){return document.getElementById(id);}function ddd(){console.log.apply(console,arguments);}})();
View
BIN  public/iui/redButton.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
20 spec/god_web_spec.rb
@@ -0,0 +1,20 @@
+require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
+
+GOD_LOG = "I [2009-09-08 02:50:33] INFO: integra [ok] process is running (ProcessRunning)\nI [2009-09-08 02:50:42] INFO: integra [ok] memory within bounds [23600kb, 23600kb, 23600kb, 23604kb, 23604kb] (MemoryUsage)"
+
+describe "GodWeb" do
+
+ it "should find possible statuses" do
+ GodWeb.possible_statuses(:up).should eql(["stop", "restart", "unmonitor"])
+ end
+
+ it "should format log" do
+ DRb.stub!(:start_service)
+ God::Socket.stub!(:socket)
+ DRbObject.should_receive(:new).and_return(mock_drb = mock("DRB"))
+ mock_drb.should_receive(:ping).and_return(true)
+ g = GodWeb.new("foo")
+ g.send(:format_log, GOD_LOG).should eql( "<span class='gray'>02:50:33</span> | <span class='green'>ok</span> | process is running </br><span class='gray'>02:50:42</span> | <span class='green'>ok</span> | memory mb [23, 23, 23, 23, 23] ")
+ end
+end
+
View
11 spec/spec_helper.rb
@@ -0,0 +1,11 @@
+$LOAD_PATH.unshift(File.dirname(__FILE__))
+$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
+require 'rubygems'
+require 'god'
+require 'god_web'
+require 'spec'
+require 'spec/autorun'
+
+Spec::Runner.configure do |config|
+
+end
View
31 views/status.erb
@@ -3,25 +3,28 @@
<title><%= @title %></title>
<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
<style type="text/css" media="screen">@import "/iui/iui.css";</style>
+ <style type="text/css" media="screen">@import "/app.css";</style>
<script type="application/x-javascript" src="/iui/iui.js"></script>
+ <script type="text/javascript"> iui.animOn = true;</script>
</head>
<body>
<div class="toolbar">
- <h1 id="pageTitle"><%= @title %></h1>
- <a id="backButton" class="button" href="#"></a>
- <a class="button" href="/" target="_self">Refresh</a>
- </div>
+ <h1 id="pageTitle"><%= @title %><img src="icons/up.png"></img></h1>
+ <a id="backButton" class="button" href="#"></a>
+ <a class="button" href="/" target="_self">Refresh</a>
+ </div>
<ul id="home" selected="true" title="GodWeb">
- <% unless @groups.empty? %>
- <li class="group">Groups</li>
- <% @groups.each do |watch| %>
- <li id="<%= watch %>"><a href="/g/<%= watch %>"><%= watch %></a></li>
- <% end %>
- <% end %>
+ <% unless @groups.empty? %>
+ <li class="group">Groups</li>
+ <% @groups.each do |watch| %>
+ <li id="<%= watch %>" class="groups"><a href="/g/<%= watch %>"><%= watch %></a></li>
+ <% end %>
+ <% end %>
<li class="group">Watches</li>
- <% @watches.each do |watch| %>
- <li id="<%= watch %>" class="<%= @statuses[watch][:state] %>"><a href="/w/<%= watch %>"><%= watch %>[<%= @statuses[watch][:state] %>]</a></li>
- <% end %>
+ <% @watches.each do |watch| %>
+ <li id="<%= watch %>" class="<%= @statuses[watch][:state] %>">
+ <a href="/w/<%= watch %>"><%= watch %></a></li>
+ <% end %>
</ul>
</body>
-</html>
+</html>
View
9 views/watch.erb
@@ -1,5 +1,10 @@
<ul id="<%= @watch %>_commands" title="<%= @title %>">
+ <li class="<%= @status %>"> <%= @status %> [<%= Time.now.strftime("%H:%m %m/%d") %>]</li>
+ <li class="group">Commands</li>
<% @commands.each do |command| %>
- <li id="<%= command %>_<%= @watch %>" class="<%= command %>"><a href="/w/<%= @watch %>/<%= command %>"><%= command %></a></li>
+ <li id="<%= command %>_<%= @watch %>" class="<%= command %>">
+ <a href="/w/<%= @watch %>/<%= command %>"><%= command %></a></li>
<% end %>
-</ul>
+ <li class="group">Log</li>
+ <div class="info"><p><%= @log %></p></div>
+</ul>

No commit comments for this range

Something went wrong with that request. Please try again.