├── .gitignore ├── Gemfile ├── MIT-LICENSE.txt ├── README.org ├── Rakefile ├── bin └── nagios-dashboard ├── lib └── nagios-dashboard │ ├── app.rb │ ├── static │ ├── css │ │ └── style.css │ ├── fancybox │ │ ├── blank.gif │ │ ├── fancy_close.png │ │ ├── fancy_loading.png │ │ ├── fancy_nav_left.png │ │ ├── fancy_nav_right.png │ │ ├── fancy_shadow_e.png │ │ ├── fancy_shadow_n.png │ │ ├── fancy_shadow_ne.png │ │ ├── fancy_shadow_nw.png │ │ ├── fancy_shadow_s.png │ │ ├── fancy_shadow_se.png │ │ ├── fancy_shadow_sw.png │ │ ├── fancy_shadow_w.png │ │ ├── fancy_title_left.png │ │ ├── fancy_title_main.png │ │ ├── fancy_title_over.png │ │ ├── fancy_title_right.png │ │ ├── fancybox-x.png │ │ ├── fancybox-y.png │ │ ├── fancybox.png │ │ ├── jquery.easing-1.3.pack.js │ │ ├── jquery.fancybox-1.3.4.css │ │ ├── jquery.fancybox-1.3.4.js │ │ ├── jquery.fancybox-1.3.4.pack.js │ │ └── jquery.mousewheel-3.0.4.pack.js │ ├── favicon.ico │ ├── img │ │ └── bg.jpg │ └── js │ │ ├── FABridge.js │ │ ├── WebSocketMain.swf │ │ ├── nagios-dashboard.js │ │ ├── swfobject.js │ │ └── web_socket.js │ ├── version.rb │ └── views │ └── dashboard.haml └── nagios-dashboard.gemspec /.gitignore: -------------------------------------------------------------------------------- 1 | \#* 2 | *~ 3 | *.gem 4 | *.log 5 | .DS_Store 6 | .bundle 7 | Gemfile.lock 8 | pkg/* 9 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | # specify gem dependencies in nagios-dashboard.gemspec 3 | gemspec 4 | -------------------------------------------------------------------------------- /MIT-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Sean Porter & Justin Kolberg 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | #+TITLE: A Nagios dashboard with OpsCode Chef integration. 2 | #+Options: num:nil 3 | #+STARTUP: odd 4 | #+Style: 5 | 6 | * How It Works 7 | Nagios-Dashboard parses the nagios status.dat file & sends the current status to clients via an HTML5 WebSocket. 8 | 9 | The dashboard monitors the status.dat file for changes, any modifications trigger client updates (push). 10 | 11 | Nagios-Dashboard queries a Chef server or Opscode platform organization for additional host information. 12 | 13 | * Requirements 14 | - Nagios http://www.nagios.org/ 15 | - Ruby (MRI) & RubyGems http://www.ruby-lang.org/en/ 16 | - An OpsCode Chef server or platform oranization http://opscode.com/chef/ http://opscode.com/platform/ 17 | - Credentials to query Chef, user name & private key http://wiki.opscode.com/display/chef/Authentication 18 | - Two open ports, one for the UI (default is 80, can change with -p), and port 8000 for an HTML5 WebSocket 19 | 20 | * Install 21 | : sudo gem install nagios-dashboard 22 | 23 | * Run 24 | : -> % nagios-dashboard -h 25 | : Usage: nagios-dashboard (options) 26 | : -c, --chef SERVER Use a Chef SERVER 27 | : -d, --datfile FILE Location of Nagios status.dat FILE 28 | : -k, --key KEY Chef user KEY 29 | : -l, --logfile FILE Log to a different FILE 30 | : -o, --organization ORGANIZATION Use a OpsCode platform ORGANIZATION 31 | : -p, --port PORT Listen on a different PORT 32 | : -u, --user USER Chef USER name 33 | : -v, --verbose Output debug messages to screen 34 | : -h, --help Show this message 35 | 36 | Example: 37 | : nagios-dashboard -u user -k ~/.chef/platform/user.pem -o chef-organization -d /var/cache/nagios3/status.dat -p 8080 -v 38 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'bundler' 2 | Bundler::GemHelper.install_tasks 3 | -------------------------------------------------------------------------------- /bin/nagios-dashboard: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | require 'nagios-dashboard/app.rb' 4 | rescue LoadError => e 5 | require 'rubygems' 6 | path = File.expand_path '../../lib', __FILE__ 7 | $:.unshift(path) if File.directory?(path) && !$:.include?(path) 8 | require 'nagios-dashboard/app.rb' 9 | end 10 | -------------------------------------------------------------------------------- /lib/nagios-dashboard/app.rb: -------------------------------------------------------------------------------- 1 | %w{ 2 | mixlib/cli 3 | mixlib/log 4 | json 5 | thin 6 | eventmachine 7 | em-websocket 8 | directory_watcher 9 | nagios_analyzer 10 | sinatra/async 11 | haml 12 | spice 13 | }.each do |gem| 14 | require gem 15 | end 16 | 17 | class Options 18 | include Mixlib::CLI 19 | option :verbose, 20 | :short => '-v', 21 | :long => '--verbose', 22 | :boolean => true, 23 | :default => false, 24 | :description => 'Output debug messages to screen' 25 | 26 | option :datfile, 27 | :short => '-d FILE', 28 | :long => '--datfile FILE', 29 | :default => '/var/cache/nagios3/status.dat', 30 | :description => 'Location of Nagios status.dat FILE' 31 | 32 | option :port, 33 | :short => '-p PORT', 34 | :long => '--port PORT', 35 | :default => 80, 36 | :description => 'Listen on a different PORT' 37 | 38 | option :logfile, 39 | :short => '-l FILE', 40 | :long => '--logfile FILE', 41 | :default => '/tmp/nagios-dashboard.log', 42 | :description => 'Log to a different FILE' 43 | 44 | option :chef, 45 | :short => '-c SERVER', 46 | :long => '--chef SERVER', 47 | :description => 'Use a Chef SERVER' 48 | 49 | option :user, 50 | :short => '-u USER', 51 | :long => '--user USER', 52 | :description => 'Chef USER name' 53 | 54 | option :key, 55 | :short => '-k KEY', 56 | :long => '--key KEY', 57 | :default => '/etc/chef/client.pem', 58 | :description => 'Chef user KEY' 59 | 60 | option :organization, 61 | :short => '-o ORGANIZATION', 62 | :long => '--organization ORGANIZATION', 63 | :description => 'Use a OpsCode platform ORGANIZATION' 64 | 65 | option :help, 66 | :short => "-h", 67 | :long => "--help", 68 | :description => "Show this message", 69 | :on => :tail, 70 | :boolean => true, 71 | :show_options => true, 72 | :exit => 0 73 | end 74 | 75 | class Log 76 | extend Mixlib::Log 77 | end 78 | 79 | OPTIONS = Options.new 80 | OPTIONS.parse_options 81 | 82 | Log.init(OPTIONS.config[:logfile]) 83 | Log.debug('starting dashboard ...') 84 | 85 | EventMachine.epoll if EventMachine.epoll? 86 | EventMachine.kqueue if EventMachine.kqueue? 87 | EventMachine.run do 88 | class Dashboard < Sinatra::Base 89 | register Sinatra::Async 90 | set :root, File.dirname(__FILE__) 91 | set :static, true 92 | set :public, Proc.new { File.join(root, "static") } 93 | 94 | Spice.setup do |s| 95 | s.host = OPTIONS.config[:chef] || "api.opscode.com" 96 | s.port = 443 97 | s.scheme = "https" 98 | s.url_path = '/organizations/' + OPTIONS.config[:organization] if OPTIONS.config[:chef].nil? 99 | s.client_name = OPTIONS.config[:user] 100 | s.key_file = OPTIONS.config[:key] 101 | end 102 | Spice.connect! 103 | 104 | aget '/' do 105 | EventMachine.defer(proc { haml :dashboard }, proc { |result| body result }) 106 | end 107 | 108 | aget '/node/:hostname' do |hostname| 109 | content_type 'application/json' 110 | EventMachine.defer(proc { JSON.parse(Spice::Search.node('hostname:' + hostname))['rows'][0] }, proc { |result| body result.to_json }) 111 | end 112 | end 113 | 114 | def log_message(message) 115 | if OPTIONS.config[:verbose] 116 | puts message 117 | end 118 | EventMachine.defer(proc { Log.debug(message) }) 119 | end 120 | 121 | websocket_connections = Array.new 122 | EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8000) do |websocket| 123 | websocket.onopen do 124 | websocket_connections.push websocket 125 | log_message('client connected to websocket') 126 | end 127 | websocket.onclose do 128 | websocket_connections.delete websocket 129 | log_message('client disconnected from websocket') 130 | end 131 | end 132 | 133 | nagios_status = proc do 134 | begin 135 | nagios = NagiosAnalyzer::Status.new(OPTIONS.config[:datfile]) 136 | nagios.items.to_json 137 | rescue => error 138 | log_message(error) 139 | end 140 | end 141 | 142 | update_clients = proc do |nagios| 143 | unless nagios.nil? 144 | websocket_connections.each do |websocket| 145 | websocket.send nagios 146 | end 147 | log_message('updated clients') 148 | end 149 | end 150 | 151 | watcher = DirectoryWatcher.new File.dirname(File.expand_path(OPTIONS.config[:datfile])), :glob => '*.dat', :scanner => :em 152 | watcher.add_observer do |*args| 153 | args.each do |event| 154 | unless websocket_connections.count == 0 155 | EventMachine.defer(nagios_status, update_clients) 156 | end 157 | end 158 | end 159 | watcher.start 160 | 161 | Dashboard.run!({:port => OPTIONS.config[:port]}) 162 | end 163 | 164 | Log.debug('stopping dashboard ...') 165 | -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/css/style.css: -------------------------------------------------------------------------------- 1 | body 2 | { 3 | background-color: #333; 4 | background-image: url("/img/bg.jpg"); 5 | font-family: Helvetica; 6 | margin: 0; 7 | padding: 20px; 8 | } 9 | 10 | div#MainContainer 11 | { 12 | background-color: rgba(30, 30, 30, 0.7); 13 | -webkit-border-radius: 6px; 14 | -moz-border-radius: 6px; 15 | border-radius: 6px; 16 | } 17 | 18 | div#MainContainer h1 19 | { 20 | color: #fff; 21 | padding-left: 14px; 22 | padding-top: 14px; 23 | } 24 | 25 | div#MainContainer table 26 | { 27 | border-collapse: collapse; 28 | width: 100%; 29 | } 30 | 31 | div#MainContainer table thead tr 32 | { 33 | background-color: #000; 34 | } 35 | 36 | div#MainContainer table thead tr th 37 | { 38 | padding: 7px 14px 7px 14px; 39 | text-align: left; 40 | } 41 | 42 | div#MainContainer table thead tr th:first-child 43 | { 44 | -webkit-border-top-left-radius: 6px; 45 | -moz-border-radius-topleft: 6px; 46 | border-top-left-radius: 6px; 47 | width: 200px; 48 | } 49 | 50 | div#MainContainer table thead tr th:last-child 51 | { 52 | -webkit-border-top-right-radius: 6px; 53 | -moz-border-radius-topright: 6px; 54 | border-top-right-radius: 6px; 55 | } 56 | 57 | div#MainContainer table thead tr th 58 | { 59 | color: #fff; 60 | font-weight: bold; 61 | font-family: Helvetica; 62 | font-size: 16px; 63 | } 64 | 65 | div#MainContainer table tbody tr:last-child td:first-child 66 | { 67 | -webkit-border-bottom-left-radius: 6px; 68 | -moz-border-radius-bottomleft: 6px; 69 | border-bottom-left-radius: 6px; 70 | } 71 | 72 | div#MainContainer table tbody tr:last-child td:last-child 73 | { 74 | -webkit-border-bottom-right-radius: 6px; 75 | -moz-border-radius-bottomright: 6px; 76 | border-bottom-right-radius: 6px; 77 | } 78 | 79 | div#MainContainer table tbody tr 80 | { 81 | cursor: pointer; 82 | } 83 | 84 | div#MainContainer table tbody tr.Critical 85 | { 86 | background-color: rgba(144, 0, 0, 0.6); 87 | /*background-color: #900;*/ 88 | color: #fff; 89 | } 90 | 91 | div#MainContainer table tbody tr.Warning 92 | { 93 | background-color: rgba(255, 165, 0, 0.6); 94 | /*background-color: #ffa500;*/ 95 | color: #fff; 96 | } 97 | 98 | div#MainContainer table tbody tr td 99 | { 100 | padding: 14px 14px 14px 14px; 101 | font-family: Helvetica; 102 | font-size: 14px; 103 | } 104 | -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/blank.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/blank.gif -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/fancy_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/fancy_close.png -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/fancy_loading.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/fancy_loading.png -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/fancy_nav_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/fancy_nav_left.png -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/fancy_nav_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/fancy_nav_right.png -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/fancy_shadow_e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/fancy_shadow_e.png -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/fancy_shadow_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/fancy_shadow_n.png -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/fancy_shadow_ne.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/fancy_shadow_ne.png -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/fancy_shadow_nw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/fancy_shadow_nw.png -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/fancy_shadow_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/fancy_shadow_s.png -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/fancy_shadow_se.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/fancy_shadow_se.png -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/fancy_shadow_sw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/fancy_shadow_sw.png -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/fancy_shadow_w.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/fancy_shadow_w.png -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/fancy_title_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/fancy_title_left.png -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/fancy_title_main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/fancy_title_main.png -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/fancy_title_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/fancy_title_over.png -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/fancy_title_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/fancy_title_right.png -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/fancybox-x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/fancybox-x.png -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/fancybox-y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/fancybox-y.png -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/fancybox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/fancybox/fancybox.png -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/jquery.easing-1.3.pack.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ 3 | * 4 | * Uses the built in easing capabilities added In jQuery 1.1 5 | * to offer multiple easing options 6 | * 7 | * TERMS OF USE - jQuery Easing 8 | * 9 | * Open source under the BSD License. 10 | * 11 | * Copyright © 2008 George McGinley Smith 12 | * All rights reserved. 13 | * 14 | * Redistribution and use in source and binary forms, with or without modification, 15 | * are permitted provided that the following conditions are met: 16 | * 17 | * Redistributions of source code must retain the above copyright notice, this list of 18 | * conditions and the following disclaimer. 19 | * Redistributions in binary form must reproduce the above copyright notice, this list 20 | * of conditions and the following disclaimer in the documentation and/or other materials 21 | * provided with the distribution. 22 | * 23 | * Neither the name of the author nor the names of contributors may be used to endorse 24 | * or promote products derived from this software without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 27 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 28 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 29 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 30 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 31 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 32 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 33 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | // t: current time, b: begInnIng value, c: change In value, d: duration 39 | eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('h.i[\'1a\']=h.i[\'z\'];h.O(h.i,{y:\'D\',z:9(x,t,b,c,d){6 h.i[h.i.y](x,t,b,c,d)},17:9(x,t,b,c,d){6 c*(t/=d)*t+b},D:9(x,t,b,c,d){6-c*(t/=d)*(t-2)+b},13:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t+b;6-c/2*((--t)*(t-2)-1)+b},X:9(x,t,b,c,d){6 c*(t/=d)*t*t+b},U:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t+1)+b},R:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t+b;6 c/2*((t-=2)*t*t+2)+b},N:9(x,t,b,c,d){6 c*(t/=d)*t*t*t+b},M:9(x,t,b,c,d){6-c*((t=t/d-1)*t*t*t-1)+b},L:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t+b;6-c/2*((t-=2)*t*t*t-2)+b},K:9(x,t,b,c,d){6 c*(t/=d)*t*t*t*t+b},J:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t*t*t+1)+b},I:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t*t+b;6 c/2*((t-=2)*t*t*t*t+2)+b},G:9(x,t,b,c,d){6-c*8.C(t/d*(8.g/2))+c+b},15:9(x,t,b,c,d){6 c*8.n(t/d*(8.g/2))+b},12:9(x,t,b,c,d){6-c/2*(8.C(8.g*t/d)-1)+b},Z:9(x,t,b,c,d){6(t==0)?b:c*8.j(2,10*(t/d-1))+b},Y:9(x,t,b,c,d){6(t==d)?b+c:c*(-8.j(2,-10*t/d)+1)+b},W:9(x,t,b,c,d){e(t==0)6 b;e(t==d)6 b+c;e((t/=d/2)<1)6 c/2*8.j(2,10*(t-1))+b;6 c/2*(-8.j(2,-10*--t)+2)+b},V:9(x,t,b,c,d){6-c*(8.o(1-(t/=d)*t)-1)+b},S:9(x,t,b,c,d){6 c*8.o(1-(t=t/d-1)*t)+b},Q:9(x,t,b,c,d){e((t/=d/2)<1)6-c/2*(8.o(1-t*t)-1)+b;6 c/2*(8.o(1-(t-=2)*t)+1)+b},P:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);6-(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b},H:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);6 a*8.j(2,-10*t)*8.n((t*d-s)*(2*8.g)/p)+c+b},T:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d/2)==2)6 b+c;e(!p)p=d*(.3*1.5);e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);e(t<1)6-.5*(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b;6 a*8.j(2,-10*(t-=1))*8.n((t*d-s)*(2*8.g)/p)*.5+c+b},F:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*(t/=d)*t*((s+1)*t-s)+b},E:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},16:9(x,t,b,c,d,s){e(s==u)s=1.l;e((t/=d/2)<1)6 c/2*(t*t*(((s*=(1.B))+1)*t-s))+b;6 c/2*((t-=2)*t*(((s*=(1.B))+1)*t+s)+2)+b},A:9(x,t,b,c,d){6 c-h.i.v(x,d-t,0,c,d)+b},v:9(x,t,b,c,d){e((t/=d)<(1/2.k)){6 c*(7.q*t*t)+b}m e(t<(2/2.k)){6 c*(7.q*(t-=(1.5/2.k))*t+.k)+b}m e(t<(2.5/2.k)){6 c*(7.q*(t-=(2.14/2.k))*t+.11)+b}m{6 c*(7.q*(t-=(2.18/2.k))*t+.19)+b}},1b:9(x,t,b,c,d){e(t')[0], { prop: 0 }), 28 | 29 | isIE6 = $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest, 30 | 31 | /* 32 | * Private methods 33 | */ 34 | 35 | _abort = function() { 36 | loading.hide(); 37 | 38 | imgPreloader.onerror = imgPreloader.onload = null; 39 | 40 | if (ajaxLoader) { 41 | ajaxLoader.abort(); 42 | } 43 | 44 | tmp.empty(); 45 | }, 46 | 47 | _error = function() { 48 | if (false === selectedOpts.onError(selectedArray, selectedIndex, selectedOpts)) { 49 | loading.hide(); 50 | busy = false; 51 | return; 52 | } 53 | 54 | selectedOpts.titleShow = false; 55 | 56 | selectedOpts.width = 'auto'; 57 | selectedOpts.height = 'auto'; 58 | 59 | tmp.html( '

