├── 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 = $(' 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>")+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>");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("