subduino 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +26 -0
- data/Rakefile +76 -0
- data/Readme.textile +46 -0
- data/VERSION +1 -0
- data/bin/subduino +34 -0
- data/bin/subduino-cli +65 -0
- data/duino/.gitignore +2 -0
- data/duino/Makefile +401 -0
- data/duino/duino.pde +17 -0
- data/duino/duino.rb +16 -0
- data/duino/methods.pde +5 -0
- data/lib/subduino/ard_io.rb +60 -0
- data/lib/subduino/ard_ps.rb +38 -0
- data/lib/subduino/arduino.rb +30 -0
- data/lib/subduino/parse.rb +61 -0
- data/lib/subduino/scaffold/Makefile +401 -0
- data/lib/subduino/scaffold/Makefile2 +247 -0
- data/lib/subduino/scaffold/generator.rb +29 -0
- data/lib/subduino/scaffold/scaffold.pde +17 -0
- data/lib/subduino/scaffold/scaffold.rb +16 -0
- data/lib/subduino/store.rb +65 -0
- data/lib/subduino.rb +48 -0
- data/node/arduinode.js +68 -0
- data/node/server.js +45 -0
- data/node/vendor/faye.js +1925 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/subduino/ard_io_spec.rb +9 -0
- data/spec/subduino/parse_spec.rb +21 -0
- data/spec/subduino/store_spec.rb +17 -0
- data/spec/subduino_spec.rb +20 -0
- data/subduino.gemspec +239 -0
- data/webapp/Gemfile +8 -0
- data/webapp/Gemfile.lock +14 -0
- data/webapp/Rakefile +49 -0
- data/webapp/Readme.textile +45 -0
- data/webapp/VERSION +1 -0
- data/webapp/lib/app.rb +103 -0
- data/webapp/lib/duino.rb +213 -0
- data/webapp/lib/environment.rb +36 -0
- data/webapp/lib/messenger.rb +16 -0
- data/webapp/public/app.css +119 -0
- data/webapp/public/app.js +34 -0
- data/webapp/public/faye.js +1 -0
- data/webapp/public/icons/alarm-clock-blue.png +0 -0
- data/webapp/public/icons/alarm-clock.png +0 -0
- data/webapp/public/icons/balloon-left.png +0 -0
- data/webapp/public/icons/bandaid.png +0 -0
- data/webapp/public/icons/bell-disable.png +0 -0
- data/webapp/public/icons/bell.png +0 -0
- data/webapp/public/icons/big_icon.png +0 -0
- data/webapp/public/icons/bomb.png +0 -0
- data/webapp/public/icons/bookmark.png +0 -0
- data/webapp/public/icons/box-label.png +0 -0
- data/webapp/public/icons/brightness-control-up.png +0 -0
- data/webapp/public/icons/brightness-control.png +0 -0
- data/webapp/public/icons/brightness-small.png +0 -0
- data/webapp/public/icons/broom.png +0 -0
- data/webapp/public/icons/bug.png +0 -0
- data/webapp/public/icons/calculator.png +0 -0
- data/webapp/public/icons/calendar-day.png +0 -0
- data/webapp/public/icons/camera.png +0 -0
- data/webapp/public/icons/cards-address.png +0 -0
- data/webapp/public/icons/chart.png +0 -0
- data/webapp/public/icons/clock-select.png +0 -0
- data/webapp/public/icons/color.png +0 -0
- data/webapp/public/icons/compass.png +0 -0
- data/webapp/public/icons/control-power-small.png +0 -0
- data/webapp/public/icons/control-power.png +0 -0
- data/webapp/public/icons/control-record-small.png +0 -0
- data/webapp/public/icons/cpus.png +0 -0
- data/webapp/public/icons/credit-card.png +0 -0
- data/webapp/public/icons/cross-small.png +0 -0
- data/webapp/public/icons/dashboard.png +0 -0
- data/webapp/public/icons/database.png +0 -0
- data/webapp/public/icons/databases.png +0 -0
- data/webapp/public/icons/door-open-in.png +0 -0
- data/webapp/public/icons/door-open-out.png +0 -0
- data/webapp/public/icons/door-open.png +0 -0
- data/webapp/public/icons/door.png +0 -0
- data/webapp/public/icons/drive-globe.png +0 -0
- data/webapp/public/icons/equalizer.png +0 -0
- data/webapp/public/icons/exclamation-diamond.png +0 -0
- data/webapp/public/icons/exclamation.png +0 -0
- data/webapp/public/icons/eye-disable.png +0 -0
- data/webapp/public/icons/eye.png +0 -0
- data/webapp/public/icons/false.png +0 -0
- data/webapp/public/icons/gear-small.png +0 -0
- data/webapp/public/icons/gear.png +0 -0
- data/webapp/public/icons/groups.png +0 -0
- data/webapp/public/icons/heart.png +0 -0
- data/webapp/public/icons/heart_empty.png +0 -0
- data/webapp/public/icons/info.png +0 -0
- data/webapp/public/icons/key.png +0 -0
- data/webapp/public/icons/lightbulb.png +0 -0
- data/webapp/public/icons/lightbulb_off.png +0 -0
- data/webapp/public/icons/lightning-disable.png +0 -0
- data/webapp/public/icons/lightning-small.png +0 -0
- data/webapp/public/icons/lightning.png +0 -0
- data/webapp/public/icons/lock-unlock.png +0 -0
- data/webapp/public/icons/lock.png +0 -0
- data/webapp/public/icons/marker.png +0 -0
- data/webapp/public/icons/media-player-phone.png +0 -0
- data/webapp/public/icons/megaphone.png +0 -0
- data/webapp/public/icons/mem.png +0 -0
- data/webapp/public/icons/microphone.png +0 -0
- data/webapp/public/icons/monitor.png +0 -0
- data/webapp/public/icons/navigation.png +0 -0
- data/webapp/public/icons/off.png +0 -0
- data/webapp/public/icons/on.png +0 -0
- data/webapp/public/icons/pin.png +0 -0
- data/webapp/public/icons/plug--exclamation.png +0 -0
- data/webapp/public/icons/plug-disable.png +0 -0
- data/webapp/public/icons/plug.png +0 -0
- data/webapp/public/icons/restart.png +0 -0
- data/webapp/public/icons/ruby.png +0 -0
- data/webapp/public/icons/server.png +0 -0
- data/webapp/public/icons/shield-disable.png +0 -0
- data/webapp/public/icons/shield.png +0 -0
- data/webapp/public/icons/socket--exclamation.png +0 -0
- data/webapp/public/icons/socket-disable.png +0 -0
- data/webapp/public/icons/socket.png +0 -0
- data/webapp/public/icons/start.png +0 -0
- data/webapp/public/icons/stop.png +0 -0
- data/webapp/public/icons/switch--exclamation.png +0 -0
- data/webapp/public/icons/switch-disable.png +0 -0
- data/webapp/public/icons/switch-small.png +0 -0
- data/webapp/public/icons/switch.png +0 -0
- data/webapp/public/icons/target.png +0 -0
- data/webapp/public/icons/television-off.png +0 -0
- data/webapp/public/icons/television.png +0 -0
- data/webapp/public/icons/terminal.png +0 -0
- data/webapp/public/icons/tick-small.png +0 -0
- data/webapp/public/icons/traffic-light-off.png +0 -0
- data/webapp/public/icons/traffic-light.png +0 -0
- data/webapp/public/icons/traffic.png +0 -0
- data/webapp/public/icons/true.png +0 -0
- data/webapp/public/icons/umbrella.png +0 -0
- data/webapp/public/icons/unmonitor.png +0 -0
- data/webapp/public/icons/unmonitored.png +0 -0
- data/webapp/public/icons/users.png +0 -0
- data/webapp/public/icons/vcard.png +0 -0
- data/webapp/public/icons/wall.png +0 -0
- data/webapp/public/icons/wall_brick.png +0 -0
- data/webapp/public/icons/wall_disable.png +0 -0
- data/webapp/public/icons/wand-disable.png +0 -0
- data/webapp/public/icons/wand.png +0 -0
- data/webapp/public/icons/warn.png +0 -0
- data/webapp/public/icons/weather_clouds.png +0 -0
- data/webapp/public/icons/weather_cloudy.png +0 -0
- data/webapp/public/icons/weather_lightning.png +0 -0
- data/webapp/public/icons/weather_rain.png +0 -0
- data/webapp/public/icons/weather_snow.png +0 -0
- data/webapp/public/icons/weather_sun.png +0 -0
- data/webapp/public/icons/wrench-screwdriver.png +0 -0
- data/webapp/public/icons/wrench.png +0 -0
- data/webapp/public/iui/backButton.png +0 -0
- data/webapp/public/iui/blueButton.png +0 -0
- data/webapp/public/iui/cancel.png +0 -0
- data/webapp/public/iui/grayButton.png +0 -0
- data/webapp/public/iui/greenButton.png +0 -0
- data/webapp/public/iui/iui-logo-touch-icon.png +0 -0
- data/webapp/public/iui/iui.css +396 -0
- data/webapp/public/iui/iui.js +511 -0
- data/webapp/public/iui/iuix.css +1 -0
- data/webapp/public/iui/iuix.js +1 -0
- data/webapp/public/iui/listArrow.png +0 -0
- data/webapp/public/iui/listArrowSel.png +0 -0
- data/webapp/public/iui/listGroup.png +0 -0
- data/webapp/public/iui/loading.gif +0 -0
- data/webapp/public/iui/pinstripes.png +0 -0
- data/webapp/public/iui/redButton.png +0 -0
- data/webapp/public/iui/selection.png +0 -0
- data/webapp/public/iui/thumb.png +0 -0
- data/webapp/public/iui/toggle.png +0 -0
- data/webapp/public/iui/toggleOn.png +0 -0
- data/webapp/public/iui/toolButton.png +0 -0
- data/webapp/public/iui/toolbar.png +0 -0
- data/webapp/public/iui/whiteButton.png +0 -0
- data/webapp/public/iui/yellowButton.png +0 -0
- data/webapp/public/jquery.js +154 -0
- data/webapp/public/layout.css +33 -0
- data/webapp/public/right.js +9 -0
- data/webapp/public/rt.js +7 -0
- data/webapp/public/sparkline.js +85 -0
- data/webapp/spec/duino_spec.rb +8 -0
- data/webapp/spec/spec_helper.rb +10 -0
- data/webapp/views/command.haml +4 -0
- data/webapp/views/icon.haml +6 -0
- data/webapp/views/index.haml +51 -0
- data/webapp/views/layout.haml +17 -0
- data/webapp/views/mobile.haml +21 -0
- data/webapp/views/switch.haml +56 -0
- data/webapp/views/top.haml +4 -0
- data/webapp/views/watch.haml +26 -0
- metadata +277 -0
data/webapp/lib/duino.rb
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
|
2
|
+
class Duino
|
3
|
+
Sensors = { :i0 => "Bool", :i1 => "Bool", :temp => "Temp", :lux => "Lux", :knob => "Knob" }
|
4
|
+
|
5
|
+
def initialize(config)
|
6
|
+
@config = config
|
7
|
+
@redis = Redis.new(:timeout => 0)
|
8
|
+
end
|
9
|
+
|
10
|
+
def sensors(one=nil)
|
11
|
+
s = one ? Sensors.select { |k,v| k.to_s == one.to_s } : Sensors
|
12
|
+
s.reduce({}) do |h, s|
|
13
|
+
val = @redis.get(s[0]) rescue nil
|
14
|
+
next unless val
|
15
|
+
k, v = *s
|
16
|
+
sensor = Subduino::Parse.work(v, val)
|
17
|
+
# if v == "Bool"
|
18
|
+
# info = "#{)} (#{val}~)"
|
19
|
+
# val = k
|
20
|
+
# else
|
21
|
+
# info = "#{k.capitalize} (#{val}~)"
|
22
|
+
# val = Subduino::Parse.work(v, val).to_s
|
23
|
+
# end
|
24
|
+
h.merge!({ k => sensor })
|
25
|
+
h
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def switch(pins, comm)
|
30
|
+
comm = Message.new(comm =~ /start/).txt
|
31
|
+
puts "[OUT] #{pins} #{comm}"
|
32
|
+
command(comm)
|
33
|
+
end
|
34
|
+
|
35
|
+
def log(n)
|
36
|
+
key = n + "_log"
|
37
|
+
size = @redis.llen key
|
38
|
+
@redis.lrange key, size - 100, size
|
39
|
+
end
|
40
|
+
|
41
|
+
# ping server to ensure that it is responsive
|
42
|
+
def ping
|
43
|
+
tries = 3
|
44
|
+
begin
|
45
|
+
# @server.ping
|
46
|
+
rescue Exception => e
|
47
|
+
retry if (tries -= 1) > 1
|
48
|
+
raise e, "The server is not available (or you do not have permissions to access it)"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def last_log(watch)
|
53
|
+
format_log(log_command(watch, true))
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.possible_statuses(status)
|
57
|
+
# need to check, but god doesn't have a monitored and offline state...
|
58
|
+
case status
|
59
|
+
when :up then [true, true] #%w{start monitor}
|
60
|
+
when :unmonitored then [false, false] #%w{start monitor}
|
61
|
+
else [] # nil #[false, false] #%w{start stop restart}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.ram_status
|
66
|
+
mem = `free -mo`.split(" ")
|
67
|
+
used, free, cached, swap = mem[8], mem[9], mem[12], mem[15]
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.cpu_status
|
71
|
+
#stat = `cat /proc/stat`.split(" ")
|
72
|
+
# top = `top -bn 1`
|
73
|
+
# info, tasks, cpus, mem, swap, *rest = *top
|
74
|
+
# # Use array to keep order (ruby < 1.9)
|
75
|
+
# [[:info, info.gsub(/top - |\d{2}:\d{2}(:\d{2})?(\s|,)|\saverage/, "")],
|
76
|
+
# [:cpus, cpus.gsub("Cpu\(s\): ", "").split(", ")[0..4].join(", ")],
|
77
|
+
# [:mem, mem.gsub("Mem: ", "").gsub(/(\d*k)/) { ($1.to_i / 1000).to_s }]]
|
78
|
+
[]
|
79
|
+
end
|
80
|
+
def status
|
81
|
+
status_command
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
def command(line)
|
87
|
+
@redis.publish('subduin', line) unless line.empty?
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
# def method_missing(meth,*args)
|
92
|
+
# if %w{groups status log quit terminate}.include?(meth.to_s)
|
93
|
+
# ping
|
94
|
+
# send("#{meth}_command")
|
95
|
+
# # elsif %w{start stop restart unmonitor monitor}.include?(meth.to_s)
|
96
|
+
# # ping
|
97
|
+
# # lifecycle_command(args.first, meth.to_s)
|
98
|
+
# else
|
99
|
+
# raise NoMethodError, meth
|
100
|
+
# end
|
101
|
+
# end
|
102
|
+
|
103
|
+
def groups_command
|
104
|
+
groups = []
|
105
|
+
@server.groups.each do |key, value|
|
106
|
+
groups << key
|
107
|
+
end
|
108
|
+
groups.sort
|
109
|
+
end
|
110
|
+
|
111
|
+
def status_command
|
112
|
+
# @server.status
|
113
|
+
end
|
114
|
+
|
115
|
+
#
|
116
|
+
# To make it look good (no horiz scrollbars) in the iphone
|
117
|
+
#
|
118
|
+
def format_log(raw)
|
119
|
+
return "..." unless raw
|
120
|
+
raw.split("\n").map do |l|
|
121
|
+
# clean stuff we don't need
|
122
|
+
l.gsub!(/I\s+|\(\w*\)|within bounds/, "") # gsub(/\(\w*\)/, """)
|
123
|
+
# if ok, span is green
|
124
|
+
ok = l =~ /\[ok\]/
|
125
|
+
if l =~ /\[\w*\]/
|
126
|
+
# get some data we want...
|
127
|
+
l.gsub(/\[\S*\s(\S*)\]\W+INFO: (\w*-?\w*|.*)?\s\[(\w*)?\]/, "<span class='gray'>\\1</span> | <span class='#{ok ? 'green' : 'red'}'>\\3</span> |").
|
128
|
+
# take only the integer from cpu
|
129
|
+
gsub(/cpu/, "cpu %").gsub(/(\d{1,3})\.\d*%/, "\\1").
|
130
|
+
# show mem usage in mb
|
131
|
+
gsub(/memory/, "mem mb").gsub(/(\d*kb)/) { ($1.to_i / 1000).to_s }
|
132
|
+
else
|
133
|
+
l.gsub(/\[\S*\s(\S*)\]\W+INFO: \w*\s(\w*)/, "<span class='gray'>\\1</span> | <span class='act'>act</span> | \\2")
|
134
|
+
end
|
135
|
+
|
136
|
+
end.reverse.join("</br>")
|
137
|
+
end
|
138
|
+
|
139
|
+
#TODO
|
140
|
+
def log_command(name, sample=false)
|
141
|
+
# begin
|
142
|
+
# Signal.trap('INT') { exit }
|
143
|
+
# # name = @args[1]
|
144
|
+
|
145
|
+
# unless name
|
146
|
+
# puts "You must specify a Task or Group name"
|
147
|
+
# exit!
|
148
|
+
# end
|
149
|
+
|
150
|
+
# t = Time.at(0)
|
151
|
+
# if sample
|
152
|
+
# @server.running_log(name, t)
|
153
|
+
# else
|
154
|
+
# loop do
|
155
|
+
# @server.running_log(name, t)
|
156
|
+
# t = Time.now
|
157
|
+
# sleep 1
|
158
|
+
# end
|
159
|
+
# end
|
160
|
+
# rescue God::NoSuchWatchError
|
161
|
+
# puts "No such watch"
|
162
|
+
# rescue DRb::DRbConnError
|
163
|
+
# puts "The server went away"
|
164
|
+
# end
|
165
|
+
end
|
166
|
+
|
167
|
+
def quit_command
|
168
|
+
begin
|
169
|
+
@server.terminate
|
170
|
+
return false
|
171
|
+
rescue DRb::DRbConnError
|
172
|
+
return true
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def terminate_command
|
177
|
+
stopped_all = false
|
178
|
+
if @server.stop_all
|
179
|
+
stopped_all = true
|
180
|
+
end
|
181
|
+
|
182
|
+
begin
|
183
|
+
@server.terminate
|
184
|
+
return false
|
185
|
+
rescue DRb::DRbConnError
|
186
|
+
return stopped_all
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
|
191
|
+
def lifecycle_command(*args)
|
192
|
+
# get the name of the watch/group
|
193
|
+
name = args.first
|
194
|
+
command = args.last
|
195
|
+
|
196
|
+
# send @command
|
197
|
+
watches = @server.control(name, command)
|
198
|
+
|
199
|
+
watches.empty? ? [] : watches
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|
203
|
+
|
204
|
+
|
205
|
+
# def halt!
|
206
|
+
# puts "Closing server"
|
207
|
+
# @redis.quit
|
208
|
+
# puts "..."
|
209
|
+
# exit
|
210
|
+
# end
|
211
|
+
|
212
|
+
# trap(:TERM) { halt! }
|
213
|
+
# trap(:INT) { halt! }
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__)))
|
3
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'sinatra'
|
7
|
+
require 'eventmachine'
|
8
|
+
require 'readline'
|
9
|
+
require 'redis'
|
10
|
+
require 'stringio'
|
11
|
+
require 'yaml'
|
12
|
+
require 'haml'
|
13
|
+
require 'optparse'
|
14
|
+
require 'duino'
|
15
|
+
require 'subduino/parse'
|
16
|
+
|
17
|
+
config = {
|
18
|
+
'username' => nil,
|
19
|
+
'password' => nil
|
20
|
+
}
|
21
|
+
|
22
|
+
begin
|
23
|
+
config.merge!(YAML.load(File.read(ARGV[0])))
|
24
|
+
DUINO_CONFIG = config
|
25
|
+
rescue
|
26
|
+
DUINO_CONFIG = config
|
27
|
+
end
|
28
|
+
DUINO = Duino.new(config)
|
29
|
+
|
30
|
+
# Require app
|
31
|
+
require "messenger"
|
32
|
+
include Messenger
|
33
|
+
require "app"
|
34
|
+
|
35
|
+
Sinatra::Application.public = File.dirname(__FILE__) + "/../public"
|
36
|
+
Sinatra::Application.views = File.dirname(__FILE__) + "/../views"
|
@@ -0,0 +1,119 @@
|
|
1
|
+
body {
|
2
|
+
color: #222;
|
3
|
+
}
|
4
|
+
|
5
|
+
.home_icon_div {
|
6
|
+
padding-top: 80px;
|
7
|
+
background: transparent url(../icons/big_icon.png) no-repeat scroll center center;
|
8
|
+
height: 300px;
|
9
|
+
}
|
10
|
+
|
11
|
+
.home_icon_txt {
|
12
|
+
font-size: 4em;
|
13
|
+
font-weight: bold;
|
14
|
+
color: #2f6a9f;
|
15
|
+
text-shadow: rgba(255, 255, 255, 0.75) 2px 2px 0;
|
16
|
+
margin-bottom: 50px
|
17
|
+
}
|
18
|
+
|
19
|
+
.home_icon_info {
|
20
|
+
position: absolute
|
21
|
+
top: -100px
|
22
|
+
font-size: 1em;
|
23
|
+
margin-bottom: 100px;
|
24
|
+
font-weight: bold;
|
25
|
+
color: #eee
|
26
|
+
}
|
27
|
+
|
28
|
+
fieldset > ul {
|
29
|
+
padding: 0px 10px;
|
30
|
+
}
|
31
|
+
|
32
|
+
fieldset > ul > li {
|
33
|
+
text-align: left;
|
34
|
+
background:#FFFFFF none repeat scroll 0 0;
|
35
|
+
position: relative;
|
36
|
+
margin: 0;
|
37
|
+
border-bottom: 1px solid #E0E0E0;
|
38
|
+
padding: 8px 0 8px 0px;
|
39
|
+
font-size: 20px;
|
40
|
+
font-weight: bold;
|
41
|
+
list-style: none;
|
42
|
+
}
|
43
|
+
|
44
|
+
fieldset > ul > li > a {
|
45
|
+
display: block;
|
46
|
+
margin: -8px 0 -8px -10px;
|
47
|
+
padding: 8px 32px 8px 10px;
|
48
|
+
text-decoration: none;
|
49
|
+
color: inherit;
|
50
|
+
background: url(iui/listArrow.png) no-repeat right center;
|
51
|
+
}
|
52
|
+
|
53
|
+
li img {
|
54
|
+
border:medium none;
|
55
|
+
float:left;
|
56
|
+
margin:4px 8px 0px 0px;
|
57
|
+
}
|
58
|
+
|
59
|
+
.pico {font-size: 0.6em; }
|
60
|
+
.tiny {font-size: 0.8em; }
|
61
|
+
li.tiny img { margin-top: 0px; }
|
62
|
+
|
63
|
+
.gray { color: #aaa; }
|
64
|
+
|
65
|
+
.green {
|
66
|
+
color: #00aa00;
|
67
|
+
font-weight: bold;
|
68
|
+
}
|
69
|
+
.red {
|
70
|
+
color: #aa0000;
|
71
|
+
font-weight: bold;
|
72
|
+
}
|
73
|
+
.act {
|
74
|
+
color: #999900;
|
75
|
+
font-weight: bold;
|
76
|
+
}
|
77
|
+
|
78
|
+
.yellowButton,
|
79
|
+
.greenButton {
|
80
|
+
display: block;
|
81
|
+
border-width: 0 12px;
|
82
|
+
padding: 10px;
|
83
|
+
text-align: center;
|
84
|
+
font-size: 20px;
|
85
|
+
font-weight: bold;
|
86
|
+
text-decoration: inherit;
|
87
|
+
color: inherit;
|
88
|
+
}
|
89
|
+
|
90
|
+
.greenButton {
|
91
|
+
-webkit-border-image: url(../iui/greenButton.png) 0 12 0 12;
|
92
|
+
color:#fff;
|
93
|
+
text-shadow: #007a00 0 -1px 0;
|
94
|
+
}
|
95
|
+
|
96
|
+
.yellowButton {
|
97
|
+
-webkit-border-image: url(../iui/yellowButton.png) 0 12 0 12;
|
98
|
+
color:#fff;
|
99
|
+
text-shadow: #007a7a 0 -1px 0;
|
100
|
+
}
|
101
|
+
|
102
|
+
.code {
|
103
|
+
font-size: 14px;
|
104
|
+
font-family: Courier;
|
105
|
+
color: #33EE33;
|
106
|
+
background-color: #222;
|
107
|
+
padding-left: 15px;
|
108
|
+
white-space: nowrap;
|
109
|
+
overflow: auto;
|
110
|
+
padding-top: 8px;
|
111
|
+
}
|
112
|
+
|
113
|
+
|
114
|
+
/* PC */
|
115
|
+
|
116
|
+
.right {
|
117
|
+
width: 50%;
|
118
|
+
float: right;
|
119
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
//FIXME: grr... bug if you run once, cancel, and try to run on another watch (hate js..)
|
2
|
+
function submitCommand(action, watch) {
|
3
|
+
var comm;
|
4
|
+
var act;
|
5
|
+
var s;
|
6
|
+
|
7
|
+
if (document.getElementById("toggle_" + action)) {
|
8
|
+
act = document.getElementById("toggle_" + action);
|
9
|
+
s = act.getAttribute("toggled");
|
10
|
+
|
11
|
+
if(action == "power") {
|
12
|
+
comm = (s == "true") ? "start" : "stop";
|
13
|
+
} else {
|
14
|
+
comm = (s == "true") ? "monitor" : "unmonitor";
|
15
|
+
}
|
16
|
+
} else {
|
17
|
+
comm = action;
|
18
|
+
}
|
19
|
+
|
20
|
+
// if (confirm("God will " + comm + " " + watch + "..")) {
|
21
|
+
//var results = document.getElementById("results");
|
22
|
+
var divTag = document.createElement("div");
|
23
|
+
divTag.id = "cresult";
|
24
|
+
document.body.appendChild(divTag);
|
25
|
+
var res = document.getElementById("cresult");
|
26
|
+
|
27
|
+
// res.innerHTML = "";
|
28
|
+
iui.showPageByHref("/w/" + watch + "/" + comm, null, null, res, null);
|
29
|
+
// } else {
|
30
|
+
//act.setAttribute("toggled", (s == "true") ? "false" : "true");
|
31
|
+
// }
|
32
|
+
return false;
|
33
|
+
}
|
34
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
if(!this.Faye)Faye={};Faye.extend=function(a,b,c){if(!b)return a;for(var d in b){if(!b.hasOwnProperty(d))continue;if(a.hasOwnProperty(d)&&c===false)continue;if(a[d]!==b[d])a[d]=b[d]}return a};Faye.extend(Faye,{VERSION:'0.5.2',BAYEUX_VERSION:'1.0',ID_LENGTH:128,JSONP_CALLBACK:'jsonpcallback',CONNECTION_TYPES:['long-polling','callback-polling','websocket'],MANDATORY_CONNECTION_TYPES:['long-polling','callback-polling','in-process'],ENV:(function(){return this})(),random:function(a){a=a||this.ID_LENGTH;if(a>32){var b=Math.ceil(a/32),c='';while(b--)c+=this.random(32);return c}var d=Math.pow(2,a);return Math.floor(Math.random()*d).toString(36)},commonElement:function(a,b){for(var c=0,d=a.length;c<d;c++){if(this.indexOf(b,a[c])!==-1)return a[c]}return null},indexOf:function(a,b){for(var c=0,d=a.length;c<d;c++){if(a[c]===b)return c}return-1},each:function(a,b,c){if(a instanceof Array){for(var d=0,f=a.length;d<f;d++){if(a[d]!==undefined)b.call(c||null,a[d],d)}}else{for(var g in a){if(a.hasOwnProperty(g))b.call(c||null,g,a[g])}}},map:function(a,b,c){var d=[];this.each(a,function(){d.push(b.apply(c||null,arguments))});return d},filter:function(a,b,c){var d=[];this.each(a,function(){if(b.apply(c,arguments))d.push(arguments[0])});return d},size:function(a){var b=0;this.each(a,function(){b+=1});return b},enumEqual:function(c,d){if(d instanceof Array){if(!(c instanceof Array))return false;var f=c.length;if(f!==d.length)return false;while(f--){if(c[f]!==d[f])return false}return true}else{if(!(c instanceof Object))return false;if(this.size(d)!==this.size(c))return false;var g=true;this.each(c,function(a,b){g=g&&(d[a]===b)});return g}},toJSON:function(a){if(this.stringify)return this.stringify(a,function(key,value){return(this[key]instanceof Array)?this[key]:value});return JSON.stringify(a)},timestamp:function(){var b=new Date(),c=b.getFullYear(),d=b.getMonth()+1,f=b.getDate(),g=b.getHours(),h=b.getMinutes(),j=b.getSeconds();var i=function(a){return a<10?'0'+a:String(a)};return i(c)+'-'+i(d)+'-'+i(f)+' '+i(g)+':'+i(h)+':'+i(j)}});Faye.Class=function(a,b){if(typeof a!=='function'){b=a;a=Object}var c=function(){if(!this.initialize)return this;return this.initialize.apply(this,arguments)||this};var d=function(){};d.prototype=a.prototype;c.prototype=new d();Faye.extend(c.prototype,b);return c};Faye.Namespace=Faye.Class({initialize:function(){this._u={}},generate:function(){var a=Faye.random();while(this._u.hasOwnProperty(a))a=Faye.random();return this._u[a]=a}});Faye.Deferrable={callback:function(a,b){if(!a)return;if(this._B==='succeeded')return a.apply(b,this._v);this._9=this._9||[];this._9.push([a,b])},setDeferredStatus:function(){var b=Array.prototype.slice.call(arguments),c=b.shift();this._B=c;this._v=b;if(c!=='succeeded')return;if(!this._9)return;Faye.each(this._9,function(a){a[0].apply(a[1],this._v)},this);this._9=[]}};Faye.Publisher={countSubscribers:function(a){if(!this._2||!this._2[a])return 0;return this._2[a].length},addSubscriber:function(a,b,c){this._2=this._2||{};var d=this._2[a]=this._2[a]||[];d.push([b,c])},removeSubscriber:function(a,b,c){if(!this._2||!this._2[a])return;var d=this._2[a],f=d.length;while(f--){if(b&&d[f][0]!==b)continue;if(c&&d[f][1]!==c)continue;d.splice(f,1)}},publishEvent:function(){var b=Array.prototype.slice.call(arguments),c=b.shift();if(!this._2||!this._2[c])return;Faye.each(this._2[c],function(a){a[0].apply(a[1],b)})}};Faye.Timeouts={addTimeout:function(a,b,c,d){this._6=this._6||{};if(this._6.hasOwnProperty(a))return;var f=this;this._6[a]=setTimeout(function(){delete f._6[a];c.call(d)},1000*b)},removeTimeout:function(a){this._6=this._6||{};var b=this._6[a];if(!b)return;clearTimeout(b);delete this._6[a]}};Faye.Logging={LOG_LEVELS:{error:3,warn:2,info:1,debug:0},logLevel:'error',log:function(a,b){if(!Faye.logger)return;var c=Faye.Logging.LOG_LEVELS;if(c[Faye.Logging.logLevel]>c[b])return;var a=Array.prototype.slice.apply(a),d=' ['+b.toUpperCase()+'] [Faye',f=null,g=a.shift().replace(/\?/g,function(){try{return Faye.toJSON(a.shift())}catch(e){return'[Object]'}});for(var h in Faye){if(f)continue;if(typeof Faye[h]!=='function')continue;if(this instanceof Faye[h])f=h}if(f)d+='.'+f;d+='] ';Faye.logger(Faye.timestamp()+d+g)}};Faye.each(Faye.Logging.LOG_LEVELS,function(a,b){Faye.Logging[a]=function(){this.log(arguments,a)}});Faye.Grammar={LOWALPHA:/^[a-z]$/,UPALPHA:/^[A-Z]$/,ALPHA:/^([a-z]|[A-Z])$/,DIGIT:/^[0-9]$/,ALPHANUM:/^(([a-z]|[A-Z])|[0-9])$/,MARK:/^(\-|\_|\!|\~|\(|\)|\$|\@)$/,STRING:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*$/,TOKEN:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+$/,INTEGER:/^([0-9])+$/,CHANNEL_SEGMENT:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+$/,CHANNEL_SEGMENTS:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*$/,CHANNEL_NAME:/^\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*$/,WILD_CARD:/^\*{1,2}$/,CHANNEL_PATTERN:/^(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*\/\*{1,2}$/,VERSION_ELEMENT:/^(([a-z]|[A-Z])|[0-9])(((([a-z]|[A-Z])|[0-9])|\-|\_))*$/,VERSION:/^([0-9])+(\.(([a-z]|[A-Z])|[0-9])(((([a-z]|[A-Z])|[0-9])|\-|\_))*)*$/,CLIENT_ID:/^((([a-z]|[A-Z])|[0-9]))+$/,ID:/^((([a-z]|[A-Z])|[0-9]))+$/,ERROR_MESSAGE:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*$/,ERROR_ARGS:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*(,(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)*$/,ERROR_CODE:/^[0-9][0-9][0-9]$/,ERROR:/^([0-9][0-9][0-9]:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*(,(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)*:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*|[0-9][0-9][0-9]::(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)$/};Faye.Extensible={addExtension:function(a){this._7=this._7||[];this._7.push(a);if(a.added)a.added()},removeExtension:function(a){if(!this._7)return;var b=this._7.length;while(b--){if(this._7[b]!==a)continue;this._7.splice(b,1);if(a.removed)a.removed()}},pipeThroughExtensions:function(c,d,f,g){if(!this._7)return f.call(g,d);var h=this._7.slice();var j=function(a){if(!a)return f.call(g,a);var b=h.shift();if(!b)return f.call(g,a);if(b[c])b[c](a,j);else j(a)};j(d)}};Faye.Channel=Faye.Class({initialize:function(a){this.id=this.name=a},push:function(a){this.publishEvent('message',a)}});Faye.extend(Faye.Channel.prototype,Faye.Publisher);Faye.extend(Faye.Channel,{HANDSHAKE:'/meta/handshake',CONNECT:'/meta/connect',SUBSCRIBE:'/meta/subscribe',UNSUBSCRIBE:'/meta/unsubscribe',DISCONNECT:'/meta/disconnect',META:'meta',SERVICE:'service',isValid:function(a){return Faye.Grammar.CHANNEL_NAME.test(a)||Faye.Grammar.CHANNEL_PATTERN.test(a)},parse:function(a){if(!this.isValid(a))return null;return a.split('/').slice(1)},isMeta:function(a){var b=this.parse(a);return b?(b[0]===this.META):null},isService:function(a){var b=this.parse(a);return b?(b[0]===this.SERVICE):null},isSubscribable:function(a){if(!this.isValid(a))return null;return!this.isMeta(a)&&!this.isService(a)},Tree:Faye.Class({initialize:function(a){this._4=a;this._a={}},eachChild:function(c,d){Faye.each(this._a,function(a,b){c.call(d,a,b)})},each:function(c,d,f){this.eachChild(function(a,b){a=c.concat(a);b.each(a,d,f)});if(this._4!==undefined)d.call(f,c,this._4)},getKeys:function(){return this.map(function(a,b){return'/'+a.join('/')})},map:function(c,d){var f=[];this.each([],function(a,b){f.push(c.call(d,a,b))});return f},get:function(a){var b=this.traverse(a);return b?b._4:null},set:function(a,b){var c=this.traverse(a,true);if(c)c._4=b},traverse:function(a,b){if(typeof a==='string')a=Faye.Channel.parse(a);if(a===null)return null;if(a.length===0)return this;var c=this._a[a[0]];if(!c&&!b)return null;if(!c)c=this._a[a[0]]=new Faye.Channel.Tree();return c.traverse(a.slice(1),b)},findOrCreate:function(a){var b=this.get(a);if(b)return b;b=new Faye.Channel(a);this.set(a,b);return b},glob:function(f){if(typeof f==='string')f=Faye.Channel.parse(f);if(f===null)return[];if(f.length===0)return(this._4===undefined)?[]:[this._4];var g=[];if(Faye.enumEqual(f,['*'])){Faye.each(this._a,function(a,b){if(b._4!==undefined)g.push(b._4)});return g}if(Faye.enumEqual(f,['**'])){g=this.map(function(a,b){return b});if(this._4!==undefined)g.pop();return g}Faye.each(this._a,function(b,c){if(b!==f[0]&&b!=='*')return;var d=c.glob(f.slice(1));Faye.each(d,function(a){g.push(a)})});if(this._a['**'])g.push(this._a['**']._4);return g},subscribe:function(c,d,f){if(!d)return;Faye.each(c,function(a){var b=this.findOrCreate(a);b.addSubscriber('message',d,f)},this)},unsubscribe:function(a,b,c){var d=this.get(a);if(!d)return false;d.removeSubscriber('message',b,c);return d.countSubscribers('message')===0},distributeMessage:function(b){var c=this.glob(b.channel);Faye.each(c,function(a){a.publishEvent('message',b.data)})}})});Faye.Subscription=Faye.Class({initialize:function(a,b,c,d){this._c=a;this._b=b;this._m=c;this._d=d;this._w=false},cancel:function(){if(this._w)return;this._c.unsubscribe(this._b,this._m,this._d);this._w=true},unsubscribe:function(){this.cancel()}});Faye.Client=Faye.Class({UNCONNECTED:1,CONNECTING:2,CONNECTED:3,DISCONNECTED:4,HANDSHAKE:'handshake',RETRY:'retry',NONE:'none',CONNECTION_TIMEOUT:60.0,DEFAULT_ENDPOINT:'/bayeux',MAX_DELAY:0.001,INTERVAL:0.0,initialize:function(a,b){this.info('New client created for ?',a);this._3=a||this.DEFAULT_ENDPOINT;this._x=b||{};this._f=Faye.Transport.get(this,Faye.MANDATORY_CONNECTION_TYPES);this._1=this.UNCONNECTED;this._h=[];this._b=new Faye.Channel.Tree();this._C=new Faye.Namespace();this._n={};this._8={reconnect:this.RETRY,interval:1000*(this._x.interval||this.INTERVAL),timeout:1000*(this._x.timeout||this.CONNECTION_TIMEOUT)};if(Faye.Event)Faye.Event.on(Faye.ENV,'beforeunload',this.disconnect,this)},handshake:function(b,c){if(this._8.reconnect===this.NONE)return;if(this._1!==this.UNCONNECTED)return;this._1=this.CONNECTING;var d=this;this.info('Initiating handshake with ?',this._3);this._e({channel:Faye.Channel.HANDSHAKE,version:Faye.BAYEUX_VERSION,supportedConnectionTypes:[this._f.connectionType]},function(a){if(a.successful){this._1=this.CONNECTED;this._0=a.clientId;this._f=Faye.Transport.get(this,a.supportedConnectionTypes);this.info('Handshake successful: ?',this._0);this.subscribe(this._b.getKeys());if(b)b.call(c)}else{this.info('Handshake unsuccessful');setTimeout(function(){d.handshake(b,c)},this._8.interval);this._1=this.UNCONNECTED}},this)},connect:function(a,b){if(this._8.reconnect===this.NONE)return;if(this._1===this.DISCONNECTED)return;if(this._1===this.UNCONNECTED)return this.handshake(function(){this.connect(a,b)},this);this.callback(a,b);if(this._1!==this.CONNECTED)return;this.info('Calling deferred actions for ?',this._0);this.setDeferredStatus('succeeded');this.setDeferredStatus('deferred');if(this._o)return;this._o=true;this.info('Initiating connection for ?',this._0);this._e({channel:Faye.Channel.CONNECT,clientId:this._0,connectionType:this._f.connectionType},this._y,this)},disconnect:function(){if(this._1!==this.CONNECTED)return;this._1=this.DISCONNECTED;this.info('Disconnecting ?',this._0);this._e({channel:Faye.Channel.DISCONNECT,clientId:this._0});this.info('Clearing channel listeners for ?',this._0);this._b=new Faye.Channel.Tree()},subscribe:function(c,d,f){if(c instanceof Array)return Faye.each(c,function(channel){this.subscribe(channel,d,f)},this);this._p(c);this.connect(function(){this.info('Client ? attempting to subscribe to ?',this._0,c);this._e({channel:Faye.Channel.SUBSCRIBE,clientId:this._0,subscription:c},function(a){if(!a.successful)return;var b=[].concat(a.subscription);this.info('Subscription acknowledged for ? to ?',this._0,b);this._b.subscribe(b,d,f)},this)},this);return new Faye.Subscription(this,c,d,f)},unsubscribe:function(c,d,f){if(c instanceof Array)return Faye.each(c,function(channel){this.unsubscribe(channel,d,f)},this);this._p(c);var g=this._b.unsubscribe(c,d,f);if(!g)return;this.connect(function(){this.info('Client ? attempting to unsubscribe from ?',this._0,c);this._e({channel:Faye.Channel.UNSUBSCRIBE,clientId:this._0,subscription:c},function(a){if(!a.successful)return;var b=[].concat(a.subscription);this.info('Unsubscription acknowledged for ? from ?',this._0,b)},this)},this)},publish:function(a,b){this._p(a);this.connect(function(){this.info('Client ? queueing published message to ?: ?',this._0,a,b);this._e({channel:a,data:b,clientId:this._0})},this)},receiveMessage:function(c){this.pipeThroughExtensions('incoming',c,function(a){if(!a)return;if(a.advice)this._D(a.advice);var b=this._n[a.id];if(b){delete this._n[a.id];b[0].call(b[1],a)}this._E(a)},this)},_D:function(a){Faye.extend(this._8,a);if(this._8.reconnect===this.HANDSHAKE&&this._1!==this.DISCONNECTED){this._1=this.UNCONNECTED;this._0=null;this._y()}},_E:function(a){if(!a.channel||!a.data)return;this.info('Client ? calling listeners for ? with ?',this._0,a.channel,a.data);this._b.distributeMessage(a)},_F:function(){if(!this._o)return;this._o=null;this.info('Closed connection for ?',this._0)},_y:function(){this._F();var a=this;setTimeout(function(){a.connect()},this._8.interval)},_e:function(b,c,d){b.id=this._C.generate();if(c)this._n[b.id]=[c,d];this.pipeThroughExtensions('outgoing',b,function(a){if(!a)return;if(a.channel===Faye.Channel.HANDSHAKE)return this._f.send(a,this._8.timeout/1000);this._h.push(a);if(a.channel===Faye.Channel.CONNECT)this._q=a;this.addTimeout('publish',this.MAX_DELAY,this._G,this)},this)},_G:function(){this.removeTimeout('publish');if(this._h.length>1&&this._q)this._q.advice={timeout:0};this._q=null;this._f.send(this._h,this._8.timeout/1000);this._h=[]},_p:function(a){if(!Faye.Channel.isValid(a))throw'"'+a+'" is not a valid channel name';if(!Faye.Channel.isSubscribable(a))throw'Clients may not subscribe to channel "'+a+'"';}});Faye.extend(Faye.Client.prototype,Faye.Deferrable);Faye.extend(Faye.Client.prototype,Faye.Timeouts);Faye.extend(Faye.Client.prototype,Faye.Logging);Faye.extend(Faye.Client.prototype,Faye.Extensible);Faye.Transport=Faye.extend(Faye.Class({initialize:function(a,b){this.debug('Created new ? transport for ?',this.connectionType,b);this._c=a;this._3=b},send:function(a,b){a=[].concat(a);this.debug('Client ? sending message to ?: ?',this._c._0,this._3,a);return this.request(a,b)},receive:function(a){this.debug('Client ? received from ?: ?',this._c._0,this._3,a);Faye.each(a,this._c.receiveMessage,this._c)},retry:function(a,b){var c=this;return function(){setTimeout(function(){c.request(a,2*b)},1000*b)}}}),{get:function(d,f){var g=d._3;if(f===undefined)f=this.supportedConnectionTypes();var h=null;Faye.each(this._r,function(a){var b=a[0],c=a[1];if(Faye.indexOf(f,b)<0)return;if(h)return;if(c.isUsable(g))h=c});if(!h)throw'Could not find a usable connection type for '+g;return new h(d,g)},register:function(a,b){this._r.push([a,b]);b.prototype.connectionType=a},_r:[],supportedConnectionTypes:function(){return Faye.map(this._r,function(a){return a[0]})}});Faye.extend(Faye.Transport.prototype,Faye.Logging);Faye.Event={_i:[],on:function(a,b,c,d){var f=function(){c.call(d)};if(a.addEventListener)a.addEventListener(b,f,false);else a.attachEvent('on'+b,f);this._i.push({_j:a,_s:b,_m:c,_d:d,_z:f})},detach:function(a,b,c,d){var f=this._i.length,g;while(f--){g=this._i[f];if((a&&a!==g._j)||(b&&b!==g._s)||(c&&c!==g._m)||(d&&d!==g._d))continue;if(g._j.removeEventListener)g._j.removeEventListener(g._s,g._z,false);else g._j.detachEvent('on'+g._s,g._z);this._i.splice(f,1);g=null}}};Faye.Event.on(Faye.ENV,'unload',Faye.Event.detach,Faye.Event);Faye.URI=Faye.extend(Faye.Class({queryString:function(){var c=[],d;Faye.each(this.params,function(a,b){c.push(encodeURIComponent(a)+'='+encodeURIComponent(b))});return c.join('&')},isLocal:function(){var a=Faye.URI.parse(Faye.ENV.location.href);var b=(a.hostname!==this.hostname)||(a.port!==this.port)||(a.protocol!==this.protocol);return!b},toURL:function(){var a=this.queryString();return this.protocol+this.hostname+':'+this.port+this.pathname+(a?'?'+a:'')}}),{parse:function(d,f){if(typeof d!=='string')return d;var g=new this();var h=function(b,c){d=d.replace(c,function(a){if(a)g[b]=a;return''})};h('protocol',/^https?\:\/+/);h('hostname',/^[^\/\:]+/);h('port',/^:[0-9]+/);Faye.extend(g,{protocol:'http://',hostname:Faye.ENV.location.hostname,port:Faye.ENV.location.port},false);if(!g.port)g.port=(g.protocol==='https://')?'443':'80';g.port=g.port.replace(/\D/g,'');var j=d.split('?'),i=j.shift(),l=j.join('?'),n=l?l.split('&'):[],o=n.length,k={};while(o--){j=n[o].split('=');k[decodeURIComponent(j[0]||'')]=decodeURIComponent(j[1]||'')}if(typeof f==='object')Faye.extend(k,f);g.pathname=i;g.params=k;return g}});Faye.XHR={request:function(a,b,c,d,f){var g=new this.Request(a,b,c,d,f);g.send();return g},getXhrObject:function(){return Faye.ENV.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest()},Request:Faye.Class({initialize:function(a,b,c,d,f){this._k=a.toUpperCase();this._3=Faye.URI.parse(b,c);this._H=(typeof c==='string')?c:null;this._9=(typeof d==='function')?{success:d}:d;this._d=f||null;this._5=null},send:function(){if(this._t)return;var a=this._3.pathname,b=this._3.queryString();if(this._k==='GET')a+='?'+b;var c=(this._k==='POST')?(this._H||b):'';this._t=true;this._5=Faye.XHR.getXhrObject();this._5.open(this._k,a,true);if(this._k==='POST')this._5.setRequestHeader('Content-Type','application/json');var d=this,f=function(){if(d._5.readyState!==4)return;if(g){clearInterval(g);g=null}Faye.Event.detach(Faye.ENV,'beforeunload',d.abort,d);d._t=false;d._I();d=null};var g=setInterval(f,10);Faye.Event.on(Faye.ENV,'beforeunload',this.abort,this);this._5.send(c)},abort:function(){this._5.abort()},_I:function(){var a=this._9;if(!a)return;return this.success()?a.success&&a.success.call(this._d,this):a.failure&&a.failure.call(this._d,this)},waiting:function(){return!!this._t},complete:function(){return this._5&&!this.waiting()},success:function(){if(!this.complete())return false;var a=this._5.status;return(a>=200&&a<300)||a===304||a===1223},failure:function(){if(!this.complete())return false;return!this.success()},text:function(){if(!this.complete())return null;return this._5.responseText},status:function(){if(!this.complete())return null;return this._5.status}})};if(!this.JSON){JSON={}}(function(){function l(a){return a<10?'0'+a:a}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(a){return this.getUTCFullYear()+'-'+l(this.getUTCMonth()+1)+'-'+l(this.getUTCDate())+'T'+l(this.getUTCHours())+':'+l(this.getUTCMinutes())+':'+l(this.getUTCSeconds())+'Z'};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()}}var n=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,o=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,k,p,s={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},m;function r(c){o.lastIndex=0;return o.test(c)?'"'+c.replace(o,function(a){var b=s[a];return typeof b==='string'?b:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+c+'"'}function q(a,b){var c,d,f,g,h=k,j,i=b[a];if(i&&typeof i==='object'&&typeof i.toJSON==='function'){i=i.toJSON(a)}if(typeof m==='function'){i=m.call(b,a,i)}switch(typeof i){case'string':return r(i);case'number':return isFinite(i)?String(i):'null';case'boolean':case'null':return String(i);case'object':if(!i){return'null'}k+=p;j=[];if(Object.prototype.toString.apply(i)==='[object Array]'){g=i.length;for(c=0;c<g;c+=1){j[c]=q(c,i)||'null'}f=j.length===0?'[]':k?'[\n'+k+j.join(',\n'+k)+'\n'+h+']':'['+j.join(',')+']';k=h;return f}if(m&&typeof m==='object'){g=m.length;for(c=0;c<g;c+=1){d=m[c];if(typeof d==='string'){f=q(d,i);if(f){j.push(r(d)+(k?': ':':')+f)}}}}else{for(d in i){if(Object.hasOwnProperty.call(i,d)){f=q(d,i);if(f){j.push(r(d)+(k?': ':':')+f)}}}}f=j.length===0?'{}':k?'{\n'+k+j.join(',\n'+k)+'\n'+h+'}':'{'+j.join(',')+'}';k=h;return f}}Faye.stringify=function(a,b,c){var d;k='';p='';if(typeof c==='number'){for(d=0;d<c;d+=1){p+=' '}}else if(typeof c==='string'){p=c}m=b;if(b&&typeof b!=='function'&&(typeof b!=='object'||typeof b.length!=='number')){throw new Error('JSON.stringify');}return q('',{'':a})};if(typeof JSON.stringify!=='function'){JSON.stringify=Faye.stringify}if(typeof JSON.parse!=='function'){JSON.parse=function(g,h){var j;function i(a,b){var c,d,f=a[b];if(f&&typeof f==='object'){for(c in f){if(Object.hasOwnProperty.call(f,c)){d=i(f,c);if(d!==undefined){f[c]=d}else{delete f[c]}}}}return h.call(a,b,f)}n.lastIndex=0;if(n.test(g)){g=g.replace(n,function(a){return'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(g.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+g+')');return typeof h==='function'?i({'':j},''):j}throw new SyntaxError('JSON.parse');}}}());Faye.WebSocketTransport=Faye.Class(Faye.Transport,{UNCONNECTED:1,CONNECTING:2,CONNECTED:3,request:function(b,c){this._l=this._l||{};Faye.each(b,function(a){this._l[a.id]=a},this);this.withSocket(function(a){a.send(Faye.toJSON(b))})},withSocket:function(d,f){this.callback(d,f);this._1=this._1||this.UNCONNECTED;if(this._1!==this.UNCONNECTED)return;this._1=this.CONNECTING;var g=Faye.URI.parse(this._3).toURL().replace(/^https?/ig,'ws');this._g=new WebSocket(g);var h=this;this._g.onopen=function(){h._1=h.CONNECTED;h.setDeferredStatus('succeeded',h._g)};this._g.onmessage=function(b){var c=[].concat(JSON.parse(b.data));Faye.each(c,function(a){delete h._l[a.id]});h.receive(c)};this._g.onclose=function(){h.setDeferredStatus('deferred');h._1=h.UNCONNECTED;h._g=null;h.resend()}},resend:function(){var c=Faye.map(this._l,function(a,b){return b});this.request(c)}});Faye.extend(Faye.WebSocketTransport.prototype,Faye.Deferrable);Faye.WebSocketTransport.isUsable=function(a){return!!Faye.ENV.WebSocket};Faye.Transport.register('websocket',Faye.WebSocketTransport);Faye.XHRTransport=Faye.Class(Faye.Transport,{request:function(b,c){var d=this.retry(b,c);Faye.XHR.request('post',this._3,Faye.toJSON(b),{success:function(a){try{this.receive(JSON.parse(a.text()))}catch(e){d()}},failure:d},this)}});Faye.XHRTransport.isUsable=function(a){return Faye.URI.parse(a).isLocal()};Faye.Transport.register('long-polling',Faye.XHRTransport);Faye.JSONPTransport=Faye.extend(Faye.Class(Faye.Transport,{request:function(b,c){var d={message:Faye.toJSON(b)},f=document.getElementsByTagName('head')[0],g=document.createElement('script'),h=Faye.JSONPTransport.getCallbackName(),j=Faye.URI.parse(this._3,d),i=this;var l=function(){if(!g.parentNode)return false;g.parentNode.removeChild(g);return true};Faye.ENV[h]=function(a){Faye.ENV[h]=undefined;try{delete Faye.ENV[h]}catch(e){}if(!l())return;i.receive(a)};setTimeout(function(){if(!Faye.ENV[h])return;l();i.request(b,2*c)},1000*c);j.params.jsonp=h;g.type='text/javascript';g.src=j.toURL();f.appendChild(g)}}),{_A:0,getCallbackName:function(){this._A+=1;return'__jsonp'+this._A+'__'}});Faye.JSONPTransport.isUsable=function(a){return true};Faye.Transport.register('callback-polling',Faye.JSONPTransport);
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|