The requested content cannot be loaded.
Please try again later.

' ); 60 | 61 | _process_inline(); 62 | }, 63 | 64 | _start = function() { 65 | var obj = selectedArray[ selectedIndex ], 66 | href, 67 | type, 68 | title, 69 | str, 70 | emb, 71 | ret; 72 | 73 | _abort(); 74 | 75 | selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox'))); 76 | 77 | ret = selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts); 78 | 79 | if (ret === false) { 80 | busy = false; 81 | return; 82 | } else if (typeof ret == 'object') { 83 | selectedOpts = $.extend(selectedOpts, ret); 84 | } 85 | 86 | title = selectedOpts.title || (obj.nodeName ? $(obj).attr('title') : obj.title) || ''; 87 | 88 | if (obj.nodeName && !selectedOpts.orig) { 89 | selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj); 90 | } 91 | 92 | if (title === '' && selectedOpts.orig && selectedOpts.titleFromAlt) { 93 | title = selectedOpts.orig.attr('alt'); 94 | } 95 | 96 | href = selectedOpts.href || (obj.nodeName ? $(obj).attr('href') : obj.href) || null; 97 | 98 | if ((/^(?:javascript)/i).test(href) || href == '#') { 99 | href = null; 100 | } 101 | 102 | if (selectedOpts.type) { 103 | type = selectedOpts.type; 104 | 105 | if (!href) { 106 | href = selectedOpts.content; 107 | } 108 | 109 | } else if (selectedOpts.content) { 110 | type = 'html'; 111 | 112 | } else if (href) { 113 | if (href.match(imgRegExp)) { 114 | type = 'image'; 115 | 116 | } else if (href.match(swfRegExp)) { 117 | type = 'swf'; 118 | 119 | } else if ($(obj).hasClass("iframe")) { 120 | type = 'iframe'; 121 | 122 | } else if (href.indexOf("#") === 0) { 123 | type = 'inline'; 124 | 125 | } else { 126 | type = 'ajax'; 127 | } 128 | } 129 | 130 | if (!type) { 131 | _error(); 132 | return; 133 | } 134 | 135 | if (type == 'inline') { 136 | obj = href.substr(href.indexOf("#")); 137 | type = $(obj).length > 0 ? 'inline' : 'ajax'; 138 | } 139 | 140 | selectedOpts.type = type; 141 | selectedOpts.href = href; 142 | selectedOpts.title = title; 143 | 144 | if (selectedOpts.autoDimensions) { 145 | if (selectedOpts.type == 'html' || selectedOpts.type == 'inline' || selectedOpts.type == 'ajax') { 146 | selectedOpts.width = 'auto'; 147 | selectedOpts.height = 'auto'; 148 | } else { 149 | selectedOpts.autoDimensions = false; 150 | } 151 | } 152 | 153 | if (selectedOpts.modal) { 154 | selectedOpts.overlayShow = true; 155 | selectedOpts.hideOnOverlayClick = false; 156 | selectedOpts.hideOnContentClick = false; 157 | selectedOpts.enableEscapeButton = false; 158 | selectedOpts.showCloseButton = false; 159 | } 160 | 161 | selectedOpts.padding = parseInt(selectedOpts.padding, 10); 162 | selectedOpts.margin = parseInt(selectedOpts.margin, 10); 163 | 164 | tmp.css('padding', (selectedOpts.padding + selectedOpts.margin)); 165 | 166 | $('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() { 167 | $(this).replaceWith(content.children()); 168 | }); 169 | 170 | switch (type) { 171 | case 'html' : 172 | tmp.html( selectedOpts.content ); 173 | _process_inline(); 174 | break; 175 | 176 | case 'inline' : 177 | if ( $(obj).parent().is('#fancybox-content') === true) { 178 | busy = false; 179 | return; 180 | } 181 | 182 | $('
') 183 | .hide() 184 | .insertBefore( $(obj) ) 185 | .bind('fancybox-cleanup', function() { 186 | $(this).replaceWith(content.children()); 187 | }).bind('fancybox-cancel', function() { 188 | $(this).replaceWith(tmp.children()); 189 | }); 190 | 191 | $(obj).appendTo(tmp); 192 | 193 | _process_inline(); 194 | break; 195 | 196 | case 'image': 197 | busy = false; 198 | 199 | $.fancybox.showActivity(); 200 | 201 | imgPreloader = new Image(); 202 | 203 | imgPreloader.onerror = function() { 204 | _error(); 205 | }; 206 | 207 | imgPreloader.onload = function() { 208 | busy = true; 209 | 210 | imgPreloader.onerror = imgPreloader.onload = null; 211 | 212 | _process_image(); 213 | }; 214 | 215 | imgPreloader.src = href; 216 | break; 217 | 218 | case 'swf': 219 | selectedOpts.scrolling = 'no'; 220 | 221 | str = ''; 222 | emb = ''; 223 | 224 | $.each(selectedOpts.swf, function(name, val) { 225 | str += ''; 226 | emb += ' ' + name + '="' + val + '"'; 227 | }); 228 | 229 | str += ''; 230 | 231 | tmp.html(str); 232 | 233 | _process_inline(); 234 | break; 235 | 236 | case 'ajax': 237 | busy = false; 238 | 239 | $.fancybox.showActivity(); 240 | 241 | selectedOpts.ajax.win = selectedOpts.ajax.success; 242 | 243 | ajaxLoader = $.ajax($.extend({}, selectedOpts.ajax, { 244 | url : href, 245 | data : selectedOpts.ajax.data || {}, 246 | error : function(XMLHttpRequest, textStatus, errorThrown) { 247 | if ( XMLHttpRequest.status > 0 ) { 248 | _error(); 249 | } 250 | }, 251 | success : function(data, textStatus, XMLHttpRequest) { 252 | var o = typeof XMLHttpRequest == 'object' ? XMLHttpRequest : ajaxLoader; 253 | if (o.status == 200) { 254 | if ( typeof selectedOpts.ajax.win == 'function' ) { 255 | ret = selectedOpts.ajax.win(href, data, textStatus, XMLHttpRequest); 256 | 257 | if (ret === false) { 258 | loading.hide(); 259 | return; 260 | } else if (typeof ret == 'string' || typeof ret == 'object') { 261 | data = ret; 262 | } 263 | } 264 | 265 | tmp.html( data ); 266 | _process_inline(); 267 | } 268 | } 269 | })); 270 | 271 | break; 272 | 273 | case 'iframe': 274 | _show(); 275 | break; 276 | } 277 | }, 278 | 279 | _process_inline = function() { 280 | var 281 | w = selectedOpts.width, 282 | h = selectedOpts.height; 283 | 284 | if (w.toString().indexOf('%') > -1) { 285 | w = parseInt( ($(window).width() - (selectedOpts.margin * 2)) * parseFloat(w) / 100, 10) + 'px'; 286 | 287 | } else { 288 | w = w == 'auto' ? 'auto' : w + 'px'; 289 | } 290 | 291 | if (h.toString().indexOf('%') > -1) { 292 | h = parseInt( ($(window).height() - (selectedOpts.margin * 2)) * parseFloat(h) / 100, 10) + 'px'; 293 | 294 | } else { 295 | h = h == 'auto' ? 'auto' : h + 'px'; 296 | } 297 | 298 | tmp.wrapInner('
'); 299 | 300 | selectedOpts.width = tmp.width(); 301 | selectedOpts.height = tmp.height(); 302 | 303 | _show(); 304 | }, 305 | 306 | _process_image = function() { 307 | selectedOpts.width = imgPreloader.width; 308 | selectedOpts.height = imgPreloader.height; 309 | 310 | $("").attr({ 311 | 'id' : 'fancybox-img', 312 | 'src' : imgPreloader.src, 313 | 'alt' : selectedOpts.title 314 | }).appendTo( tmp ); 315 | 316 | _show(); 317 | }, 318 | 319 | _show = function() { 320 | var pos, equal; 321 | 322 | loading.hide(); 323 | 324 | if (wrap.is(":visible") && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) { 325 | $.event.trigger('fancybox-cancel'); 326 | 327 | busy = false; 328 | return; 329 | } 330 | 331 | busy = true; 332 | 333 | $(content.add( overlay )).unbind(); 334 | 335 | $(window).unbind("resize.fb scroll.fb"); 336 | $(document).unbind('keydown.fb'); 337 | 338 | if (wrap.is(":visible") && currentOpts.titlePosition !== 'outside') { 339 | wrap.css('height', wrap.height()); 340 | } 341 | 342 | currentArray = selectedArray; 343 | currentIndex = selectedIndex; 344 | currentOpts = selectedOpts; 345 | 346 | if (currentOpts.overlayShow) { 347 | overlay.css({ 348 | 'background-color' : currentOpts.overlayColor, 349 | 'opacity' : currentOpts.overlayOpacity, 350 | 'cursor' : currentOpts.hideOnOverlayClick ? 'pointer' : 'auto', 351 | 'height' : $(document).height() 352 | }); 353 | 354 | if (!overlay.is(':visible')) { 355 | if (isIE6) { 356 | $('select:not(#fancybox-tmp select)').filter(function() { 357 | return this.style.visibility !== 'hidden'; 358 | }).css({'visibility' : 'hidden'}).one('fancybox-cleanup', function() { 359 | this.style.visibility = 'inherit'; 360 | }); 361 | } 362 | 363 | overlay.show(); 364 | } 365 | } else { 366 | overlay.hide(); 367 | } 368 | 369 | final_pos = _get_zoom_to(); 370 | 371 | _process_title(); 372 | 373 | if (wrap.is(":visible")) { 374 | $( close.add( nav_left ).add( nav_right ) ).hide(); 375 | 376 | pos = wrap.position(), 377 | 378 | start_pos = { 379 | top : pos.top, 380 | left : pos.left, 381 | width : wrap.width(), 382 | height : wrap.height() 383 | }; 384 | 385 | equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height); 386 | 387 | content.fadeTo(currentOpts.changeFade, 0.3, function() { 388 | var finish_resizing = function() { 389 | content.html( tmp.contents() ).fadeTo(currentOpts.changeFade, 1, _finish); 390 | }; 391 | 392 | $.event.trigger('fancybox-change'); 393 | 394 | content 395 | .empty() 396 | .removeAttr('filter') 397 | .css({ 398 | 'border-width' : currentOpts.padding, 399 | 'width' : final_pos.width - currentOpts.padding * 2, 400 | 'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2 401 | }); 402 | 403 | if (equal) { 404 | finish_resizing(); 405 | 406 | } else { 407 | fx.prop = 0; 408 | 409 | $(fx).animate({prop: 1}, { 410 | duration : currentOpts.changeSpeed, 411 | easing : currentOpts.easingChange, 412 | step : _draw, 413 | complete : finish_resizing 414 | }); 415 | } 416 | }); 417 | 418 | return; 419 | } 420 | 421 | wrap.removeAttr("style"); 422 | 423 | content.css('border-width', currentOpts.padding); 424 | 425 | if (currentOpts.transitionIn == 'elastic') { 426 | start_pos = _get_zoom_from(); 427 | 428 | content.html( tmp.contents() ); 429 | 430 | wrap.show(); 431 | 432 | if (currentOpts.opacity) { 433 | final_pos.opacity = 0; 434 | } 435 | 436 | fx.prop = 0; 437 | 438 | $(fx).animate({prop: 1}, { 439 | duration : currentOpts.speedIn, 440 | easing : currentOpts.easingIn, 441 | step : _draw, 442 | complete : _finish 443 | }); 444 | 445 | return; 446 | } 447 | 448 | if (currentOpts.titlePosition == 'inside' && titleHeight > 0) { 449 | title.show(); 450 | } 451 | 452 | content 453 | .css({ 454 | 'width' : final_pos.width - currentOpts.padding * 2, 455 | 'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2 456 | }) 457 | .html( tmp.contents() ); 458 | 459 | wrap 460 | .css(final_pos) 461 | .fadeIn( currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish ); 462 | }, 463 | 464 | _format_title = function(title) { 465 | if (title && title.length) { 466 | if (currentOpts.titlePosition == 'float') { 467 | return '
' + title + '
'; 468 | } 469 | 470 | return '
' + title + '
'; 471 | } 472 | 473 | return false; 474 | }, 475 | 476 | _process_title = function() { 477 | titleStr = currentOpts.title || ''; 478 | titleHeight = 0; 479 | 480 | title 481 | .empty() 482 | .removeAttr('style') 483 | .removeClass(); 484 | 485 | if (currentOpts.titleShow === false) { 486 | title.hide(); 487 | return; 488 | } 489 | 490 | titleStr = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(titleStr, currentArray, currentIndex, currentOpts) : _format_title(titleStr); 491 | 492 | if (!titleStr || titleStr === '') { 493 | title.hide(); 494 | return; 495 | } 496 | 497 | title 498 | .addClass('fancybox-title-' + currentOpts.titlePosition) 499 | .html( titleStr ) 500 | .appendTo( 'body' ) 501 | .show(); 502 | 503 | switch (currentOpts.titlePosition) { 504 | case 'inside': 505 | title 506 | .css({ 507 | 'width' : final_pos.width - (currentOpts.padding * 2), 508 | 'marginLeft' : currentOpts.padding, 509 | 'marginRight' : currentOpts.padding 510 | }); 511 | 512 | titleHeight = title.outerHeight(true); 513 | 514 | title.appendTo( outer ); 515 | 516 | final_pos.height += titleHeight; 517 | break; 518 | 519 | case 'over': 520 | title 521 | .css({ 522 | 'marginLeft' : currentOpts.padding, 523 | 'width' : final_pos.width - (currentOpts.padding * 2), 524 | 'bottom' : currentOpts.padding 525 | }) 526 | .appendTo( outer ); 527 | break; 528 | 529 | case 'float': 530 | title 531 | .css('left', parseInt((title.width() - final_pos.width - 40)/ 2, 10) * -1) 532 | .appendTo( wrap ); 533 | break; 534 | 535 | default: 536 | title 537 | .css({ 538 | 'width' : final_pos.width - (currentOpts.padding * 2), 539 | 'paddingLeft' : currentOpts.padding, 540 | 'paddingRight' : currentOpts.padding 541 | }) 542 | .appendTo( wrap ); 543 | break; 544 | } 545 | 546 | title.hide(); 547 | }, 548 | 549 | _set_navigation = function() { 550 | if (currentOpts.enableEscapeButton || currentOpts.enableKeyboardNav) { 551 | $(document).bind('keydown.fb', function(e) { 552 | if (e.keyCode == 27 && currentOpts.enableEscapeButton) { 553 | e.preventDefault(); 554 | $.fancybox.close(); 555 | 556 | } else if ((e.keyCode == 37 || e.keyCode == 39) && currentOpts.enableKeyboardNav && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') { 557 | e.preventDefault(); 558 | $.fancybox[ e.keyCode == 37 ? 'prev' : 'next'](); 559 | } 560 | }); 561 | } 562 | 563 | if (!currentOpts.showNavArrows) { 564 | nav_left.hide(); 565 | nav_right.hide(); 566 | return; 567 | } 568 | 569 | if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) { 570 | nav_left.show(); 571 | } 572 | 573 | if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length -1)) { 574 | nav_right.show(); 575 | } 576 | }, 577 | 578 | _finish = function () { 579 | if (!$.support.opacity) { 580 | content.get(0).style.removeAttribute('filter'); 581 | wrap.get(0).style.removeAttribute('filter'); 582 | } 583 | 584 | if (selectedOpts.autoDimensions) { 585 | content.css('height', 'auto'); 586 | } 587 | 588 | wrap.css('height', 'auto'); 589 | 590 | if (titleStr && titleStr.length) { 591 | title.show(); 592 | } 593 | 594 | if (currentOpts.showCloseButton) { 595 | close.show(); 596 | } 597 | 598 | _set_navigation(); 599 | 600 | if (currentOpts.hideOnContentClick) { 601 | content.bind('click', $.fancybox.close); 602 | } 603 | 604 | if (currentOpts.hideOnOverlayClick) { 605 | overlay.bind('click', $.fancybox.close); 606 | } 607 | 608 | $(window).bind("resize.fb", $.fancybox.resize); 609 | 610 | if (currentOpts.centerOnScroll) { 611 | $(window).bind("scroll.fb", $.fancybox.center); 612 | } 613 | 614 | if (currentOpts.type == 'iframe') { 615 | $('').appendTo(content); 616 | } 617 | 618 | wrap.show(); 619 | 620 | busy = false; 621 | 622 | $.fancybox.center(); 623 | 624 | currentOpts.onComplete(currentArray, currentIndex, currentOpts); 625 | 626 | _preload_images(); 627 | }, 628 | 629 | _preload_images = function() { 630 | var href, 631 | objNext; 632 | 633 | if ((currentArray.length -1) > currentIndex) { 634 | href = currentArray[ currentIndex + 1 ].href; 635 | 636 | if (typeof href !== 'undefined' && href.match(imgRegExp)) { 637 | objNext = new Image(); 638 | objNext.src = href; 639 | } 640 | } 641 | 642 | if (currentIndex > 0) { 643 | href = currentArray[ currentIndex - 1 ].href; 644 | 645 | if (typeof href !== 'undefined' && href.match(imgRegExp)) { 646 | objNext = new Image(); 647 | objNext.src = href; 648 | } 649 | } 650 | }, 651 | 652 | _draw = function(pos) { 653 | var dim = { 654 | width : parseInt(start_pos.width + (final_pos.width - start_pos.width) * pos, 10), 655 | height : parseInt(start_pos.height + (final_pos.height - start_pos.height) * pos, 10), 656 | 657 | top : parseInt(start_pos.top + (final_pos.top - start_pos.top) * pos, 10), 658 | left : parseInt(start_pos.left + (final_pos.left - start_pos.left) * pos, 10) 659 | }; 660 | 661 | if (typeof final_pos.opacity !== 'undefined') { 662 | dim.opacity = pos < 0.5 ? 0.5 : pos; 663 | } 664 | 665 | wrap.css(dim); 666 | 667 | content.css({ 668 | 'width' : dim.width - currentOpts.padding * 2, 669 | 'height' : dim.height - (titleHeight * pos) - currentOpts.padding * 2 670 | }); 671 | }, 672 | 673 | _get_viewport = function() { 674 | return [ 675 | $(window).width() - (currentOpts.margin * 2), 676 | $(window).height() - (currentOpts.margin * 2), 677 | $(document).scrollLeft() + currentOpts.margin, 678 | $(document).scrollTop() + currentOpts.margin 679 | ]; 680 | }, 681 | 682 | _get_zoom_to = function () { 683 | var view = _get_viewport(), 684 | to = {}, 685 | resize = currentOpts.autoScale, 686 | double_padding = currentOpts.padding * 2, 687 | ratio; 688 | 689 | if (currentOpts.width.toString().indexOf('%') > -1) { 690 | to.width = parseInt((view[0] * parseFloat(currentOpts.width)) / 100, 10); 691 | } else { 692 | to.width = currentOpts.width + double_padding; 693 | } 694 | 695 | if (currentOpts.height.toString().indexOf('%') > -1) { 696 | to.height = parseInt((view[1] * parseFloat(currentOpts.height)) / 100, 10); 697 | } else { 698 | to.height = currentOpts.height + double_padding; 699 | } 700 | 701 | if (resize && (to.width > view[0] || to.height > view[1])) { 702 | if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') { 703 | ratio = (currentOpts.width ) / (currentOpts.height ); 704 | 705 | if ((to.width ) > view[0]) { 706 | to.width = view[0]; 707 | to.height = parseInt(((to.width - double_padding) / ratio) + double_padding, 10); 708 | } 709 | 710 | if ((to.height) > view[1]) { 711 | to.height = view[1]; 712 | to.width = parseInt(((to.height - double_padding) * ratio) + double_padding, 10); 713 | } 714 | 715 | } else { 716 | to.width = Math.min(to.width, view[0]); 717 | to.height = Math.min(to.height, view[1]); 718 | } 719 | } 720 | 721 | to.top = parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - to.height - 40) * 0.5)), 10); 722 | to.left = parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - to.width - 40) * 0.5)), 10); 723 | 724 | return to; 725 | }, 726 | 727 | _get_obj_pos = function(obj) { 728 | var pos = obj.offset(); 729 | 730 | pos.top += parseInt( obj.css('paddingTop'), 10 ) || 0; 731 | pos.left += parseInt( obj.css('paddingLeft'), 10 ) || 0; 732 | 733 | pos.top += parseInt( obj.css('border-top-width'), 10 ) || 0; 734 | pos.left += parseInt( obj.css('border-left-width'), 10 ) || 0; 735 | 736 | pos.width = obj.width(); 737 | pos.height = obj.height(); 738 | 739 | return pos; 740 | }, 741 | 742 | _get_zoom_from = function() { 743 | var orig = selectedOpts.orig ? $(selectedOpts.orig) : false, 744 | from = {}, 745 | pos, 746 | view; 747 | 748 | if (orig && orig.length) { 749 | pos = _get_obj_pos(orig); 750 | 751 | from = { 752 | width : pos.width + (currentOpts.padding * 2), 753 | height : pos.height + (currentOpts.padding * 2), 754 | top : pos.top - currentOpts.padding - 20, 755 | left : pos.left - currentOpts.padding - 20 756 | }; 757 | 758 | } else { 759 | view = _get_viewport(); 760 | 761 | from = { 762 | width : currentOpts.padding * 2, 763 | height : currentOpts.padding * 2, 764 | top : parseInt(view[3] + view[1] * 0.5, 10), 765 | left : parseInt(view[2] + view[0] * 0.5, 10) 766 | }; 767 | } 768 | 769 | return from; 770 | }, 771 | 772 | _animate_loading = function() { 773 | if (!loading.is(':visible')){ 774 | clearInterval(loadingTimer); 775 | return; 776 | } 777 | 778 | $('div', loading).css('top', (loadingFrame * -40) + 'px'); 779 | 780 | loadingFrame = (loadingFrame + 1) % 12; 781 | }; 782 | 783 | /* 784 | * Public methods 785 | */ 786 | 787 | $.fn.fancybox = function(options) { 788 | if (!$(this).length) { 789 | return this; 790 | } 791 | 792 | $(this) 793 | .data('fancybox', $.extend({}, options, ($.metadata ? $(this).metadata() : {}))) 794 | .unbind('click.fb') 795 | .bind('click.fb', function(e) { 796 | e.preventDefault(); 797 | 798 | if (busy) { 799 | return; 800 | } 801 | 802 | busy = true; 803 | 804 | $(this).blur(); 805 | 806 | selectedArray = []; 807 | selectedIndex = 0; 808 | 809 | var rel = $(this).attr('rel') || ''; 810 | 811 | if (!rel || rel == '' || rel === 'nofollow') { 812 | selectedArray.push(this); 813 | 814 | } else { 815 | selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]"); 816 | selectedIndex = selectedArray.index( this ); 817 | } 818 | 819 | _start(); 820 | 821 | return; 822 | }); 823 | 824 | return this; 825 | }; 826 | 827 | $.fancybox = function(obj) { 828 | var opts; 829 | 830 | if (busy) { 831 | return; 832 | } 833 | 834 | busy = true; 835 | opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {}; 836 | 837 | selectedArray = []; 838 | selectedIndex = parseInt(opts.index, 10) || 0; 839 | 840 | if ($.isArray(obj)) { 841 | for (var i = 0, j = obj.length; i < j; i++) { 842 | if (typeof obj[i] == 'object') { 843 | $(obj[i]).data('fancybox', $.extend({}, opts, obj[i])); 844 | } else { 845 | obj[i] = $({}).data('fancybox', $.extend({content : obj[i]}, opts)); 846 | } 847 | } 848 | 849 | selectedArray = jQuery.merge(selectedArray, obj); 850 | 851 | } else { 852 | if (typeof obj == 'object') { 853 | $(obj).data('fancybox', $.extend({}, opts, obj)); 854 | } else { 855 | obj = $({}).data('fancybox', $.extend({content : obj}, opts)); 856 | } 857 | 858 | selectedArray.push(obj); 859 | } 860 | 861 | if (selectedIndex > selectedArray.length || selectedIndex < 0) { 862 | selectedIndex = 0; 863 | } 864 | 865 | _start(); 866 | }; 867 | 868 | $.fancybox.showActivity = function() { 869 | clearInterval(loadingTimer); 870 | 871 | loading.show(); 872 | loadingTimer = setInterval(_animate_loading, 66); 873 | }; 874 | 875 | $.fancybox.hideActivity = function() { 876 | loading.hide(); 877 | }; 878 | 879 | $.fancybox.next = function() { 880 | return $.fancybox.pos( currentIndex + 1); 881 | }; 882 | 883 | $.fancybox.prev = function() { 884 | return $.fancybox.pos( currentIndex - 1); 885 | }; 886 | 887 | $.fancybox.pos = function(pos) { 888 | if (busy) { 889 | return; 890 | } 891 | 892 | pos = parseInt(pos); 893 | 894 | selectedArray = currentArray; 895 | 896 | if (pos > -1 && pos < currentArray.length) { 897 | selectedIndex = pos; 898 | _start(); 899 | 900 | } else if (currentOpts.cyclic && currentArray.length > 1) { 901 | selectedIndex = pos >= currentArray.length ? 0 : currentArray.length - 1; 902 | _start(); 903 | } 904 | 905 | return; 906 | }; 907 | 908 | $.fancybox.cancel = function() { 909 | if (busy) { 910 | return; 911 | } 912 | 913 | busy = true; 914 | 915 | $.event.trigger('fancybox-cancel'); 916 | 917 | _abort(); 918 | 919 | selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts); 920 | 921 | busy = false; 922 | }; 923 | 924 | // Note: within an iframe use - parent.$.fancybox.close(); 925 | $.fancybox.close = function() { 926 | if (busy || wrap.is(':hidden')) { 927 | return; 928 | } 929 | 930 | busy = true; 931 | 932 | if (currentOpts && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) { 933 | busy = false; 934 | return; 935 | } 936 | 937 | _abort(); 938 | 939 | $(close.add( nav_left ).add( nav_right )).hide(); 940 | 941 | $(content.add( overlay )).unbind(); 942 | 943 | $(window).unbind("resize.fb scroll.fb"); 944 | $(document).unbind('keydown.fb'); 945 | 946 | content.find('iframe').attr('src', isIE6 && /^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank'); 947 | 948 | if (currentOpts.titlePosition !== 'inside') { 949 | title.empty(); 950 | } 951 | 952 | wrap.stop(); 953 | 954 | function _cleanup() { 955 | overlay.fadeOut('fast'); 956 | 957 | title.empty().hide(); 958 | wrap.hide(); 959 | 960 | $.event.trigger('fancybox-cleanup'); 961 | 962 | content.empty(); 963 | 964 | currentOpts.onClosed(currentArray, currentIndex, currentOpts); 965 | 966 | currentArray = selectedOpts = []; 967 | currentIndex = selectedIndex = 0; 968 | currentOpts = selectedOpts = {}; 969 | 970 | busy = false; 971 | } 972 | 973 | if (currentOpts.transitionOut == 'elastic') { 974 | start_pos = _get_zoom_from(); 975 | 976 | var pos = wrap.position(); 977 | 978 | final_pos = { 979 | top : pos.top , 980 | left : pos.left, 981 | width : wrap.width(), 982 | height : wrap.height() 983 | }; 984 | 985 | if (currentOpts.opacity) { 986 | final_pos.opacity = 1; 987 | } 988 | 989 | title.empty().hide(); 990 | 991 | fx.prop = 1; 992 | 993 | $(fx).animate({ prop: 0 }, { 994 | duration : currentOpts.speedOut, 995 | easing : currentOpts.easingOut, 996 | step : _draw, 997 | complete : _cleanup 998 | }); 999 | 1000 | } else { 1001 | wrap.fadeOut( currentOpts.transitionOut == 'none' ? 0 : currentOpts.speedOut, _cleanup); 1002 | } 1003 | }; 1004 | 1005 | $.fancybox.resize = function() { 1006 | if (overlay.is(':visible')) { 1007 | overlay.css('height', $(document).height()); 1008 | } 1009 | 1010 | $.fancybox.center(true); 1011 | }; 1012 | 1013 | $.fancybox.center = function() { 1014 | var view, align; 1015 | 1016 | if (busy) { 1017 | return; 1018 | } 1019 | 1020 | align = arguments[0] === true ? 1 : 0; 1021 | view = _get_viewport(); 1022 | 1023 | if (!align && (wrap.width() > view[0] || wrap.height() > view[1])) { 1024 | return; 1025 | } 1026 | 1027 | wrap 1028 | .stop() 1029 | .animate({ 1030 | 'top' : parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - content.height() - 40) * 0.5) - currentOpts.padding)), 1031 | 'left' : parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - content.width() - 40) * 0.5) - currentOpts.padding)) 1032 | }, typeof arguments[0] == 'number' ? arguments[0] : 200); 1033 | }; 1034 | 1035 | $.fancybox.init = function() { 1036 | if ($("#fancybox-wrap").length) { 1037 | return; 1038 | } 1039 | 1040 | $('body').append( 1041 | tmp = $('
'), 1042 | loading = $('
'), 1043 | overlay = $('
'), 1044 | wrap = $('
') 1045 | ); 1046 | 1047 | outer = $('
') 1048 | .append('
') 1049 | .appendTo( wrap ); 1050 | 1051 | outer.append( 1052 | content = $('
'), 1053 | close = $(''), 1054 | title = $('
'), 1055 | 1056 | nav_left = $(''), 1057 | nav_right = $('') 1058 | ); 1059 | 1060 | close.click($.fancybox.close); 1061 | loading.click($.fancybox.cancel); 1062 | 1063 | nav_left.click(function(e) { 1064 | e.preventDefault(); 1065 | $.fancybox.prev(); 1066 | }); 1067 | 1068 | nav_right.click(function(e) { 1069 | e.preventDefault(); 1070 | $.fancybox.next(); 1071 | }); 1072 | 1073 | if ($.fn.mousewheel) { 1074 | wrap.bind('mousewheel.fb', function(e, delta) { 1075 | if (busy) { 1076 | e.preventDefault(); 1077 | 1078 | } else if ($(e.target).get(0).clientHeight == 0 || $(e.target).get(0).scrollHeight === $(e.target).get(0).clientHeight) { 1079 | e.preventDefault(); 1080 | $.fancybox[ delta > 0 ? 'prev' : 'next'](); 1081 | } 1082 | }); 1083 | } 1084 | 1085 | if (!$.support.opacity) { 1086 | wrap.addClass('fancybox-ie'); 1087 | } 1088 | 1089 | if (isIE6) { 1090 | loading.addClass('fancybox-ie6'); 1091 | wrap.addClass('fancybox-ie6'); 1092 | 1093 | $('').prependTo(outer); 1094 | } 1095 | }; 1096 | 1097 | $.fn.fancybox.defaults = { 1098 | padding : 10, 1099 | margin : 40, 1100 | opacity : false, 1101 | modal : false, 1102 | cyclic : false, 1103 | scrolling : 'auto', // 'auto', 'yes' or 'no' 1104 | 1105 | width : 560, 1106 | height : 340, 1107 | 1108 | autoScale : true, 1109 | autoDimensions : true, 1110 | centerOnScroll : false, 1111 | 1112 | ajax : {}, 1113 | swf : { wmode: 'transparent' }, 1114 | 1115 | hideOnOverlayClick : true, 1116 | hideOnContentClick : false, 1117 | 1118 | overlayShow : true, 1119 | overlayOpacity : 0.7, 1120 | overlayColor : '#777', 1121 | 1122 | titleShow : true, 1123 | titlePosition : 'float', // 'float', 'outside', 'inside' or 'over' 1124 | titleFormat : null, 1125 | titleFromAlt : false, 1126 | 1127 | transitionIn : 'fade', // 'elastic', 'fade' or 'none' 1128 | transitionOut : 'fade', // 'elastic', 'fade' or 'none' 1129 | 1130 | speedIn : 300, 1131 | speedOut : 300, 1132 | 1133 | changeSpeed : 300, 1134 | changeFade : 'fast', 1135 | 1136 | easingIn : 'swing', 1137 | easingOut : 'swing', 1138 | 1139 | showCloseButton : true, 1140 | showNavArrows : true, 1141 | enableEscapeButton : true, 1142 | enableKeyboardNav : true, 1143 | 1144 | onStart : function(){}, 1145 | onCancel : function(){}, 1146 | onComplete : function(){}, 1147 | onCleanup : function(){}, 1148 | onClosed : function(){}, 1149 | onError : function(){} 1150 | }; 1151 | 1152 | $(document).ready(function() { 1153 | $.fancybox.init(); 1154 | }); 1155 | 1156 | })(jQuery); -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/jquery.fancybox-1.3.4.pack.js: -------------------------------------------------------------------------------- 1 | /* 2 | * FancyBox - jQuery Plugin 3 | * Simple and fancy lightbox alternative 4 | * 5 | * Examples and documentation at: http://fancybox.net 6 | * 7 | * Copyright (c) 2008 - 2010 Janis Skarnelis 8 | * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated. 9 | * 10 | * Version: 1.3.4 (11/11/2010) 11 | * Requires: jQuery v1.3+ 12 | * 13 | * Dual licensed under the MIT and GPL licenses: 14 | * http://www.opensource.org/licenses/mit-license.php 15 | * http://www.gnu.org/licenses/gpl.html 16 | */ 17 | 18 | ;(function(b){var m,t,u,f,D,j,E,n,z,A,q=0,e={},o=[],p=0,d={},l=[],G=null,v=new Image,J=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,W=/[^\.]\.(swf)\s*$/i,K,L=1,y=0,s="",r,i,h=false,B=b.extend(b("
")[0],{prop:0}),M=b.browser.msie&&b.browser.version<7&&!window.XMLHttpRequest,N=function(){t.hide();v.onerror=v.onload=null;G&&G.abort();m.empty()},O=function(){if(false===e.onError(o,q,e)){t.hide();h=false}else{e.titleShow=false;e.width="auto";e.height="auto";m.html('

The requested content cannot be loaded.
Please try again later.

'); 19 | F()}},I=function(){var a=o[q],c,g,k,C,P,w;N();e=b.extend({},b.fn.fancybox.defaults,typeof b(a).data("fancybox")=="undefined"?e:b(a).data("fancybox"));w=e.onStart(o,q,e);if(w===false)h=false;else{if(typeof w=="object")e=b.extend(e,w);k=e.title||(a.nodeName?b(a).attr("title"):a.title)||"";if(a.nodeName&&!e.orig)e.orig=b(a).children("img:first").length?b(a).children("img:first"):b(a);if(k===""&&e.orig&&e.titleFromAlt)k=e.orig.attr("alt");c=e.href||(a.nodeName?b(a).attr("href"):a.href)||null;if(/^(?:javascript)/i.test(c)|| 20 | c=="#")c=null;if(e.type){g=e.type;if(!c)c=e.content}else if(e.content)g="html";else if(c)g=c.match(J)?"image":c.match(W)?"swf":b(a).hasClass("iframe")?"iframe":c.indexOf("#")===0?"inline":"ajax";if(g){if(g=="inline"){a=c.substr(c.indexOf("#"));g=b(a).length>0?"inline":"ajax"}e.type=g;e.href=c;e.title=k;if(e.autoDimensions)if(e.type=="html"||e.type=="inline"||e.type=="ajax"){e.width="auto";e.height="auto"}else e.autoDimensions=false;if(e.modal){e.overlayShow=true;e.hideOnOverlayClick=false;e.hideOnContentClick= 21 | false;e.enableEscapeButton=false;e.showCloseButton=false}e.padding=parseInt(e.padding,10);e.margin=parseInt(e.margin,10);m.css("padding",e.padding+e.margin);b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){b(this).replaceWith(j.children())});switch(g){case "html":m.html(e.content);F();break;case "inline":if(b(a).parent().is("#fancybox-content")===true){h=false;break}b('
').hide().insertBefore(b(a)).bind("fancybox-cleanup",function(){b(this).replaceWith(j.children())}).bind("fancybox-cancel", 22 | function(){b(this).replaceWith(m.children())});b(a).appendTo(m);F();break;case "image":h=false;b.fancybox.showActivity();v=new Image;v.onerror=function(){O()};v.onload=function(){h=true;v.onerror=v.onload=null;e.width=v.width;e.height=v.height;b("").attr({id:"fancybox-img",src:v.src,alt:e.title}).appendTo(m);Q()};v.src=c;break;case "swf":e.scrolling="no";C='';P="";b.each(e.swf,function(x,H){C+='';P+=" "+x+'="'+H+'"'});C+='";m.html(C);F();break;case "ajax":h=false;b.fancybox.showActivity();e.ajax.win=e.ajax.success;G=b.ajax(b.extend({},e.ajax,{url:c,data:e.ajax.data||{},error:function(x){x.status>0&&O()},success:function(x,H,R){if((typeof R=="object"?R:G).status==200){if(typeof e.ajax.win== 24 | "function"){w=e.ajax.win(c,x,H,R);if(w===false){t.hide();return}else if(typeof w=="string"||typeof w=="object")x=w}m.html(x);F()}}}));break;case "iframe":Q()}}else O()}},F=function(){var a=e.width,c=e.height;a=a.toString().indexOf("%")>-1?parseInt((b(window).width()-e.margin*2)*parseFloat(a)/100,10)+"px":a=="auto"?"auto":a+"px";c=c.toString().indexOf("%")>-1?parseInt((b(window).height()-e.margin*2)*parseFloat(c)/100,10)+"px":c=="auto"?"auto":c+"px";m.wrapInner('
');e.width=m.width();e.height=m.height();Q()},Q=function(){var a,c;t.hide();if(f.is(":visible")&&false===d.onCleanup(l,p,d)){b.event.trigger("fancybox-cancel");h=false}else{h=true;b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");f.is(":visible")&&d.titlePosition!=="outside"&&f.css("height",f.height());l=o;p=q;d=e;if(d.overlayShow){u.css({"background-color":d.overlayColor, 26 | opacity:d.overlayOpacity,cursor:d.hideOnOverlayClick?"pointer":"auto",height:b(document).height()});if(!u.is(":visible")){M&&b("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"});u.show()}}else u.hide();i=X();s=d.title||"";y=0;n.empty().removeAttr("style").removeClass();if(d.titleShow!==false){if(b.isFunction(d.titleFormat))a=d.titleFormat(s,l,p,d);else a=s&&s.length? 27 | d.titlePosition=="float"?'
'+s+'
':'
'+s+"
":false;s=a;if(!(!s||s==="")){n.addClass("fancybox-title-"+d.titlePosition).html(s).appendTo("body").show();switch(d.titlePosition){case "inside":n.css({width:i.width-d.padding*2,marginLeft:d.padding,marginRight:d.padding}); 28 | y=n.outerHeight(true);n.appendTo(D);i.height+=y;break;case "over":n.css({marginLeft:d.padding,width:i.width-d.padding*2,bottom:d.padding}).appendTo(D);break;case "float":n.css("left",parseInt((n.width()-i.width-40)/2,10)*-1).appendTo(f);break;default:n.css({width:i.width-d.padding*2,paddingLeft:d.padding,paddingRight:d.padding}).appendTo(f)}}}n.hide();if(f.is(":visible")){b(E.add(z).add(A)).hide();a=f.position();r={top:a.top,left:a.left,width:f.width(),height:f.height()};c=r.width==i.width&&r.height== 29 | i.height;j.fadeTo(d.changeFade,0.3,function(){var g=function(){j.html(m.contents()).fadeTo(d.changeFade,1,S)};b.event.trigger("fancybox-change");j.empty().removeAttr("filter").css({"border-width":d.padding,width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2});if(c)g();else{B.prop=0;b(B).animate({prop:1},{duration:d.changeSpeed,easing:d.easingChange,step:T,complete:g})}})}else{f.removeAttr("style");j.css("border-width",d.padding);if(d.transitionIn=="elastic"){r=V();j.html(m.contents()); 30 | f.show();if(d.opacity)i.opacity=0;B.prop=0;b(B).animate({prop:1},{duration:d.speedIn,easing:d.easingIn,step:T,complete:S})}else{d.titlePosition=="inside"&&y>0&&n.show();j.css({width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2}).html(m.contents());f.css(i).fadeIn(d.transitionIn=="none"?0:d.speedIn,S)}}}},Y=function(){if(d.enableEscapeButton||d.enableKeyboardNav)b(document).bind("keydown.fb",function(a){if(a.keyCode==27&&d.enableEscapeButton){a.preventDefault();b.fancybox.close()}else if((a.keyCode== 31 | 37||a.keyCode==39)&&d.enableKeyboardNav&&a.target.tagName!=="INPUT"&&a.target.tagName!=="TEXTAREA"&&a.target.tagName!=="SELECT"){a.preventDefault();b.fancybox[a.keyCode==37?"prev":"next"]()}});if(d.showNavArrows){if(d.cyclic&&l.length>1||p!==0)z.show();if(d.cyclic&&l.length>1||p!=l.length-1)A.show()}else{z.hide();A.hide()}},S=function(){if(!b.support.opacity){j.get(0).style.removeAttribute("filter");f.get(0).style.removeAttribute("filter")}e.autoDimensions&&j.css("height","auto");f.css("height","auto"); 32 | s&&s.length&&n.show();d.showCloseButton&&E.show();Y();d.hideOnContentClick&&j.bind("click",b.fancybox.close);d.hideOnOverlayClick&&u.bind("click",b.fancybox.close);b(window).bind("resize.fb",b.fancybox.resize);d.centerOnScroll&&b(window).bind("scroll.fb",b.fancybox.center);if(d.type=="iframe")b('').appendTo(j); 33 | f.show();h=false;b.fancybox.center();d.onComplete(l,p,d);var a,c;if(l.length-1>p){a=l[p+1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}if(p>0){a=l[p-1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}},T=function(a){var c={width:parseInt(r.width+(i.width-r.width)*a,10),height:parseInt(r.height+(i.height-r.height)*a,10),top:parseInt(r.top+(i.top-r.top)*a,10),left:parseInt(r.left+(i.left-r.left)*a,10)};if(typeof i.opacity!=="undefined")c.opacity=a<0.5?0.5:a;f.css(c); 34 | j.css({width:c.width-d.padding*2,height:c.height-y*a-d.padding*2})},U=function(){return[b(window).width()-d.margin*2,b(window).height()-d.margin*2,b(document).scrollLeft()+d.margin,b(document).scrollTop()+d.margin]},X=function(){var a=U(),c={},g=d.autoScale,k=d.padding*2;c.width=d.width.toString().indexOf("%")>-1?parseInt(a[0]*parseFloat(d.width)/100,10):d.width+k;c.height=d.height.toString().indexOf("%")>-1?parseInt(a[1]*parseFloat(d.height)/100,10):d.height+k;if(g&&(c.width>a[0]||c.height>a[1]))if(e.type== 35 | "image"||e.type=="swf"){g=d.width/d.height;if(c.width>a[0]){c.width=a[0];c.height=parseInt((c.width-k)/g+k,10)}if(c.height>a[1]){c.height=a[1];c.width=parseInt((c.height-k)*g+k,10)}}else{c.width=Math.min(c.width,a[0]);c.height=Math.min(c.height,a[1])}c.top=parseInt(Math.max(a[3]-20,a[3]+(a[1]-c.height-40)*0.5),10);c.left=parseInt(Math.max(a[2]-20,a[2]+(a[0]-c.width-40)*0.5),10);return c},V=function(){var a=e.orig?b(e.orig):false,c={};if(a&&a.length){c=a.offset();c.top+=parseInt(a.css("paddingTop"), 36 | 10)||0;c.left+=parseInt(a.css("paddingLeft"),10)||0;c.top+=parseInt(a.css("border-top-width"),10)||0;c.left+=parseInt(a.css("border-left-width"),10)||0;c.width=a.width();c.height=a.height();c={width:c.width+d.padding*2,height:c.height+d.padding*2,top:c.top-d.padding-20,left:c.left-d.padding-20}}else{a=U();c={width:d.padding*2,height:d.padding*2,top:parseInt(a[3]+a[1]*0.5,10),left:parseInt(a[2]+a[0]*0.5,10)}}return c},Z=function(){if(t.is(":visible")){b("div",t).css("top",L*-40+"px");L=(L+1)%12}else clearInterval(K)}; 37 | b.fn.fancybox=function(a){if(!b(this).length)return this;b(this).data("fancybox",b.extend({},a,b.metadata?b(this).metadata():{})).unbind("click.fb").bind("click.fb",function(c){c.preventDefault();if(!h){h=true;b(this).blur();o=[];q=0;c=b(this).attr("rel")||"";if(!c||c==""||c==="nofollow")o.push(this);else{o=b("a[rel="+c+"], area[rel="+c+"]");q=o.index(this)}I()}});return this};b.fancybox=function(a,c){var g;if(!h){h=true;g=typeof c!=="undefined"?c:{};o=[];q=parseInt(g.index,10)||0;if(b.isArray(a)){for(var k= 38 | 0,C=a.length;ko.length||q<0)q=0;I()}};b.fancybox.showActivity=function(){clearInterval(K);t.show();K=setInterval(Z,66)};b.fancybox.hideActivity=function(){t.hide()};b.fancybox.next=function(){return b.fancybox.pos(p+ 39 | 1)};b.fancybox.prev=function(){return b.fancybox.pos(p-1)};b.fancybox.pos=function(a){if(!h){a=parseInt(a);o=l;if(a>-1&&a1){q=a>=l.length?0:l.length-1;I()}}};b.fancybox.cancel=function(){if(!h){h=true;b.event.trigger("fancybox-cancel");N();e.onCancel(o,q,e);h=false}};b.fancybox.close=function(){function a(){u.fadeOut("fast");n.empty().hide();f.hide();b.event.trigger("fancybox-cleanup");j.empty();d.onClosed(l,p,d);l=e=[];p=q=0;d=e={};h=false}if(!(h||f.is(":hidden"))){h= 40 | true;if(d&&false===d.onCleanup(l,p,d))h=false;else{N();b(E.add(z).add(A)).hide();b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");j.find("iframe").attr("src",M&&/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank");d.titlePosition!=="inside"&&n.empty();f.stop();if(d.transitionOut=="elastic"){r=V();var c=f.position();i={top:c.top,left:c.left,width:f.width(),height:f.height()};if(d.opacity)i.opacity=1;n.empty().hide();B.prop=1; 41 | b(B).animate({prop:0},{duration:d.speedOut,easing:d.easingOut,step:T,complete:a})}else f.fadeOut(d.transitionOut=="none"?0:d.speedOut,a)}}};b.fancybox.resize=function(){u.is(":visible")&&u.css("height",b(document).height());b.fancybox.center(true)};b.fancybox.center=function(a){var c,g;if(!h){g=a===true?1:0;c=U();!g&&(f.width()>c[0]||f.height()>c[1])||f.stop().animate({top:parseInt(Math.max(c[3]-20,c[3]+(c[1]-j.height()-40)*0.5-d.padding)),left:parseInt(Math.max(c[2]-20,c[2]+(c[0]-j.width()-40)*0.5- 42 | d.padding))},typeof a=="number"?a:200)}};b.fancybox.init=function(){if(!b("#fancybox-wrap").length){b("body").append(m=b('
'),t=b('
'),u=b('
'),f=b('
'));D=b('
').append('
').appendTo(f); 43 | D.append(j=b('
'),E=b(''),n=b('
'),z=b(''),A=b(''));E.click(b.fancybox.close);t.click(b.fancybox.cancel);z.click(function(a){a.preventDefault();b.fancybox.prev()});A.click(function(a){a.preventDefault();b.fancybox.next()}); 44 | b.fn.mousewheel&&f.bind("mousewheel.fb",function(a,c){if(h)a.preventDefault();else if(b(a.target).get(0).clientHeight==0||b(a.target).get(0).scrollHeight===b(a.target).get(0).clientHeight){a.preventDefault();b.fancybox[c>0?"prev":"next"]()}});b.support.opacity||f.addClass("fancybox-ie");if(M){t.addClass("fancybox-ie6");f.addClass("fancybox-ie6");b('').prependTo(D)}}}; 45 | b.fn.fancybox.defaults={padding:10,margin:40,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.7,overlayColor:"#777",titleShow:true,titlePosition:"float",titleFormat:null,titleFromAlt:false,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast",easingIn:"swing", 46 | easingOut:"swing",showCloseButton:true,showNavArrows:true,enableEscapeButton:true,enableKeyboardNav:true,onStart:function(){},onCancel:function(){},onComplete:function(){},onCleanup:function(){},onClosed:function(){},onError:function(){}};b(document).ready(function(){b.fancybox.init()})})(jQuery); -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/fancybox/jquery.mousewheel-3.0.4.pack.js: -------------------------------------------------------------------------------- 1 | /*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net) 2 | * Licensed under the MIT License (LICENSE.txt). 3 | * 4 | * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. 5 | * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. 6 | * Thanks to: Seamus Leahy for adding deltaX and deltaY 7 | * 8 | * Version: 3.0.4 9 | * 10 | * Requires: 1.2.2+ 11 | */ 12 | 13 | (function(d){function g(a){var b=a||window.event,i=[].slice.call(arguments,1),c=0,h=0,e=0;a=d.event.fix(b);a.type="mousewheel";if(a.wheelDelta)c=a.wheelDelta/120;if(a.detail)c=-a.detail/3;e=c;if(b.axis!==undefined&&b.axis===b.HORIZONTAL_AXIS){e=0;h=-1*c}if(b.wheelDeltaY!==undefined)e=b.wheelDeltaY/120;if(b.wheelDeltaX!==undefined)h=-1*b.wheelDeltaX/120;i.unshift(a,c,h,e);return d.event.handle.apply(this,i)}var f=["DOMMouseScroll","mousewheel"];d.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a= 14 | f.length;a;)this.addEventListener(f[--a],g,false);else this.onmousewheel=g},teardown:function(){if(this.removeEventListener)for(var a=f.length;a;)this.removeEventListener(f[--a],g,false);else this.onmousewheel=null}};d.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery); -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/favicon.ico -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/img/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/img/bg.jpg -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/js/FABridge.js: -------------------------------------------------------------------------------- 1 | /* 2 | /* 3 | Copyright 2006 Adobe Systems Incorporated 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), 6 | to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 15 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | 17 | */ 18 | 19 | 20 | /* 21 | * The Bridge class, responsible for navigating AS instances 22 | */ 23 | function FABridge(target,bridgeName) 24 | { 25 | this.target = target; 26 | this.remoteTypeCache = {}; 27 | this.remoteInstanceCache = {}; 28 | this.remoteFunctionCache = {}; 29 | this.localFunctionCache = {}; 30 | this.bridgeID = FABridge.nextBridgeID++; 31 | this.name = bridgeName; 32 | this.nextLocalFuncID = 0; 33 | FABridge.instances[this.name] = this; 34 | FABridge.idMap[this.bridgeID] = this; 35 | 36 | return this; 37 | } 38 | 39 | // type codes for packed values 40 | FABridge.TYPE_ASINSTANCE = 1; 41 | FABridge.TYPE_ASFUNCTION = 2; 42 | 43 | FABridge.TYPE_JSFUNCTION = 3; 44 | FABridge.TYPE_ANONYMOUS = 4; 45 | 46 | FABridge.initCallbacks = {}; 47 | FABridge.userTypes = {}; 48 | 49 | FABridge.addToUserTypes = function() 50 | { 51 | for (var i = 0; i < arguments.length; i++) 52 | { 53 | FABridge.userTypes[arguments[i]] = { 54 | 'typeName': arguments[i], 55 | 'enriched': false 56 | }; 57 | } 58 | } 59 | 60 | FABridge.argsToArray = function(args) 61 | { 62 | var result = []; 63 | for (var i = 0; i < args.length; i++) 64 | { 65 | result[i] = args[i]; 66 | } 67 | return result; 68 | } 69 | 70 | function instanceFactory(objID) 71 | { 72 | this.fb_instance_id = objID; 73 | return this; 74 | } 75 | 76 | function FABridge__invokeJSFunction(args) 77 | { 78 | var funcID = args[0]; 79 | var throughArgs = args.concat();//FABridge.argsToArray(arguments); 80 | throughArgs.shift(); 81 | 82 | var bridge = FABridge.extractBridgeFromID(funcID); 83 | return bridge.invokeLocalFunction(funcID, throughArgs); 84 | } 85 | 86 | FABridge.addInitializationCallback = function(bridgeName, callback) 87 | { 88 | var inst = FABridge.instances[bridgeName]; 89 | if (inst != undefined) 90 | { 91 | callback.call(inst); 92 | return; 93 | } 94 | 95 | var callbackList = FABridge.initCallbacks[bridgeName]; 96 | if(callbackList == null) 97 | { 98 | FABridge.initCallbacks[bridgeName] = callbackList = []; 99 | } 100 | 101 | callbackList.push(callback); 102 | } 103 | 104 | // updated for changes to SWFObject2 105 | function FABridge__bridgeInitialized(bridgeName) { 106 | var objects = document.getElementsByTagName("object"); 107 | var ol = objects.length; 108 | var activeObjects = []; 109 | if (ol > 0) { 110 | for (var i = 0; i < ol; i++) { 111 | if (typeof objects[i].SetVariable != "undefined") { 112 | activeObjects[activeObjects.length] = objects[i]; 113 | } 114 | } 115 | } 116 | var embeds = document.getElementsByTagName("embed"); 117 | var el = embeds.length; 118 | var activeEmbeds = []; 119 | if (el > 0) { 120 | for (var j = 0; j < el; j++) { 121 | if (typeof embeds[j].SetVariable != "undefined") { 122 | activeEmbeds[activeEmbeds.length] = embeds[j]; 123 | } 124 | } 125 | } 126 | var aol = activeObjects.length; 127 | var ael = activeEmbeds.length; 128 | var searchStr = "bridgeName="+ bridgeName; 129 | if ((aol == 1 && !ael) || (aol == 1 && ael == 1)) { 130 | FABridge.attachBridge(activeObjects[0], bridgeName); 131 | } 132 | else if (ael == 1 && !aol) { 133 | FABridge.attachBridge(activeEmbeds[0], bridgeName); 134 | } 135 | else { 136 | var flash_found = false; 137 | if (aol > 1) { 138 | for (var k = 0; k < aol; k++) { 139 | var params = activeObjects[k].childNodes; 140 | for (var l = 0; l < params.length; l++) { 141 | var param = params[l]; 142 | if (param.nodeType == 1 && param.tagName.toLowerCase() == "param" && param["name"].toLowerCase() == "flashvars" && param["value"].indexOf(searchStr) >= 0) { 143 | FABridge.attachBridge(activeObjects[k], bridgeName); 144 | flash_found = true; 145 | break; 146 | } 147 | } 148 | if (flash_found) { 149 | break; 150 | } 151 | } 152 | } 153 | if (!flash_found && ael > 1) { 154 | for (var m = 0; m < ael; m++) { 155 | var flashVars = activeEmbeds[m].attributes.getNamedItem("flashVars").nodeValue; 156 | if (flashVars.indexOf(searchStr) >= 0) { 157 | FABridge.attachBridge(activeEmbeds[m], bridgeName); 158 | break; 159 | } 160 | } 161 | } 162 | } 163 | return true; 164 | } 165 | 166 | // used to track multiple bridge instances, since callbacks from AS are global across the page. 167 | 168 | FABridge.nextBridgeID = 0; 169 | FABridge.instances = {}; 170 | FABridge.idMap = {}; 171 | FABridge.refCount = 0; 172 | 173 | FABridge.extractBridgeFromID = function(id) 174 | { 175 | var bridgeID = (id >> 16); 176 | return FABridge.idMap[bridgeID]; 177 | } 178 | 179 | FABridge.attachBridge = function(instance, bridgeName) 180 | { 181 | var newBridgeInstance = new FABridge(instance, bridgeName); 182 | 183 | FABridge[bridgeName] = newBridgeInstance; 184 | 185 | /* FABridge[bridgeName] = function() { 186 | return newBridgeInstance.root(); 187 | } 188 | */ 189 | var callbacks = FABridge.initCallbacks[bridgeName]; 190 | if (callbacks == null) 191 | { 192 | return; 193 | } 194 | for (var i = 0; i < callbacks.length; i++) 195 | { 196 | callbacks[i].call(newBridgeInstance); 197 | } 198 | delete FABridge.initCallbacks[bridgeName] 199 | } 200 | 201 | // some methods can't be proxied. You can use the explicit get,set, and call methods if necessary. 202 | 203 | FABridge.blockedMethods = 204 | { 205 | toString: true, 206 | get: true, 207 | set: true, 208 | call: true 209 | }; 210 | 211 | FABridge.prototype = 212 | { 213 | 214 | 215 | // bootstrapping 216 | 217 | root: function() 218 | { 219 | return this.deserialize(this.target.getRoot()); 220 | }, 221 | //clears all of the AS objects in the cache maps 222 | releaseASObjects: function() 223 | { 224 | return this.target.releaseASObjects(); 225 | }, 226 | //clears a specific object in AS from the type maps 227 | releaseNamedASObject: function(value) 228 | { 229 | if(typeof(value) != "object") 230 | { 231 | return false; 232 | } 233 | else 234 | { 235 | var ret = this.target.releaseNamedASObject(value.fb_instance_id); 236 | return ret; 237 | } 238 | }, 239 | //create a new AS Object 240 | create: function(className) 241 | { 242 | return this.deserialize(this.target.create(className)); 243 | }, 244 | 245 | 246 | // utilities 247 | 248 | makeID: function(token) 249 | { 250 | return (this.bridgeID << 16) + token; 251 | }, 252 | 253 | 254 | // low level access to the flash object 255 | 256 | //get a named property from an AS object 257 | getPropertyFromAS: function(objRef, propName) 258 | { 259 | if (FABridge.refCount > 0) 260 | { 261 | throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround."); 262 | } 263 | else 264 | { 265 | FABridge.refCount++; 266 | retVal = this.target.getPropFromAS(objRef, propName); 267 | retVal = this.handleError(retVal); 268 | FABridge.refCount--; 269 | return retVal; 270 | } 271 | }, 272 | //set a named property on an AS object 273 | setPropertyInAS: function(objRef,propName, value) 274 | { 275 | if (FABridge.refCount > 0) 276 | { 277 | throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround."); 278 | } 279 | else 280 | { 281 | FABridge.refCount++; 282 | retVal = this.target.setPropInAS(objRef,propName, this.serialize(value)); 283 | retVal = this.handleError(retVal); 284 | FABridge.refCount--; 285 | return retVal; 286 | } 287 | }, 288 | 289 | //call an AS function 290 | callASFunction: function(funcID, args) 291 | { 292 | if (FABridge.refCount > 0) 293 | { 294 | throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround."); 295 | } 296 | else 297 | { 298 | FABridge.refCount++; 299 | retVal = this.target.invokeASFunction(funcID, this.serialize(args)); 300 | retVal = this.handleError(retVal); 301 | FABridge.refCount--; 302 | return retVal; 303 | } 304 | }, 305 | //call a method on an AS object 306 | callASMethod: function(objID, funcName, args) 307 | { 308 | if (FABridge.refCount > 0) 309 | { 310 | throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround."); 311 | } 312 | else 313 | { 314 | FABridge.refCount++; 315 | args = this.serialize(args); 316 | retVal = this.target.invokeASMethod(objID, funcName, args); 317 | retVal = this.handleError(retVal); 318 | FABridge.refCount--; 319 | return retVal; 320 | } 321 | }, 322 | 323 | // responders to remote calls from flash 324 | 325 | //callback from flash that executes a local JS function 326 | //used mostly when setting js functions as callbacks on events 327 | invokeLocalFunction: function(funcID, args) 328 | { 329 | var result; 330 | var func = this.localFunctionCache[funcID]; 331 | 332 | if(func != undefined) 333 | { 334 | result = this.serialize(func.apply(null, this.deserialize(args))); 335 | } 336 | 337 | return result; 338 | }, 339 | 340 | // Object Types and Proxies 341 | 342 | // accepts an object reference, returns a type object matching the obj reference. 343 | getTypeFromName: function(objTypeName) 344 | { 345 | return this.remoteTypeCache[objTypeName]; 346 | }, 347 | //create an AS proxy for the given object ID and type 348 | createProxy: function(objID, typeName) 349 | { 350 | var objType = this.getTypeFromName(typeName); 351 | instanceFactory.prototype = objType; 352 | var instance = new instanceFactory(objID); 353 | this.remoteInstanceCache[objID] = instance; 354 | return instance; 355 | }, 356 | //return the proxy associated with the given object ID 357 | getProxy: function(objID) 358 | { 359 | return this.remoteInstanceCache[objID]; 360 | }, 361 | 362 | // accepts a type structure, returns a constructed type 363 | addTypeDataToCache: function(typeData) 364 | { 365 | newType = new ASProxy(this, typeData.name); 366 | var accessors = typeData.accessors; 367 | for (var i = 0; i < accessors.length; i++) 368 | { 369 | this.addPropertyToType(newType, accessors[i]); 370 | } 371 | 372 | var methods = typeData.methods; 373 | for (var i = 0; i < methods.length; i++) 374 | { 375 | if (FABridge.blockedMethods[methods[i]] == undefined) 376 | { 377 | this.addMethodToType(newType, methods[i]); 378 | } 379 | } 380 | 381 | 382 | this.remoteTypeCache[newType.typeName] = newType; 383 | return newType; 384 | }, 385 | 386 | //add a property to a typename; used to define the properties that can be called on an AS proxied object 387 | addPropertyToType: function(ty, propName) 388 | { 389 | var c = propName.charAt(0); 390 | var setterName; 391 | var getterName; 392 | if(c >= "a" && c <= "z") 393 | { 394 | getterName = "get" + c.toUpperCase() + propName.substr(1); 395 | setterName = "set" + c.toUpperCase() + propName.substr(1); 396 | } 397 | else 398 | { 399 | getterName = "get" + propName; 400 | setterName = "set" + propName; 401 | } 402 | ty[setterName] = function(val) 403 | { 404 | this.bridge.setPropertyInAS(this.fb_instance_id, propName, val); 405 | } 406 | ty[getterName] = function() 407 | { 408 | return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id, propName)); 409 | } 410 | }, 411 | 412 | //add a method to a typename; used to define the methods that can be callefd on an AS proxied object 413 | addMethodToType: function(ty, methodName) 414 | { 415 | ty[methodName] = function() 416 | { 417 | return this.bridge.deserialize(this.bridge.callASMethod(this.fb_instance_id, methodName, FABridge.argsToArray(arguments))); 418 | } 419 | }, 420 | 421 | // Function Proxies 422 | 423 | //returns the AS proxy for the specified function ID 424 | getFunctionProxy: function(funcID) 425 | { 426 | var bridge = this; 427 | if (this.remoteFunctionCache[funcID] == null) 428 | { 429 | this.remoteFunctionCache[funcID] = function() 430 | { 431 | bridge.callASFunction(funcID, FABridge.argsToArray(arguments)); 432 | } 433 | } 434 | return this.remoteFunctionCache[funcID]; 435 | }, 436 | 437 | //reutrns the ID of the given function; if it doesnt exist it is created and added to the local cache 438 | getFunctionID: function(func) 439 | { 440 | if (func.__bridge_id__ == undefined) 441 | { 442 | func.__bridge_id__ = this.makeID(this.nextLocalFuncID++); 443 | this.localFunctionCache[func.__bridge_id__] = func; 444 | } 445 | return func.__bridge_id__; 446 | }, 447 | 448 | // serialization / deserialization 449 | 450 | serialize: function(value) 451 | { 452 | var result = {}; 453 | 454 | var t = typeof(value); 455 | //primitives are kept as such 456 | if (t == "number" || t == "string" || t == "boolean" || t == null || t == undefined) 457 | { 458 | result = value; 459 | } 460 | else if (value instanceof Array) 461 | { 462 | //arrays are serializesd recursively 463 | result = []; 464 | for (var i = 0; i < value.length; i++) 465 | { 466 | result[i] = this.serialize(value[i]); 467 | } 468 | } 469 | else if (t == "function") 470 | { 471 | //js functions are assigned an ID and stored in the local cache 472 | result.type = FABridge.TYPE_JSFUNCTION; 473 | result.value = this.getFunctionID(value); 474 | } 475 | else if (value instanceof ASProxy) 476 | { 477 | result.type = FABridge.TYPE_ASINSTANCE; 478 | result.value = value.fb_instance_id; 479 | } 480 | else 481 | { 482 | result.type = FABridge.TYPE_ANONYMOUS; 483 | result.value = value; 484 | } 485 | 486 | return result; 487 | }, 488 | 489 | //on deserialization we always check the return for the specific error code that is used to marshall NPE's into JS errors 490 | // the unpacking is done by returning the value on each pachet for objects/arrays 491 | deserialize: function(packedValue) 492 | { 493 | 494 | var result; 495 | 496 | var t = typeof(packedValue); 497 | if (t == "number" || t == "string" || t == "boolean" || packedValue == null || packedValue == undefined) 498 | { 499 | result = this.handleError(packedValue); 500 | } 501 | else if (packedValue instanceof Array) 502 | { 503 | result = []; 504 | for (var i = 0; i < packedValue.length; i++) 505 | { 506 | result[i] = this.deserialize(packedValue[i]); 507 | } 508 | } 509 | else if (t == "object") 510 | { 511 | for(var i = 0; i < packedValue.newTypes.length; i++) 512 | { 513 | this.addTypeDataToCache(packedValue.newTypes[i]); 514 | } 515 | for (var aRefID in packedValue.newRefs) 516 | { 517 | this.createProxy(aRefID, packedValue.newRefs[aRefID]); 518 | } 519 | if (packedValue.type == FABridge.TYPE_PRIMITIVE) 520 | { 521 | result = packedValue.value; 522 | } 523 | else if (packedValue.type == FABridge.TYPE_ASFUNCTION) 524 | { 525 | result = this.getFunctionProxy(packedValue.value); 526 | } 527 | else if (packedValue.type == FABridge.TYPE_ASINSTANCE) 528 | { 529 | result = this.getProxy(packedValue.value); 530 | } 531 | else if (packedValue.type == FABridge.TYPE_ANONYMOUS) 532 | { 533 | result = packedValue.value; 534 | } 535 | } 536 | return result; 537 | }, 538 | //increases the reference count for the given object 539 | addRef: function(obj) 540 | { 541 | this.target.incRef(obj.fb_instance_id); 542 | }, 543 | //decrease the reference count for the given object and release it if needed 544 | release:function(obj) 545 | { 546 | this.target.releaseRef(obj.fb_instance_id); 547 | }, 548 | 549 | // check the given value for the components of the hard-coded error code : __FLASHERROR 550 | // used to marshall NPE's into flash 551 | 552 | handleError: function(value) 553 | { 554 | if (typeof(value)=="string" && value.indexOf("__FLASHERROR")==0) 555 | { 556 | var myErrorMessage = value.split("||"); 557 | if(FABridge.refCount > 0 ) 558 | { 559 | FABridge.refCount--; 560 | } 561 | throw new Error(myErrorMessage[1]); 562 | return value; 563 | } 564 | else 565 | { 566 | return value; 567 | } 568 | } 569 | }; 570 | 571 | // The root ASProxy class that facades a flash object 572 | 573 | ASProxy = function(bridge, typeName) 574 | { 575 | this.bridge = bridge; 576 | this.typeName = typeName; 577 | return this; 578 | }; 579 | //methods available on each ASProxy object 580 | ASProxy.prototype = 581 | { 582 | get: function(propName) 583 | { 584 | return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id, propName)); 585 | }, 586 | 587 | set: function(propName, value) 588 | { 589 | this.bridge.setPropertyInAS(this.fb_instance_id, propName, value); 590 | }, 591 | 592 | call: function(funcName, args) 593 | { 594 | this.bridge.callASMethod(this.fb_instance_id, funcName, args); 595 | }, 596 | 597 | addRef: function() { 598 | this.bridge.addRef(this); 599 | }, 600 | 601 | release: function() { 602 | this.bridge.release(this); 603 | } 604 | }; 605 | -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/js/WebSocketMain.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portertech/nagios-dashboard/bb04eac57ebea4f657815b78a5d1d08c8948bb42/lib/nagios-dashboard/static/js/WebSocketMain.swf -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/js/nagios-dashboard.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function(){ 2 | function get_chef_attributes(hostname) { 3 | $.getJSON('node/'+hostname, function(attributes) { 4 | var roles = ''; 5 | $.each(attributes['automatic']['roles'], function() { 6 | roles += this + ' '; 7 | }); 8 | var ip_address = ''; 9 | if ("ec2" in attributes['automatic']) { 10 | ip_address = attributes['automatic']['ec2']['public_ipv4']; 11 | } else { 12 | ip_address = attributes['automatic']['ipaddress']; 13 | } 14 | $('.chef_attributes').html( 15 | 'Node Name:
'+attributes['name']+'

' 16 | +'Public IP:
'+ip_address+'

' 17 | +'Roles:
'+roles+'
' 18 | ); 19 | }); 20 | } 21 | ws = new WebSocket("ws://" + location.hostname + ":8000"); 22 | ws.onmessage = function(evt) { 23 | $("#messages").empty(); 24 | $("#popups_container").empty(); 25 | data = JSON.parse(evt.data); 26 | for(var msg in data) { 27 | var status = ''; 28 | if(data[msg]['status'] == 'CRITICAL') { 29 | status = "Critical"; 30 | } else { 31 | status = "Warning"; 32 | } 33 | var last_time_ok = new Date(data[msg]['last_time_ok'] * 1000); 34 | var last_check = new Date(data[msg]['last_check'] * 1000); 35 | $("#messages").append(''+data[msg]['host_name'] 36 | +''+data[msg]['plugin_output']+'
' 37 | +'
' 38 | +'
' 39 | +''+last_time_ok.toLocaleString() 40 | +''+last_check.toLocaleString()+''); 41 | var plugin_output = ''; 42 | if (data[msg]['long_plugin_output'] != '') { 43 | plugin_output = data[msg]['long_plugin_output']; 44 | } else { 45 | plugin_output = data[msg]['plugin_output']; 46 | } 47 | $("#popups_container").append(''); 52 | $("#link_"+msg).fancybox({ 53 | 'autoDimensions' : false, 54 | 'width' : 700, 55 | 'height' : 460, 56 | 'padding' : 5, 57 | 'title' : data[msg]['host_name'], 58 | 'transitionIn' : 'fade', 59 | 'transitionOut' : 'fade', 60 | 'onComplete' : function() { get_chef_attributes($("#fancybox-title-float-main").html()); }, 61 | 'onClosed' : function() { $('.chef_attributes').html('Querying Chef ...'); } 62 | }); 63 | }; 64 | }; 65 | }); 66 | -------------------------------------------------------------------------------- /lib/nagios-dashboard/static/js/swfobject.js: -------------------------------------------------------------------------------- 1 | /* SWFObject v2.2 2 | is released under the MIT License 3 | */ 4 | var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y0){for(var af=0;af0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad'}}aa.outerHTML='"+af+"";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab 2 | // Lincense: New BSD Lincense 3 | // Reference: http://dev.w3.org/html5/websockets/ 4 | // Reference: http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol 5 | 6 | (function() { 7 | 8 | if (window.WebSocket) return; 9 | 10 | var console = window.console; 11 | if (!console) console = {log: function(){ }, error: function(){ }}; 12 | 13 | function hasFlash() { 14 | if ('navigator' in window && 'plugins' in navigator && navigator.plugins['Shockwave Flash']) { 15 | return !!navigator.plugins['Shockwave Flash'].description; 16 | } 17 | if ('ActiveXObject' in window) { 18 | try { 19 | return !!new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version'); 20 | } catch (e) {} 21 | } 22 | return false; 23 | } 24 | 25 | if (!hasFlash()) { 26 | console.error("Flash Player is not installed."); 27 | return; 28 | } 29 | 30 | WebSocket = function(url, protocol, proxyHost, proxyPort, headers) { 31 | var self = this; 32 | self.readyState = WebSocket.CONNECTING; 33 | self.bufferedAmount = 0; 34 | WebSocket.__addTask(function() { 35 | self.__flash = 36 | WebSocket.__flash.create(url, protocol, proxyHost || null, proxyPort || 0, headers || null); 37 | 38 | self.__flash.addEventListener("open", function(fe) { 39 | try { 40 | if (self.onopen) self.onopen(); 41 | } catch (e) { 42 | console.error(e.toString()); 43 | } 44 | }); 45 | 46 | self.__flash.addEventListener("close", function(fe) { 47 | try { 48 | if (self.onclose) self.onclose(); 49 | } catch (e) { 50 | console.error(e.toString()); 51 | } 52 | }); 53 | 54 | self.__flash.addEventListener("message", function(fe) { 55 | var data = decodeURIComponent(fe.getData()); 56 | try { 57 | if (self.onmessage) { 58 | var e; 59 | if (window.MessageEvent) { 60 | e = document.createEvent("MessageEvent"); 61 | e.initMessageEvent("message", false, false, data, null, null, window); 62 | } else { // IE 63 | e = {data: data}; 64 | } 65 | self.onmessage(e); 66 | } 67 | } catch (e) { 68 | console.error(e.toString()); 69 | } 70 | }); 71 | 72 | self.__flash.addEventListener("stateChange", function(fe) { 73 | try { 74 | self.readyState = fe.getReadyState(); 75 | self.bufferedAmount = fe.getBufferedAmount(); 76 | } catch (e) { 77 | console.error(e.toString()); 78 | } 79 | }); 80 | 81 | //console.log("[WebSocket] Flash object is ready"); 82 | }); 83 | } 84 | 85 | WebSocket.prototype.send = function(data) { 86 | if (!this.__flash || this.readyState == WebSocket.CONNECTING) { 87 | throw "INVALID_STATE_ERR: Web Socket connection has not been established"; 88 | } 89 | var result = this.__flash.send(data); 90 | if (result < 0) { // success 91 | return true; 92 | } else { 93 | this.bufferedAmount = result; 94 | return false; 95 | } 96 | }; 97 | 98 | WebSocket.prototype.close = function() { 99 | if (!this.__flash) return; 100 | if (this.readyState != WebSocket.OPEN) return; 101 | this.__flash.close(); 102 | // Sets/calls them manually here because Flash WebSocketConnection.close cannot fire events 103 | // which causes weird error: 104 | // > You are trying to call recursively into the Flash Player which is not allowed. 105 | this.readyState = WebSocket.CLOSED; 106 | if (this.onclose) this.onclose(); 107 | }; 108 | 109 | /** 110 | * Implementation of {@link DOM 2 EventTarget Interface} 111 | * 112 | * @param {string} type 113 | * @param {function} listener 114 | * @param {boolean} useCapture !NB Not implemented yet 115 | * @return void 116 | */ 117 | WebSocket.prototype.addEventListener = function(type, listener, useCapture) { 118 | if (!('__events' in this)) { 119 | this.__events = {}; 120 | } 121 | if (!(type in this.__events)) { 122 | this.__events[type] = []; 123 | if ('function' == typeof this['on' + type]) { 124 | this.__events[type].defaultHandler = this['on' + type]; 125 | this['on' + type] = WebSocket_FireEvent(this, type); 126 | } 127 | } 128 | this.__events[type].push(listener); 129 | }; 130 | 131 | /** 132 | * Implementation of {@link DOM 2 EventTarget Interface} 133 | * 134 | * @param {string} type 135 | * @param {function} listener 136 | * @param {boolean} useCapture NB! Not implemented yet 137 | * @return void 138 | */ 139 | WebSocket.prototype.removeEventListener = function(type, listener, useCapture) { 140 | if (!('__events' in this)) { 141 | this.__events = {}; 142 | } 143 | if (!(type in this.__events)) return; 144 | for (var i = this.__events.length; i > -1; --i) { 145 | if (listener === this.__events[type][i]) { 146 | this.__events[type].splice(i, 1); 147 | break; 148 | } 149 | } 150 | }; 151 | 152 | /** 153 | * Implementation of {@link DOM 2 EventTarget Interface} 154 | * 155 | * @param {WebSocketEvent} event 156 | * @return void 157 | */ 158 | WebSocket.prototype.dispatchEvent = function(event) { 159 | if (!('__events' in this)) throw 'UNSPECIFIED_EVENT_TYPE_ERR'; 160 | if (!(event.type in this.__events)) throw 'UNSPECIFIED_EVENT_TYPE_ERR'; 161 | 162 | for (var i = 0, l = this.__events[event.type].length; i < l; ++ i) { 163 | this.__events[event.type][i](event); 164 | if (event.cancelBubble) break; 165 | } 166 | 167 | if (false !== event.returnValue && 168 | 'function' == typeof this.__events[event.type].defaultHandler) 169 | { 170 | this.__events[event.type].defaultHandler(event); 171 | } 172 | }; 173 | 174 | /** 175 | * 176 | * @param {object} object 177 | * @param {string} type 178 | */ 179 | function WebSocket_FireEvent(object, type) { 180 | return function(data) { 181 | var event = new WebSocketEvent(); 182 | event.initEvent(type, true, true); 183 | event.target = event.currentTarget = object; 184 | for (var key in data) { 185 | event[key] = data[key]; 186 | } 187 | object.dispatchEvent(event, arguments); 188 | }; 189 | } 190 | 191 | /** 192 | * Basic implementation of {@link DOM 2 EventInterface} 193 | * 194 | * @class 195 | * @constructor 196 | */ 197 | function WebSocketEvent(){} 198 | 199 | /** 200 | * 201 | * @type boolean 202 | */ 203 | WebSocketEvent.prototype.cancelable = true; 204 | 205 | /** 206 | * 207 | * @type boolean 208 | */ 209 | WebSocketEvent.prototype.cancelBubble = false; 210 | 211 | /** 212 | * 213 | * @return void 214 | */ 215 | WebSocketEvent.prototype.preventDefault = function() { 216 | if (this.cancelable) { 217 | this.returnValue = false; 218 | } 219 | }; 220 | 221 | /** 222 | * 223 | * @return void 224 | */ 225 | WebSocketEvent.prototype.stopPropagation = function() { 226 | this.cancelBubble = true; 227 | }; 228 | 229 | /** 230 | * 231 | * @param {string} eventTypeArg 232 | * @param {boolean} canBubbleArg 233 | * @param {boolean} cancelableArg 234 | * @return void 235 | */ 236 | WebSocketEvent.prototype.initEvent = function(eventTypeArg, canBubbleArg, cancelableArg) { 237 | this.type = eventTypeArg; 238 | this.cancelable = cancelableArg; 239 | this.timeStamp = new Date(); 240 | }; 241 | 242 | 243 | WebSocket.CONNECTING = 0; 244 | WebSocket.OPEN = 1; 245 | WebSocket.CLOSED = 2; 246 | 247 | WebSocket.__tasks = []; 248 | 249 | WebSocket.__initialize = function() { 250 | if (!WebSocket.__swfLocation) { 251 | //console.error("[WebSocket] set WebSocket.__swfLocation to location of WebSocketMain.swf"); 252 | //return; 253 | WebSocket.__swfLocation = "js/WebSocketMain.swf"; 254 | } 255 | var container = document.createElement("div"); 256 | container.id = "webSocketContainer"; 257 | // Puts the Flash out of the window. Note that we cannot use display: none or visibility: hidden 258 | // here because it prevents Flash from loading at least in IE. 259 | container.style.position = "absolute"; 260 | container.style.left = "-100px"; 261 | container.style.top = "-100px"; 262 | var holder = document.createElement("div"); 263 | holder.id = "webSocketFlash"; 264 | container.appendChild(holder); 265 | document.body.appendChild(container); 266 | swfobject.embedSWF( 267 | WebSocket.__swfLocation, "webSocketFlash", "8", "8", "9.0.0", 268 | null, {bridgeName: "webSocket"}, null, null, 269 | function(e) { 270 | if (!e.success) console.error("[WebSocket] swfobject.embedSWF failed"); 271 | } 272 | ); 273 | FABridge.addInitializationCallback("webSocket", function() { 274 | try { 275 | //console.log("[WebSocket] FABridge initializad"); 276 | WebSocket.__flash = FABridge.webSocket.root(); 277 | WebSocket.__flash.setCallerUrl(location.href); 278 | for (var i = 0; i < WebSocket.__tasks.length; ++i) { 279 | WebSocket.__tasks[i](); 280 | } 281 | WebSocket.__tasks = []; 282 | } catch (e) { 283 | console.error("[WebSocket] " + e.toString()); 284 | } 285 | }); 286 | }; 287 | 288 | WebSocket.__addTask = function(task) { 289 | if (WebSocket.__flash) { 290 | task(); 291 | } else { 292 | WebSocket.__tasks.push(task); 293 | } 294 | } 295 | 296 | // called from Flash 297 | function webSocketLog(message) { 298 | console.log(decodeURIComponent(message)); 299 | } 300 | 301 | // called from Flash 302 | function webSocketError(message) { 303 | console.error(decodeURIComponent(message)); 304 | } 305 | 306 | if (window.addEventListener) { 307 | window.addEventListener("load", WebSocket.__initialize, false); 308 | } else { 309 | window.attachEvent("onload", WebSocket.__initialize); 310 | } 311 | 312 | })(); 313 | -------------------------------------------------------------------------------- /lib/nagios-dashboard/version.rb: -------------------------------------------------------------------------------- 1 | module Nagios 2 | module Dashboard 3 | VERSION = "0.0.4" 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /lib/nagios-dashboard/views/dashboard.haml: -------------------------------------------------------------------------------- 1 | !!! Strict 2 | %html 3 | %head 4 | %title Nagios Dashboard 5 | %link(href='css/style.css' media='screen' rel='stylesheet' type='text/css') 6 | %link(href='fancybox/jquery.fancybox-1.3.4.css' media='screen' rel='stylesheet' type='text/css') 7 | %script(type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js') 8 | %script(type='text/javascript' src='js/swfobject.js') 9 | %script(type='text/javascript' src='js/FABridge.js') 10 | %script(type='text/javascript' src='js/web_socket.js') 11 | %script(type='text/javascript' src='js/nagios-dashboard.js') 12 | %script(type='text/javascript' src='fancybox/jquery.fancybox-1.3.4.pack.js') 13 | %body 14 | %div#MainContainer 15 | %h1 Dashboard 16 | %table 17 | %thead 18 | %tr 19 | %th Hostname 20 | %th Plugin Output 21 | %th Last Time OK 22 | %th Last Check 23 | %tbody#messages 24 | %div(id='popups_container' style='display: none;') 25 | -------------------------------------------------------------------------------- /nagios-dashboard.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | $:.push File.expand_path("../lib", __FILE__) 3 | require "nagios-dashboard/version" 4 | 5 | Gem::Specification.new do |s| 6 | s.name = "nagios-dashboard" 7 | s.version = Nagios::Dashboard::VERSION 8 | s.platform = Gem::Platform::RUBY 9 | s.authors = ["Sean Porter"] 10 | s.email = ["portertech@gmail.com"] 11 | s.homepage = "https://github.com/portertech/nagios-dashboard" 12 | s.summary = %q{A Nagios dashboard with OpsCode Chef integration.} 13 | s.description = %q{A Nagios dashboard with OpsCode Chef integration.} 14 | s.has_rdoc = false 15 | s.license = "MIT" 16 | 17 | s.rubyforge_project = "nagios-dashboard" 18 | 19 | s.add_development_dependency('bundler') 20 | 21 | s.add_dependency('mixlib-cli') 22 | s.add_dependency('mixlib-log') 23 | s.add_dependency('json') 24 | s.add_dependency('thin', '1.2.11') 25 | s.add_dependency('eventmachine') 26 | s.add_dependency('em-websocket') 27 | s.add_dependency('directory_watcher') 28 | s.add_dependency('nagios_analyzer') 29 | s.add_dependency('async_sinatra') 30 | s.add_dependency('haml') 31 | s.add_dependency('spice', '0.5.0') 32 | 33 | s.files = `git ls-files`.split("\n") 34 | s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") 35 | s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } 36 | s.require_paths = ["lib"] 37 | end 38 | --------------------------------------------------------------------------------