├── source
├── js
│ ├── chrome.coffee
│ ├── chrome-pipe.coffee
│ ├── command-parser.coffee
│ ├── commands
│ │ └── terminal
│ │ │ ├── eval.coffee
│ │ │ └── base.coffee
│ ├── background-page.coffee
│ ├── stream.coffee
│ ├── utils.coffee
│ └── terminal.coffee
└── css
│ └── chrome.scss
├── shared
├── app-icons
│ ├── icon.png
│ ├── icon-16x16.png
│ ├── icon-19x19.png
│ ├── icon-38x38.png
│ ├── icon-48x48.png
│ ├── icon-128x128.png
│ ├── icon-16x16-unsharp.png
│ ├── icon-19x19-unsharp.png
│ ├── icon-38x38-unsharp.png
│ ├── icon-48x48-unsharp.png
│ ├── icon-128x128-unsharp.png
│ └── size.rb
└── vendor
│ ├── selectorgadget
│ └── selectorgadget_combined.css
│ ├── underscore-min.js
│ └── jquery-min.js
├── spec
├── spec-helper.coffee
├── jasmine
│ ├── MIT.LICENSE
│ ├── jasmine.css
│ └── jasmine-html.js
├── utils-spec.coffee
├── SpecRunner.html
├── stream-spec.coffee
├── command-parser-spec.coffee
└── helpers
│ └── jquery-matchers.js
├── .gitignore
├── Gemfile
├── README.md
├── LICENSE
├── chrome
└── manifest.json
├── Gemfile.lock
└── Guardfile
/source/js/chrome.coffee:
--------------------------------------------------------------------------------
1 | ChromePipe.start()
--------------------------------------------------------------------------------
/shared/app-icons/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cantino/chrome_pipe/HEAD/shared/app-icons/icon.png
--------------------------------------------------------------------------------
/shared/app-icons/icon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cantino/chrome_pipe/HEAD/shared/app-icons/icon-16x16.png
--------------------------------------------------------------------------------
/shared/app-icons/icon-19x19.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cantino/chrome_pipe/HEAD/shared/app-icons/icon-19x19.png
--------------------------------------------------------------------------------
/shared/app-icons/icon-38x38.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cantino/chrome_pipe/HEAD/shared/app-icons/icon-38x38.png
--------------------------------------------------------------------------------
/shared/app-icons/icon-48x48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cantino/chrome_pipe/HEAD/shared/app-icons/icon-48x48.png
--------------------------------------------------------------------------------
/shared/app-icons/icon-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cantino/chrome_pipe/HEAD/shared/app-icons/icon-128x128.png
--------------------------------------------------------------------------------
/shared/app-icons/icon-16x16-unsharp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cantino/chrome_pipe/HEAD/shared/app-icons/icon-16x16-unsharp.png
--------------------------------------------------------------------------------
/shared/app-icons/icon-19x19-unsharp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cantino/chrome_pipe/HEAD/shared/app-icons/icon-19x19-unsharp.png
--------------------------------------------------------------------------------
/shared/app-icons/icon-38x38-unsharp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cantino/chrome_pipe/HEAD/shared/app-icons/icon-38x38-unsharp.png
--------------------------------------------------------------------------------
/shared/app-icons/icon-48x48-unsharp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cantino/chrome_pipe/HEAD/shared/app-icons/icon-48x48-unsharp.png
--------------------------------------------------------------------------------
/shared/app-icons/icon-128x128-unsharp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cantino/chrome_pipe/HEAD/shared/app-icons/icon-128x128-unsharp.png
--------------------------------------------------------------------------------
/shared/app-icons/size.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | [128, 48, 38, 19, 16].each do |size|
4 | system "convert -resize #{size}x#{size}! icon.png icon-#{size}x#{size}.png"
5 | system "convert -resize #{size}x#{size}! -unsharp 1.5x1+0.7+0.02 icon.png icon-#{size}x#{size}-unsharp.png"
6 | end
7 |
--------------------------------------------------------------------------------
/spec/spec-helper.coffee:
--------------------------------------------------------------------------------
1 | beforeEach ->
2 | $.fx.off = true
3 | jasmine.Clock.useMock()
4 |
5 | $.ajaxSettings.xhr = ->
6 | expect("you to mock all ajax, but your tests actually seem").toContain "an ajax call"
7 |
8 | afterEach ->
9 | $('#jasmine-content').empty()
10 | $('body').removeClass()
11 | jasmine.Clock.reset()
12 |
13 | # Clear any jQuery events
14 | $('body').off()
15 | $(document).off()
16 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2 | #
3 | # If you find yourself ignoring temporary files generated by your text editor
4 | # or operating system, you probably want to add a global ignore instead:
5 | # git config --global core.excludesfile '~/.gitignore_global'
6 |
7 | # Ignore bundler config.
8 | /.bundle
9 | .idea
10 | .DS_Store
11 | tmp
12 | .sass-cache
13 | compiled
14 | spec/compiled
15 | .ruby-gemset
16 | .ruby-version
17 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | # A sample Gemfile
2 | source "https://rubygems.org"
3 |
4 | group :development do
5 | gem 'guard', '2.0.5'
6 | gem 'coffee-script'
7 | gem 'sass'
8 | gem 'yui-compressor'
9 | gem 'uglifier'
10 | gem 'webrick'
11 |
12 | gem 'guard-coffeescript', '1.3.4', require: false # newer wasn't working as of December 27, 2014.
13 | gem 'guard-sass', require: false
14 | gem 'guard-shell', require: false
15 | gem 'guard-concat', github: 'makevoid/guard-concat', require: false
16 | end
17 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ChromePipe Extension
2 |
3 | ## An experiment in a JavaScript UNIXy terminal
4 |
5 | * Free in the [Chrome Store](https://chrome.google.com/webstore/detail/chromepipe/ikkdlidmhdbibjhhakdjcjeganhgbnmf)
6 | * [Exciting video!](https://vimeo.com/118090094)
7 |
8 | # Technologies
9 |
10 | * JavaScript
11 | * CoffeeScript
12 | * jQuery
13 | * SelectorGadget
14 |
15 | # Local Development
16 |
17 | ## Compiling
18 |
19 | Start by installing development dependencies with
20 |
21 | bundle
22 |
23 | and then run
24 |
25 | bundle exec guard
26 |
27 | ## Chrome Extension
28 |
29 | `guard` will automatically compile the chrome extension in `compiled/chrome-extension` and `compiled/chrome-extension.zip`. You can load this into Chrome by going to Extensions, then clicking "Developer mode", and then "Load unpacked extension..." and selecting the `compiled/chrome-extension` directory.
30 |
31 | ## Testing
32 |
33 | JavaScript and CoffeeScript is tested with [https://jasmine.github.io/](jasmine). With guard running,
34 | open _spec/SpecRunner.html_ in your browser to run the tests. (On a Mac, just do `open spec/SpecRunner.html`.)
35 |
--------------------------------------------------------------------------------
/spec/jasmine/MIT.LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2008-2011 Pivotal Labs
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 |
--------------------------------------------------------------------------------
/source/js/chrome-pipe.coffee:
--------------------------------------------------------------------------------
1 | class window.ChromePipe
2 | constructor: ->
3 |
4 | init: ->
5 | @listen document
6 |
7 | showTerminal: ->
8 | if @terminalWindow?
9 | @terminalWindow.show()
10 | @terminal.focus()
11 | else
12 | @terminalWindow = Utils.makeWindow
13 | height: '200px'
14 | animate: true
15 | closable: false
16 | css:
17 | left: 0
18 | right: 0
19 | bottom: 0
20 | width: "100%"
21 |
22 | @listen @terminalWindow.document
23 | Utils.load "terminal.js", callback: =>
24 | @terminal = new ChromePipe.Terminal(@terminalWindow, this)
25 | @terminal.focus()
26 |
27 | hideTerminal: -> @terminalWindow?.hide()
28 |
29 | terminalShown: -> @terminalWindow?.shown
30 |
31 | listen: (target) ->
32 | $(target).on "keydown", (e) =>
33 | if e.which == 84 && e.altKey
34 | e.preventDefault()
35 | if @terminalShown() then @hideTerminal() else @showTerminal()
36 |
37 | log: (args...) -> Utils.log args...
38 |
39 | # Class Methods
40 |
41 | @start: ->
42 | extension = new this()
43 | extension.init()
44 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2015, Andrew Cantino (Iteration Labs, LLC)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/spec/utils-spec.coffee:
--------------------------------------------------------------------------------
1 | describe "Utils", ->
2 | describe "not", ->
3 | it "returns the inverse of a function, as a function", ->
4 | expect(Utils.not(-> true)()).toEqual false
5 | expect(Utils.not(-> false)()).toEqual true
6 |
7 | describe "whenTrue", ->
8 | it "calls the callback when the condition returns true", ->
9 | result = false
10 | something = -> result
11 | callback = jasmine.createSpy("callback")
12 | Utils.whenTrue something, callback
13 | expect(callback).not.toHaveBeenCalled()
14 | result = true
15 | jasmine.Clock.tick(49)
16 | expect(callback).not.toHaveBeenCalled()
17 | jasmine.Clock.tick(2)
18 | expect(callback).toHaveBeenCalled()
19 |
20 | describe "escape", ->
21 | it "should escape HTML", ->
22 | expect(Utils.escape("hi & stuff")).toEqual "<strong>hi & stuff</strong>"
23 |
24 | describe "escapeAndLinkify", ->
25 | it "should make links clickable and escape HTML", ->
26 | expect(Utils.escapeAndLinkify("> http://google.com/foo/bar?a=b
\"")).toEqual "> http://google.com/foo/bar?a=b <br/>""
27 |
--------------------------------------------------------------------------------
/chrome/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "manifest_version": 2,
3 | "version": "0.1",
4 | "icons": { "16": "app-icons/icon-16x16-unsharp.png",
5 | "48": "app-icons/icon-48x48-unsharp.png",
6 | "128": "app-icons/icon-128x128.png" },
7 | "name": "ChromePipe",
8 | "homepage_url": "https://github.com/cantino/chrome_pipe",
9 | "description": "A Chrome extension experiment with JavaScript UNIXy pipes",
10 | "permissions": [
11 | "tabs", "storage", "clipboardRead", "clipboardWrite", "webNavigation", "http://*/*", "https://*/*"
12 | ],
13 | "content_scripts": [
14 | {
15 | "matches": ["https://*/*", "http://*/*"],
16 | "css": ["chrome.css"],
17 | "js": ["vendor/jquery-min.js", "vendor/underscore-min.js", "chrome.js"]
18 | }
19 | ],
20 | "background": {
21 | "scripts": [
22 | "vendor/jquery-min.js",
23 | "vendor/underscore-min.js",
24 | "vendor/coffee-script.js",
25 | "background-page.js"
26 | ]
27 | },
28 | "web_accessible_resources": [
29 | "chrome.css",
30 | "chrome.js",
31 | "terminal.js",
32 | "vendor/jquery-min.js",
33 | "vendor/coffee-script.js",
34 | "vendor/underscore-min.js",
35 | "vendor/selectorgadget/selectorgadget_combined.js",
36 | "vendor/selectorgadget/selectorgadget_combined.css"
37 | ]
38 | }
39 |
--------------------------------------------------------------------------------
/source/js/command-parser.coffee:
--------------------------------------------------------------------------------
1 | class window.CommandParser
2 | constructor: (fullCommandLine, env) ->
3 | @fullCommandLine = fullCommandLine
4 | @env = env
5 | @env.helpers ||= @helpers
6 | @errors = []
7 | @individualCommands = []
8 |
9 | parse: ->
10 | if @individualCommands.length == 0
11 | for line in @fullCommandLine.split(/\s*\|\s*/)
12 | firstSpace = line.indexOf(" ")
13 | if firstSpace != -1
14 | @individualCommands.push [line.slice(0, firstSpace), line.slice(firstSpace + 1)]
15 | else
16 | @individualCommands.push [line, ""]
17 | @individualCommands
18 |
19 | valid: ->
20 | @parse()
21 |
22 | for [command, args] in @individualCommands when !@env.bin[command]
23 | @errors.push "Unknown command '#{command}'"
24 |
25 | @errors.length == 0
26 |
27 | execute: ->
28 | @parse()
29 |
30 | stdin = null
31 | for [command, args] in @individualCommands
32 | cmdOpts = @env.bin[command]
33 | run = cmdOpts.run || (stdin, stdout) -> stdout.onReceiver -> stdout.senderClose()
34 | stdout = new ChromePipe.Stream("stdout for #{command}")
35 | run.call(@env.helpers, stdin, stdout, @env, args)
36 | stdin = stdout
37 |
38 | stdin
39 |
40 | helpers:
41 | argsOrStdin: (args, stdin, callback) ->
42 | if stdin
43 | stdin.receiveAll (rows) -> callback rows
44 | else
45 | callback args
46 |
47 | fail: (env, stdout, message) ->
48 | message = message.join(", ") if _.isArray(message)
49 | env.terminal.error message
50 | unless stdout.senderClosed
51 | if stdout.hasReceiver()
52 | stdout.senderClose()
53 | else
54 | stdout.onReceiver -> stdout.senderClose()
55 | "FAIL"
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GIT
2 | remote: git://github.com/makevoid/guard-concat.git
3 | revision: 1df9b385770a6fad125405cf9de5247c77df5e33
4 | specs:
5 | guard-concat (0.8.0)
6 | guard (>= 2.0)
7 |
8 | GEM
9 | remote: https://rubygems.org/
10 | specs:
11 | celluloid (0.16.0)
12 | timers (~> 4.0.0)
13 | coderay (1.1.0)
14 | coffee-script (2.2.0)
15 | coffee-script-source
16 | execjs
17 | coffee-script-source (1.6.3)
18 | execjs (2.0.2)
19 | ffi (1.9.6)
20 | formatador (0.2.5)
21 | guard (2.0.5)
22 | formatador (>= 0.2.4)
23 | listen (~> 2.0)
24 | lumberjack (~> 1.0)
25 | pry (>= 0.9.12)
26 | thor (>= 0.18.1)
27 | guard-coffeescript (1.3.4)
28 | coffee-script (>= 2.2.0)
29 | guard (>= 1.1.0)
30 | guard-sass (1.3.2)
31 | guard (>= 1.1.0)
32 | sass (>= 3.1)
33 | guard-shell (0.5.1)
34 | guard (>= 1.1.0)
35 | hitimes (1.2.2)
36 | listen (2.8.4)
37 | celluloid (>= 0.15.2)
38 | rb-fsevent (>= 0.9.3)
39 | rb-inotify (>= 0.9)
40 | lumberjack (1.0.9)
41 | method_source (0.8.2)
42 | multi_json (1.8.1)
43 | pry (0.10.1)
44 | coderay (~> 1.1.0)
45 | method_source (~> 0.8.1)
46 | slop (~> 3.4)
47 | rb-fsevent (0.9.4)
48 | rb-inotify (0.9.5)
49 | ffi (>= 0.5.0)
50 | sass (3.2.12)
51 | slop (3.6.0)
52 | thor (0.19.1)
53 | timers (4.0.1)
54 | hitimes
55 | uglifier (2.2.1)
56 | execjs (>= 0.3.0)
57 | multi_json (~> 1.0, >= 1.0.2)
58 | webrick (1.3.1)
59 | yui-compressor (0.12.0)
60 |
61 | PLATFORMS
62 | ruby
63 |
64 | DEPENDENCIES
65 | coffee-script
66 | guard (= 2.0.5)
67 | guard-coffeescript (= 1.3.4)
68 | guard-concat!
69 | guard-sass
70 | guard-shell
71 | sass
72 | uglifier
73 | webrick
74 | yui-compressor
75 |
--------------------------------------------------------------------------------
/source/js/commands/terminal/eval.coffee:
--------------------------------------------------------------------------------
1 | window.ChromePipe.Commands ||= {}
2 | window.ChromePipe.Commands.Terminal ||= {}
3 |
4 | $.extend window.ChromePipe.Commands.Terminal,
5 | eval:
6 | desc: "Run inline CoffeeScript"
7 | run: (stdin, stdout, env, args) ->
8 |
9 | evalAndEmit = (javascript, input, readyForMore) ->
10 | result = eval(javascript)
11 | result = result.split(/\n/) if _.isString(result)
12 | result = [result] unless _.isArray(result)
13 |
14 | if result.length > 0
15 | for line, index in result
16 | if index == result.length - 1 && readyForMore?
17 | stdout.send line, readyForMore
18 | else
19 | stdout.send line
20 | else
21 | readyForMore() if readyForMore?
22 |
23 | closed = false
24 | pendingCount = 0
25 | stdout.onReceiver ->
26 | if stdin
27 | stdin.onSenderClose ->
28 | closed = true
29 | stdout.senderClose() if pendingCount == 0
30 |
31 | stdin.receive (input, readyForMore) ->
32 | source = if args then args else input
33 | pendingCount += 1
34 | Utils.remote "coffeeCompile", { coffeescript: "return #{source}" }, (response) ->
35 | pendingCount -= 1
36 | try
37 | throw response.errors if response.errors
38 | evalAndEmit response.javascript, input, readyForMore
39 | stdout.senderClose() if closed && pendingCount == 0
40 | catch e
41 | env.helpers.fail(env, stdout, e)
42 | else if args
43 | Utils.remote "coffeeCompile", { coffeescript: "return #{args}" }, (response) ->
44 | try
45 | throw response.errors if response.errors
46 | evalAndEmit response.javascript
47 | stdout.senderClose()
48 | catch e
49 | env.helpers.fail(env, stdout, e)
50 | else
51 | env.helpers.fail(env, stdout, "args or stdin required")
--------------------------------------------------------------------------------
/source/css/chrome.scss:
--------------------------------------------------------------------------------
1 | div.chrome-pipe-wrapper {
2 | position: fixed;
3 | height: 0px;
4 | border-width: 0px;
5 | z-index: 999999999999;
6 | overflow: hidden;
7 | margin: 0;
8 | padding: 0;
9 | border-radius: 0;
10 | background-color: transparent;
11 |
12 | iframe {
13 | width: 100%;
14 | height: 500px;
15 | border-width: 0;
16 | opacity: 0.9;
17 | }
18 | }
19 |
20 | body.chrome-pipe-iframe {
21 | border-width: 0;
22 | padding: 0;
23 | margin: 0;
24 | background-color: #000;
25 | line-height: 16px;
26 |
27 | .close-window {
28 | position: absolute;
29 | right: 5px;
30 | top: 5px;
31 | cursor: pointer;
32 | display: block;
33 | color: white;
34 | }
35 |
36 | #terminal-app {
37 | color: #3AF540;
38 | font-family: "Courier New", Courier, monospace;
39 | padding: 10px;
40 | font-size: 14px;
41 |
42 | .prompt-wrapper {
43 | overflow: hidden;
44 |
45 | .prompt {
46 | float: left;
47 | margin: 0;
48 | margin-right: 8px;
49 | padding: 0;
50 | }
51 |
52 | textarea {
53 | width: 95%;
54 | background-color: transparent;
55 | border-width: 0;
56 | resize: none;
57 | outline: none;
58 | color: #3AF540;
59 | font-family: "Courier New", Courier, monospace;
60 | float: left;
61 | font-size: 14px;
62 | padding: 0;
63 | height: 17px;
64 | }
65 | }
66 |
67 | .history {
68 | max-height: 150px;
69 | overflow: auto;
70 |
71 | &::-webkit-scrollbar {
72 | display: none;
73 | }
74 |
75 | .item {
76 | line-height: 16px;
77 |
78 | a {
79 | color: #7ff218;
80 | }
81 |
82 | &.output {
83 | color: white;
84 | }
85 |
86 | &.error {
87 | color: #E73E33;
88 | }
89 |
90 | &.input {
91 | color: #3AF540;
92 | }
93 | }
94 | }
95 |
96 | .history-metadata {
97 | color: #888888;
98 | }
99 | }
100 | }
--------------------------------------------------------------------------------
/source/js/background-page.coffee:
--------------------------------------------------------------------------------
1 | class window.ChromePipeBackgroundPage
2 | memory: {}
3 |
4 | STORED_KEYS: ['commands']
5 |
6 | constructor: ->
7 | @listen()
8 | @updateMemory()
9 |
10 | updateMemory: (callback = null) ->
11 | @chromeStorageGet @STORED_KEYS, (answers) =>
12 | for key in @STORED_KEYS
13 | @memory[key] = answers[key] if key of answers
14 | callback?()
15 |
16 | chromeStorageGet: (variables, callback) ->
17 | chrome.storage.local.get variables, (answers) => callback?(answers)
18 |
19 | chromeStorageSet: (variables, callback) ->
20 | @memory[key] = value for key, value of variables
21 | chrome.storage.local.set variables, => callback?()
22 |
23 | listen: ->
24 | chrome.runtime.onMessage.addListener (request, sender, sendResponse) =>
25 | handler = =>
26 | Utils.log "Remote received from #{sender.tab.url} (#{sender.tab.incognito && 'incognito'}): #{JSON.stringify request}"
27 | switch request.command
28 | when 'copy'
29 | Utils.putInClipboard(request.payload.text)
30 | sendResponse()
31 | when 'paste'
32 | sendResponse(text: Utils.getFromClipboard())
33 | when 'coffeeCompile'
34 | try
35 | sendResponse(javascript: CoffeeScript.compile(request.payload.coffeescript))
36 | catch e
37 | sendResponse(errors: e)
38 | when 'getHistory'
39 | sendResponse(commands: @memory.commands || [])
40 | when 'recordCommand'
41 | @updateMemory =>
42 | @memory.commands ||= []
43 | @memory.commands.unshift(request.payload)
44 | @memory.commands = @memory.commands[0..50]
45 | @chromeStorageSet({ commands: @memory.commands }, -> sendResponse({}))
46 | else sendResponse(errors: "unknown command")
47 |
48 | setTimeout handler, 10
49 | true # Return true to indicate async message passing: http://developer.chrome.com/extensions/runtime#event-onMessage
50 |
51 | errorResponse: (callback, message) ->
52 | Utils.log message
53 | callback errors: [message]
54 |
55 | window.backgroundPage = new ChromePipeBackgroundPage()
--------------------------------------------------------------------------------
/spec/SpecRunner.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 | Jasmine Specs
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/source/js/stream.coffee:
--------------------------------------------------------------------------------
1 | class window.ChromePipe.Stream
2 | constructor: (name) ->
3 | @name = name
4 | @senderClosed = false
5 | @receiverClosed = false
6 |
7 | senderClose: ->
8 | throw "Cannot sender-close already sender-closed stream '#{@name}'" if @senderClosed
9 | throw "Cannot close stream not opened for read '#{@name}'" unless @receiveCallback
10 | Utils.log "Stream#<#{@name}> received senderClose"
11 | @senderClosed = true
12 | @onSenderCloseCallback?()
13 |
14 | receiverClose: ->
15 | throw "Cannot receiver-close already receiver-closed stream '#{@name}'" if @receiverClosed
16 | throw "Cannot close stream not opened for read '#{@name}'" unless @receiveCallback
17 | Utils.log "Stream#<#{@name}> received receiverClose"
18 | @receiverClosed = true
19 | @onReceiverCloseCallback?()
20 |
21 | onSenderClose: (callback) ->
22 | throw "Cannot bind more than one sender-close callback to '#{@name}'" if @onSenderCloseCallback
23 | @onSenderCloseCallback = callback
24 | @onSenderCloseCallback() if @senderClosed
25 |
26 | onReceiverClose: (callback) ->
27 | throw "Cannot bind more than one receiver-close callback to '#{@name}'" if @onReceiverCloseCallback
28 | @onReceiverCloseCallback = callback
29 | @onReceiverCloseCallback() if @receiverClosed
30 |
31 | onReceiver: (callback) ->
32 | throw "Cannot bind more than one receiver callback to '#{@name}'" if @onReceiverCallback
33 | @onReceiverCallback = callback
34 | @onReceiverCallback() if @receiveCallback
35 |
36 | hasReceiver: -> !!@onReceiverCallback
37 |
38 | send: (text, readyForMore = ->) ->
39 | throw "Cannot write to sender-closed stream '#{@name}'" if @senderClosed
40 | throw "Cannot write to stream not opened for read '#{@name}'" unless @receiveCallback
41 | throw "Cannot write to receiver-closed stream '#{@name}" if @receiverClosed
42 | Utils.log "Stream#<#{@name}> sent '#{text}'"
43 | @receiveCallback(text, readyForMore)
44 |
45 | receive: (callback) ->
46 | throw "Cannot bind more than one receive callback to '#{@name}'" if @receiveCallback
47 | @receiveCallback = callback
48 | @onReceiverCallback?()
49 |
50 | receiveAll: (callback) ->
51 | fullData = []
52 | @receive (text, readyForMore) ->
53 | fullData.push text
54 | readyForMore()
55 | @onSenderClose -> callback fullData
56 |
--------------------------------------------------------------------------------
/spec/stream-spec.coffee:
--------------------------------------------------------------------------------
1 | describe "Stream", ->
2 | stream = null
3 |
4 | beforeEach ->
5 | stream = new ChromePipe.Stream()
6 |
7 | describe "basic behavior", ->
8 | it "can handle a simple bind receive and then send", ->
9 | receivedText = null
10 | readyForMoreSpy = jasmine.createSpy()
11 | stream.receive (text, readyForMore) ->
12 | receivedText = text
13 | readyForMore()
14 | stream.onReceiver ->
15 | stream.send "hello!", readyForMoreSpy
16 | expect(receivedText).toEqual "hello!"
17 | expect(readyForMoreSpy).toHaveBeenCalled()
18 |
19 | it "can handle multiple steps with receive pulling more data when desired", ->
20 | receivedLines = []
21 | stream.onReceiver ->
22 | stream.send "hello 0", ->
23 | stream.send "hello 1", ->
24 | setTimeout ->
25 | stream.send "hello 2", ->
26 | stream.send "hello 3"
27 | stream.senderClose()
28 | , 10
29 |
30 | stream.receive (text, readyForMore) ->
31 | receivedLines.push text
32 | if receivedLines.length == 3
33 | setTimeout(readyForMore, 2)
34 | else
35 | readyForMore()
36 |
37 | expect(receivedLines).toEqual ["hello 0", "hello 1"]
38 |
39 | jasmine.Clock.tick(9)
40 |
41 | expect(receivedLines).toEqual ["hello 0", "hello 1"]
42 |
43 | jasmine.Clock.tick(1)
44 |
45 | expect(receivedLines).toEqual ["hello 0", "hello 1", "hello 2"]
46 |
47 | expect(stream.senderClosed).toBe false
48 | jasmine.Clock.tick(2)
49 | expect(stream.senderClosed).toBe true
50 |
51 | expect(receivedLines).toEqual ["hello 0", "hello 1", "hello 2", "hello 3"]
52 |
53 | describe "closing of streams", ->
54 | it "calls the callback on close", ->
55 | closeSpy = jasmine.createSpy()
56 | stream.onSenderClose closeSpy
57 | expect(closeSpy).not.toHaveBeenCalled()
58 | stream.receive (text, callback) -> callback()
59 | stream.onReceiver ->
60 | stream.senderClose()
61 | expect(closeSpy).toHaveBeenCalled()
62 |
63 | it "calls the callback when bound after close", ->
64 | stream.receive (text, callback) -> callback()
65 | stream.onReceiver ->
66 | stream.senderClose()
67 | closeSpy = jasmine.createSpy()
68 | stream.onSenderClose closeSpy
69 | expect(closeSpy).toHaveBeenCalled()
--------------------------------------------------------------------------------
/spec/command-parser-spec.coffee:
--------------------------------------------------------------------------------
1 | describe "CommandParser", ->
2 | env = parser = null
3 | beforeEach ->
4 | env = { terminal: {}, bin: {} }
5 |
6 | describe "parse", ->
7 | it "splits on pipes", ->
8 | parser = new CommandParser("something | something more foo", env)
9 | parser.parse()
10 | expect(parser.individualCommands).toEqual [["something", ""], ["something", "more foo"]]
11 |
12 | describe "valid", ->
13 | it "returns true when all commands are known", ->
14 | env.bin.something = {}
15 | env.bin.more = {}
16 | parser = new CommandParser("something | more", env)
17 | expect(parser.valid()).toBe true
18 | delete env.bin.more
19 | expect(parser.valid()).toBe false
20 |
21 | it "stores errors", ->
22 | env.bin.something = {}
23 | parser = new CommandParser("something | more foo bar", env)
24 | expect(parser.valid()).toBe false
25 | expect(parser.errors).toEqual ["Unknown command 'more'"]
26 |
27 | describe "execute", ->
28 | it "creates input and output streams and calls each command in a chain", ->
29 | stdin1 = stdin2 = stdout1 = stdout2 = null
30 | env.bin.something =
31 | run: (stdin, stdout) ->
32 | stdin1 = stdin
33 | stdout1 = stdout
34 | stdout.onReceiver -> stdout.senderClose()
35 | env.bin.more =
36 | run: (stdin, stdout) ->
37 | stdin2 = stdin
38 | stdout2 = stdout
39 | stdout.onReceiver -> stdout.senderClose()
40 | parser = new CommandParser("something | more", env)
41 | stdin3 = parser.execute()
42 | expect(stdin1).toEqual null
43 | expect(stdin2).toEqual stdout1
44 | expect(stdin3).toEqual stdout2
45 |
46 | it "sets the helpers as 'this' and provides an env", ->
47 | cmdThis = cmdEnv = null
48 | env.bin.something =
49 | run: (stdin, stdout, env) ->
50 | cmdThis = this
51 | cmdEnv = env
52 | parser = new CommandParser("something", env)
53 | stdin3 = parser.execute()
54 | expect(cmdThis).toEqual parser.helpers
55 | expect(cmdEnv).toEqual env
56 | expect(cmdEnv.helpers).toEqual parser.helpers
57 |
58 | describe "Some example command flows", ->
59 | runCommand = (command, callback) ->
60 | parser = new CommandParser(command, bin: ChromePipe.Commands.Terminal)
61 | expect(parser.valid()).toBe true
62 | stdin = parser.execute()
63 | output = []
64 | stdin.receive (text, readyForMore) ->
65 | console.log "got #{text}"
66 | output.push text
67 | readyForMore()
68 | stdin.onSenderClose ->
69 | console.log "closed"
70 | callback(output)
71 |
72 | beforeEach ->
73 | spyOn(Utils, 'remote').andCallFake (cmd, args, callback) -> callback(javascript: CoffeeScript.compile(args.coffeescript))
74 |
75 | describe "eval", ->
76 | it "works with data on input", ->
77 | runCommand "echo 2 | eval parseInt(input) + 2 | grep 4", (output) ->
78 | expect(output).toEqual ["4"]
79 | runCommand "eval [1,2,3] | eval input * 2", (output) ->
80 | expect(output).toEqual [2, 4, 6]
81 | runCommand "eval [1,2,3] | eval input * 2 | grep 4", (output) ->
82 | expect(output).toEqual ["4"]
83 |
84 | it "works with code on input", ->
85 | runCommand "echo 2 + 2 | eval", (output) ->
86 | expect(output).toEqual [4]
87 |
88 | it "compiles coffeescript and emits arrays as individual items", ->
89 | runCommand "eval [1,2,3] | eval ((i) -> i * i)(input) | collect | eval (i - 1 for i in input)", (output) ->
90 | expect(output).toEqual [0, 3, 8]
--------------------------------------------------------------------------------
/Guardfile:
--------------------------------------------------------------------------------
1 | # A Guardfile
2 | # More info at https://github.com/guard/guard#readme
3 |
4 | require 'uglifier'
5 | require 'yui/compressor'
6 | require 'fileutils'
7 |
8 | # Make the directory structure
9 |
10 | %w[combined js css targets].each do |path|
11 | FileUtils.mkdir_p File.join(File.dirname(__FILE__), 'compiled', path)
12 | end
13 |
14 | FileUtils.mkdir_p File.join(File.dirname(__FILE__), 'spec', 'compiled')
15 |
16 | # Specs
17 |
18 | guard 'coffeescript', :input => 'spec', :output => 'spec/compiled', :all_on_start => true
19 |
20 | # Core Code
21 |
22 | guard 'coffeescript', :input => 'source/js', :output => 'compiled/js', :all_on_start => true
23 | guard 'sass', :input => 'source/css', :output => 'compiled/css', :all_on_start => true, :line_numbers => true
24 |
25 | # Chrome Extension
26 |
27 | guard 'concat',
28 | :all_on_start => true,
29 | :type => "js",
30 | :files => %w(utils chrome-pipe chrome),
31 | :input_dir => "compiled/js",
32 | :output => "compiled/combined/chrome"
33 |
34 | guard 'concat',
35 | :all_on_start => true,
36 | :type => "js",
37 | :files => %w(utils background-page),
38 | :input_dir => "compiled/js",
39 | :output => "compiled/combined/background-page"
40 |
41 | guard 'concat',
42 | :all_on_start => true,
43 | :type => "js",
44 | :files => %w(stream terminal command-parser commands/terminal/*),
45 | :input_dir => "compiled/js",
46 | :output => "compiled/combined/terminal"
47 |
48 | guard 'concat',
49 | :all_on_start => true,
50 | :type => "css",
51 | :files => %w(chrome),
52 | :input_dir => "compiled/css",
53 | :output => "compiled/combined/chrome"
54 |
55 | # Specs
56 |
57 | guard 'concat',
58 | :all_on_start => true,
59 | :type => "js",
60 | :files => %w(utils chrome-pipe stream terminal command-parser commands/always/* commands/terminal/*),
61 | :input_dir => "compiled/js",
62 | :output => "compiled/combined/specs"
63 |
64 | guard 'concat',
65 | :all_on_start => true,
66 | :type => "css",
67 | :files => %w(chrome),
68 | :input_dir => "compiled/css",
69 | :output => "compiled/combined/specs"
70 |
71 | guard :shell, :all_on_start => true do
72 | watch %r{compiled/combined/(.+?)\.js$} do |m|
73 | puts "Compressing #{m[1]}"
74 | File.open("compiled/targets/#{m[1]}.js", 'w') do |file|
75 | file.print Uglifier.compile(File.read(m[0]))
76 | end
77 | end
78 | end
79 |
80 | last_compile = nil
81 | Thread.abort_on_exception = true
82 |
83 | guard :shell, :all_on_start => true do
84 | watch %r{compiled/targets/(chrome|background-page|terminal)\.(css|js)$} do |m|
85 | if last_compile.nil? || last_compile < Time.now - 8
86 | last_compile = Time.now
87 | puts "Building Chrome (#{m[0]})"
88 | Thread.new do
89 | sleep 3
90 | puts "Chrome extension building..."
91 | FileUtils.mkdir_p "compiled/chrome-extension"
92 | system "rm -rf compiled/chrome-extension/*"
93 |
94 | FileUtils.cp "compiled/combined/chrome.css", "compiled/chrome-extension/chrome.css"
95 | FileUtils.cp "compiled/targets/chrome.js", "compiled/chrome-extension/chrome.js"
96 | FileUtils.cp "compiled/targets/terminal.js", "compiled/chrome-extension/terminal.js"
97 | FileUtils.cp "compiled/targets/background-page.js", "compiled/chrome-extension/background-page.js"
98 |
99 | FileUtils.cp_r %w[chrome/manifest.json], "compiled/chrome-extension"
100 |
101 | FileUtils.cp_r %w[shared/app-icons shared/vendor], "compiled/chrome-extension"
102 |
103 | FileUtils.rm_f "compiled/chrome-extension.zip"
104 | system "zip -r compiled/chrome-extension.zip compiled/chrome-extension"
105 | puts "Chrome extension built!"
106 | end
107 | end
108 | end
109 | end
110 |
--------------------------------------------------------------------------------
/spec/helpers/jquery-matchers.js:
--------------------------------------------------------------------------------
1 | // This is Wojciech's jasmine-jquery library without the fixtures. See https://github.com/velesin/jasmine-jquery
2 |
3 | // Copyright (c) 2010 Wojciech Zawistowski
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining
6 | // a copy of this software and associated documentation files (the
7 | // "Software"), to deal in the Software without restriction, including
8 | // without limitation the rights to use, copy, modify, merge, publish,
9 | // distribute, sublicense, and/or sell copies of the Software, and to
10 | // permit persons to whom the Software is furnished to do so, subject to
11 | // the following conditions:
12 | //
13 | // The above copyright notice and this permission notice shall be
14 | // included in all copies or substantial portions of the Software.
15 | //
16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 |
24 | jasmine.JQuery = function() {};
25 |
26 | jasmine.JQuery.browserTagCaseIndependentHtml = function(html) {
27 | return $('').append(html).html();
28 | };
29 |
30 | jasmine.JQuery.elementToString = function(element) {
31 | return $('').append(element.clone()).html();
32 | };
33 |
34 | jasmine.JQuery.matchersClass = {};
35 |
36 | (function(){
37 | var jQueryMatchers = {
38 | toHaveClass: function(className) {
39 | return this.actual.hasClass(className);
40 | },
41 |
42 | toBeVisible: function() {
43 | return this.actual.is(':visible');
44 | },
45 |
46 | toBeHidden: function() {
47 | return this.actual.is(':hidden');
48 | },
49 |
50 | toBeSelected: function() {
51 | return this.actual.is(':selected');
52 | },
53 |
54 | toBeChecked: function() {
55 | return this.actual.is(':checked');
56 | },
57 |
58 | toBeEmpty: function() {
59 | return this.actual.is(':empty');
60 | },
61 |
62 | toExist: function() {
63 | return this.actual.size() > 0;
64 | },
65 |
66 | toHaveAttr: function(attributeName, expectedAttributeValue) {
67 | return hasProperty(this.actual.attr(attributeName), expectedAttributeValue);
68 | },
69 |
70 | toHaveProp: function(attributeName, expectedAttributeValue) {
71 | return hasProperty(this.actual.prop(attributeName), expectedAttributeValue);
72 | },
73 |
74 | toHaveId: function(id) {
75 | return this.actual.attr('id') == id;
76 | },
77 |
78 | toHaveHtml: function(html) {
79 | return this.actual.html() == jasmine.JQuery.browserTagCaseIndependentHtml(html);
80 | },
81 |
82 | toHaveText: function(text) {
83 | return this.actual.text() == text;
84 | },
85 |
86 | toHaveValue: function(value) {
87 | return this.actual.val() == value;
88 | },
89 |
90 | toHaveData: function(key, expectedValue) {
91 | return hasProperty(this.actual.data(key), expectedValue);
92 | },
93 |
94 | toBe: function(selector) {
95 | return this.actual.is(selector);
96 | },
97 |
98 | toContain: function(selector) {
99 | return this.actual.find(selector).size() > 0;
100 | }
101 | };
102 |
103 | var hasProperty = function(actualValue, expectedValue) {
104 | if (expectedValue === undefined) {
105 | return actualValue !== undefined;
106 | }
107 | return actualValue == expectedValue;
108 | };
109 |
110 | var bindMatcher = function(methodName) {
111 | var builtInMatcher = jasmine.Matchers.prototype[methodName];
112 |
113 | jasmine.JQuery.matchersClass[methodName] = function() {
114 | if (this.actual instanceof jQuery) {
115 | var result = jQueryMatchers[methodName].apply(this, arguments);
116 | this.actual = jasmine.JQuery.elementToString(this.actual);
117 | return result;
118 | }
119 |
120 | if (builtInMatcher) {
121 | return builtInMatcher.apply(this, arguments);
122 | } else {
123 | throw ("There is no " + methodName + " method on this object. Did you forget a $ jQuery call in your expect?"); // Added to help debugging.
124 | }
125 |
126 | return false;
127 | };
128 | };
129 |
130 | for(var methodName in jQueryMatchers) {
131 | bindMatcher(methodName);
132 | }
133 | })();
134 |
135 | beforeEach(function() {
136 | this.addMatchers(jasmine.JQuery.matchersClass);
137 | });
138 |
--------------------------------------------------------------------------------
/source/js/utils.coffee:
--------------------------------------------------------------------------------
1 | window.Utils =
2 | attachElement: (elem, target = null) ->
3 | head = target || document.getElementsByTagName('head')[0]
4 | if head
5 | head.appendChild elem
6 | else
7 | document.body.appendChild elem
8 |
9 | loadScript: (src, opts = {}) ->
10 | script = document.createElement('SCRIPT')
11 | script.setAttribute('type', 'text/javascript');
12 | script.setAttribute('src', @forChrome(src + (if opts.reload then "?r=#{Math.random()}" else "")));
13 | @attachElement script
14 | @whenTrue((-> window[opts.loads]?), opts.then) if opts.loads? && opts.then?
15 |
16 | loadCSS: (href, opts = {}) ->
17 | link = document.createElement('LINK')
18 | link.setAttribute('rel', 'stylesheet')
19 | link.setAttribute('href', @forChrome(href))
20 | link.setAttribute('type', 'text/css')
21 | link.setAttribute('media', opts.media || 'all')
22 | @attachElement link, opts.target
23 |
24 | forChrome: (path) ->
25 | if path.match(/^http/i) then path else chrome?.extension?.getURL(path)
26 |
27 | afterRender: (callback) ->
28 | c = =>
29 | try
30 | callback.call(@)
31 | catch e
32 | Utils.log("Exception in afterRender", e, e?.stack)
33 |
34 | window.setTimeout c, 1
35 |
36 | log: (s...) -> console.log?("ChromePipe: ", s...) if typeof console != 'undefined'
37 |
38 | reload: (e = null) ->
39 | e.preventDefault() if e
40 | window.location.reload()
41 |
42 | newWindow: (url) -> window.open(url, '_blank')
43 |
44 | redirectTo: (url) -> window.location.href = url
45 |
46 | alert: (message) -> alert message
47 |
48 | urlMatches: (pattern) -> @location()?.match(pattern)
49 |
50 | location: -> window.location?.href
51 |
52 | title: -> $.trim $("title").text()
53 |
54 | domain: -> window.location?.origin?.replace(/^https?:\/\//i, '')
55 |
56 | load: (path, opts = {}) ->
57 | @pathCache ||= {}
58 |
59 | if @pathCache[path]
60 | opts.callback?()
61 | else
62 | @pathCache[path] = true
63 | xhr = new XMLHttpRequest()
64 | xhr.open("GET", chrome.extension.getURL(path), true)
65 | xhr.onreadystatechange = (e) ->
66 | if xhr.readyState == 4 && xhr.status == 200
67 | if opts.exports
68 | module = {}
69 | eval "(function() { " + xhr.responseText + " })();"
70 | window[opts.exports] = module.exports
71 | else
72 | eval xhr.responseText
73 | opts.callback?()
74 | xhr.send(null)
75 |
76 | whenTrue: (condition, callback) ->
77 | go = =>
78 | if condition()
79 | callback()
80 | else
81 | setTimeout go, 50
82 | go()
83 |
84 | not: (func) -> return -> !func()
85 |
86 | putInClipboard: (text) ->
87 | $elem = $('')
88 | $('body').append($elem)
89 | $elem.text(text).select()
90 | document.execCommand("copy", true)
91 | $elem.remove()
92 |
93 | getFromClipboard: ->
94 | pasteTarget = document.createElement("div");
95 | pasteTarget.contentEditable = true;
96 | actElem = document.activeElement.appendChild(pasteTarget).parentNode
97 | pasteTarget.focus()
98 | document.execCommand("Paste", null, null)
99 | paste = pasteTarget.innerText
100 | actElem.removeChild(pasteTarget)
101 | paste
102 |
103 | remote: (command, payload, callback = ->) ->
104 | chrome.runtime.sendMessage { command: command, payload: payload }, (response) -> callback response
105 |
106 | escape: (text) ->
107 | entityMap =
108 | "&": "&"
109 | "<": "<"
110 | ">": ">"
111 | '"': '"'
112 | "'": '''
113 |
114 | String(text).replace(/[&<>"']/g, (s) -> entityMap[s] )
115 |
116 | escapeAndLinkify: (text) ->
117 | @escape(text).replace(/https?:\/\/[^\s]+/i, (s) -> "#{s}")
118 |
119 | truncate: (text, length) ->
120 | if text.length > length - 3
121 | text.slice(0, length - 3) + "..."
122 | else
123 | text
124 |
125 | makeWindow: (options = {}) ->
126 | $wrapper = $("")
127 | $("body").append $wrapper
128 | $wrapper.css(options.css) if options.css?
129 | $iframe = $wrapper.find("iframe")
130 | iframeDocument = $iframe.contents()
131 |
132 | win =
133 | shown: true
134 | height: options.height || '500px'
135 | $wrapper: $wrapper
136 | $iframe: $iframe
137 | document: iframeDocument
138 | $body: iframeDocument.find("body")
139 | $head: iframeDocument.find("head")
140 |
141 | hide: ->
142 | @shown = false
143 | if options.animate
144 | @$wrapper.animate { height: '0px' }, 150, =>
145 | @$wrapper.hide()
146 | else
147 | @$wrapper.hide()
148 |
149 | show: ->
150 | @shown = true
151 | if options.animate
152 | @$wrapper.css('height', '0px').show()
153 | @$wrapper.animate({ height: @height }, 150)
154 | else
155 | @$wrapper.css('height', @height).show()
156 |
157 | close: ->
158 | if options.animate
159 | @$wrapper.animate { height: '0px' }, 150, =>
160 | @$wrapper.remove()
161 | else
162 | @$wrapper.remove()
163 |
164 | win.$body.addClass('chrome-pipe-iframe')
165 | Utils.loadCSS "chrome.css", target: win.$head.get(0)
166 |
167 | unless options.closable == false
168 | $("✕
").appendTo(win.$body).on 'click', ->
169 | options.onClose?()
170 | win.close()
171 |
172 | win.$iframe.css('height', win.height)
173 | win.show()
174 |
175 | win
--------------------------------------------------------------------------------
/spec/jasmine/jasmine.css:
--------------------------------------------------------------------------------
1 | body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
2 |
3 | #HTMLReporter { font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; }
4 | #HTMLReporter a { text-decoration: none; }
5 | #HTMLReporter a:hover { text-decoration: underline; }
6 | #HTMLReporter p, #HTMLReporter h1, #HTMLReporter h2, #HTMLReporter h3, #HTMLReporter h4, #HTMLReporter h5, #HTMLReporter h6 { margin: 0; line-height: 14px; }
7 | #HTMLReporter .banner, #HTMLReporter .symbolSummary, #HTMLReporter .summary, #HTMLReporter .resultMessage, #HTMLReporter .specDetail .description, #HTMLReporter .alert .bar, #HTMLReporter .stackTrace { padding-left: 9px; padding-right: 9px; }
8 | /*#HTMLReporter #jasmine_content { position: fixed; right: 100%; }*/
9 | #HTMLReporter .version { color: #aaaaaa; }
10 | #HTMLReporter .banner { margin-top: 14px; }
11 | #HTMLReporter .duration { color: #aaaaaa; float: right; }
12 | #HTMLReporter .symbolSummary { overflow: hidden; *zoom: 1; margin: 14px 0; }
13 | #HTMLReporter .symbolSummary li { display: block; float: left; height: 7px; width: 14px; margin-bottom: 7px; font-size: 16px; }
14 | #HTMLReporter .symbolSummary li.passed { font-size: 14px; }
15 | #HTMLReporter .symbolSummary li.passed:before { color: #5e7d00; content: "\02022"; }
16 | #HTMLReporter .symbolSummary li.failed { line-height: 9px; }
17 | #HTMLReporter .symbolSummary li.failed:before { color: #b03911; content: "x"; font-weight: bold; margin-left: -1px; }
18 | #HTMLReporter .symbolSummary li.skipped { font-size: 14px; }
19 | #HTMLReporter .symbolSummary li.skipped:before { color: #bababa; content: "\02022"; }
20 | #HTMLReporter .symbolSummary li.pending { line-height: 11px; }
21 | #HTMLReporter .symbolSummary li.pending:before { color: #aaaaaa; content: "-"; }
22 | #HTMLReporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
23 | #HTMLReporter .runningAlert { background-color: #666666; }
24 | #HTMLReporter .skippedAlert { background-color: #aaaaaa; }
25 | #HTMLReporter .skippedAlert:first-child { background-color: #333333; }
26 | #HTMLReporter .skippedAlert:hover { text-decoration: none; color: white; text-decoration: underline; }
27 | #HTMLReporter .passingAlert { background-color: #a6b779; }
28 | #HTMLReporter .passingAlert:first-child { background-color: #5e7d00; }
29 | #HTMLReporter .failingAlert { background-color: #cf867e; }
30 | #HTMLReporter .failingAlert:first-child { background-color: #b03911; }
31 | #HTMLReporter .results { margin-top: 14px; }
32 | #HTMLReporter #details { display: none; }
33 | #HTMLReporter .resultsMenu, #HTMLReporter .resultsMenu a { background-color: #fff; color: #333333; }
34 | #HTMLReporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
35 | #HTMLReporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
36 | #HTMLReporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
37 | #HTMLReporter.showDetails .summary { display: none; }
38 | #HTMLReporter.showDetails #details { display: block; }
39 | #HTMLReporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
40 | #HTMLReporter .summary { margin-top: 14px; }
41 | #HTMLReporter .summary .suite .suite, #HTMLReporter .summary .specSummary { margin-left: 14px; }
42 | #HTMLReporter .summary .specSummary.passed a { color: #5e7d00; }
43 | #HTMLReporter .summary .specSummary.failed a { color: #b03911; }
44 | #HTMLReporter .description + .suite { margin-top: 0; }
45 | #HTMLReporter .suite { margin-top: 14px; }
46 | #HTMLReporter .suite a { color: #333333; }
47 | #HTMLReporter #details .specDetail { margin-bottom: 28px; }
48 | #HTMLReporter #details .specDetail .description { display: block; color: white; background-color: #b03911; }
49 | #HTMLReporter .resultMessage { padding-top: 14px; color: #333333; }
50 | #HTMLReporter .resultMessage span.result { display: block; }
51 | #HTMLReporter .stackTrace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
52 |
53 | #TrivialReporter { padding: 8px 13px; position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow-y: scroll; background-color: white; font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; /*.resultMessage {*/ /*white-space: pre;*/ /*}*/ }
54 | #TrivialReporter a:visited, #TrivialReporter a { color: #303; }
55 | #TrivialReporter a:hover, #TrivialReporter a:active { color: blue; }
56 | #TrivialReporter .run_spec { float: right; padding-right: 5px; font-size: .8em; text-decoration: none; }
57 | #TrivialReporter .banner { color: #303; background-color: #fef; padding: 5px; }
58 | #TrivialReporter .logo { float: left; font-size: 1.1em; padding-left: 5px; }
59 | #TrivialReporter .logo .version { font-size: .6em; padding-left: 1em; }
60 | #TrivialReporter .runner.running { background-color: yellow; }
61 | #TrivialReporter .options { text-align: right; font-size: .8em; }
62 | #TrivialReporter .suite { border: 1px outset gray; margin: 5px 0; padding-left: 1em; }
63 | #TrivialReporter .suite .suite { margin: 5px; }
64 | #TrivialReporter .suite.passed { background-color: #dfd; }
65 | #TrivialReporter .suite.failed { background-color: #fdd; }
66 | #TrivialReporter .spec { margin: 5px; padding-left: 1em; clear: both; }
67 | #TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped { padding-bottom: 5px; border: 1px solid gray; }
68 | #TrivialReporter .spec.failed { background-color: #fbb; border-color: red; }
69 | #TrivialReporter .spec.passed { background-color: #bfb; border-color: green; }
70 | #TrivialReporter .spec.skipped { background-color: #bbb; }
71 | #TrivialReporter .messages { border-left: 1px dashed gray; padding-left: 1em; padding-right: 1em; }
72 | #TrivialReporter .passed { background-color: #cfc; display: none; }
73 | #TrivialReporter .failed { background-color: #fbb; }
74 | #TrivialReporter .skipped { color: #777; background-color: #eee; display: none; }
75 | #TrivialReporter .resultMessage span.result { display: block; line-height: 2em; color: black; }
76 | #TrivialReporter .resultMessage .mismatch { color: black; }
77 | #TrivialReporter .stackTrace { white-space: pre; font-size: .8em; margin-left: 10px; max-height: 5em; overflow: auto; border: 1px inset red; padding: 1em; background: #eef; }
78 | #TrivialReporter .finished-at { padding-left: 1em; font-size: .6em; }
79 | #TrivialReporter.show-passed .passed, #TrivialReporter.show-skipped .skipped { display: block; }
80 | /*#TrivialReporter #jasmine_content { position: fixed; right: 100%; }*/
81 | #TrivialReporter .runner { border: 1px solid gray; display: block; margin: 5px 0; padding: 2px 0 2px 10px; }
82 |
--------------------------------------------------------------------------------
/source/js/terminal.coffee:
--------------------------------------------------------------------------------
1 | class window.ChromePipe.Terminal
2 | MAX_OUTPUT_BUFFER: 1024
3 |
4 | constructor: (win, ChromePipe, options = {}) ->
5 | @win = win
6 | @ChromePipe = ChromePipe
7 | @$body = win.$body
8 | @$body.append """
9 |
10 |
11 |
12 | $
13 |
14 |
15 |
16 |
17 | """
18 | @$history = @$body.find(".history")
19 | @$historyMetadata = @$body.find(".history-metadata")
20 | @history = []
21 | @partialCmd = ''
22 | @lastAutocompleteIndex = 0
23 | @lastAutocompletePrefix = null
24 | @$textarea = @$body.find("textarea")
25 | @setupBin()
26 | @setupNewTerminalSession()
27 | @initInput()
28 |
29 | setupBin: ->
30 | @bin = _.chain({})
31 | .extend(ChromePipe.Commands.Terminal)
32 | .reduce(((memo, value, key) -> memo[key] = value if value.run ; memo), {})
33 | .value()
34 |
35 | setupNewTerminalSession: ->
36 | @remote 'getHistory', {}, (response) =>
37 | unless @history.length
38 | @history.unshift(command: command.command, output: command.output.split("\n")) for command in response.commands
39 | @historyIndex = @history.length
40 |
41 | hidePrompt: ->
42 | @$body.find(".prompt, textarea").hide()
43 |
44 | showPrompt: ->
45 | @$body.find(".prompt, textarea").show().focus()
46 |
47 | focus: ->
48 | @$textarea.focus()
49 |
50 | showHistory: (change) ->
51 | if change == 'up'
52 | @partialCmd = @val() if @historyIndex == @history.length
53 | @historyIndex -= 1
54 | @historyIndex = 0 if @historyIndex < 0
55 | if @history[@historyIndex]
56 | @$textarea.val(@history[@historyIndex].command)
57 | @historyPreview(@history[@historyIndex].output, @history.length - @historyIndex)
58 | else
59 | @historyIndex += 1
60 | if @historyIndex == @history.length
61 | @$textarea.val @partialCmd
62 | @historyPreview(null)
63 | else if @historyIndex > @history.length
64 | @historyIndex = @history.length
65 | else
66 | if @history[@historyIndex]
67 | @$textarea.val(@history[@historyIndex].command)
68 | @historyPreview(@history[@historyIndex].output, @history.length - @historyIndex)
69 |
70 | clearInput: ->
71 | @partialCmd = ''
72 | @historyIndex = @history.length
73 | @historyPreview(null)
74 | @val('')
75 |
76 | initInput: ->
77 | # @$body.on "click", => @$textarea.focus()
78 |
79 | @$textarea.on "keydown", (e) =>
80 | propagate = false
81 | autocompleteIndex = 0
82 | autocompletePrefix = null
83 |
84 | if e.which == 13 # return
85 | @process()
86 | else if e.which == 38 # up arrow
87 | @showHistory 'up'
88 | else if e.which == 40 # down arrow
89 | @showHistory 'down'
90 | else if e.which == 37 || e.which == 39 # left and right arrows
91 | propagate = true
92 | else if e.which == 9 # TAB
93 | val = @val()
94 | tokens = val.split(/[^a-zA-Z0-9_-]+/)
95 | lastToken = tokens[tokens.length - 1]
96 | rest = val.slice(0, val.length - lastToken.length)
97 | if lastToken.length > 0
98 | lastToken = @lastAutocompletePrefix if @lastAutocompletePrefix
99 | autocompletePrefix = lastToken
100 | matches = (key for key of @bin when key.indexOf(lastToken) == 0)
101 | if matches.length > 0
102 | @val rest + matches[@lastAutocompleteIndex % matches.length]
103 | autocompleteIndex = @lastAutocompleteIndex + 1
104 | else if e.which == 27 # ESC
105 | if @val() then @clearInput() else @hide()
106 | else
107 | propagate = true
108 | @historyPreview(null)
109 | @historyIndex = @history.length
110 |
111 | @lastAutocompleteIndex = autocompleteIndex
112 | @lastAutocompletePrefix = autocompletePrefix
113 | e.preventDefault() unless propagate
114 |
115 | val: (newVal) ->
116 | if newVal?
117 | @$textarea.val(newVal)
118 | else
119 | $.trim(@$textarea.val())
120 |
121 | historyPreview: (output, index = 1) ->
122 | if output
123 | @$historyMetadata.html("output##{index}: " + Utils.escapeAndLinkify(Utils.truncate(output.join(", "), 100))).show()
124 | else
125 | @$historyMetadata.hide()
126 |
127 | process: ->
128 | text = @val()
129 | if text
130 | @write "$ " + text, 'input'
131 | @clearInput()
132 |
133 | env =
134 | terminal: this
135 | onCommandFinish: []
136 | bin: @bin
137 |
138 | parser = new CommandParser(text, env)
139 |
140 | if parser.valid()
141 | @hidePrompt()
142 |
143 | signalCatcher = (e) =>
144 | if e.which == 67 && e.ctrlKey # control-c
145 | e.preventDefault()
146 | @error "Caught control-c"
147 | env.int = true
148 |
149 | @$body.on "keydown", signalCatcher
150 |
151 | stdin = parser.execute()
152 |
153 | outputLog = []
154 |
155 | stdin.onSenderClose =>
156 | @$body.off "keydown", signalCatcher
157 | @recordCommand text, outputLog, (response) ->
158 | callback(response) for callback in env.onCommandFinish
159 | @showPrompt()
160 |
161 | stdin.receive (text, readyForMore) =>
162 | @write text, 'output'
163 | outputLog.push text
164 | outputLog.shift() if outputLog.length > @MAX_OUTPUT_BUFFER
165 | readyForMore()
166 | else
167 | errorMessage = parser.errors.join(", ")
168 | @recordCommand text, ["Error: #{errorMessage}"]
169 | @error errorMessage
170 |
171 | error: (text) ->
172 | text = text.join(", ") if _.isArray(text)
173 | @write text, 'error'
174 |
175 | write: (text, type) ->
176 | @$history.append($("").html(Utils.escapeAndLinkify line).addClass(type)) for line in text.toString().split("\n")
177 | @$history.scrollTop(@$history[0].scrollHeight)
178 |
179 | recordCommand: (command, output, callback) ->
180 | @history.push(command: command, output: output)
181 | @historyIndex = @history.length
182 |
183 | @remote 'recordCommand', { command: command, output: output.join("\n") }
184 |
185 | remote: (cmd, options, callback = null) ->
186 | Utils.remote cmd, options, callback || (response) =>
187 | @error(response.errors) if response.errors?
188 |
189 | clear: ->
190 | @$history.empty()
191 |
192 | hide: -> @ChromePipe.hideTerminal()
193 | show: -> @ChromePipe.showTerminal()
--------------------------------------------------------------------------------
/shared/vendor/selectorgadget/selectorgadget_combined.css:
--------------------------------------------------------------------------------
1 | div#selectorgadget_main {
2 | azimuth: center !important;
3 | background-attachment: scroll !important;
4 | background-image: none !important;
5 | background-position: 0% 0% !important;
6 | background-repeat: repeat !important;
7 | border-collapse: separate !important;
8 | border-spacing: 0 !important;
9 | bottom: auto !important;
10 | caption-side: top !important;
11 | clear: none !important;
12 | clip: auto !important;
13 | color: black !important;
14 | content: normal !important;
15 | counter-increment: none !important;
16 | counter-reset: none !important;
17 | cursor: auto !important;
18 | direction: ltr !important;
19 | elevation: level !important;
20 | empty-cells: show !important;
21 | font-family: sans-serif !important;
22 | font-variant: normal !important;
23 | font-weight: normal !important;
24 | height: auto !important;
25 | left: auto !important;
26 | letter-spacing: normal !important;
27 | line-height: normal !important;
28 | list-style-image: none !important;
29 | list-style-position: outside !important;
30 | list-style-type: disc !important;
31 | max-height: none !important;
32 | max-width: none !important;
33 | min-height: 0 !important;
34 | min-width: 0 !important;
35 | orphans: 2 !important;
36 | outline-color: invert !important;
37 | outline-style: none !important;
38 | outline-width: medium !important;
39 | overflow: visible !important;
40 | page-break-after: auto !important;
41 | page-break-before: auto !important;
42 | page-break-inside: auto !important;
43 | table-layout: auto !important;
44 | text-align: left !important;
45 | text-decoration: none !important;
46 | text-indent: 0 !important;
47 | text-transform: none !important;
48 | top: auto !important;
49 | unicode-bidi: normal !important;
50 | vertical-align: baseline !important;
51 | visibility: visible !important;
52 | white-space: normal !important;
53 | widows: 2 !important;
54 | width: auto !important;
55 | word-spacing: normal !important;
56 | position: fixed !important;
57 | z-index: 9999999 !important;
58 | display: block !important;
59 | right: 5px !important;
60 | margin: 5px !important;
61 | padding: 5px !important;
62 | font-size: 14px !important;
63 | float: none !important;
64 | border: 1px solid black !important;
65 | font-style: none !important;
66 | background: white !important;
67 | text-align: left !important; }
68 |
69 | div#selectorgadget_main *, .selectorgadget_clean, .selectorgadget_clean * {
70 | azimuth: center;
71 | background-attachment: scroll;
72 | background-image: none;
73 | background-position: 0% 0%;
74 | background-repeat: repeat;
75 | border-collapse: separate;
76 | border-spacing: 0;
77 | bottom: auto;
78 | caption-side: top;
79 | clear: none;
80 | clip: auto;
81 | color: black;
82 | content: normal;
83 | counter-increment: none;
84 | counter-reset: none;
85 | cursor: auto;
86 | direction: ltr;
87 | elevation: level;
88 | empty-cells: show;
89 | font-family: sans-serif;
90 | font-variant: normal;
91 | font-weight: normal;
92 | height: auto;
93 | left: auto;
94 | letter-spacing: normal;
95 | line-height: normal;
96 | list-style-image: none;
97 | list-style-position: outside;
98 | list-style-type: disc;
99 | max-height: none;
100 | max-width: none;
101 | min-height: 0;
102 | min-width: 0;
103 | orphans: 2;
104 | outline-color: invert;
105 | outline-style: none;
106 | outline-width: medium;
107 | overflow: visible;
108 | page-break-after: auto;
109 | page-break-before: auto;
110 | page-break-inside: auto;
111 | table-layout: auto;
112 | text-align: left;
113 | text-decoration: none;
114 | text-indent: 0;
115 | text-transform: none;
116 | top: auto;
117 | unicode-bidi: normal;
118 | vertical-align: baseline;
119 | visibility: visible;
120 | white-space: normal;
121 | widows: 2;
122 | width: auto;
123 | word-spacing: normal;
124 | right: 0px;
125 | margin: 0;
126 | padding: 0;
127 | font-size: 14px;
128 | float: none;
129 | font-style: none;
130 | background: white;
131 | text-align: left; }
132 |
133 | .selectorgadget_clean a {
134 | color: blue;
135 | text-decoration: underline;
136 | cursor: pointer; }
137 |
138 | div#selectorgadget_main .selectorgadget_input_field {
139 | display: block;
140 | float: left;
141 | margin: 0 7px 0 0;
142 | background-color: #f5f5f5;
143 | border: 1px solid #dedede;
144 | border-top: 1px solid #eee;
145 | border-left: 1px solid #eee;
146 | font-family: "Lucida Grande", Tahoma, Arial, Verdana, sans-serif;
147 | text-decoration: none;
148 | color: #565656;
149 | cursor: pointer;
150 | padding: 5px 8px 6px 7px; }
151 |
152 | div#selectorgadget_main .selectorgadget_wizard .selectorgadget_input_field {
153 | margin: 7px 3px 7px 3px;
154 | float: none;
155 | display: inline; }
156 |
157 | div#selectorgadget_main .selectorgadget_prompt {
158 | margin: 3px 0px 3px 0px;
159 | font-family: "Lucida Grande", Tahoma, Arial, Verdana, sans-serif;
160 | font-weight: bold;
161 | float: none; }
162 |
163 | div#selectorgadget_main .selectorgadget_wizard #selectorgadget_path_field {
164 | margin: 5px 0px;
165 | clear: both;
166 | float: none;
167 | display: block; }
168 |
169 | .selectorgadget_selected {
170 | background-color: #0F0 !important;
171 | background-image: none !important; }
172 |
173 | .selectorgadget_suggested {
174 | background-color: #FF5 !important;
175 | background-image: none !important; }
176 |
177 | .selectorgadget_border {
178 | position: absolute !important;
179 | z-index: 999999 !important;
180 | background: white !important;
181 | background-color: orange !important;
182 | margin: 0px !important;
183 | padding: 0px !important;
184 | display: block !important;
185 | float: none !important;
186 | border: 0 !important;
187 | font-style: none !important;
188 | outline: 0 !important;
189 | vertical-align: baseline !important;
190 | text-align: left !important; }
191 |
192 | .selectorgadget_bottom_border {
193 | font-size: 10px !important;
194 | padding: 2px 0px 2px 5px !important; }
195 |
196 | .selectorgadget_border_red {
197 | background-color: #F00 !important; }
198 |
199 | .selectorgadget_rejected {
200 | background-color: #F00 !important;
201 | background-image: none !important; }
202 |
203 | img.selectorgadget_rejected {
204 | border: 5px solid #F00 !important; }
205 | img.selectorgadget_suggested {
206 | border: 5px solid #FF5 !important; }
207 | img.selectorgadget_selected {
208 | border: 5px solid #0F0 !important; }
209 |
210 | #selectorgadget_main.selectorgadget_top {
211 | top: 5px !important; }
212 |
213 | #selectorgadget_main.selectorgadget_bottom {
214 | bottom: 5px !important; }
215 |
216 | #selectorgadget_main input {
217 | margin-right: 10px !important;
218 | font-size: 15px !important; }
219 |
220 | #selectorgadget_path_field {
221 | width: 400px !important; }
222 |
223 | #selectorgadget_main .selectorgadget_new_line {
224 | clear: both; }
225 |
226 | #selectorgadget_main .selectorgadget_option {
227 | float: left; }
228 |
229 | #selectorgadget_main .selectorgadget_selected_option {
230 | text-decoration: underline; }
231 |
--------------------------------------------------------------------------------
/source/js/commands/terminal/base.coffee:
--------------------------------------------------------------------------------
1 | window.ChromePipe.Commands ||= {}
2 | window.ChromePipe.Commands.Terminal ||= {}
3 |
4 | $.extend window.ChromePipe.Commands.Terminal,
5 | exit:
6 | desc: "Close the terminal"
7 | run: (stdin, stdout, env) ->
8 | stdout.onReceiver ->
9 | env.terminal.hide()
10 | stdout.senderClose()
11 |
12 | clear:
13 | desc: "Clear the terminal"
14 | run: (stdin, stdout, env) ->
15 | stdout.onReceiver ->
16 | env.terminal.clear()
17 | stdout.senderClose()
18 |
19 | bugmenot:
20 | desc: "Launch BugMeNot for this site, or the site passed"
21 | run: (stdin, stdout, env, args) ->
22 | args = Utils.domain() unless args
23 | stdout.onReceiver ->
24 | env.terminal.hide()
25 | env.helpers.argsOrStdin [args], stdin, (domains) ->
26 | domain = domains[0]
27 | unless env.int
28 | window.open("http://bugmenot.com/view/" + domain, 'BugMeNot', 'height=500,width=700').focus?()
29 | stdout.send "Launching BugMeNot for '#{domain}'"
30 | stdout.senderClose()
31 |
32 | selectorgadget:
33 | desc: "Launch selectorGadget"
34 | run: (stdin, stdout, env) ->
35 | stdout.onReceiver ->
36 | env.terminal.hide()
37 | Utils.loadCSS "vendor/selectorgadget/selectorgadget_combined.css"
38 | Utils.load "vendor/selectorgadget/selectorgadget_combined.js", callback: =>
39 | SelectorGadget.toggle();
40 |
41 | Utils.whenTrue (-> $("#selectorgadget_path_field").length > 0 || env.int), ->
42 | lastVal = null
43 | interval = setInterval ->
44 | val = $("#selectorgadget_path_field").val()
45 | lastVal = val unless val == "No valid path found."
46 | , 100
47 | Utils.whenTrue (-> $("#selectorgadget_path_field").length == 0 || env.int), ->
48 | clearInterval interval
49 | env.terminal.show()
50 | stdout.send lastVal || 'unknown'
51 | stdout.senderClose()
52 |
53 | random_link:
54 | desc: "Open a random page link"
55 | run: (stdin, stdout) ->
56 | stdout.onReceiver ->
57 | Utils.newWindow document.links[Math.floor(Math.random() * document.links.length)].href
58 | stdout.senderClose()
59 |
60 | waybackmachine:
61 | desc: "Open this page in Archive.org's Wayback Machine"
62 | run: (stdin, stdout) ->
63 | stdout.onReceiver ->
64 | Utils.newWindow 'http://web.archive.org/web/*/' + Utils.domain()
65 | stdout.senderClose()
66 |
67 | help:
68 | desc: "This help view"
69 | run: (stdin, stdout, env) ->
70 | stdout.onReceiver ->
71 | stdout.send ("#{cmd} - #{opts.desc}" for cmd, opts of env.bin when opts.desc?).join("\n")
72 | stdout.senderClose()
73 |
74 | gist:
75 | desc: "Make a new GitHub gist"
76 | run: (stdin, stdout, env, args) ->
77 | stdout.onReceiver ->
78 | if stdin
79 | stdin.receiveAll (rows) ->
80 | if env.int
81 | stdout.senderClose()
82 | else
83 | files = {}
84 | files[args || 'data.txt'] = { content: rows.join("\n") }
85 | $.post("https://api.github.com/gists", JSON.stringify({ public: true, files: files })).fail(-> stdout.senderClose()).done (resp) ->
86 | stdout.send resp.html_url
87 | stdout.senderClose()
88 | else
89 | Utils.newWindow "https://gist.github.com/"
90 | stdout.senderClose()
91 |
92 | namegrep:
93 | desc: "Grep for domain names"
94 | run: (stdin, stdout, env, args) ->
95 | stdout.onReceiver ->
96 | env.helpers.argsOrStdin [args], stdin, (lines) ->
97 | Utils.newWindow "http://namegrep.com/##{lines.join("|")}"
98 | stdout.senderClose()
99 |
100 | requestbin:
101 | desc: "Make a requestb.in"
102 | run: (stdin, stdout, env, args) ->
103 | stdout.onReceiver ->
104 | env.helpers.argsOrStdin [args], stdin, (lines) ->
105 | if env.int
106 | stdout.senderClose()
107 | else
108 | $.post "http://requestb.in/api/v1/bins", { private: lines[0] == "private" }, (response) ->
109 | stdout.send "http://requestb.in/#{response['name']}?inspect"
110 | stdout.senderClose()
111 |
112 | selection:
113 | desc: "Get the current document selection"
114 | run: (stdin, stdout, env) ->
115 | stdout.onReceiver ->
116 | for line in document.getSelection().toString().split("\n")
117 | stdout.send line
118 | stdout.senderClose()
119 |
120 | echo:
121 | desc: "Output to the terminal"
122 | run: (stdin, stdout, env, args) ->
123 | stdout.onReceiver ->
124 | stdout.send args
125 | stdout.senderClose()
126 |
127 | grep:
128 | desc: "Search for lines matching a pattern"
129 | run: (stdin, stdout, env, args) ->
130 | return @fail(env, stdout, "stdin required for grep") unless stdin
131 | pattern = new RegExp(args, 'i')
132 | stdout.onReceiver ->
133 | stdin.onSenderClose -> stdout.senderClose()
134 | stdin.receive (text, readyForMore) ->
135 | matches = _.filter(String(text).split("\n"), (line) -> line.match(pattern))
136 | if matches.length > 0
137 | for line, index in matches
138 | if index == matches.length - 1
139 | stdout.send line, readyForMore
140 | else
141 | stdout.send line
142 | else
143 | readyForMore()
144 |
145 | _:
146 | desc: "Access the previous command's output"
147 | run: (stdin, stdout, env, args) ->
148 | args = '1' unless args
149 | stdout.onReceiver ->
150 | env.helpers.argsOrStdin [args], stdin, (back) ->
151 | for line in (env.terminal.history[env.terminal.historyIndex - parseInt(back[0])]?.output || [])
152 | stdout.send line
153 | stdout.senderClose()
154 |
155 | text:
156 | desc: "Access the page's text"
157 | run: (stdin, stdout, env, args) ->
158 | args = 'body' unless args
159 | stdout.onReceiver ->
160 | env.helpers.argsOrStdin [args], stdin, (selectors) ->
161 | for selector in selectors
162 | for item in $(selector)
163 | stdout.send $(item).text()
164 | stdout.senderClose()
165 |
166 | collect:
167 | desc: "Grab all input into an array"
168 | run: (stdin, stdout, env, args) ->
169 | stdout.onReceiver ->
170 | env.helpers.argsOrStdin [args], stdin, (rows) ->
171 | stdout.send rows
172 | stdout.senderClose()
173 |
174 | jquery:
175 | desc: "Access the page's dom"
176 | run: (stdin, stdout, env, args) ->
177 | args = 'body' unless args
178 | stdout.onReceiver ->
179 | env.helpers.argsOrStdin [args], stdin, (selectors) ->
180 | for selector in selectors
181 | for elem in $(selector)
182 | stdout.send $(elem)
183 | stdout.senderClose()
184 |
185 | tick:
186 | desc: "Read once per second"
187 | run: (stdin, stdout, env, args) ->
188 | return @fail(env, stdout, "stdin required for tick") unless stdin
189 | stdout.onReceiver ->
190 | stdin.onSenderClose -> stdout.senderClose()
191 | stdin.receive (line, readyForMore) ->
192 | stdout.send line
193 | setTimeout ->
194 | if env.int
195 | stdout.senderClose() unless stdout.senderClosed
196 | else
197 | readyForMore()
198 | , parseInt(args) || 500
199 |
200 | yes:
201 | desc: "Emit the given text continuously"
202 | run: (stdin, stdout, env, args) ->
203 | stdout.onReceiver ->
204 | env.helpers.argsOrStdin [args], stdin, (text) ->
205 | emit = ->
206 | # for sanity
207 | setTimeout ->
208 | if env.int
209 | stdout.senderClose()
210 | else
211 | stdout.send text[0], emit
212 | , 50
213 | emit()
214 |
215 | bgPage:
216 | desc: "Manually execute a background page command"
217 | run: (stdin, stdout, env, args) ->
218 | args = 'fetch' unless args
219 | stdout.onReceiver ->
220 | env.helpers.argsOrStdin [args], stdin, (cmdLine) ->
221 | [cmd, rest...] = cmdLine[0].split(" ")
222 |
223 | payload = {}
224 | for segment in rest
225 | [k, v] = [segment.slice(0, segment.indexOf(':')), segment.slice(segment.indexOf(':') + 1)]
226 | payload[k] = v
227 |
228 | Utils.remote cmd, payload, (response) ->
229 | stdout.send JSON.stringify(response)
230 | stdout.senderClose()
231 |
232 | pbcopy:
233 | desc: "Put data into the clipboard"
234 | run: (stdin, stdout, env, args) ->
235 | stdout.onReceiver ->
236 | env.helpers.argsOrStdin [args], stdin, (lines) ->
237 | Utils.remote 'copy', { text: lines.join("\n") }, (response) ->
238 | stdout.senderClose()
239 |
240 | pbpaste:
241 | desc: "Pull data from the clipboard"
242 | run: (stdin, stdout, env, args) ->
243 | stdout.onReceiver ->
244 | Utils.remote 'paste', {}, (response) ->
245 | for line in response.text.split("\n")
246 | stdout.send line
247 | stdout.senderClose()
248 |
249 | hn:
250 | desc: "Search hn"
251 | run: (stdin, stdout, env, args) ->
252 | stdout.onReceiver ->
253 | env.helpers.argsOrStdin [args], stdin, (query) ->
254 | Utils.newWindow 'https://hn.algolia.com/?q=' + encodeURIComponent(query)
255 | stdout.senderClose()
256 |
--------------------------------------------------------------------------------
/shared/vendor/underscore-min.js:
--------------------------------------------------------------------------------
1 | // Underscore.js 1.7.0
2 | // http://underscorejs.org
3 | // (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
4 | // Underscore may be freely distributed under the MIT license.
5 | (function(){var n=this,t=n._,r=Array.prototype,e=Object.prototype,u=Function.prototype,i=r.push,a=r.slice,o=r.concat,l=e.toString,c=e.hasOwnProperty,f=Array.isArray,s=Object.keys,p=u.bind,h=function(n){return n instanceof h?n:this instanceof h?void(this._wrapped=n):new h(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=h),exports._=h):n._=h,h.VERSION="1.7.0";var g=function(n,t,r){if(t===void 0)return n;switch(null==r?3:r){case 1:return function(r){return n.call(t,r)};case 2:return function(r,e){return n.call(t,r,e)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,i){return n.call(t,r,e,u,i)}}return function(){return n.apply(t,arguments)}};h.iteratee=function(n,t,r){return null==n?h.identity:h.isFunction(n)?g(n,t,r):h.isObject(n)?h.matches(n):h.property(n)},h.each=h.forEach=function(n,t,r){if(null==n)return n;t=g(t,r);var e,u=n.length;if(u===+u)for(e=0;u>e;e++)t(n[e],e,n);else{var i=h.keys(n);for(e=0,u=i.length;u>e;e++)t(n[i[e]],i[e],n)}return n},h.map=h.collect=function(n,t,r){if(null==n)return[];t=h.iteratee(t,r);for(var e,u=n.length!==+n.length&&h.keys(n),i=(u||n).length,a=Array(i),o=0;i>o;o++)e=u?u[o]:o,a[o]=t(n[e],e,n);return a};var v="Reduce of empty array with no initial value";h.reduce=h.foldl=h.inject=function(n,t,r,e){null==n&&(n=[]),t=g(t,e,4);var u,i=n.length!==+n.length&&h.keys(n),a=(i||n).length,o=0;if(arguments.length<3){if(!a)throw new TypeError(v);r=n[i?i[o++]:o++]}for(;a>o;o++)u=i?i[o]:o,r=t(r,n[u],u,n);return r},h.reduceRight=h.foldr=function(n,t,r,e){null==n&&(n=[]),t=g(t,e,4);var u,i=n.length!==+n.length&&h.keys(n),a=(i||n).length;if(arguments.length<3){if(!a)throw new TypeError(v);r=n[i?i[--a]:--a]}for(;a--;)u=i?i[a]:a,r=t(r,n[u],u,n);return r},h.find=h.detect=function(n,t,r){var e;return t=h.iteratee(t,r),h.some(n,function(n,r,u){return t(n,r,u)?(e=n,!0):void 0}),e},h.filter=h.select=function(n,t,r){var e=[];return null==n?e:(t=h.iteratee(t,r),h.each(n,function(n,r,u){t(n,r,u)&&e.push(n)}),e)},h.reject=function(n,t,r){return h.filter(n,h.negate(h.iteratee(t)),r)},h.every=h.all=function(n,t,r){if(null==n)return!0;t=h.iteratee(t,r);var e,u,i=n.length!==+n.length&&h.keys(n),a=(i||n).length;for(e=0;a>e;e++)if(u=i?i[e]:e,!t(n[u],u,n))return!1;return!0},h.some=h.any=function(n,t,r){if(null==n)return!1;t=h.iteratee(t,r);var e,u,i=n.length!==+n.length&&h.keys(n),a=(i||n).length;for(e=0;a>e;e++)if(u=i?i[e]:e,t(n[u],u,n))return!0;return!1},h.contains=h.include=function(n,t){return null==n?!1:(n.length!==+n.length&&(n=h.values(n)),h.indexOf(n,t)>=0)},h.invoke=function(n,t){var r=a.call(arguments,2),e=h.isFunction(t);return h.map(n,function(n){return(e?t:n[t]).apply(n,r)})},h.pluck=function(n,t){return h.map(n,h.property(t))},h.where=function(n,t){return h.filter(n,h.matches(t))},h.findWhere=function(n,t){return h.find(n,h.matches(t))},h.max=function(n,t,r){var e,u,i=-1/0,a=-1/0;if(null==t&&null!=n){n=n.length===+n.length?n:h.values(n);for(var o=0,l=n.length;l>o;o++)e=n[o],e>i&&(i=e)}else t=h.iteratee(t,r),h.each(n,function(n,r,e){u=t(n,r,e),(u>a||u===-1/0&&i===-1/0)&&(i=n,a=u)});return i},h.min=function(n,t,r){var e,u,i=1/0,a=1/0;if(null==t&&null!=n){n=n.length===+n.length?n:h.values(n);for(var o=0,l=n.length;l>o;o++)e=n[o],i>e&&(i=e)}else t=h.iteratee(t,r),h.each(n,function(n,r,e){u=t(n,r,e),(a>u||1/0===u&&1/0===i)&&(i=n,a=u)});return i},h.shuffle=function(n){for(var t,r=n&&n.length===+n.length?n:h.values(n),e=r.length,u=Array(e),i=0;e>i;i++)t=h.random(0,i),t!==i&&(u[i]=u[t]),u[t]=r[i];return u},h.sample=function(n,t,r){return null==t||r?(n.length!==+n.length&&(n=h.values(n)),n[h.random(n.length-1)]):h.shuffle(n).slice(0,Math.max(0,t))},h.sortBy=function(n,t,r){return t=h.iteratee(t,r),h.pluck(h.map(n,function(n,r,e){return{value:n,index:r,criteria:t(n,r,e)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var m=function(n){return function(t,r,e){var u={};return r=h.iteratee(r,e),h.each(t,function(e,i){var a=r(e,i,t);n(u,e,a)}),u}};h.groupBy=m(function(n,t,r){h.has(n,r)?n[r].push(t):n[r]=[t]}),h.indexBy=m(function(n,t,r){n[r]=t}),h.countBy=m(function(n,t,r){h.has(n,r)?n[r]++:n[r]=1}),h.sortedIndex=function(n,t,r,e){r=h.iteratee(r,e,1);for(var u=r(t),i=0,a=n.length;a>i;){var o=i+a>>>1;r(n[o])t?[]:a.call(n,0,t)},h.initial=function(n,t,r){return a.call(n,0,Math.max(0,n.length-(null==t||r?1:t)))},h.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:a.call(n,Math.max(n.length-t,0))},h.rest=h.tail=h.drop=function(n,t,r){return a.call(n,null==t||r?1:t)},h.compact=function(n){return h.filter(n,h.identity)};var y=function(n,t,r,e){if(t&&h.every(n,h.isArray))return o.apply(e,n);for(var u=0,a=n.length;a>u;u++){var l=n[u];h.isArray(l)||h.isArguments(l)?t?i.apply(e,l):y(l,t,r,e):r||e.push(l)}return e};h.flatten=function(n,t){return y(n,t,!1,[])},h.without=function(n){return h.difference(n,a.call(arguments,1))},h.uniq=h.unique=function(n,t,r,e){if(null==n)return[];h.isBoolean(t)||(e=r,r=t,t=!1),null!=r&&(r=h.iteratee(r,e));for(var u=[],i=[],a=0,o=n.length;o>a;a++){var l=n[a];if(t)a&&i===l||u.push(l),i=l;else if(r){var c=r(l,a,n);h.indexOf(i,c)<0&&(i.push(c),u.push(l))}else h.indexOf(u,l)<0&&u.push(l)}return u},h.union=function(){return h.uniq(y(arguments,!0,!0,[]))},h.intersection=function(n){if(null==n)return[];for(var t=[],r=arguments.length,e=0,u=n.length;u>e;e++){var i=n[e];if(!h.contains(t,i)){for(var a=1;r>a&&h.contains(arguments[a],i);a++);a===r&&t.push(i)}}return t},h.difference=function(n){var t=y(a.call(arguments,1),!0,!0,[]);return h.filter(n,function(n){return!h.contains(t,n)})},h.zip=function(n){if(null==n)return[];for(var t=h.max(arguments,"length").length,r=Array(t),e=0;t>e;e++)r[e]=h.pluck(arguments,e);return r},h.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},h.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=h.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}for(;u>e;e++)if(n[e]===t)return e;return-1},h.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=n.length;for("number"==typeof r&&(e=0>r?e+r+1:Math.min(e,r+1));--e>=0;)if(n[e]===t)return e;return-1},h.range=function(n,t,r){arguments.length<=1&&(t=n||0,n=0),r=r||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=Array(e),i=0;e>i;i++,n+=r)u[i]=n;return u};var d=function(){};h.bind=function(n,t){var r,e;if(p&&n.bind===p)return p.apply(n,a.call(arguments,1));if(!h.isFunction(n))throw new TypeError("Bind must be called on a function");return r=a.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(a.call(arguments)));d.prototype=n.prototype;var u=new d;d.prototype=null;var i=n.apply(u,r.concat(a.call(arguments)));return h.isObject(i)?i:u}},h.partial=function(n){var t=a.call(arguments,1);return function(){for(var r=0,e=t.slice(),u=0,i=e.length;i>u;u++)e[u]===h&&(e[u]=arguments[r++]);for(;r=e)throw new Error("bindAll must be passed function names");for(t=1;e>t;t++)r=arguments[t],n[r]=h.bind(n[r],n);return n},h.memoize=function(n,t){var r=function(e){var u=r.cache,i=t?t.apply(this,arguments):e;return h.has(u,i)||(u[i]=n.apply(this,arguments)),u[i]};return r.cache={},r},h.delay=function(n,t){var r=a.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},h.defer=function(n){return h.delay.apply(h,[n,1].concat(a.call(arguments,1)))},h.throttle=function(n,t,r){var e,u,i,a=null,o=0;r||(r={});var l=function(){o=r.leading===!1?0:h.now(),a=null,i=n.apply(e,u),a||(e=u=null)};return function(){var c=h.now();o||r.leading!==!1||(o=c);var f=t-(c-o);return e=this,u=arguments,0>=f||f>t?(clearTimeout(a),a=null,o=c,i=n.apply(e,u),a||(e=u=null)):a||r.trailing===!1||(a=setTimeout(l,f)),i}},h.debounce=function(n,t,r){var e,u,i,a,o,l=function(){var c=h.now()-a;t>c&&c>0?e=setTimeout(l,t-c):(e=null,r||(o=n.apply(i,u),e||(i=u=null)))};return function(){i=this,u=arguments,a=h.now();var c=r&&!e;return e||(e=setTimeout(l,t)),c&&(o=n.apply(i,u),i=u=null),o}},h.wrap=function(n,t){return h.partial(t,n)},h.negate=function(n){return function(){return!n.apply(this,arguments)}},h.compose=function(){var n=arguments,t=n.length-1;return function(){for(var r=t,e=n[t].apply(this,arguments);r--;)e=n[r].call(this,e);return e}},h.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},h.before=function(n,t){var r;return function(){return--n>0?r=t.apply(this,arguments):t=null,r}},h.once=h.partial(h.before,2),h.keys=function(n){if(!h.isObject(n))return[];if(s)return s(n);var t=[];for(var r in n)h.has(n,r)&&t.push(r);return t},h.values=function(n){for(var t=h.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},h.pairs=function(n){for(var t=h.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},h.invert=function(n){for(var t={},r=h.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},h.functions=h.methods=function(n){var t=[];for(var r in n)h.isFunction(n[r])&&t.push(r);return t.sort()},h.extend=function(n){if(!h.isObject(n))return n;for(var t,r,e=1,u=arguments.length;u>e;e++){t=arguments[e];for(r in t)c.call(t,r)&&(n[r]=t[r])}return n},h.pick=function(n,t,r){var e,u={};if(null==n)return u;if(h.isFunction(t)){t=g(t,r);for(e in n){var i=n[e];t(i,e,n)&&(u[e]=i)}}else{var l=o.apply([],a.call(arguments,1));n=new Object(n);for(var c=0,f=l.length;f>c;c++)e=l[c],e in n&&(u[e]=n[e])}return u},h.omit=function(n,t,r){if(h.isFunction(t))t=h.negate(t);else{var e=h.map(o.apply([],a.call(arguments,1)),String);t=function(n,t){return!h.contains(e,t)}}return h.pick(n,t,r)},h.defaults=function(n){if(!h.isObject(n))return n;for(var t=1,r=arguments.length;r>t;t++){var e=arguments[t];for(var u in e)n[u]===void 0&&(n[u]=e[u])}return n},h.clone=function(n){return h.isObject(n)?h.isArray(n)?n.slice():h.extend({},n):n},h.tap=function(n,t){return t(n),n};var b=function(n,t,r,e){if(n===t)return 0!==n||1/n===1/t;if(null==n||null==t)return n===t;n instanceof h&&(n=n._wrapped),t instanceof h&&(t=t._wrapped);var u=l.call(n);if(u!==l.call(t))return!1;switch(u){case"[object RegExp]":case"[object String]":return""+n==""+t;case"[object Number]":return+n!==+n?+t!==+t:0===+n?1/+n===1/t:+n===+t;case"[object Date]":case"[object Boolean]":return+n===+t}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]===n)return e[i]===t;var a=n.constructor,o=t.constructor;if(a!==o&&"constructor"in n&&"constructor"in t&&!(h.isFunction(a)&&a instanceof a&&h.isFunction(o)&&o instanceof o))return!1;r.push(n),e.push(t);var c,f;if("[object Array]"===u){if(c=n.length,f=c===t.length)for(;c--&&(f=b(n[c],t[c],r,e)););}else{var s,p=h.keys(n);if(c=p.length,f=h.keys(t).length===c)for(;c--&&(s=p[c],f=h.has(t,s)&&b(n[s],t[s],r,e)););}return r.pop(),e.pop(),f};h.isEqual=function(n,t){return b(n,t,[],[])},h.isEmpty=function(n){if(null==n)return!0;if(h.isArray(n)||h.isString(n)||h.isArguments(n))return 0===n.length;for(var t in n)if(h.has(n,t))return!1;return!0},h.isElement=function(n){return!(!n||1!==n.nodeType)},h.isArray=f||function(n){return"[object Array]"===l.call(n)},h.isObject=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},h.each(["Arguments","Function","String","Number","Date","RegExp"],function(n){h["is"+n]=function(t){return l.call(t)==="[object "+n+"]"}}),h.isArguments(arguments)||(h.isArguments=function(n){return h.has(n,"callee")}),"function"!=typeof/./&&(h.isFunction=function(n){return"function"==typeof n||!1}),h.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},h.isNaN=function(n){return h.isNumber(n)&&n!==+n},h.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"===l.call(n)},h.isNull=function(n){return null===n},h.isUndefined=function(n){return n===void 0},h.has=function(n,t){return null!=n&&c.call(n,t)},h.noConflict=function(){return n._=t,this},h.identity=function(n){return n},h.constant=function(n){return function(){return n}},h.noop=function(){},h.property=function(n){return function(t){return t[n]}},h.matches=function(n){var t=h.pairs(n),r=t.length;return function(n){if(null==n)return!r;n=new Object(n);for(var e=0;r>e;e++){var u=t[e],i=u[0];if(u[1]!==n[i]||!(i in n))return!1}return!0}},h.times=function(n,t,r){var e=Array(Math.max(0,n));t=g(t,r,1);for(var u=0;n>u;u++)e[u]=t(u);return e},h.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},h.now=Date.now||function(){return(new Date).getTime()};var _={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},w=h.invert(_),j=function(n){var t=function(t){return n[t]},r="(?:"+h.keys(n).join("|")+")",e=RegExp(r),u=RegExp(r,"g");return function(n){return n=null==n?"":""+n,e.test(n)?n.replace(u,t):n}};h.escape=j(_),h.unescape=j(w),h.result=function(n,t){if(null==n)return void 0;var r=n[t];return h.isFunction(r)?n[t]():r};var x=0;h.uniqueId=function(n){var t=++x+"";return n?n+t:t},h.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var A=/(.)^/,k={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},O=/\\|'|\r|\n|\u2028|\u2029/g,F=function(n){return"\\"+k[n]};h.template=function(n,t,r){!t&&r&&(t=r),t=h.defaults({},t,h.templateSettings);var e=RegExp([(t.escape||A).source,(t.interpolate||A).source,(t.evaluate||A).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,a,o){return i+=n.slice(u,o).replace(O,F),u=o+t.length,r?i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":e?i+="'+\n((__t=("+e+"))==null?'':__t)+\n'":a&&(i+="';\n"+a+"\n__p+='"),t}),i+="';\n",t.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var a=new Function(t.variable||"obj","_",i)}catch(o){throw o.source=i,o}var l=function(n){return a.call(this,n,h)},c=t.variable||"obj";return l.source="function("+c+"){\n"+i+"}",l},h.chain=function(n){var t=h(n);return t._chain=!0,t};var E=function(n){return this._chain?h(n).chain():n};h.mixin=function(n){h.each(h.functions(n),function(t){var r=h[t]=n[t];h.prototype[t]=function(){var n=[this._wrapped];return i.apply(n,arguments),E.call(this,r.apply(h,n))}})},h.mixin(h),h.each(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=r[n];h.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==n&&"splice"!==n||0!==r.length||delete r[0],E.call(this,r)}}),h.each(["concat","join","slice"],function(n){var t=r[n];h.prototype[n]=function(){return E.call(this,t.apply(this._wrapped,arguments))}}),h.prototype.value=function(){return this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return h})}).call(this);
--------------------------------------------------------------------------------
/spec/jasmine/jasmine-html.js:
--------------------------------------------------------------------------------
1 | jasmine.HtmlReporterHelpers = {};
2 |
3 | jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) {
4 | var el = document.createElement(type);
5 |
6 | for (var i = 2; i < arguments.length; i++) {
7 | var child = arguments[i];
8 |
9 | if (typeof child === 'string') {
10 | el.appendChild(document.createTextNode(child));
11 | } else {
12 | if (child) {
13 | el.appendChild(child);
14 | }
15 | }
16 | }
17 |
18 | for (var attr in attrs) {
19 | if (attr == "className") {
20 | el[attr] = attrs[attr];
21 | } else {
22 | el.setAttribute(attr, attrs[attr]);
23 | }
24 | }
25 |
26 | return el;
27 | };
28 |
29 | jasmine.HtmlReporterHelpers.getSpecStatus = function(child) {
30 | var results = child.results();
31 | var status = results.passed() ? 'passed' : 'failed';
32 | if (results.skipped) {
33 | status = 'skipped';
34 | }
35 |
36 | return status;
37 | };
38 |
39 | jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) {
40 | var parentDiv = this.dom.summary;
41 | var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite';
42 | var parent = child[parentSuite];
43 |
44 | if (parent) {
45 | if (typeof this.views.suites[parent.id] == 'undefined') {
46 | this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views);
47 | }
48 | parentDiv = this.views.suites[parent.id].element;
49 | }
50 |
51 | parentDiv.appendChild(childElement);
52 | };
53 |
54 |
55 | jasmine.HtmlReporterHelpers.addHelpers = function(ctor) {
56 | for(var fn in jasmine.HtmlReporterHelpers) {
57 | ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn];
58 | }
59 | };
60 |
61 | jasmine.HtmlReporter = function(_doc) {
62 | var self = this;
63 | var doc = _doc || window.document;
64 |
65 | var reporterView;
66 |
67 | var dom = {};
68 |
69 | // Jasmine Reporter Public Interface
70 | self.logRunningSpecs = false;
71 |
72 | self.reportRunnerStarting = function(runner) {
73 | var specs = runner.specs() || [];
74 |
75 | if (specs.length == 0) {
76 | return;
77 | }
78 |
79 | createReporterDom(runner.env.versionString());
80 | doc.body.appendChild(dom.reporter);
81 |
82 | reporterView = new jasmine.HtmlReporter.ReporterView(dom);
83 | reporterView.addSpecs(specs, self.specFilter);
84 | };
85 |
86 | self.reportRunnerResults = function(runner) {
87 | reporterView && reporterView.complete();
88 | };
89 |
90 | self.reportSuiteResults = function(suite) {
91 | reporterView.suiteComplete(suite);
92 | };
93 |
94 | self.reportSpecStarting = function(spec) {
95 | if (self.logRunningSpecs) {
96 | self.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
97 | }
98 | };
99 |
100 | self.reportSpecResults = function(spec) {
101 | reporterView.specComplete(spec);
102 | };
103 |
104 | self.log = function() {
105 | var console = jasmine.getGlobal().console;
106 | if (console && console.log) {
107 | if (console.log.apply) {
108 | console.log.apply(console, arguments);
109 | } else {
110 | console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
111 | }
112 | }
113 | };
114 |
115 | self.specFilter = function(spec) {
116 | if (!focusedSpecName()) {
117 | return true;
118 | }
119 |
120 | return spec.getFullName().indexOf(focusedSpecName()) === 0;
121 | };
122 |
123 | return self;
124 |
125 | function focusedSpecName() {
126 | var specName;
127 |
128 | (function memoizeFocusedSpec() {
129 | if (specName) {
130 | return;
131 | }
132 |
133 | var paramMap = [];
134 | var params = doc.location.search.substring(1).split('&');
135 |
136 | for (var i = 0; i < params.length; i++) {
137 | var p = params[i].split('=');
138 | paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
139 | }
140 |
141 | specName = paramMap.spec;
142 | })();
143 |
144 | return specName;
145 | }
146 |
147 | function createReporterDom(version) {
148 | dom.reporter = self.createDom('div', { id: 'HTMLReporter', className: 'jasmine_reporter' },
149 | dom.banner = self.createDom('div', { className: 'banner' },
150 | self.createDom('span', { className: 'title' }, "Jasmine "),
151 | self.createDom('span', { className: 'version' }, version)),
152 |
153 | dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
154 | dom.alert = self.createDom('div', {className: 'alert'}),
155 | dom.results = self.createDom('div', {className: 'results'},
156 | dom.summary = self.createDom('div', { className: 'summary' }),
157 | dom.details = self.createDom('div', { id: 'details' }))
158 | );
159 | }
160 | };
161 | jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);jasmine.HtmlReporter.ReporterView = function(dom) {
162 | this.startedAt = new Date();
163 | this.runningSpecCount = 0;
164 | this.completeSpecCount = 0;
165 | this.passedCount = 0;
166 | this.failedCount = 0;
167 | this.skippedCount = 0;
168 |
169 | this.createResultsMenu = function() {
170 | this.resultsMenu = this.createDom('span', {className: 'resultsMenu bar'},
171 | this.summaryMenuItem = this.createDom('a', {className: 'summaryMenuItem', href: "#"}, '0 specs'),
172 | ' | ',
173 | this.detailsMenuItem = this.createDom('a', {className: 'detailsMenuItem', href: "#"}, '0 failing'));
174 |
175 | this.summaryMenuItem.onclick = function() {
176 | dom.reporter.className = dom.reporter.className.replace(/ showDetails/g, '');
177 | };
178 |
179 | this.detailsMenuItem.onclick = function() {
180 | showDetails();
181 | };
182 | };
183 |
184 | this.addSpecs = function(specs, specFilter) {
185 | this.totalSpecCount = specs.length;
186 |
187 | this.views = {
188 | specs: {},
189 | suites: {}
190 | };
191 |
192 | for (var i = 0; i < specs.length; i++) {
193 | var spec = specs[i];
194 | this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
195 | if (specFilter(spec)) {
196 | this.runningSpecCount++;
197 | }
198 | }
199 | };
200 |
201 | this.specComplete = function(spec) {
202 | this.completeSpecCount++;
203 |
204 | if (isUndefined(this.views.specs[spec.id])) {
205 | this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
206 | }
207 |
208 | var specView = this.views.specs[spec.id];
209 |
210 | switch (specView.status()) {
211 | case 'passed':
212 | this.passedCount++;
213 | break;
214 |
215 | case 'failed':
216 | this.failedCount++;
217 | break;
218 |
219 | case 'skipped':
220 | this.skippedCount++;
221 | break;
222 | }
223 |
224 | specView.refresh();
225 | this.refresh();
226 | };
227 |
228 | this.suiteComplete = function(suite) {
229 | var suiteView = this.views.suites[suite.id];
230 | if (isUndefined(suiteView)) {
231 | return;
232 | }
233 | suiteView.refresh();
234 | };
235 |
236 | this.refresh = function() {
237 |
238 | if (isUndefined(this.resultsMenu)) {
239 | this.createResultsMenu();
240 | }
241 |
242 | // currently running UI
243 | if (isUndefined(this.runningAlert)) {
244 | this.runningAlert = this.createDom('a', {href: "?", className: "runningAlert bar"});
245 | dom.alert.appendChild(this.runningAlert);
246 | }
247 | this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
248 |
249 | // skipped specs UI
250 | if (isUndefined(this.skippedAlert)) {
251 | this.skippedAlert = this.createDom('a', {href: "?", className: "skippedAlert bar"});
252 | }
253 |
254 | this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
255 |
256 | if (this.skippedCount === 1 && isDefined(dom.alert)) {
257 | dom.alert.appendChild(this.skippedAlert);
258 | }
259 |
260 | // passing specs UI
261 | if (isUndefined(this.passedAlert)) {
262 | this.passedAlert = this.createDom('span', {href: "?", className: "passingAlert bar"});
263 | }
264 | this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
265 |
266 | // failing specs UI
267 | if (isUndefined(this.failedAlert)) {
268 | this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"});
269 | }
270 | this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount);
271 |
272 | if (this.failedCount === 1 && isDefined(dom.alert)) {
273 | dom.alert.appendChild(this.failedAlert);
274 | dom.alert.appendChild(this.resultsMenu);
275 | }
276 |
277 | // summary info
278 | this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount);
279 | this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
280 | };
281 |
282 | this.complete = function() {
283 | dom.alert.removeChild(this.runningAlert);
284 |
285 | this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
286 |
287 | if (this.failedCount === 0) {
288 | dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
289 | } else {
290 | showDetails();
291 | }
292 |
293 | dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"));
294 | };
295 |
296 | return this;
297 |
298 | function showDetails() {
299 | if (dom.reporter.className.search(/showDetails/) === -1) {
300 | dom.reporter.className += " showDetails";
301 | }
302 | }
303 |
304 | function isUndefined(obj) {
305 | return typeof obj === 'undefined';
306 | }
307 |
308 | function isDefined(obj) {
309 | return !isUndefined(obj);
310 | }
311 |
312 | function specPluralizedFor(count) {
313 | var str = count + " spec";
314 | if (count > 1) {
315 | str += "s"
316 | }
317 | return str;
318 | }
319 |
320 | };
321 |
322 | jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);
323 |
324 |
325 | jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
326 | this.spec = spec;
327 | this.dom = dom;
328 | this.views = views;
329 |
330 | this.symbol = this.createDom('li', { className: 'pending' });
331 | this.dom.symbolSummary.appendChild(this.symbol);
332 |
333 | this.summary = this.createDom('div', { className: 'specSummary' },
334 | this.createDom('a', {
335 | className: 'description',
336 | href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
337 | title: this.spec.getFullName()
338 | }, this.spec.description)
339 | );
340 |
341 | this.detail = this.createDom('div', { className: 'specDetail' },
342 | this.createDom('a', {
343 | className: 'description',
344 | href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
345 | title: this.spec.getFullName()
346 | }, this.spec.getFullName())
347 | );
348 | };
349 |
350 | jasmine.HtmlReporter.SpecView.prototype.status = function() {
351 | return this.getSpecStatus(this.spec);
352 | };
353 |
354 | jasmine.HtmlReporter.SpecView.prototype.refresh = function() {
355 | this.symbol.className = this.status();
356 |
357 | switch (this.status()) {
358 | case 'skipped':
359 | break;
360 |
361 | case 'passed':
362 | this.appendSummaryToSuiteDiv();
363 | break;
364 |
365 | case 'failed':
366 | this.appendSummaryToSuiteDiv();
367 | this.appendFailureDetail();
368 | break;
369 | }
370 | };
371 |
372 | jasmine.HtmlReporter.SpecView.prototype.appendSummaryToSuiteDiv = function() {
373 | this.summary.className += ' ' + this.status();
374 | this.appendToSummary(this.spec, this.summary);
375 | };
376 |
377 | jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
378 | this.detail.className += ' ' + this.status();
379 |
380 | var resultItems = this.spec.results().getItems();
381 | var messagesDiv = this.createDom('div', { className: 'messages' });
382 |
383 | for (var i = 0; i < resultItems.length; i++) {
384 | var result = resultItems[i];
385 |
386 | if (result.type == 'log') {
387 | messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
388 | } else if (result.type == 'expect' && result.passed && !result.passed()) {
389 | messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
390 |
391 | if (result.trace.stack) {
392 | messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
393 | }
394 | }
395 | }
396 |
397 | if (messagesDiv.childNodes.length > 0) {
398 | this.detail.appendChild(messagesDiv);
399 | this.dom.details.appendChild(this.detail);
400 | }
401 | };
402 |
403 | jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
404 | this.suite = suite;
405 | this.dom = dom;
406 | this.views = views;
407 |
408 | this.element = this.createDom('div', { className: 'suite' },
409 | this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(this.suite.getFullName()) }, this.suite.description)
410 | );
411 |
412 | this.appendToSummary(this.suite, this.element);
413 | };
414 |
415 | jasmine.HtmlReporter.SuiteView.prototype.status = function() {
416 | return this.getSpecStatus(this.suite);
417 | };
418 |
419 | jasmine.HtmlReporter.SuiteView.prototype.refresh = function() {
420 | this.element.className += " " + this.status();
421 | };
422 |
423 | jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView);
424 |
425 | /* @deprecated Use jasmine.HtmlReporter instead
426 | */
427 | jasmine.TrivialReporter = function(doc) {
428 | this.document = doc || document;
429 | this.suiteDivs = {};
430 | this.logRunningSpecs = false;
431 | };
432 |
433 | jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
434 | var el = document.createElement(type);
435 |
436 | for (var i = 2; i < arguments.length; i++) {
437 | var child = arguments[i];
438 |
439 | if (typeof child === 'string') {
440 | el.appendChild(document.createTextNode(child));
441 | } else {
442 | if (child) { el.appendChild(child); }
443 | }
444 | }
445 |
446 | for (var attr in attrs) {
447 | if (attr == "className") {
448 | el[attr] = attrs[attr];
449 | } else {
450 | el.setAttribute(attr, attrs[attr]);
451 | }
452 | }
453 |
454 | return el;
455 | };
456 |
457 | jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
458 | var showPassed, showSkipped;
459 |
460 | this.outerDiv = this.createDom('div', { id: 'TrivialReporter', className: 'jasmine_reporter' },
461 | this.createDom('div', { className: 'banner' },
462 | this.createDom('div', { className: 'logo' },
463 | this.createDom('span', { className: 'title' }, "Jasmine"),
464 | this.createDom('span', { className: 'version' }, runner.env.versionString())),
465 | this.createDom('div', { className: 'options' },
466 | "Show ",
467 | showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
468 | this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
469 | showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
470 | this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
471 | )
472 | ),
473 |
474 | this.runnerDiv = this.createDom('div', { className: 'runner running' },
475 | this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
476 | this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
477 | this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
478 | );
479 |
480 | this.document.body.appendChild(this.outerDiv);
481 |
482 | var suites = runner.suites();
483 | for (var i = 0; i < suites.length; i++) {
484 | var suite = suites[i];
485 | var suiteDiv = this.createDom('div', { className: 'suite' },
486 | this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
487 | this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
488 | this.suiteDivs[suite.id] = suiteDiv;
489 | var parentDiv = this.outerDiv;
490 | if (suite.parentSuite) {
491 | parentDiv = this.suiteDivs[suite.parentSuite.id];
492 | }
493 | parentDiv.appendChild(suiteDiv);
494 | }
495 |
496 | this.startedAt = new Date();
497 |
498 | var self = this;
499 | showPassed.onclick = function(evt) {
500 | if (showPassed.checked) {
501 | self.outerDiv.className += ' show-passed';
502 | } else {
503 | self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
504 | }
505 | };
506 |
507 | showSkipped.onclick = function(evt) {
508 | if (showSkipped.checked) {
509 | self.outerDiv.className += ' show-skipped';
510 | } else {
511 | self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
512 | }
513 | };
514 | };
515 |
516 | jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
517 | var results = runner.results();
518 | var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
519 | this.runnerDiv.setAttribute("class", className);
520 | //do it twice for IE
521 | this.runnerDiv.setAttribute("className", className);
522 | var specs = runner.specs();
523 | var specCount = 0;
524 | for (var i = 0; i < specs.length; i++) {
525 | if (this.specFilter(specs[i])) {
526 | specCount++;
527 | }
528 | }
529 | var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
530 | message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
531 | this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
532 |
533 | this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
534 | };
535 |
536 | jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
537 | var results = suite.results();
538 | var status = results.passed() ? 'passed' : 'failed';
539 | if (results.totalCount === 0) { // todo: change this to check results.skipped
540 | status = 'skipped';
541 | }
542 | this.suiteDivs[suite.id].className += " " + status;
543 | };
544 |
545 | jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
546 | if (this.logRunningSpecs) {
547 | this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
548 | }
549 | };
550 |
551 | jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
552 | var results = spec.results();
553 | var status = results.passed() ? 'passed' : 'failed';
554 | if (results.skipped) {
555 | status = 'skipped';
556 | }
557 | var specDiv = this.createDom('div', { className: 'spec ' + status },
558 | this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
559 | this.createDom('a', {
560 | className: 'description',
561 | href: '?spec=' + encodeURIComponent(spec.getFullName()),
562 | title: spec.getFullName()
563 | }, spec.description));
564 |
565 |
566 | var resultItems = results.getItems();
567 | var messagesDiv = this.createDom('div', { className: 'messages' });
568 | for (var i = 0; i < resultItems.length; i++) {
569 | var result = resultItems[i];
570 |
571 | if (result.type == 'log') {
572 | messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
573 | } else if (result.type == 'expect' && result.passed && !result.passed()) {
574 | messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
575 |
576 | if (result.trace.stack) {
577 | messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
578 | }
579 | }
580 | }
581 |
582 | if (messagesDiv.childNodes.length > 0) {
583 | specDiv.appendChild(messagesDiv);
584 | }
585 |
586 | this.suiteDivs[spec.suite.id].appendChild(specDiv);
587 | };
588 |
589 | jasmine.TrivialReporter.prototype.log = function() {
590 | var console = jasmine.getGlobal().console;
591 | if (console && console.log) {
592 | if (console.log.apply) {
593 | console.log.apply(console, arguments);
594 | } else {
595 | console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
596 | }
597 | }
598 | };
599 |
600 | jasmine.TrivialReporter.prototype.getLocation = function() {
601 | return this.document.location;
602 | };
603 |
604 | jasmine.TrivialReporter.prototype.specFilter = function(spec) {
605 | var paramMap = {};
606 | var params = this.getLocation().search.substring(1).split('&');
607 | for (var i = 0; i < params.length; i++) {
608 | var p = params[i].split('=');
609 | paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
610 | }
611 |
612 | if (!paramMap.spec) {
613 | return true;
614 | }
615 | return spec.getFullName().indexOf(paramMap.spec) === 0;
616 | };
617 |
--------------------------------------------------------------------------------
/shared/vendor/jquery-min.js:
--------------------------------------------------------------------------------
1 | /*! jQuery v2.1.3 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
2 | !function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.3",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)+1>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=hb(),z=hb(),A=hb(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+N+"))|)"+L+"*\\]",P=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+O+")*)|.*)\\)|)",Q=new RegExp(L+"+","g"),R=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),S=new RegExp("^"+L+"*,"+L+"*"),T=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),U=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),V=new RegExp(P),W=new RegExp("^"+N+"$"),X={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+O),PSEUDO:new RegExp("^"+P),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+K+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},eb=function(){m()};try{H.apply(E=I.call(v.childNodes),v.childNodes),E[v.childNodes.length].nodeType}catch(fb){H={apply:E.length?function(a,b){G.apply(a,I.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function gb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],k=b.nodeType,"string"!=typeof a||!a||1!==k&&9!==k&&11!==k)return d;if(!e&&p){if(11!==k&&(f=_.exec(a)))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return H.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName)return H.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=1!==k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+rb(o[l]);w=ab.test(a)&&pb(b.parentNode)||b,x=o.join(",")}if(x)try{return H.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function hb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ib(a){return a[u]=!0,a}function jb(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function kb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function lb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||C)-(~a.sourceIndex||C);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function nb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function ob(a){return ib(function(b){return b=+b,ib(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function pb(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=gb.support={},f=gb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=gb.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=g.documentElement,e=g.defaultView,e&&e!==e.top&&(e.addEventListener?e.addEventListener("unload",eb,!1):e.attachEvent&&e.attachEvent("onunload",eb)),p=!f(g),c.attributes=jb(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=jb(function(a){return a.appendChild(g.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(g.getElementsByClassName),c.getById=jb(function(a){return o.appendChild(a).id=u,!g.getElementsByName||!g.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(g.querySelectorAll))&&(jb(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+L+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+L+"*(?:value|"+K+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),jb(function(a){var b=g.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+L+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&jb(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",P)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===g||a.ownerDocument===v&&t(v,a)?-1:b===g||b.ownerDocument===v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,h=[a],i=[b];if(!e||!f)return a===g?-1:b===g?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return lb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?lb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},g):n},gb.matches=function(a,b){return gb(a,null,null,b)},gb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return gb(b,n,null,[a]).length>0},gb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},gb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&D.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},gb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},gb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=gb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=gb.selectors={cacheLength:50,createPseudo:ib,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||gb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&gb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+L+")"+a+"("+L+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=gb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(Q," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||gb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ib(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ib(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?ib(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ib(function(a){return function(b){return gb(a,b).length>0}}),contains:ib(function(a){return a=a.replace(cb,db),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ib(function(a){return W.test(a||"")||gb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:ob(function(){return[0]}),last:ob(function(a,b){return[b-1]}),eq:ob(function(a,b,c){return[0>c?c+b:c]}),even:ob(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:ob(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:ob(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:ob(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function sb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function tb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ub(a,b,c){for(var d=0,e=b.length;e>d;d++)gb(a,b[d],c);return c}function vb(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function wb(a,b,c,d,e,f){return d&&!d[u]&&(d=wb(d)),e&&!e[u]&&(e=wb(e,f)),ib(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ub(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:vb(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=vb(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=vb(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function xb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=sb(function(a){return a===b},h,!0),l=sb(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[sb(tb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return wb(i>1&&tb(m),i>1&&rb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&xb(a.slice(i,e)),f>e&&xb(a=a.slice(e)),f>e&&rb(a))}m.push(c)}return tb(m)}function yb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=F.call(i));s=vb(s)}H.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&gb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?ib(f):f}return h=gb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=xb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,yb(e,d)),f.selector=a}return f},i=gb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&pb(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&rb(j),!a)return H.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&pb(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=jb(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),jb(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||kb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&jb(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||kb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),jb(function(a){return null==a.getAttribute("disabled")})||kb(K,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),gb}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return g.call(b,a)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;c>b;b++)if(n.contains(e[b],this))return!0}));for(b=0;c>b;b++)n.find(a,e[b],d);return d=this.pushStack(c>1?n.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:l,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=l.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=l,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};A.prototype=n.fn,y=n(l);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(n(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(C[a]||n.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return n.each(a.match(E)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&n.each(arguments,function(a,b){var c;while((c=n.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(H.resolveWith(l,[n]),n.fn.triggerHandler&&(n(l).triggerHandler("ready"),n(l).off("ready"))))}});function I(){l.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),n.ready()}n.ready.promise=function(b){return H||(H=n.Deferred(),"complete"===l.readyState?setTimeout(n.ready):(l.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},n.ready.promise();var J=n.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)n.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};n.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=n.expando+K.uid++}K.uid=1,K.accepts=n.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,n.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(n.isEmptyObject(f))n.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!n.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){return M.access(a,b,c)
3 | },removeData:function(a,b){M.remove(a,b)},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthx",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},e||!o.trigger||o.trigger.apply(d,c)!==!1)){if(!e&&!o.noBubble&&!n.isWindow(d)){for(i=o.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||l)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:o.bindType||q,m=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),m&&m.apply(g,c),m=k&&g[k],m&&m.apply&&n.acceptData(g)&&(b.result=m.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!n.acceptData(d)||k&&n.isFunction(d[q])&&!n.isWindow(d)&&(h=d[k],h&&(d[k]=null),n.event.triggered=q,d[q](),n.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>=0:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h]*)\/>/gi,bb=/<([\w:]+)/,cb=/<|?\w+;/,db=/<(?:script|style|link)/i,eb=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/^$|\/(?:java|ecma)script/i,gb=/^true\/(.*)/,hb=/^\s*\s*$/g,ib={option:[1,""],thead:[1,""],col:[2,""],tr:[2,""],td:[3,""],_default:[0,"",""]};ib.optgroup=ib.option,ib.tbody=ib.tfoot=ib.colgroup=ib.caption=ib.thead,ib.th=ib.td;function jb(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function kb(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function lb(a){var b=gb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function mb(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function nb(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=n.extend({},h),M.set(b,i))}}function ob(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function pb(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}n.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=ob(h),f=ob(a),d=0,e=f.length;e>d;d++)pb(f[d],g[d]);if(b)if(c)for(f=f||ob(a),g=g||ob(h),d=0,e=f.length;e>d;d++)nb(f[d],g[d]);else nb(a,h);return g=ob(h,"script"),g.length>0&&mb(g,!i&&ob(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,o=a.length;o>m;m++)if(e=a[m],e||0===e)if("object"===n.type(e))n.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1>$2>")+h[2],j=h[0];while(j--)f=f.lastChild;n.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===n.inArray(e,d))&&(i=n.contains(e.ownerDocument,e),f=ob(k.appendChild(e),"script"),i&&mb(f),c)){j=0;while(e=f[j++])fb.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f=n.event.special,g=0;void 0!==(c=a[g]);g++){if(n.acceptData(c)&&(e=c[L.expando],e&&(b=L.cache[e]))){if(b.events)for(d in b.events)f[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);L.cache[e]&&delete L.cache[e]}delete M.cache[c[M.expando]]}}}),n.fn.extend({text:function(a){return J(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(ob(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&mb(ob(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(ob(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1>$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(ob(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(ob(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,m=this,o=l-1,p=a[0],q=n.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&eb.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(c=n.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=n.map(ob(c,"script"),kb),g=f.length;l>j;j++)h=c,j!==o&&(h=n.clone(h,!0,!0),g&&n.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,n.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&n.contains(i,h)&&(h.src?n._evalUrl&&n._evalUrl(h.src):n.globalEval(h.textContent.replace(hb,"")))}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),n(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d,e=n(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:n.css(e[0],"display");return e.detach(),f}function tb(a){var b=l,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||n("")).appendTo(b.documentElement),b=qb[0].contentDocument,b.write(),b.close(),c=sb(a,b),qb.detach()),rb[a]=c),c}var ub=/^margin/,vb=new RegExp("^("+Q+")(?!px)[a-z%]+$","i"),wb=function(b){return b.ownerDocument.defaultView.opener?b.ownerDocument.defaultView.getComputedStyle(b,null):a.getComputedStyle(b,null)};function xb(a,b,c){var d,e,f,g,h=a.style;return c=c||wb(a),c&&(g=c.getPropertyValue(b)||c[b]),c&&(""!==g||n.contains(a.ownerDocument,a)||(g=n.style(a,b)),vb.test(g)&&ub.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0!==g?g+"":g}function yb(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d=l.documentElement,e=l.createElement("div"),f=l.createElement("div");if(f.style){f.style.backgroundClip="content-box",f.cloneNode(!0).style.backgroundClip="",k.clearCloneStyle="content-box"===f.style.backgroundClip,e.style.cssText="border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;position:absolute",e.appendChild(f);function g(){f.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute",f.innerHTML="",d.appendChild(e);var g=a.getComputedStyle(f,null);b="1%"!==g.top,c="4px"===g.width,d.removeChild(e)}a.getComputedStyle&&n.extend(k,{pixelPosition:function(){return g(),b},boxSizingReliable:function(){return null==c&&g(),c},reliableMarginRight:function(){var b,c=f.appendChild(l.createElement("div"));return c.style.cssText=f.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",c.style.marginRight=c.style.width="0",f.style.width="1px",d.appendChild(e),b=!parseFloat(a.getComputedStyle(c,null).marginRight),d.removeChild(e),f.removeChild(c),b}})}}(),n.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var zb=/^(none|table(?!-c[ea]).+)/,Ab=new RegExp("^("+Q+")(.*)$","i"),Bb=new RegExp("^([+-])=("+Q+")","i"),Cb={position:"absolute",visibility:"hidden",display:"block"},Db={letterSpacing:"0",fontWeight:"400"},Eb=["Webkit","O","Moz","ms"];function Fb(a,b){if(b in a)return b;var c=b[0].toUpperCase()+b.slice(1),d=b,e=Eb.length;while(e--)if(b=Eb[e]+c,b in a)return b;return d}function Gb(a,b,c){var d=Ab.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Hb(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=n.css(a,c+R[f],!0,e)),d?("content"===c&&(g-=n.css(a,"padding"+R[f],!0,e)),"margin"!==c&&(g-=n.css(a,"border"+R[f]+"Width",!0,e))):(g+=n.css(a,"padding"+R[f],!0,e),"padding"!==c&&(g+=n.css(a,"border"+R[f]+"Width",!0,e)));return g}function Ib(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=wb(a),g="border-box"===n.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=xb(a,b,f),(0>e||null==e)&&(e=a.style[b]),vb.test(e))return e;d=g&&(k.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Hb(a,b,c||(g?"border":"content"),d,f)+"px"}function Jb(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=L.get(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&S(d)&&(f[g]=L.access(d,"olddisplay",tb(d.nodeName)))):(e=S(d),"none"===c&&e||L.set(d,"olddisplay",e?c:n.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}n.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=xb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=n.camelCase(b),i=a.style;return b=n.cssProps[h]||(n.cssProps[h]=Fb(i,h)),g=n.cssHooks[b]||n.cssHooks[h],void 0===c?g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b]:(f=typeof c,"string"===f&&(e=Bb.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(n.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||n.cssNumber[h]||(c+="px"),k.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),g&&"set"in g&&void 0===(c=g.set(a,c,d))||(i[b]=c)),void 0)}},css:function(a,b,c,d){var e,f,g,h=n.camelCase(b);return b=n.cssProps[h]||(n.cssProps[h]=Fb(a.style,h)),g=n.cssHooks[b]||n.cssHooks[h],g&&"get"in g&&(e=g.get(a,!0,c)),void 0===e&&(e=xb(a,b,d)),"normal"===e&&b in Db&&(e=Db[b]),""===c||c?(f=parseFloat(e),c===!0||n.isNumeric(f)?f||0:e):e}}),n.each(["height","width"],function(a,b){n.cssHooks[b]={get:function(a,c,d){return c?zb.test(n.css(a,"display"))&&0===a.offsetWidth?n.swap(a,Cb,function(){return Ib(a,b,d)}):Ib(a,b,d):void 0},set:function(a,c,d){var e=d&&wb(a);return Gb(a,c,d?Hb(a,b,d,"border-box"===n.css(a,"boxSizing",!1,e),e):0)}}}),n.cssHooks.marginRight=yb(k.reliableMarginRight,function(a,b){return b?n.swap(a,{display:"inline-block"},xb,[a,"marginRight"]):void 0}),n.each({margin:"",padding:"",border:"Width"},function(a,b){n.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+R[d]+b]=f[d]||f[d-2]||f[0];return e}},ub.test(a)||(n.cssHooks[a+b].set=Gb)}),n.fn.extend({css:function(a,b){return J(this,function(a,b,c){var d,e,f={},g=0;if(n.isArray(b)){for(d=wb(a),e=b.length;e>g;g++)f[b[g]]=n.css(a,b[g],!1,d);return f}return void 0!==c?n.style(a,b,c):n.css(a,b)},a,b,arguments.length>1)},show:function(){return Jb(this,!0)},hide:function(){return Jb(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){S(this)?n(this).show():n(this).hide()})}});function Kb(a,b,c,d,e){return new Kb.prototype.init(a,b,c,d,e)}n.Tween=Kb,Kb.prototype={constructor:Kb,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(n.cssNumber[c]?"":"px")},cur:function(){var a=Kb.propHooks[this.prop];return a&&a.get?a.get(this):Kb.propHooks._default.get(this)},run:function(a){var b,c=Kb.propHooks[this.prop];return this.pos=b=this.options.duration?n.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Kb.propHooks._default.set(this),this}},Kb.prototype.init.prototype=Kb.prototype,Kb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=n.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){n.fx.step[a.prop]?n.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[n.cssProps[a.prop]]||n.cssHooks[a.prop])?n.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Kb.propHooks.scrollTop=Kb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},n.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},n.fx=Kb.prototype.init,n.fx.step={};var Lb,Mb,Nb=/^(?:toggle|show|hide)$/,Ob=new RegExp("^(?:([+-])=|)("+Q+")([a-z%]*)$","i"),Pb=/queueHooks$/,Qb=[Vb],Rb={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=Ob.exec(b),f=e&&e[3]||(n.cssNumber[a]?"":"px"),g=(n.cssNumber[a]||"px"!==f&&+d)&&Ob.exec(n.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,n.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function Sb(){return setTimeout(function(){Lb=void 0}),Lb=n.now()}function Tb(a,b){var c,d=0,e={height:a};for(b=b?1:0;4>d;d+=2-b)c=R[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function Ub(a,b,c){for(var d,e=(Rb[b]||[]).concat(Rb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function Vb(a,b,c){var d,e,f,g,h,i,j,k,l=this,m={},o=a.style,p=a.nodeType&&S(a),q=L.get(a,"fxshow");c.queue||(h=n._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,l.always(function(){l.always(function(){h.unqueued--,n.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[o.overflow,o.overflowX,o.overflowY],j=n.css(a,"display"),k="none"===j?L.get(a,"olddisplay")||tb(a.nodeName):j,"inline"===k&&"none"===n.css(a,"float")&&(o.display="inline-block")),c.overflow&&(o.overflow="hidden",l.always(function(){o.overflow=c.overflow[0],o.overflowX=c.overflow[1],o.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],Nb.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(p?"hide":"show")){if("show"!==e||!q||void 0===q[d])continue;p=!0}m[d]=q&&q[d]||n.style(a,d)}else j=void 0;if(n.isEmptyObject(m))"inline"===("none"===j?tb(a.nodeName):j)&&(o.display=j);else{q?"hidden"in q&&(p=q.hidden):q=L.access(a,"fxshow",{}),f&&(q.hidden=!p),p?n(a).show():l.done(function(){n(a).hide()}),l.done(function(){var b;L.remove(a,"fxshow");for(b in m)n.style(a,b,m[b])});for(d in m)g=Ub(p?q[d]:0,d,l),d in q||(q[d]=g.start,p&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function Wb(a,b){var c,d,e,f,g;for(c in a)if(d=n.camelCase(c),e=b[d],f=a[c],n.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=n.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function Xb(a,b,c){var d,e,f=0,g=Qb.length,h=n.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=Lb||Sb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:n.extend({},b),opts:n.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:Lb||Sb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=n.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(Wb(k,j.opts.specialEasing);g>f;f++)if(d=Qb[f].call(j,a,k,j.opts))return d;return n.map(k,Ub,j),n.isFunction(j.opts.start)&&j.opts.start.call(a,j),n.fx.timer(n.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}n.Animation=n.extend(Xb,{tweener:function(a,b){n.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],Rb[c]=Rb[c]||[],Rb[c].unshift(b)},prefilter:function(a,b){b?Qb.unshift(a):Qb.push(a)}}),n.speed=function(a,b,c){var d=a&&"object"==typeof a?n.extend({},a):{complete:c||!c&&b||n.isFunction(a)&&a,duration:a,easing:c&&b||b&&!n.isFunction(b)&&b};return d.duration=n.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in n.fx.speeds?n.fx.speeds[d.duration]:n.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){n.isFunction(d.old)&&d.old.call(this),d.queue&&n.dequeue(this,d.queue)},d},n.fn.extend({fadeTo:function(a,b,c,d){return this.filter(S).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=n.isEmptyObject(a),f=n.speed(b,c,d),g=function(){var b=Xb(this,n.extend({},a),f);(e||L.get(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=n.timers,g=L.get(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&Pb.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&n.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=L.get(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=n.timers,g=d?d.length:0;for(c.finish=!0,n.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),n.each(["toggle","show","hide"],function(a,b){var c=n.fn[b];n.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(Tb(b,!0),a,d,e)}}),n.each({slideDown:Tb("show"),slideUp:Tb("hide"),slideToggle:Tb("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){n.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),n.timers=[],n.fx.tick=function(){var a,b=0,c=n.timers;for(Lb=n.now();b1)},removeAttr:function(a){return this.each(function(){n.removeAttr(this,a)})}}),n.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===U?n.prop(a,b,c):(1===f&&n.isXMLDoc(a)||(b=b.toLowerCase(),d=n.attrHooks[b]||(n.expr.match.bool.test(b)?Zb:Yb)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void n.removeAttr(a,b))
4 | },removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=n.propFix[c]||c,n.expr.match.bool.test(c)&&(a[d]=!1),a.removeAttribute(c)},attrHooks:{type:{set:function(a,b){if(!k.radioValue&&"radio"===b&&n.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),Zb={set:function(a,b,c){return b===!1?n.removeAttr(a,c):a.setAttribute(c,c),c}},n.each(n.expr.match.bool.source.match(/\w+/g),function(a,b){var c=$b[b]||n.find.attr;$b[b]=function(a,b,d){var e,f;return d||(f=$b[b],$b[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,$b[b]=f),e}});var _b=/^(?:input|select|textarea|button)$/i;n.fn.extend({prop:function(a,b){return J(this,n.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[n.propFix[a]||a]})}}),n.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!n.isXMLDoc(a),f&&(b=n.propFix[b]||b,e=n.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){return a.hasAttribute("tabindex")||_b.test(a.nodeName)||a.href?a.tabIndex:-1}}}}),k.optSelected||(n.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null}}),n.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){n.propFix[this.toLowerCase()]=this});var ac=/[\t\r\n\f]/g;n.fn.extend({addClass:function(a){var b,c,d,e,f,g,h="string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).addClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=n.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0===arguments.length||"string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).removeClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?n.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(n.isFunction(a)?function(c){n(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=n(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===U||"boolean"===c)&&(this.className&&L.set(this,"__className__",this.className),this.className=this.className||a===!1?"":L.get(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(ac," ").indexOf(b)>=0)return!0;return!1}});var bc=/\r/g;n.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=n.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,n(this).val()):a,null==e?e="":"number"==typeof e?e+="":n.isArray(e)&&(e=n.map(e,function(a){return null==a?"":a+""})),b=n.valHooks[this.type]||n.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=n.valHooks[e.type]||n.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(bc,""):null==c?"":c)}}}),n.extend({valHooks:{option:{get:function(a){var b=n.find.attr(a,"value");return null!=b?b:n.trim(n.text(a))}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(k.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&n.nodeName(c.parentNode,"optgroup"))){if(b=n(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=n.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=n.inArray(d.value,f)>=0)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),n.each(["radio","checkbox"],function(){n.valHooks[this]={set:function(a,b){return n.isArray(b)?a.checked=n.inArray(n(a).val(),b)>=0:void 0}},k.checkOn||(n.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})}),n.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){n.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),n.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var cc=n.now(),dc=/\?/;n.parseJSON=function(a){return JSON.parse(a+"")},n.parseXML=function(a){var b,c;if(!a||"string"!=typeof a)return null;try{c=new DOMParser,b=c.parseFromString(a,"text/xml")}catch(d){b=void 0}return(!b||b.getElementsByTagName("parsererror").length)&&n.error("Invalid XML: "+a),b};var ec=/#.*$/,fc=/([?&])_=[^&]*/,gc=/^(.*?):[ \t]*([^\r\n]*)$/gm,hc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,ic=/^(?:GET|HEAD)$/,jc=/^\/\//,kc=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,lc={},mc={},nc="*/".concat("*"),oc=a.location.href,pc=kc.exec(oc.toLowerCase())||[];function qc(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(n.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function rc(a,b,c,d){var e={},f=a===mc;function g(h){var i;return e[h]=!0,n.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function sc(a,b){var c,d,e=n.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&n.extend(!0,a,d),a}function tc(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function uc(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}n.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:oc,type:"GET",isLocal:hc.test(pc[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":nc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":n.parseJSON,"text xml":n.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?sc(sc(a,n.ajaxSettings),b):sc(n.ajaxSettings,a)},ajaxPrefilter:qc(lc),ajaxTransport:qc(mc),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=n.ajaxSetup({},b),l=k.context||k,m=k.context&&(l.nodeType||l.jquery)?n(l):n.event,o=n.Deferred(),p=n.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!f){f={};while(b=gc.exec(e))f[b[1].toLowerCase()]=b[2]}b=f[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?e:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return c&&c.abort(b),x(0,b),this}};if(o.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||oc)+"").replace(ec,"").replace(jc,pc[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=n.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(h=kc.exec(k.url.toLowerCase()),k.crossDomain=!(!h||h[1]===pc[1]&&h[2]===pc[2]&&(h[3]||("http:"===h[1]?"80":"443"))===(pc[3]||("http:"===pc[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=n.param(k.data,k.traditional)),rc(lc,k,b,v),2===t)return v;i=n.event&&k.global,i&&0===n.active++&&n.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!ic.test(k.type),d=k.url,k.hasContent||(k.data&&(d=k.url+=(dc.test(d)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=fc.test(d)?d.replace(fc,"$1_="+cc++):d+(dc.test(d)?"&":"?")+"_="+cc++)),k.ifModified&&(n.lastModified[d]&&v.setRequestHeader("If-Modified-Since",n.lastModified[d]),n.etag[d]&&v.setRequestHeader("If-None-Match",n.etag[d])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+nc+"; q=0.01":""):k.accepts["*"]);for(j in k.headers)v.setRequestHeader(j,k.headers[j]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(j in{success:1,error:1,complete:1})v[j](k[j]);if(c=rc(mc,k,b,v)){v.readyState=1,i&&m.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,c.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,f,h){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),c=void 0,e=h||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,f&&(u=tc(k,v,f)),u=uc(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(n.lastModified[d]=w),w=v.getResponseHeader("etag"),w&&(n.etag[d]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?o.resolveWith(l,[r,x,v]):o.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,i&&m.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),i&&(m.trigger("ajaxComplete",[v,k]),--n.active||n.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return n.get(a,b,c,"json")},getScript:function(a,b){return n.get(a,void 0,b,"script")}}),n.each(["get","post"],function(a,b){n[b]=function(a,c,d,e){return n.isFunction(c)&&(e=e||d,d=c,c=void 0),n.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),n._evalUrl=function(a){return n.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},n.fn.extend({wrapAll:function(a){var b;return n.isFunction(a)?this.each(function(b){n(this).wrapAll(a.call(this,b))}):(this[0]&&(b=n(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this)},wrapInner:function(a){return this.each(n.isFunction(a)?function(b){n(this).wrapInner(a.call(this,b))}:function(){var b=n(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=n.isFunction(a);return this.each(function(c){n(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){n.nodeName(this,"body")||n(this).replaceWith(this.childNodes)}).end()}}),n.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0},n.expr.filters.visible=function(a){return!n.expr.filters.hidden(a)};var vc=/%20/g,wc=/\[\]$/,xc=/\r?\n/g,yc=/^(?:submit|button|image|reset|file)$/i,zc=/^(?:input|select|textarea|keygen)/i;function Ac(a,b,c,d){var e;if(n.isArray(b))n.each(b,function(b,e){c||wc.test(a)?d(a,e):Ac(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==n.type(b))d(a,b);else for(e in b)Ac(a+"["+e+"]",b[e],c,d)}n.param=function(a,b){var c,d=[],e=function(a,b){b=n.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=n.ajaxSettings&&n.ajaxSettings.traditional),n.isArray(a)||a.jquery&&!n.isPlainObject(a))n.each(a,function(){e(this.name,this.value)});else for(c in a)Ac(c,a[c],b,e);return d.join("&").replace(vc,"+")},n.fn.extend({serialize:function(){return n.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=n.prop(this,"elements");return a?n.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!n(this).is(":disabled")&&zc.test(this.nodeName)&&!yc.test(a)&&(this.checked||!T.test(a))}).map(function(a,b){var c=n(this).val();return null==c?null:n.isArray(c)?n.map(c,function(a){return{name:b.name,value:a.replace(xc,"\r\n")}}):{name:b.name,value:c.replace(xc,"\r\n")}}).get()}}),n.ajaxSettings.xhr=function(){try{return new XMLHttpRequest}catch(a){}};var Bc=0,Cc={},Dc={0:200,1223:204},Ec=n.ajaxSettings.xhr();a.attachEvent&&a.attachEvent("onunload",function(){for(var a in Cc)Cc[a]()}),k.cors=!!Ec&&"withCredentials"in Ec,k.ajax=Ec=!!Ec,n.ajaxTransport(function(a){var b;return k.cors||Ec&&!a.crossDomain?{send:function(c,d){var e,f=a.xhr(),g=++Bc;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)f.setRequestHeader(e,c[e]);b=function(a){return function(){b&&(delete Cc[g],b=f.onload=f.onerror=null,"abort"===a?f.abort():"error"===a?d(f.status,f.statusText):d(Dc[f.status]||f.status,f.statusText,"string"==typeof f.responseText?{text:f.responseText}:void 0,f.getAllResponseHeaders()))}},f.onload=b(),f.onerror=b("error"),b=Cc[g]=b("abort");try{f.send(a.hasContent&&a.data||null)}catch(h){if(b)throw h}},abort:function(){b&&b()}}:void 0}),n.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return n.globalEval(a),a}}}),n.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),n.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(d,e){b=n("