├── ext ├── Spritesheet-01.png ├── css │ ├── table-background.png │ ├── shadowcrypt-colors.css │ └── style.css ├── manifest.json ├── options.html ├── background.js ├── sjcl.js ├── options.js ├── shadowcrypt.js └── jquery │ └── jquery-2.1.0.min.js ├── jquerytest.htm └── design.htm /ext/Spritesheet-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunblaze-ucb/shadowcrypt/HEAD/ext/Spritesheet-01.png -------------------------------------------------------------------------------- /ext/css/table-background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunblaze-ucb/shadowcrypt/HEAD/ext/css/table-background.png -------------------------------------------------------------------------------- /ext/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "ShadowCrypt", 4 | "version": "0.3.3", 5 | 6 | "content_scripts": [ 7 | { 8 | "matches": [""], 9 | "js": ["shadowcrypt.js"], 10 | "run_at": "document_start", 11 | "all_frames": true 12 | } 13 | ], 14 | 15 | "background": { 16 | "scripts": ["background.js"] 17 | }, 18 | 19 | "options_page": "options.html", 20 | "permissions": ["storage"], 21 | "web_accessible_resources": [ 22 | "Spritesheet-01.png" 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /jquerytest.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 |
11 | 32 | -------------------------------------------------------------------------------- /design.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Hello world!

5 |

basic text =?zerokit-1ed6ba13a44a74b4cc151f69e23007d636771723f7059ae730213befeccefa20?9XuAhLWwhYpfkevRGlqLFGgwcAzO2fGSbquvf4fy??= test

6 |
7 |

8 |

9 |

you said:

10 |
11 |

12 |

=?zerokit-1ed6ba13a44a74b4cc151f69e23007d636771723f7059ae730213befeccefa20?vN9B4yqa8UAOXQbcYFb0CSvvKEDJlt5vngAwi3Y=??=
...

13 |

you said:

14 |

and now the html test: "=?zerokit-1ed6ba13a44a74b4cc151f69e23007d636771723f7059ae730213befeccefa20?GN5UWt36lmy6TxO/tx+k1zo6PT/af0rwd7vjNiMWHg92MEgKeDhnLnjHQCPr8ScdsJMVgQy+RrssLB8HQw==?#foo,@bar?=" good luck

15 | 52 |

53 |

54 | -------------------------------------------------------------------------------- /ext/css/shadowcrypt-colors.css: -------------------------------------------------------------------------------- 1 | /* Shadowcrypt colors */ 2 | 3 | .shadowcrypt-key.shadowcrypt-color-1 { 4 | background-position: 0 -25px; 5 | } 6 | 7 | .shadowcrypt-key.shadowcrypt-color-2 { 8 | background-position: 0 -50px; 9 | } 10 | 11 | .shadowcrypt-key.shadowcrypt-color-3 { 12 | background-position: 0 -75px; 13 | } 14 | 15 | .shadowcrypt-key.shadowcrypt-color-4 { 16 | background-position: 0 -100px; 17 | } 18 | 19 | .shadowcrypt-key.shadowcrypt-color-5 { 20 | background-position: 0 -125px; 21 | } 22 | 23 | .shadowcrypt-key.shadowcrypt-color-6 { 24 | background-position: 0 -150px; 25 | } 26 | 27 | .shadowcrypt-locked.shadowcrypt-color-0 .shadowcrypt-lock { 28 | background-position: -120px 0; 29 | } 30 | 31 | .shadowcrypt-locked.shadowcrypt-color-1 .shadowcrypt-lock { 32 | background-position: -120px -40px; 33 | } 34 | 35 | .shadowcrypt-locked.shadowcrypt-color-2 .shadowcrypt-lock { 36 | background-position: -120px -80px; 37 | } 38 | 39 | .shadowcrypt-locked.shadowcrypt-color-3 .shadowcrypt-lock { 40 | background-position: -120px -120px; 41 | } 42 | 43 | .shadowcrypt-locked.shadowcrypt-color-4 .shadowcrypt-lock { 44 | background-position: -160px 0; 45 | } 46 | 47 | .shadowcrypt-locked.shadowcrypt-color-5 .shadowcrypt-lock { 48 | background-position: -160px -40px; 49 | } 50 | 51 | .shadowcrypt-locked.shadowcrypt-color-6 .shadowcrypt-lock { 52 | background-position: -160px -80px; 53 | } 54 | 55 | .shadowcrypt-locked.shadowcrypt-color-0 .shadowcrypt-label, 56 | .shadowcrypt-key-name.shadowcrypt-color-0 { 57 | color: #339999; 58 | } 59 | 60 | .shadowcrypt-locked.shadowcrypt-color-0 .shadowcrypt-input { 61 | border-color: #339999; 62 | box-shadow: inset 0 0 5px #339999; 63 | } 64 | 65 | .shadowcrypt-locked.shadowcrypt-color-1 .shadowcrypt-label, 66 | .shadowcrypt-key-name.shadowcrypt-color-1 { 67 | color: #336699; 68 | } 69 | 70 | .shadowcrypt-locked.shadowcrypt-color-1 .shadowcrypt-input { 71 | border-color: #336699; 72 | box-shadow: inset 0 0 5px #336699; 73 | } 74 | 75 | .shadowcrypt-locked.shadowcrypt-color-2 .shadowcrypt-label, 76 | .shadowcrypt-key-name.shadowcrypt-color-2 { 77 | color: #666699; 78 | } 79 | 80 | .shadowcrypt-locked.shadowcrypt-color-2 .shadowcrypt-input { 81 | border-color: #666699; 82 | box-shadow: inset 0 0 5px #666699; 83 | } 84 | 85 | .shadowcrypt-locked.shadowcrypt-color-3 .shadowcrypt-label, 86 | .shadowcrypt-key-name.shadowcrypt-color-3 { 87 | color: #ad4977; 88 | } 89 | 90 | .shadowcrypt-locked.shadowcrypt-color-3 .shadowcrypt-input { 91 | border-color: #ad4977; 92 | box-shadow: inset 0 0 5px #ad4977; 93 | } 94 | 95 | .shadowcrypt-locked.shadowcrypt-color-4 .shadowcrypt-label, 96 | .shadowcrypt-key-name.shadowcrypt-color-4 { 97 | color: #d1ae4a; 98 | } 99 | 100 | .shadowcrypt-locked.shadowcrypt-color-4 .shadowcrypt-input { 101 | border-color: #d1ae4a; 102 | box-shadow: inset 0 0 5px #d1ae4a; 103 | } 104 | 105 | .shadowcrypt-locked.shadowcrypt-color-5 .shadowcrypt-label, 106 | .shadowcrypt-key-name.shadowcrypt-color-5 { 107 | color: #996633; 108 | } 109 | 110 | .shadowcrypt-locked.shadowcrypt-color-5 .shadowcrypt-input { 111 | border-color: #996633; 112 | box-shadow: inset 0 0 5px #996633; 113 | } 114 | 115 | .shadowcrypt-locked.shadowcrypt-color-6 .shadowcrypt-label, 116 | .shadowcrypt-key-name.shadowcrypt-color-6 { 117 | color: #666666; 118 | } 119 | 120 | .shadowcrypt-locked.shadowcrypt-color-6 .shadowcrypt-input { 121 | border-color: #666666; 122 | box-shadow: inset 0 0 5px #666666; 123 | } 124 | -------------------------------------------------------------------------------- /ext/options.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ShadowCrypt Key Management 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 91 | 92 | 93 | 121 | 122 | 123 | 124 | 125 | 126 |
127 | 128 |
129 |
130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /ext/background.js: -------------------------------------------------------------------------------- 1 | // initialize keys for demo 2 | chrome.storage.sync.get(function (o) { 3 | if (Object.keys(o).length === 0) { 4 | chrome.storage.sync.set( 5 | { 6 | "origin-http://www.reddit.com": { 7 | "defaultFingerprint": "0d26c1facd505778843e88b034ae695fe16db92ce0f480eb013b54ca9b93acdc", 8 | "keys": { 9 | "0d26c1facd505778843e88b034ae695fe16db92ce0f480eb013b54ca9b93acdc": { 10 | "color": 6, 11 | "name": "ShadowCrypt Users", 12 | "note": "ShadowCrypt comes with this key. Anyone can get it.", 13 | "passphrase": "wide open", 14 | "secret": [ 15 | 592810485, 16 | 1756613978, 17 | 3386531780, 18 | 3914334371 19 | ] 20 | } 21 | }, 22 | "rules": [ 23 | { 24 | urlPattern: '', 25 | selector: '.captcha', 26 | noShim: true 27 | }, 28 | { 29 | urlPattern: '', 30 | selector: '[name=user]', 31 | noShim: true 32 | }, 33 | { 34 | urlPattern: '', 35 | selector: '[name=q]', 36 | off: true 37 | } 38 | ] 39 | }, 40 | "origin-https://app.asana.com": { 41 | "defaultFingerprint": "98acda177e3fdadccfafccde193a4fb485fe61e0da45e3812a069031d16ba915", 42 | "keys": { 43 | "98acda177e3fdadccfafccde193a4fb485fe61e0da45e3812a069031d16ba915": { 44 | "color": 6, 45 | "name": "ShadowCrypt Users", 46 | "note": "ShadowCrypt comes with this key. Anyone can get it.", 47 | "passphrase": "wide open", 48 | "secret": [ 49 | 1466772937, 50 | 2591219597, 51 | 1223770414, 52 | 772868465 53 | ] 54 | } 55 | }, 56 | "rules": [ 57 | { 58 | urlPattern: '[^&?]lg*', 59 | selector: "#email_input", 60 | noShim: true, 61 | }, 62 | 63 | { 64 | urlPattern: '[^&?]lg*', 65 | selector: "#password_input", 66 | noShim: true, 67 | }, 68 | 69 | { 70 | urlPattern: '$', 71 | selector: "#nav_search_input", 72 | noShim: false, 73 | off: false, 74 | mode: "wordsQuery" 75 | }, 76 | ] 77 | }, 78 | "origin-https://mail.google.com": { 79 | "defaultFingerprint": "35edbab33e6939068818eab465968aa3eeee426bc37a571022f077da865a2c74", 80 | "keys": { 81 | "35edbab33e6939068818eab465968aa3eeee426bc37a571022f077da865a2c74": { 82 | "color": 6, 83 | "name": "ShadowCrypt Users", 84 | "note": "ShadowCrypt comes with this key. Anyone can get it.", 85 | "passphrase": "wide open", 86 | "secret": [ 87 | 1081330386, 88 | 1897912442, 89 | 1011823286, 90 | 3617319768 91 | ] 92 | } 93 | }, 94 | "rules": [ 95 | { 96 | urlPattern: '/mail/', 97 | selector: "[name=q]", 98 | off: true, 99 | mode: "wordsQuery" 100 | }, 101 | 102 | { 103 | urlPattern: "/mail/", 104 | selector: "[name=to],[name=cc],[name=bcc]", 105 | noShim: true 106 | }, 107 | 108 | { 109 | urlPattern: "/mail$", 110 | selector: "[role=textbox]", 111 | mode: "words" 112 | } 113 | ] 114 | }, 115 | "origin-https://twitter.com": { 116 | "defaultFingerprint": "4ff95cef5a76149b687f7b54908cd2fa168794e214cedf9ee1a5df1dfec13057", 117 | "keys": { 118 | "4ff95cef5a76149b687f7b54908cd2fa168794e214cedf9ee1a5df1dfec13057": { 119 | "color": 6, 120 | "name": "ShadowCrypt Users", 121 | "note": "ShadowCrypt comes with this key. Anyone can get it.", 122 | "passphrase": "wide open", 123 | "secret": [ 124 | 3974799740, 125 | 158280801, 126 | 3624313247, 127 | 1839113757 128 | ] 129 | } 130 | }, 131 | "rules": [ 132 | { 133 | urlPattern: '$', 134 | selector: ".email-input", 135 | noShim: true, 136 | off: true, 137 | mode: "none" 138 | }, 139 | 140 | { 141 | urlPattern: 'login', 142 | selector: ".js-password-field", 143 | noShim: true, 144 | off: true, 145 | mode: "none" 146 | }, 147 | 148 | { 149 | urlPattern: '$', 150 | selector: ".search-input", 151 | noShim: false, 152 | off: true, 153 | mode: "wordsQuery" 154 | }, 155 | 156 | { 157 | urlPattern: '$', 158 | selector: ".dm-to-input", 159 | noShim: true, 160 | off: true, 161 | mode: "none" 162 | }, 163 | ] 164 | }, 165 | "origin-https://www.facebook.com": { 166 | "defaultFingerprint": "0235909f3873546ad90d439679339ecec80ed8ebc4adcdd9420775fba16a9bd1", 167 | "keys": { 168 | "0235909f3873546ad90d439679339ecec80ed8ebc4adcdd9420775fba16a9bd1": { 169 | "color": 6, 170 | "name": "ShadowCrypt Users", 171 | "note": "ShadowCrypt comes with this key. Anyone can get it.", 172 | "passphrase": "wide open", 173 | "secret": [ 174 | 2200342711, 175 | 1762975859, 176 | 1997565962, 177 | 416743212 178 | ] 179 | } 180 | }, 181 | "rules": [ 182 | { 183 | urlPattern: '$', 184 | selector: "#email", 185 | noShim: true, 186 | off: true, 187 | mode: "none" 188 | }, 189 | 190 | { 191 | urlPattern: '$', 192 | selector: "#pass", 193 | noShim: true, 194 | }, 195 | 196 | { 197 | urlPattern: '$', 198 | selector: ".inputtext.DOMControl_placeholder.hidden_elem", 199 | noShim: false, 200 | off: true, 201 | mode: "wordsQuery" 202 | }, 203 | 204 | { 205 | urlPattern: '$', 206 | selector: ".inputtext.DOMControl_placeholder", 207 | noShim: true, 208 | }, 209 | 210 | { 211 | urlPattern: '$', 212 | selector: ".inputtext.inputsearch.textInput", 213 | off: true, 214 | mode: "wordsQuery" 215 | }, 216 | 217 | { 218 | urlPattern: '$', 219 | selector: ".inputtext.inputsearch", 220 | off: true, 221 | mode: "wordsQuery" 222 | }, 223 | 224 | { 225 | urlPattern: '$', 226 | selector: "#u_0_1", 227 | noShim: true 228 | }, 229 | 230 | { 231 | urlPattern: '$', 232 | selector: "#u_0_a", 233 | noShim: true 234 | }, 235 | 236 | { 237 | urlPattern: '$', 238 | selector: "#u_0_3", 239 | noShim: true 240 | }, 241 | 242 | { 243 | urlPattern: '$', 244 | selector: "#u_0_5", 245 | noShim: true 246 | }, 247 | 248 | { 249 | urlPattern: '$', 250 | selector: "#u_0_8", 251 | noShim: true 252 | }, 253 | ] 254 | } 255 | } 256 | ); 257 | } 258 | }); 259 | -------------------------------------------------------------------------------- /ext/css/style.css: -------------------------------------------------------------------------------- 1 | @import url(http://fonts.googleapis.com/css?family=Open+Sans:300); 2 | 3 | body { 4 | position: relative; 5 | font-family: "Open Sans", sans-serif; 6 | color: #333333; 7 | width: 700px; 8 | margin: 1em auto; 9 | } 10 | 11 | .button { 12 | display: inline-block; 13 | font: 500 13px "Open Sans"; 14 | text-align: center; 15 | text-transform: uppercase; 16 | padding: 0.5em 1em; 17 | margin: 0 1em 0 0; 18 | color: #333333; 19 | border-radius: 4px; 20 | cursor: pointer; 21 | border: none; 22 | background-color: #e6e6e6; 23 | } 24 | 25 | .button:hover { 26 | background-color: #9ca7af; 27 | color: white; 28 | } 29 | 30 | #domain-list { 31 | margin-top: 1em; 32 | width: 100%; 33 | min-height: 33em; 34 | } 35 | 36 | .keys-table-wrapper { 37 | border: solid 1px #cccccc; 38 | border-radius: 4px; 39 | background-image: url("table-background.png"); 40 | font: 300 17px "Open Sans"; 41 | } 42 | 43 | .keys-table { 44 | width: 100%; 45 | border-spacing: 0; 46 | border-collapse: collapse; 47 | } 48 | 49 | .keys-table .domain-name { 50 | width: 250px; 51 | } 52 | 53 | .keys-table tr { 54 | height: 40px; 55 | } 56 | 57 | .keys-table tr:hover { 58 | background-color: #9ca7af; 59 | color: white; 60 | } 61 | 62 | .keys-table td { 63 | padding: 0 0.5em; 64 | } 65 | 66 | .shadowcrypt-key { 67 | width: 40px; 68 | height: 25px; 69 | background: url("../Spritesheet-01.png"); 70 | } 71 | 72 | .keys-table .key-holder, .keys-table .delete-button { 73 | position: relative; 74 | display: inline-block; 75 | cursor: pointer; 76 | border: 0; 77 | background: none; 78 | } 79 | 80 | .keys-table .key-holder { 81 | top: 7px; 82 | } 83 | 84 | .keys-table .delete-button { 85 | visibility: hidden; 86 | float: right; 87 | background: -40px 0 url("../Spritesheet-01.png"); 88 | width: 40px; 89 | height: 40px; 90 | transition: transform ease-in-out 0.2s 0s; 91 | } 92 | 93 | .keys-table tr:hover .delete-button { 94 | visibility: visible; 95 | } 96 | 97 | .keys-table .delete-button:hover { 98 | transform: scale(1.2); 99 | } 100 | 101 | .keys-table .shadowcrypt-key { 102 | position: relative; 103 | display: inline-block; 104 | transition: transform ease-in-out 0.2s, opacity ease-in-out 0.2s; 105 | transform: scale(0.9) rotate(-20deg); 106 | opacity: 0.5; 107 | } 108 | 109 | .keys-table .key-holder.default-key .shadowcrypt-key { 110 | transform: rotate(-20deg) scale(1); 111 | opacity: 1; 112 | } 113 | 114 | .keys-table .key-holder:hover .shadowcrypt-key { 115 | transform: translate(0, -2px) rotate(-25deg) scale(1.2); 116 | opacity: 1; 117 | 118 | } 119 | 120 | .keys-table .key-name-wrapper { 121 | position: absolute; 122 | left: 50%; 123 | z-index: 1; 124 | visibility: hidden; 125 | opacity: 0; 126 | transition: all ease-in-out 0.2s 0s; 127 | } 128 | 129 | .keys-table .key-holder:hover .key-name-wrapper { 130 | visibility: visible; 131 | opacity: 1; 132 | transition: all ease-in-out 0.2s 1s; 133 | } 134 | 135 | .keys-table.tooltip-active .key-holder:hover .key-name-wrapper { 136 | transition: all ease-in-out 0.2s 0; 137 | } 138 | 139 | .keys-table .key-holder.default-key .shadowcrypt-key-name:after { 140 | content: " [default]"; 141 | font-variant: small-caps; 142 | font-weight: 500; 143 | } 144 | 145 | .keys-table .key-holder.default-key:only-child .shadowcrypt-key-name:after { 146 | content: ""; 147 | } 148 | 149 | 150 | .keys-table .shadowcrypt-key-name { 151 | position: relative; 152 | left: -50%; 153 | top: -1px; 154 | background-color: white; 155 | border: solid 1px #cccccc; 156 | white-space: nowrap; 157 | font: 10px "Open Sans"; 158 | padding: 3px; 159 | 160 | } 161 | 162 | /* MODAL DIALOGS */ 163 | 164 | .modal, .modal-fade { 165 | position: fixed; 166 | left: 0; 167 | right: 0; 168 | top: 0; 169 | bottom: 0; 170 | } 171 | 172 | .modal { 173 | z-index: 1000; 174 | transition: visibility 0s linear 0.3s, opacity 0.3s; 175 | visibility: hidden; 176 | opacity: 0; 177 | overflow: hidden; 178 | } 179 | 180 | .modal.displayed { 181 | opacity: 1; 182 | visibility: visible; 183 | transition-delay:0s; 184 | } 185 | 186 | .modal .modal-element { 187 | visibility: hidden; 188 | transition: visibility 0s linear 0.3s; 189 | } 190 | 191 | .modal.displayed .displayed.modal-element { 192 | visibility: visible; 193 | transition-delay:0s; 194 | } 195 | 196 | .modal-fade { 197 | background-color: white; 198 | opacity: 0; 199 | } 200 | 201 | .modal.fade-out .modal-fade { 202 | opacity: 0.3; 203 | } 204 | 205 | .dialog { 206 | position: absolute; 207 | display: table; 208 | margin: auto; 209 | top: 0; left: 0; bottom: 0; right: 0; 210 | width: 476px; 211 | padding: 15px 12px 20px; 212 | border-radius: 4px; 213 | font-size: 14px; 214 | 215 | border: solid 1px #ccc; 216 | box-shadow: 0px 5px 10px rgba(0,0,0,0.3); 217 | background-color: white; 218 | } 219 | 220 | #dialog-box .dialog { 221 | width: 376px; 222 | } 223 | 224 | .dialog h2 { 225 | font-size: 24px; 226 | font-weight: 300; 227 | margin-bottom: 1em; 228 | margin-top: 0; 229 | text-align: center; 230 | } 231 | 232 | .dialog h2#edit-key-title { 233 | text-align: left; 234 | } 235 | 236 | .dialog h2#edit-key-title .shadowcrypt-key { 237 | display: inline-block; 238 | transform: translate(0,4px) rotate(-20deg) ; 239 | margin-right: 0.5em; 240 | } 241 | 242 | .dialog .dialog-content { 243 | font-size: 16px; 244 | text-align: center; 245 | font-weight: 300; 246 | } 247 | 248 | .dialog p { 249 | margin: 0; 250 | } 251 | 252 | .dialog .dialog-content p { 253 | margin-bottom: 1em; 254 | } 255 | 256 | .dialog .hint { 257 | float: right; 258 | font-weight: 300; 259 | color: #999; 260 | } 261 | 262 | .dialog label, .dialog .label { 263 | text-transform: uppercase; 264 | } 265 | 266 | .dialog input, .dialog .input, .dialog textarea { 267 | width: 450px; 268 | background: #f2f2f2; 269 | border: 1px solid #cccccc; 270 | padding: 8px 12px; 271 | margin: 7px 0 22px; 272 | font: 300 18px "Open Sans"; 273 | } 274 | 275 | .dialog .key-color-selection input[type=radio] { 276 | display: none; 277 | } 278 | 279 | .dialog textarea { 280 | min-height: 4em; 281 | } 282 | 283 | .dialog .export-string, #key-dialog-import, .dialog textarea { 284 | font-size: 14px; 285 | } 286 | 287 | .dialog .key-color-selection label { 288 | display: inline-block; 289 | width: 40px; 290 | height: 40px; 291 | border-radius: 3px; 292 | cursor: pointer; 293 | } 294 | 295 | .dialog .key-color-selection .shadowcrypt-key { 296 | display: inline-block; 297 | transform: translate(1px,8px) rotate(-20deg) ; 298 | } 299 | 300 | .dialog .key-color-selection input[type=radio]:checked + label { 301 | background-color: #cccccc; 302 | } 303 | 304 | .dialog .button { 305 | display: inline-block; 306 | } 307 | 308 | .dialog .dialog-buttons { 309 | position: relative; 310 | text-align: center; 311 | } 312 | 313 | .dialog .delete-button { 314 | position: absolute; 315 | right: 0; 316 | bottom: -1px; 317 | background: -79px -4px url("../Spritesheet-01.png"); 318 | width: 40px; 319 | height: 33px; 320 | cursor: pointer; 321 | border-radius: 4px; 322 | } 323 | 324 | .dialog .delete-button:hover { 325 | background-color: #9ca7af; 326 | background-position: -79px -44px; 327 | } 328 | 329 | /* Specific dialogs */ 330 | 331 | #key-dialog .dialog-area { 332 | display: none; 333 | } 334 | 335 | #key-dialog.new-key .new-key.dialog-area { 336 | display: block; 337 | } 338 | 339 | #key-dialog.edit-key .edit-key.dialog-area { 340 | display: block; 341 | } 342 | 343 | #key-dialog.import-key .import-key.dialog-area { 344 | display: block; 345 | } 346 | 347 | -------------------------------------------------------------------------------- /ext/sjcl.js: -------------------------------------------------------------------------------- 1 | "use strict";function q(a){throw a;}var t=void 0,u=!1;var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}}}; 2 | "undefined"!==typeof module&&module.exports&&(module.exports=sjcl); 3 | sjcl.cipher.aes=function(a){this.k[0][0][0]||this.D();var b,c,d,e,f=this.k[0][4],g=this.k[1];b=a.length;var h=1;4!==b&&(6!==b&&8!==b)&&q(new sjcl.exception.invalid("invalid aes key size"));this.b=[d=a.slice(0),e=[]];for(a=b;a<4*b+28;a++){c=d[a-1];if(0===a%b||8===b&&4===a%b)c=f[c>>>24]<<24^f[c>>16&255]<<16^f[c>>8&255]<<8^f[c&255],0===a%b&&(c=c<<8^c>>>24^h<<24,h=h<<1^283*(h>>7));d[a]=d[a-b]^c}for(b=0;a;b++,a--)c=d[b&3?a:a-4],e[b]=4>=a||4>b?c:g[0][f[c>>>24]]^g[1][f[c>>16&255]]^g[2][f[c>>8&255]]^g[3][f[c& 4 | 255]]}; 5 | sjcl.cipher.aes.prototype={encrypt:function(a){return y(this,a,0)},decrypt:function(a){return y(this,a,1)},k:[[[],[],[],[],[]],[[],[],[],[],[]]],D:function(){var a=this.k[0],b=this.k[1],c=a[4],d=b[4],e,f,g,h=[],l=[],k,n,m,p;for(e=0;0x100>e;e++)l[(h[e]=e<<1^283*(e>>7))^e]=e;for(f=g=0;!c[f];f^=k||1,g=l[g]||1){m=g^g<<1^g<<2^g<<3^g<<4;m=m>>8^m&255^99;c[f]=m;d[m]=f;n=h[e=h[k=h[f]]];p=0x1010101*n^0x10001*e^0x101*k^0x1010100*f;n=0x101*h[m]^0x1010100*m;for(e=0;4>e;e++)a[e][f]=n=n<<24^n>>>8,b[e][m]=p=p<<24^p>>>8}for(e= 6 | 0;5>e;e++)a[e]=a[e].slice(0),b[e]=b[e].slice(0)}}; 7 | function y(a,b,c){4!==b.length&&q(new sjcl.exception.invalid("invalid aes block size"));var d=a.b[c],e=b[0]^d[0],f=b[c?3:1]^d[1],g=b[2]^d[2];b=b[c?1:3]^d[3];var h,l,k,n=d.length/4-2,m,p=4,s=[0,0,0,0];h=a.k[c];a=h[0];var r=h[1],v=h[2],w=h[3],x=h[4];for(m=0;m>>24]^r[f>>16&255]^v[g>>8&255]^w[b&255]^d[p],l=a[f>>>24]^r[g>>16&255]^v[b>>8&255]^w[e&255]^d[p+1],k=a[g>>>24]^r[b>>16&255]^v[e>>8&255]^w[f&255]^d[p+2],b=a[b>>>24]^r[e>>16&255]^v[f>>8&255]^w[g&255]^d[p+3],p+=4,e=h,f=l,g=k;for(m=0;4> 8 | m;m++)s[c?3&-m:m]=x[e>>>24]<<24^x[f>>16&255]<<16^x[g>>8&255]<<8^x[b&255]^d[p++],h=e,e=f,f=g,g=b,b=h;return s} 9 | sjcl.bitArray={bitSlice:function(a,b,c){a=sjcl.bitArray.P(a.slice(b/32),32-(b&31)).slice(1);return c===t?a:sjcl.bitArray.clamp(a,c-b)},extract:function(a,b,c){var d=Math.floor(-b-c&31);return((b+c-1^b)&-32?a[b/32|0]<<32-d^a[b/32+1|0]>>>d:a[b/32|0]>>>d)&(1<>b-1,1));return a},partial:function(a,b,c){return 32===a?b:(c?b|0:b<<32-a)+0x10000000000*a},getPartial:function(a){return Math.round(a/0x10000000000)||32},equal:function(a,b){if(sjcl.bitArray.bitLength(a)!==sjcl.bitArray.bitLength(b))return u;var c=0,d;for(d=0;d>>b),c=a[e]<<32-b;e=a.length?a[a.length-1]:0;a=sjcl.bitArray.getPartial(e);d.push(sjcl.bitArray.partial(b+a&31,32>>24),e<<=8;return decodeURIComponent(escape(b))},toBits:function(a){a=unescape(encodeURIComponent(a));var b=[],c,d=0;for(c=0;c>>e)>>>26),6>e?(g=a[c]<<6-e,e+=26,c++):(g<<=6,e-=6);for(;d.length&3&&!b;)d+="=";return d},toBits:function(a,b){a=a.replace(/\s|=/g,"");var c=[],d,e=0,f=sjcl.codec.base64.J,g=0,h;b&&(f=f.substr(0,62)+"-_");for(d=0;dh&&q(new sjcl.exception.invalid("this isn't base64!")),26>>e),g=h<<32-e):(e+=6,g^=h<<32-e);e&56&&c.push(sjcl.bitArray.partial(e&56,g,1));return c}};sjcl.codec.base64url={fromBits:function(a){return sjcl.codec.base64.fromBits(a,1,1)},toBits:function(a){return sjcl.codec.base64.toBits(a,1)}};sjcl.hash.sha256=function(a){this.b[0]||this.D();a?(this.r=a.r.slice(0),this.o=a.o.slice(0),this.h=a.h):this.reset()};sjcl.hash.sha256.hash=function(a){return(new sjcl.hash.sha256).update(a).finalize()}; 16 | sjcl.hash.sha256.prototype={blockSize:512,reset:function(){this.r=this.N.slice(0);this.o=[];this.h=0;return this},update:function(a){"string"===typeof a&&(a=sjcl.codec.utf8String.toBits(a));var b,c=this.o=sjcl.bitArray.concat(this.o,a);b=this.h;a=this.h=b+sjcl.bitArray.bitLength(a);for(b=512+b&-512;b<=a;b+=512)z(this,c.splice(0,16));return this},finalize:function(){var a,b=this.o,c=this.r,b=sjcl.bitArray.concat(b,[sjcl.bitArray.partial(1,1)]);for(a=b.length+2;a&15;a++)b.push(0);b.push(Math.floor(this.h/ 17 | 4294967296));for(b.push(this.h|0);b.length;)z(this,b.splice(0,16));this.reset();return c},N:[],b:[],D:function(){function a(a){return 0x100000000*(a-Math.floor(a))|0}var b=0,c=2,d;a:for(;64>b;c++){for(d=2;d*d<=c;d++)if(0===c%d)continue a;8>b&&(this.N[b]=a(Math.pow(c,0.5)));this.b[b]=a(Math.pow(c,1/3));b++}}}; 18 | function z(a,b){var c,d,e,f=b.slice(0),g=a.r,h=a.b,l=g[0],k=g[1],n=g[2],m=g[3],p=g[4],s=g[5],r=g[6],v=g[7];for(c=0;64>c;c++)16>c?d=f[c]:(d=f[c+1&15],e=f[c+14&15],d=f[c&15]=(d>>>7^d>>>18^d>>>3^d<<25^d<<14)+(e>>>17^e>>>19^e>>>10^e<<15^e<<13)+f[c&15]+f[c+9&15]|0),d=d+v+(p>>>6^p>>>11^p>>>25^p<<26^p<<21^p<<7)+(r^p&(s^r))+h[c],v=r,r=s,s=p,p=m+d|0,m=n,n=k,k=l,l=d+(k&n^m&(k^n))+(k>>>2^k>>>13^k>>>22^k<<30^k<<19^k<<10)|0;g[0]=g[0]+l|0;g[1]=g[1]+k|0;g[2]=g[2]+n|0;g[3]=g[3]+m|0;g[4]=g[4]+p|0;g[5]=g[5]+s|0;g[6]= 19 | g[6]+r|0;g[7]=g[7]+v|0} 20 | sjcl.mode.ccm={name:"ccm",encrypt:function(a,b,c,d,e){var f,g=b.slice(0),h=sjcl.bitArray,l=h.bitLength(c)/8,k=h.bitLength(g)/8;e=e||64;d=d||[];7>l&&q(new sjcl.exception.invalid("ccm: iv must be at least 7 bytes"));for(f=2;4>f&&k>>>8*f;f++);f<15-l&&(f=15-l);c=h.clamp(c,8*(15-f));b=sjcl.mode.ccm.L(a,b,c,d,e,f);g=sjcl.mode.ccm.p(a,g,c,b,e,f);return h.concat(g.data,g.tag)},decrypt:function(a,b,c,d,e){e=e||64;d=d||[];var f=sjcl.bitArray,g=f.bitLength(c)/8,h=f.bitLength(b),l=f.clamp(b,h-e),k=f.bitSlice(b, 21 | h-e),h=(h-e)/8;7>g&&q(new sjcl.exception.invalid("ccm: iv must be at least 7 bytes"));for(b=2;4>b&&h>>>8*b;b++);b<15-g&&(b=15-g);c=f.clamp(c,8*(15-b));l=sjcl.mode.ccm.p(a,l,c,k,e,b);a=sjcl.mode.ccm.L(a,l.data,c,d,e,b);f.equal(l.tag,a)||q(new sjcl.exception.corrupt("ccm: tag doesn't match"));return l.data},L:function(a,b,c,d,e,f){var g=[],h=sjcl.bitArray,l=h.l;e/=8;(e%2||4>e||16=c?g=[h.partial(16,c)]:0xffffffff>=c&&(g=h.concat([h.partial(16,65534)],[c]));g=h.concat(g,d);for(d=0;de.bitLength(c)&&(h=f(h,d(h)),c=e.concat(c,[-2147483648,0,0,0]));g=f(g,c);return a.encrypt(f(d(f(h, 27 | d(h))),g))},H:function(a){return[a[0]<<1^a[1]>>>31,a[1]<<1^a[2]>>>31,a[2]<<1^a[3]>>>31,a[3]<<1^135*(a[0]>>>31)]}}; 28 | sjcl.mode.gcm={name:"gcm",encrypt:function(a,b,c,d,e){var f=b.slice(0);b=sjcl.bitArray;d=d||[];a=sjcl.mode.gcm.p(!0,a,f,d,c,e||128);return b.concat(a.data,a.tag)},decrypt:function(a,b,c,d,e){var f=b.slice(0),g=sjcl.bitArray,h=g.bitLength(f);e=e||128;d=d||[];e<=h?(b=g.bitSlice(f,h-e),f=g.bitSlice(f,0,h-e)):(b=f,f=[]);a=sjcl.mode.gcm.p(u,a,f,d,c,e);g.equal(a.tag,b)||q(new sjcl.exception.corrupt("gcm: tag doesn't match"));return a.data},Z:function(a,b){var c,d,e,f,g,h=sjcl.bitArray.l;e=[0,0,0,0];f=b.slice(0); 29 | for(c=0;128>c;c++){(d=0!==(a[Math.floor(c/32)]&1<<31-c%32))&&(e=h(e,f));g=0!==(f[3]&1);for(d=3;0>>1|(f[d-1]&1)<<31;f[0]>>>=1;g&&(f[0]^=-0x1f000000)}return e},g:function(a,b,c){var d,e=c.length;b=b.slice(0);for(d=0;de&&(a=b.hash(a));for(d=0;dd||0>c)&&q(sjcl.exception.invalid("invalid params to pbkdf2"));"string"===typeof a&&(a=sjcl.codec.utf8String.toBits(a));"string"===typeof b&&(b=sjcl.codec.utf8String.toBits(b));e=e||sjcl.misc.hmac;a=new e(a);var f,g,h,l,k=[],n=sjcl.bitArray;for(l=1;32*k.length<(d||1);l++){e=f=a.encrypt(n.concat(b,[l]));for(g=1;gg;g++)e.push(0x100000000*Math.random()|0);for(g=0;g=1<this.j&&(this.j=f);this.F++; 36 | this.b=sjcl.hash.sha256.hash(this.b.concat(e));this.A=new sjcl.cipher.aes(this.b);for(d=0;4>d&&!(this.f[d]=this.f[d]+1|0,this.f[d]);d++);}for(d=0;d>>=1;this.c[g].update([d,this.C++,2,b,f,a.length].concat(a))}break;case "string":b===t&&(b=a.length);this.c[g].update([d,this.C++,3,b,f,a.length]);this.c[g].update(a);break;default:l=1}l&&q(new sjcl.exception.bug("random: addEntropy only supports number, array of numbers or string"));this.i[g]+=b;this.d+=b;h===this.m&&(this.isReady()!==this.m&&C("seeded",Math.max(this.j,this.d)),C("progress",this.getProgress()))},isReady:function(a){a=this.I[a!==t?a:this.B];return this.j&&this.j>=a?this.i[0]>this.R&& 39 | (new Date).valueOf()>this.O?this.u|this.t:this.t:this.d>=a?this.u|this.m:this.m},getProgress:function(a){a=this.I[a?a:this.B];return this.j>=a?1:this.d>a?1:this.d/a},startCollectors:function(){this.q||(this.a={loadTimeCollector:D(this,this.aa),mouseCollector:D(this,this.ba),keyboardCollector:D(this,this.$),accelerometerCollector:D(this,this.U)},window.addEventListener?(window.addEventListener("load",this.a.loadTimeCollector,u),window.addEventListener("mousemove",this.a.mouseCollector,u),window.addEventListener("keypress", 40 | this.a.keyboardCollector,u),window.addEventListener("devicemotion",this.a.accelerometerCollector,u)):document.attachEvent?(document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)):q(new sjcl.exception.bug("can't attach event")),this.q=!0)},stopCollectors:function(){this.q&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,u),window.removeEventListener("mousemove", 41 | this.a.mouseCollector,u),window.removeEventListener("keypress",this.a.keyboardCollector,u),window.removeEventListener("devicemotion",this.a.accelerometerCollector,u)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.q=u)},addEventListener:function(a,b){this.w[a][this.V++]=b},removeEventListener:function(a,b){var c,d,e=this.w[a],f=[];for(d in e)e.hasOwnProperty(d)&& 42 | e[d]===b&&f.push(d);for(c=0;cb&&!(a.f[b]=a.f[b]+1|0,a.f[b]);b++);return a.A.encrypt(a.f)} 44 | function D(a,b){return function(){b.apply(a,arguments)}}sjcl.random=new sjcl.prng(6); 45 | a:try{var F,G,H,I;if(I="undefined"!==typeof module){var J;if(J=module.exports){var K;try{K=require("crypto")}catch(L){K=null}J=(G=K)&&G.randomBytes}I=J}if(I)F=G.randomBytes(128),F=new Uint32Array((new Uint8Array(F)).buffer),sjcl.random.addEntropy(F,1024,"crypto['randomBytes']");else if(window&&Uint32Array){H=new Uint32Array(32);if(window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(H);else if(window.msCrypto&&window.msCrypto.getRandomValues)window.msCrypto.getRandomValues(H); 46 | else break a;sjcl.random.addEntropy(H,1024,"crypto['getRandomValues']")}}catch(M){"undefined"!==typeof window&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(M))} 47 | sjcl.json={defaults:{v:1,iter:1E3,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},Y:function(a,b,c,d){c=c||{};d=d||{};var e=sjcl.json,f=e.e({iv:sjcl.random.randomWords(4,0)},e.defaults),g;e.e(f,c);c=f.adata;"string"===typeof f.salt&&(f.salt=sjcl.codec.base64.toBits(f.salt));"string"===typeof f.iv&&(f.iv=sjcl.codec.base64.toBits(f.iv));(!sjcl.mode[f.mode]||!sjcl.cipher[f.cipher]||"string"===typeof a&&100>=f.iter||64!==f.ts&&96!==f.ts&&128!==f.ts||128!==f.ks&&192!==f.ks&&0x100!==f.ks||2>f.iv.length||4< 48 | f.iv.length)&&q(new sjcl.exception.invalid("json encrypt: invalid parameters"));"string"===typeof a?(g=sjcl.misc.cachedPbkdf2(a,f),a=g.key.slice(0,f.ks/32),f.salt=g.salt):sjcl.ecc&&a instanceof sjcl.ecc.elGamal.publicKey&&(g=a.kem(),f.kemtag=g.tag,a=g.key.slice(0,f.ks/32));"string"===typeof b&&(b=sjcl.codec.utf8String.toBits(b));"string"===typeof c&&(c=sjcl.codec.utf8String.toBits(c));g=new sjcl.cipher[f.cipher](a);e.e(d,f);d.key=a;f.ct=sjcl.mode[f.mode].encrypt(g,b,f.iv,c,f.ts);return f},encrypt:function(a, 49 | b,c,d){var e=sjcl.json,f=e.Y.apply(e,arguments);return e.encode(f)},X:function(a,b,c,d){c=c||{};d=d||{};var e=sjcl.json;b=e.e(e.e(e.e({},e.defaults),b),c,!0);var f;c=b.adata;"string"===typeof b.salt&&(b.salt=sjcl.codec.base64.toBits(b.salt));"string"===typeof b.iv&&(b.iv=sjcl.codec.base64.toBits(b.iv));(!sjcl.mode[b.mode]||!sjcl.cipher[b.cipher]||"string"===typeof a&&100>=b.iter||64!==b.ts&&96!==b.ts&&128!==b.ts||128!==b.ks&&192!==b.ks&&0x100!==b.ks||!b.iv||2>b.iv.length||4
" + key.name + "
"); 110 | 111 | // Edit key button. 112 | keyButton.click(function () { 113 | originLength = "origin-".length; 114 | $("#edit-key-domain").text(url.slice(originLength)); 115 | 116 | $("#key-dialog-name").val(key.name); 117 | 118 | $("#key-dialog-passphrase").val(key.passphrase); 119 | 120 | $("#key-dialog-note").val(key.note); 121 | 122 | for (var keyFingerprint in domain.keys) { 123 | if (domain.keys[keyFingerprint] == key) break; 124 | } 125 | 126 | $("#key-dialog-default").prop("checked", domain.defaultFingerprint == keyFingerprint); 127 | 128 | $("#key-dialog-export").text(exportKeyFunction(url, key)); 129 | 130 | var keyCopy = jQuery.extend({}, key); 131 | 132 | onKeyChangeCallback = function() { 133 | keyCopy.name = $("#key-dialog-name").val(); 134 | keyCopy.color = activeEditKeyColor; 135 | $("#key-dialog-export").text(exportKeyFunction(url, keyCopy)); 136 | }; 137 | 138 | resetEditKeyColor(key.color); 139 | 140 | displayKeyDialog("edit-key", function() { 141 | 142 | // OK action at the end of edit key. 143 | var newName = $("#key-dialog-name").val(); 144 | var newColor = activeEditKeyColor; 145 | var newNote = $("#key-dialog-note").val(); 146 | var newPassphrase = $("#key-dialog-passphrase").val(); 147 | var isDefault = $("#key-dialog-default").prop("checked"); 148 | 149 | // Verify new data. 150 | if (!verifyKeyName(newName, domain, key, url)) { 151 | return false; 152 | } 153 | 154 | // Update the UI. 155 | var label = keyButton.find(".shadowcrypt-key-name"); 156 | keyButton.find(".shadowcrypt-key").add(label).removeClass("shadowcrypt-color-" + key.color).addClass("shadowcrypt-color-" + newColor); 157 | label.text(newName); 158 | 159 | if (isDefault) { 160 | changeDefaultKey(domain, key); 161 | } 162 | 163 | // Update the object. 164 | key.name = newName; 165 | key.color = newColor; 166 | key.note = newNote; 167 | key.passphrase = newPassphrase 168 | 169 | var updateStorage = {}; 170 | updateStorage[url] = domain; 171 | 172 | 173 | // Report to callback. 174 | editKeyCallback(domain, key, url); 175 | 176 | // Return true if everything is OK and dialog should close. 177 | return true; 178 | }, function(deletedCallback){ 179 | // Delete key action. 180 | var name = $("#key-dialog-name").val(); 181 | displayOKCancelDialog("

Delete key " + name + "?

", function(){ 182 | deleteKey(domain, key, url); 183 | hideKeyDialog(); 184 | }); 185 | }); 186 | }); 187 | 188 | var hover = false; 189 | 190 | keyButton.hover(function(){ 191 | hover=true; 192 | globalHoverCounter++; 193 | setTimeout(function(){ 194 | if (hover) { 195 | keysTable.addClass("tooltip-active"); 196 | } 197 | }, 1000); 198 | }, function(){ 199 | hover=false; 200 | globalHoverCounter--; 201 | setTimeout(function(){ 202 | if (globalHoverCounter == 0 ) { 203 | keysTable.removeClass("tooltip-active"); 204 | } 205 | }, 200); 206 | }); 207 | 208 | domain.keysHolder.append(keyButton); 209 | } 210 | 211 | function createDomainUI(domain, url){ 212 | // Create domain editor row. 213 | var protocolIndex = url.indexOf("://"); 214 | 215 | if (protocolIndex > -1) { 216 | protocolIndex += 3; 217 | } else { 218 | protocolIndex = 0; 219 | } 220 | 221 | var displayName = url.substr(protocolIndex); 222 | var row = $("" + displayName + ""); 223 | domain.row = row; 224 | 225 | // Create keys cell. 226 | var keysCell = $(""); 227 | 228 | // Delete button 229 | var deleteButton = $("
"); 230 | deleteButton.click(function() { 231 | displayOKCancelDialog("

Delete all the keys for domain " + displayName + "?

", function(){ 232 | var keys = $.extend({}, domain.keys); 233 | for (var key in keys) { 234 | deleteKey(domain, keys[key], url); 235 | } 236 | }); 237 | }); 238 | keysCell.append(deleteButton); 239 | 240 | // Create keys holder. 241 | var keysHolder = $("
"); 242 | keysCell.append(keysHolder); 243 | row.append(keysCell); 244 | domain.keysHolder = keysHolder; 245 | 246 | for (var fingerprint in domain.keys) { 247 | var key = domain.keys[fingerprint]; 248 | createKeyUI(domain, key, domain.defaultFingerprint == fingerprint, url); 249 | } 250 | 251 | // Insert row. 252 | keysTable.append(row); 253 | } 254 | 255 | for (var origin in domains) { 256 | createDomainUI(domains[origin], origin); 257 | }; 258 | 259 | // Helper for updating the UI with a new key 260 | function addNewKeyUI(url, key, fingerprint, isDefault) { 261 | // Is this an existing domain? 262 | // Add the key to the database and create the UI. 263 | if (url.slice(0, "origin-".length) != "origin-") { 264 | url = 'origin-' + url; 265 | } 266 | var domain = domains[url]; 267 | 268 | if (domain) { 269 | // Verify data. 270 | if (!verifyKeyName(key.name, domain, null, url)) { 271 | return false; 272 | } 273 | domain.keys[fingerprint] = key; 274 | createKeyUI(domain, key, isDefault, url); 275 | } else { 276 | domain = { 277 | keys: {}, 278 | "defaultFingerprint": fingerprint, 279 | rules: [] 280 | }; 281 | domain.keys[fingerprint] = key; 282 | domains[url] = domain; 283 | createDomainUI(domain, url); 284 | } 285 | 286 | var newDomain = {}; 287 | newDomain[url] = domain; 288 | 289 | newKeyCallback(domain, key, url); 290 | 291 | if (isDefault) { 292 | changeDefaultKey(domain, url); 293 | } 294 | 295 | // Return true if key was added OK. 296 | return true; 297 | } 298 | 299 | // Helper for deleting a key from the UI 300 | function deleteKey(domain, key, url) { 301 | var keys = Object.keys(domain.keys), 302 | eyIndex, 303 | isEmpty, 304 | fingerprint; 305 | 306 | for (var i = 0; i < keys.length; i++) { 307 | if (domain.keys[keys[i]] == key) { 308 | fingerprint = keys[i]; 309 | keyIndex = i; 310 | break; 311 | } 312 | } 313 | 314 | delete domain.keys[fingerprint]; 315 | 316 | domain.keysHolder.find(".key-holder")[keyIndex].remove(); 317 | // If the domain is empty, remove it. 318 | if ($.isEmptyObject(domain.keys)) { 319 | domain.row.remove(); 320 | for (var site in domains) { 321 | if ($.isEmptyObject(domains[site].keys)) { 322 | delete domains[site]; 323 | isEmpty = true; 324 | } 325 | } 326 | } else { 327 | // Make sure to reassign the default if needed. 328 | if (domain.defaultFingerprint == fingerprint) { 329 | // Default was deleted, reassign to the end. 330 | var keys = Object.keys(domain.keys), 331 | newDefault = keys[keys.length - 1]; 332 | changeDefaultKey(domain, domain.keys[newDefault]); 333 | } 334 | } 335 | 336 | // Report to callback. 337 | deleteKeyCallback(domain, key, url, isEmpty); 338 | } 339 | 340 | // Helper for making sure the key name is unique 341 | function verifyKeyName(name, domain, existing, url) { 342 | var nameOK = true; 343 | 344 | for (fingerprint in domain.keys) { 345 | var key = domain.keys[fingerprint]; 346 | if (key.name == name && key != existing) { 347 | displayCloseDialog("

The name " + name + " is already in use for " + url +". Please choose another key name.

"); 348 | nameOK = false; 349 | } 350 | } 351 | 352 | return nameOK; 353 | } 354 | 355 | // Helper for changing the default key of the domain 356 | function changeDefaultKey(domain, key) { 357 | var oldDefault = domain.defaultFingerprint; 358 | 359 | // Remove old default key. 360 | 361 | // Add new one. 362 | var index = 0, 363 | oldIndex = 0; 364 | 365 | for (var fingerprint in domain.keys) { 366 | if (fingerprint == oldDefault) break; 367 | oldIndex++; 368 | } 369 | 370 | //After loop, fingerprint is current key's fingerprint 371 | for (fingerprint in domain.keys) { 372 | if (domain.keys[fingerprint] == key) break; 373 | index++; 374 | } 375 | 376 | for (var url in domains) { 377 | if (domains[url] == domain) break; 378 | } 379 | 380 | domain.keysHolder.find(".key-holder").eq(oldIndex).removeClass("default-key"); 381 | domain.defaultFingerprint = fingerprint; 382 | domain.keysHolder.find(".key-holder").eq(index).addClass("default-key"); 383 | 384 | // Report to callack if default has changed. 385 | if (domain.defaultFingerprint != oldDefault) { 386 | defaultChangedCallback(domain, key, url); 387 | } 388 | } 389 | 390 | 391 | // Hook up the main toolbar buttons. 392 | 393 | // New key 394 | $("#new-key-button").click(function(){ 395 | 396 | var url = "", 397 | secret = Array.prototype.slice.call(window.crypto.getRandomValues(new Uint32Array(4))), 398 | fingerprint = sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(secret)), 399 | key = { 400 | name: "Default", 401 | color: Math.floor(Math.random() * 7), 402 | note: "", 403 | passphrase: "", 404 | secret: secret, 405 | }; 406 | 407 | $("#key-dialog-url").val(url); 408 | 409 | $("#key-dialog-name").val(key.name); 410 | 411 | $("#key-dialog-note").val(key.note); 412 | 413 | $("#key-dialog-passphrase").val(key.passphrase); 414 | 415 | $("#key-dialog-default").prop("checked", true); 416 | 417 | $("#key-dialog-export").text(exportKeyFunction(url, key)); 418 | 419 | onKeyChangeCallback = function() { 420 | key.name = $("#key-dialog-name").val(); 421 | key.color = activeEditKeyColor; 422 | url = $("#key-dialog-url").val(); 423 | $("#key-dialog-export").text(exportKeyFunction(url, key)); 424 | }; 425 | 426 | resetEditKeyColor(key.color); 427 | 428 | displayKeyDialog("new-key", function(){ 429 | // OK action at the end of add new key. 430 | onKeyChangeCallback(); 431 | // Update the UI. 432 | var changeDefault = $("#key-dialog-default").prop("checked"); 433 | var success = addNewKeyUI(url, key, fingerprint, changeDefault); 434 | if (!success) { 435 | return false; 436 | } 437 | 438 | // Return true if everything is OK and dialog should close. 439 | setTimeout(function () { 440 | displayCloseDialog('

Key added for ' + url + '

'); 441 | }, 100); 442 | 443 | return true; 444 | }); 445 | }); 446 | 447 | // Import key 448 | $("#import-key-button").click(function () { 449 | $("#key-dialog-import").val(""); 450 | 451 | displayKeyDialog("import-key", function(){ 452 | var string = $("#key-dialog-import").val(); 453 | 454 | var entry = importKeyFunction(string); 455 | 456 | if (! string) { 457 | displayCloseDialog('

Wrong key format. Try recopying the key

'); 458 | return false; 459 | } 460 | 461 | var fingerprint = sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(entry.key.secret)); 462 | var success = addNewKeyUI(entry.url, entry.key, fingerprint, false) 463 | if (!success) return false; 464 | 465 | displayCloseDialog('

New key added for ' + entry.url + '

'); 466 | return true; 467 | }); 468 | }); 469 | 470 | // Hook up dialog buttons. 471 | $("#key-dialog-delete").click(function(){ 472 | var deleted = false; 473 | if (keyDialogDeleteCallback) { 474 | keyDialogDeleteCallback(); 475 | } 476 | 477 | return false; 478 | }); 479 | 480 | $("#key-dialog-cancel").click(function(){ 481 | hideKeyDialog(); 482 | 483 | return false; 484 | }); 485 | 486 | function keyDialogConfirmed(){ 487 | var success = true; 488 | if (keyDialogCallback) { 489 | success = keyDialogCallback(); 490 | } 491 | 492 | if (success) hideKeyDialog(); 493 | 494 | return false; 495 | } 496 | 497 | $("#key-dialog-ok").click(keyDialogConfirmed); 498 | $("#key-dialog").submit(keyDialogConfirmed); 499 | 500 | $("#dialog-cancel").add("#dialog-close").click(hideDialog); 501 | $("#dialog-ok").click(function(){ 502 | if (dialogCallback) { 503 | dialogCallback(); 504 | dialogCallback = null; 505 | } 506 | 507 | hideDialog(); 508 | }); 509 | 510 | 511 | // Hook up color selection buttons. 512 | for (var i=0;i<7;i++) { 513 | (function(i){ 514 | $("#key-dialog-color" + i).click(function(){ 515 | changeEditKeyColor(i); 516 | onKeyChangeCallback(); 517 | });})(i); 518 | } 519 | 520 | // Hook up input box changes. 521 | $("#key-dialog-name").add("#key-dialog-url").change(function(){ 522 | onKeyChangeCallback(); 523 | }); 524 | 525 | $("#key-dialog-name").add("#key-dialog-url").keyup(function(){ 526 | onKeyChangeCallback(); 527 | }); 528 | }; 529 | 530 | }; 531 | 532 | function prepareSyncData(domain, url) { 533 | var newDoamin = {}; 534 | newDoamin[url] = domain; 535 | return newDoamin; 536 | } 537 | 538 | function onNewKey(domain, key, url) { 539 | chrome.storage.sync.set(prepareSyncData(domain, url)); 540 | console.log("Key " + key.name + " created for URL " + url); 541 | return key; 542 | } 543 | 544 | function onEditKey(domain, key, url) { 545 | chrome.storage.sync.set(prepareSyncData(domain, url)); 546 | console.log("Key " + key.name + " at URL " + url + " was edited."); 547 | } 548 | 549 | function onDeletedKey(domain, key, url, isEmpty) { 550 | if (isEmpty) { 551 | chrome.storage.sync.remove(url); 552 | } else { 553 | chrome.storage.sync.set(prepareSyncData(domain, url)); 554 | } 555 | console.log("Key " + key.name + " deleted for URL " + url); 556 | }; 557 | 558 | function onDefaultChange(domain, key, url) { 559 | chrome.storage.sync.set(prepareSyncData(domain, url)); 560 | console.log("Key " + key.name + " is now the default for URL " + url + "."); 561 | } 562 | 563 | // On load initialize the UI 564 | $(function () { 565 | chrome.storage.sync.get(function (domains) { 566 | shadowCrypt.KeyManagement.initialize( 567 | domains 568 | , onNewKey 569 | , onEditKey 570 | , onDeletedKey 571 | , function(url, key){ 572 | // This is a function that transforms a key object into an export string. 573 | return url + " [" + key.name + "] " + sjcl.codec.hex.fromBits(key.secret); 574 | }, function(string){ 575 | // This is a function that transforms a key string into a key object. 576 | try { 577 | var parts = string.split(" "); 578 | var url = parts[0]; 579 | var name = parts[1].substr(1, parts[1].length-2); 580 | var secret = sjcl.codec.hex.toBits(parts[2]); 581 | return { 582 | url: url, 583 | key: { 584 | name: name, 585 | color: Math.floor(Math.random() * 7), 586 | secret: secret, 587 | } 588 | }; 589 | } catch (e) { 590 | return false; 591 | } 592 | }, onDefaultChange 593 | ); 594 | }); 595 | }); 596 | -------------------------------------------------------------------------------- /ext/shadowcrypt.js: -------------------------------------------------------------------------------- 1 | var Compat = { 2 | afterSubmit: function (f) { setTimeout(f, 0); }, 3 | getInnerText: function (e) { return e.innerText; }, 4 | matches: function (e, s) { return e.webkitMatchesSelector(s); } 5 | }; 6 | 7 | var Content = {}; 8 | 9 | Content.within = function () { 10 | function onSetup(e) { 11 | setup(e.target.contentWindow); 12 | } 13 | 14 | function onShimProp(e) { 15 | var node = e.target; 16 | var name = e.detail.name; 17 | var value = e.detail.value; 18 | Object.defineProperty(node, name, { 19 | get: function () { 20 | return value; 21 | }, 22 | set: function (v) { 23 | value = v; 24 | var event = new CustomEvent('shadowcrypt-prop-set-' + name, {detail: value}); 25 | node.dispatchEvent(event); 26 | } 27 | }); 28 | node.addEventListener('shadowcrypt-set-prop-' + name, function (e) { 29 | value = e.detail; 30 | }); 31 | } 32 | 33 | function onShimMethod(e) { 34 | // no args or return value lol 35 | var node = e.target; 36 | var name = e.detail.name; 37 | node[name] = function () { 38 | var event = new Event('shadowcrypt-method-call-' + name); 39 | node.dispatchEvent(event); 40 | }; 41 | } 42 | 43 | function onDeleteProp(e) { 44 | var node = e.target; 45 | var name = e.detail.name; 46 | delete node[name]; 47 | } 48 | 49 | function notInContentEditable(win, selection) { 50 | return !(win.document.hasFocus() && win.document.activeElement.contentEditable === 'true'); 51 | } 52 | 53 | var warned = false; 54 | 55 | function gateMethodProto(proto, methodName, predicate) { 56 | var orig = proto[methodName]; 57 | proto[methodName] = function () { 58 | if (predicate(this)) return orig.apply(this, arguments); 59 | if (!warned) { 60 | console.warn('ignoring method ' + methodName); 61 | warned = true; 62 | } 63 | }; 64 | } 65 | 66 | function selectorIsUnsafe(selectors) { 67 | selectors = '' + selectors; 68 | var withoutStrings = selectors 69 | .replace(/"(?:\\\\|\\"|[^"\\]")*"/g, '""') 70 | .replace(/'(?:\\\\|\\'|[^'\\]')*"/g, '\'\''); 71 | // http://dev.w3.org/csswg/css-scoping/#deep-combinator 72 | return /\/deep\/|>>>/.test(withoutStrings); 73 | } 74 | 75 | function shimQuerySelector(proto) { 76 | var origQuerySelector = proto.querySelector; 77 | proto.querySelector = function (selectors) { 78 | if (selectorIsUnsafe(selectors)) return null; 79 | return origQuerySelector.call(this, selectors); 80 | }; 81 | var origQuerySelectorAll = proto.querySelectorAll; 82 | proto.querySelectorAll = function (selectors) { 83 | if (selectorIsUnsafe(selectors)) return origQuerySelectorAll.call(this, ':not(*|*)'); 84 | return origQuerySelectorAll.call(this, selectors); 85 | }; 86 | } 87 | 88 | function shimSelectorsAPI(win) { 89 | shimQuerySelector(win.Document.prototype); 90 | shimQuerySelector(win.DocumentFragment.prototype); 91 | shimQuerySelector(win.Element.prototype); 92 | } 93 | 94 | function setup(win) { 95 | win.addEventListener('shadowcrypt-add-listeners', onSetup, true); 96 | win.addEventListener('shadowcrypt-shim-prop', onShimProp, true); 97 | win.addEventListener('shadowcrypt-shim-method', onShimMethod, true); 98 | win.addEventListener('shadowcrypt-delete-prop', onDeleteProp, true); 99 | // caveat: you can't touch selection anymore 100 | gateMethodProto(win.Selection.prototype, 'removeAllRanges', notInContentEditable.bind(null, win)); 101 | gateMethodProto(win.Selection.prototype, 'addRange', notInContentEditable.bind(null, win)); 102 | // caveat: breaks shadow dom for content 103 | delete Element.createShadowRoot; 104 | shimSelectorsAPI(win); 105 | } 106 | 107 | setup(window); 108 | }; 109 | 110 | Content.init = function () { 111 | var script = document.createElement('script'); 112 | script.textContent = '(' + Content.within + ')();'; 113 | document.documentElement.appendChild(script); 114 | }; 115 | 116 | Content.propagate = function (iframe) { 117 | var event = new Event('shadowcrypt-add-listeners', false, false); 118 | iframe.dispatchEvent(event); 119 | }; 120 | 121 | Content.shimProp = function (node, name, value, handler) { 122 | node.addEventListener('shadowcrypt-prop-set-' + name, function (e) { 123 | handler(e.detail); 124 | }); 125 | var event = new CustomEvent('shadowcrypt-shim-prop', {detail: {name: name, value: value}}); 126 | node.dispatchEvent(event); 127 | return function (v) { 128 | var event = new CustomEvent('shadowcrypt-set-prop-' + name, {detail: v}); 129 | node.dispatchEvent(event); 130 | }; 131 | }; 132 | 133 | Content.shimMethod = function (node, name, handler) { 134 | node.addEventListener('shadowcrypt-method-call-' + name, function (e) { 135 | handler(); 136 | }); 137 | var event = new CustomEvent('shadowcrypt-shim-method', {detail: {name: name}}); 138 | node.dispatchEvent(event); 139 | }; 140 | 141 | Content.deleteProp = function (node, name) { 142 | var event = new CustomEvent('shadowcrypt-delete-prop', {detail: {name: name}}); 143 | node.dispatchEvent(event); 144 | }; 145 | 146 | // this is sjcl configured with: 147 | // --compress=yui --without-all --with-aes --with-bitArray --with-codecString --with-codecHex --with-codecBase64 --with-sha256 --with-ccm --with-hmac 148 | var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}}};sjcl.cipher.aes=function(h){if(!this._tables[0][0][0]){this._precompute()}var d,c,e,g,l,f=this._tables[0][4],k=this._tables[1],a=h.length,b=1;if(a!==4&&a!==6&&a!==8){throw new sjcl.exception.invalid("invalid aes key size")}this._key=[g=h.slice(0),l=[]];for(d=a;d<4*a+28;d++){e=g[d-1];if(d%a===0||(a===8&&d%a===4)){e=f[e>>>24]<<24^f[e>>16&255]<<16^f[e>>8&255]<<8^f[e&255];if(d%a===0){e=e<<8^e>>>24^b<<24;b=b<<1^(b>>7)*283}}g[d]=g[d-a]^e}for(c=0;d;c++,d--){e=g[c&3?d:d-4];if(d<=4||c<4){l[c]=e}else{l[c]=k[0][f[e>>>24]]^k[1][f[e>>16&255]]^k[2][f[e>>8&255]]^k[3][f[e&255]]}}};sjcl.cipher.aes.prototype={encrypt:function(a){return this._crypt(a,0)},decrypt:function(a){return this._crypt(a,1)},_tables:[[[],[],[],[],[]],[[],[],[],[],[]]],_precompute:function(){var j=this._tables[0],q=this._tables[1],h=j[4],n=q[4],g,l,f,k=[],c=[],b,p,m,o,e,a;for(g=0;g<0x100;g++){c[(k[g]=g<<1^(g>>7)*283)^g]=g}for(l=f=0;!h[l];l^=b||1,f=c[f]||1){o=f^f<<1^f<<2^f<<3^f<<4;o=o>>8^o&255^99;h[l]=o;n[o]=l;m=k[p=k[b=k[l]]];a=m*0x1010101^p*0x10001^b*0x101^l*0x1010100;e=k[o]*0x101^o*0x1010100;for(g=0;g<4;g++){j[g][l]=e=e<<24^e>>>8;q[g][o]=a=a<<24^a>>>8}}for(g=0;g<5;g++){j[g]=j[g].slice(0);q[g]=q[g].slice(0)}},_crypt:function(k,n){if(k.length!==4){throw new sjcl.exception.invalid("invalid aes block size")}var y=this._key[n],v=k[0]^y[0],u=k[n?3:1]^y[1],t=k[2]^y[2],s=k[n?1:3]^y[3],w,e,m,x=y.length/4-2,p,o=4,q=[0,0,0,0],r=this._tables[n],j=r[0],h=r[1],g=r[2],f=r[3],l=r[4];for(p=0;p>>24]^h[u>>16&255]^g[t>>8&255]^f[s&255]^y[o];e=j[u>>>24]^h[t>>16&255]^g[s>>8&255]^f[v&255]^y[o+1];m=j[t>>>24]^h[s>>16&255]^g[v>>8&255]^f[u&255]^y[o+2];s=j[s>>>24]^h[v>>16&255]^g[u>>8&255]^f[t&255]^y[o+3];o+=4;v=w;u=e;t=m}for(p=0;p<4;p++){q[n?3&-p:p]=l[v>>>24]<<24^l[u>>16&255]<<16^l[t>>8&255]<<8^l[s&255]^y[o++];w=v;v=u;u=t;t=s;s=w}return q}};sjcl.bitArray={bitSlice:function(b,c,d){b=sjcl.bitArray._shiftRight(b.slice(c/32),32-(c&31)).slice(1);return(d===undefined)?b:sjcl.bitArray.clamp(b,d-c)},extract:function(c,d,f){var b,e=Math.floor((-d-f)&31);if((d+f-1^d)&-32){b=(c[d/32|0]<<(32-e))^(c[d/32+1|0]>>>e)}else{b=c[d/32|0]>>>e}return b&((1<0&&b){d[c-1]=sjcl.bitArray.partial(b,d[c-1]&2147483648>>(b-1),1)}return d},partial:function(b,a,c){if(b===32){return a}return(c?a|0:a<<(32-b))+b*0x10000000000},getPartial:function(a){return Math.round(a/0x10000000000)||32},equal:function(e,d){if(sjcl.bitArray.bitLength(e)!==sjcl.bitArray.bitLength(d)){return false}var c=0,f;for(f=0;f=32;c-=32){f.push(h);h=0}if(c===0){return f.concat(d)}for(g=0;g>>c);h=d[g]<<(32-c)}b=d.length?d[d.length-1]:0;e=sjcl.bitArray.getPartial(b);f.push(sjcl.bitArray.partial(c+e&31,(c+e>32)?h:f.pop(),1));return f},_xor4:function(a,b){return[a[0]^b[0],a[1]^b[1],a[2]^b[2],a[3]^b[3]]}};sjcl.codec.utf8String={fromBits:function(a){var b="",e=sjcl.bitArray.bitLength(a),d,c;for(d=0;d>>24);c<<=8}return decodeURIComponent(escape(b))},toBits:function(d){d=unescape(encodeURIComponent(d));var a=[],c,b=0;for(c=0;c>>j)>>>26);if(j<6){f=g[e]<<(6-j);j+=26;e++}else{f<<=6;j-=6}}while((d.length&3)&&!k){d+="="}return d},toBits:function(h,f){h=h.replace(/\s|=/g,"");var d=[],e,g=0,j=sjcl.codec.base64._chars,b=0,a;if(f){j=j.substr(0,62)+"-_"}for(e=0;e26){g-=26;d.push(b^a>>>g);b=a<<(32-g)}else{g+=6;b^=a<<(32-g)}}if(g&56){d.push(sjcl.bitArray.partial(g&56,b,1))}return d}};sjcl.codec.base64url={fromBits:function(a){return sjcl.codec.base64.fromBits(a,1,1)},toBits:function(a){return sjcl.codec.base64.toBits(a,1)}};sjcl.hash.sha256=function(a){if(!this._key[0]){this._precompute()}if(a){this._h=a._h.slice(0);this._buffer=a._buffer.slice(0);this._length=a._length}else{this.reset()}};sjcl.hash.sha256.hash=function(a){return(new sjcl.hash.sha256()).update(a).finalize()};sjcl.hash.sha256.prototype={blockSize:512,reset:function(){this._h=this._init.slice(0);this._buffer=[];this._length=0;return this},update:function(f){if(typeof f==="string"){f=sjcl.codec.utf8String.toBits(f)}var e,a=this._buffer=sjcl.bitArray.concat(this._buffer,f),d=this._length,c=this._length=d+sjcl.bitArray.bitLength(f);for(e=512+d&-512;e<=c;e+=512){this._block(a.splice(0,16))}return this},finalize:function(){var c,a=this._buffer,d=this._h;a=sjcl.bitArray.concat(a,[sjcl.bitArray.partial(1,1)]);for(c=a.length+2;c&15;c++){a.push(0)}a.push(Math.floor(this._length/0x100000000));a.push(this._length|0);while(a.length){this._block(a.splice(0,16))}this.reset();return d},_init:[],_key:[],_precompute:function(){var d=0,c=2,b;function a(e){return(e-Math.floor(e))*0x100000000|0}outer:for(;d<64;c++){for(b=2;b*b<=c;b++){if(c%b===0){continue outer}}if(d<8){this._init[d]=a(Math.pow(c,1/2))}this._key[d]=a(Math.pow(c,1/3));d++}},_block:function(q){var e,f,t,s,u=q.slice(0),j=this._h,c=this._key,r=j[0],p=j[1],o=j[2],n=j[3],m=j[4],l=j[5],g=j[6],d=j[7];for(e=0;e<64;e++){if(e<16){f=u[e]}else{t=u[(e+1)&15];s=u[(e+14)&15];f=u[e&15]=((t>>>7^t>>>18^t>>>3^t<<25^t<<14)+(s>>>17^s>>>19^s>>>10^s<<15^s<<13)+u[e&15]+u[(e+9)&15])|0}f=(f+d+(m>>>6^m>>>11^m>>>25^m<<26^m<<21^m<<7)+(g^m&(l^g))+c[e]);d=g;g=l;l=m;m=n+f|0;n=o;o=p;p=r;r=(f+((p&o)^(n&(p^o)))+(p>>>2^p>>>13^p>>>22^p<<30^p<<19^p<<10))|0}j[0]=j[0]+r|0;j[1]=j[1]+p|0;j[2]=j[2]+o|0;j[3]=j[3]+n|0;j[4]=j[4]+m|0;j[5]=j[5]+l|0;j[6]=j[6]+g|0;j[7]=j[7]+d|0}};sjcl.mode.ccm={name:"ccm",encrypt:function(c,b,e,m,d){var j,g,f=b.slice(0),l,k=sjcl.bitArray,a=k.bitLength(e)/8,h=k.bitLength(f)/8;d=d||64;m=m||[];if(a<7){throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes")}for(j=2;j<4&&h>>>8*j;j++){}if(j<15-a){j=15-a}e=k.clamp(e,8*(15-j));l=sjcl.mode.ccm._computeTag(c,b,e,m,d,j);f=sjcl.mode.ccm._ctrMode(c,f,e,l,d,j);return k.concat(f.data,f.tag)},decrypt:function(b,c,e,n,d){d=d||64;n=n||[];var j,g,l=sjcl.bitArray,a=l.bitLength(e)/8,h=l.bitLength(c),f=l.clamp(c,h-d),m=l.bitSlice(c,h-d),k;h=(h-d)/8;if(a<7){throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes")}for(j=2;j<4&&h>>>8*j;j++){}if(j<15-a){j=15-a}e=l.clamp(e,8*(15-j));f=sjcl.mode.ccm._ctrMode(b,f,e,m,d,j);k=sjcl.mode.ccm._computeTag(b,f.data,e,n,d,j);if(!l.equal(f.tag,k)){throw new sjcl.exception.corrupt("ccm: tag doesn't match")}return f.data},_computeTag:function(d,c,f,p,e,m){var b,l,n=0,g=24,j,h,a=[],o=sjcl.bitArray,k=o._xor4;e/=8;if(e%2||e<4||e>16){throw new sjcl.exception.invalid("ccm: invalid tag length")}if(p.length>0xffffffff||c.length>0xffffffff){throw new sjcl.exception.bug("ccm: can't deal with 4GiB or more data")}l=[o.partial(8,(p.length?1<<6:0)|(e-2)<<2|m-1)];l=o.concat(l,f);l[3]|=o.bitLength(c)/8;l=d.encrypt(l);if(p.length){j=o.bitLength(p)/8;if(j<=65279){a=[o.partial(16,j)]}else{if(j<=0xffffffff){a=o.concat([o.partial(16,65534)],[j])}}a=o.concat(a,p);for(h=0;ha){d=e.hash(d)}for(b=0;b>> Crypto.BLOOM_PREFIX_SHIFT; 201 | }; 202 | 203 | Bloom.prototype.addInternal = function (item) { 204 | for (var j = 0; j < Bloom.K; j++) { 205 | this.bits[this.hash(j, b)] = true; 206 | } 207 | this.count++; 208 | }; 209 | 210 | Bloom.prototype.addReal = function (data) { 211 | if (this.count >= Bloom.N) throw new Error('too many unique words'); 212 | var item = sjcl.codec.utf8String.toBits(data); 213 | this.addInternal(item); 214 | }; 215 | 216 | Bloom.prototype.addRandom = function () { 217 | var item = window.crypto.getRandomValues(new Uint32Array(Bloom.EXTRA_WORD_LENGTH)); 218 | this.addInternal(item); 219 | }; 220 | 221 | Bloom.prototype.pad = function () { 222 | while (this.count < Bloom.K) { 223 | this.addRandom(); 224 | } 225 | }; 226 | 227 | var Scanner = function (impl, root) { 228 | this.root = root; 229 | this.iter = impl.createNodeIterator(root, NodeFilter.SHOW_TEXT); 230 | this.u = 0; 231 | this.v = 0; 232 | this.next(); 233 | }; 234 | 235 | Scanner.getNodeLength = function (node) { 236 | // simplified implementation of 237 | // http://dom.spec.whatwg.org/#concept-node-length 238 | // supporting only Element and CharacterData Nodes 239 | if (node.nodeType === Document.TYPE_ELEMENT) { 240 | return node.childNodes.length; 241 | } else { 242 | return node.length; 243 | } 244 | }; 245 | 246 | Scanner.prototype.next = function () { 247 | this.n = this.iter.nextNode(); 248 | this.u = this.v; 249 | this.v = this.u + this.n.length; 250 | }; 251 | 252 | Scanner.prototype.setStart = function (range, index) { 253 | while (this.n) { 254 | if (index >= this.u && index < this.v) return range.setStart(this.n, index - this.u); 255 | this.next(); 256 | } 257 | throw new Error('index out of bounds', index); 258 | }; 259 | 260 | Scanner.prototype.setEnd = function (range, index) { 261 | while (this.n) { 262 | if (index > this.u && index <= this.v) return range.setEnd(this.n, index - this.u); 263 | this.next(); 264 | } 265 | throw new Error('index out of bounds', index); 266 | }; 267 | 268 | Scanner.prototype.sink = function (range, light) { 269 | // 1. sink from offsets to containers 270 | if (range.startOffset !== 0) return; 271 | if (range.endOffset !== Scanner.getNodeLength(range.endContainer)) return; 272 | 273 | // 2. sink from containers to common ancestor 274 | var ancestor = range.commonAncestorContainer; 275 | var startContainer = range.startContainer; 276 | while (startContainer !== ancestor) { 277 | if (startContainer.previousSibling) return; 278 | startContainer = startContainer.parentNode; 279 | } 280 | var endContainer = range.endContainer; 281 | while (endContainer !== ancestor) { 282 | if (endContainer.nextSibling) return; 283 | endContainer = endContainer.parentNode; 284 | } 285 | 286 | if (light) { 287 | // 3a. done 288 | range.selectNodeContents(ancestor); 289 | } else { 290 | // 3b. sink from common ancestor to first ancestor with sibling 291 | while (ancestor !== this.root) { 292 | if (ancestor.previousSibling) break; 293 | if (ancestor.nextSibling) break; 294 | ancestor = ancestor.parentNode; 295 | } 296 | 297 | // 4b. done 298 | range.selectNode(ancestor); 299 | } 300 | }; 301 | 302 | var Tags = { 303 | LINK_PATTERN: /(?:@|#|\/r\/|\/u\/)\w+/g, 304 | LINK_TEST_PATTERN: /^(?:@|#|\/r\/|\/u\/)\w+$/, // same as above, but with ^...$ 305 | WORD_PATTERN: /\w+/g, // todo: this could be better 306 | modes: {} 307 | }; 308 | 309 | Tags.modes.none = function (secret, message) { 310 | // nothing! 311 | }; 312 | 313 | Tags.modes.links = function (secret, message) { 314 | var tags = []; 315 | var seen = {}; 316 | var match; 317 | while (match = Tags.LINK_PATTERN.exec(message)) { 318 | var tag = match[0]; 319 | if (tag in seen) continue; 320 | tags.push(tag); 321 | seen[tag] = true; 322 | } 323 | return tags; 324 | }; 325 | 326 | Tags.modes.words = function (secret, message) { 327 | var tags = []; 328 | var seen = {}; 329 | var match; 330 | while (match = Tags.WORD_PATTERN.exec(message)) { 331 | // note: case sensitive 332 | var word = match[0]; 333 | var name = ':' + word; 334 | if (name in seen) continue; 335 | var tag = Crypto.hmac(secret, word); 336 | tags.push(tag); 337 | seen[name] = true; 338 | } 339 | return tags.sort(); 340 | }; 341 | 342 | Tags.modes.wordsQuery = function (secret, message) { 343 | return Tags.modes.words(secret, message); 344 | }; 345 | Tags.modes.wordsQuery.queryOnly = true; 346 | 347 | Tags.modes.bloom = function (secret, message) { 348 | var match; 349 | var seen = {}; 350 | var bloom = new Bloom(secret); 351 | var count = 0; 352 | while (match = Tags.WORD_PATTERN.exec(message)) { 353 | var word = match[0]; 354 | var name = ':' + word; 355 | if (name in seen) continue; 356 | bloom.add(word); 357 | seen[name] = true; 358 | } 359 | var tags = []; 360 | for (var i = 0; i < Bloom.M; i++) { 361 | if (i in b) tags.push('b' + i); 362 | } 363 | return tags; 364 | }; 365 | 366 | Tags.readLinks = function (impl, scanner, text, match) { 367 | var start = match.index + 16 + match[1].length + match[2].length; 368 | var end = start + match[3].length; 369 | var tags = []; 370 | while (start < end) { 371 | var comma = text.indexOf(',', start); 372 | if (comma === -1 || comma > end) comma = end; 373 | var tag = text.slice(start, comma); 374 | if (!Tags.LINK_TEST_PATTERN.test(tag)) continue; 375 | var range = impl.createRange(); 376 | scanner.setStart(range, start); 377 | scanner.setEnd(range, comma); 378 | scanner.sink(range); 379 | tags.push([tag, range.cloneContents()]); 380 | start = comma + 1; 381 | } 382 | return tags; 383 | }; 384 | 385 | Tags.insertLinks = function (impl, message, tags) { 386 | // might have matched CODE_PATTERN[3] but not any LINK_PATTERN 387 | if (!tags.length) return impl.createTextNode(message); 388 | var frags = []; 389 | var map = {}; 390 | for (var i = 0; i < tags.length; i++) { 391 | frags.push(tags[i][0] + '\\b'); 392 | map[tags[i][0]] = tags[i][1]; 393 | } 394 | var pattern = new RegExp(frags.join('|'), 'g'); 395 | var result = impl.createDocumentFragment(); 396 | var last = 0; 397 | var match; 398 | while (match = pattern.exec(message)) { 399 | if (match.index > last) { 400 | result.appendChild(impl.createTextNode(message.slice(last, match.index))); 401 | } 402 | result.appendChild(map[match[0]].cloneNode(true)); // lol chrome defaults to (false) 403 | last = match.index + match[0].length; 404 | } 405 | if (last < message.length) { 406 | result.appendChild(impl.createTextNode(message.slice(last))); 407 | } 408 | return result; 409 | }; 410 | 411 | var Codec = { 412 | CODE_PATTERN: /=\?shadowcrypt-(\w*)\?([A-Za-z0-9+\/=]*)\?([^?\s]*)\?=/g 413 | // reflect changes in Tags.readLinks 414 | }; 415 | 416 | Codec.encode = function (mode, fingerprint, message) { 417 | if (message === '') return ''; 418 | var key = Crypto.getKey(fingerprint); 419 | if (mode.queryOnly) { 420 | return mode(message).join(' '); 421 | } else { 422 | var tags = mode(key.secret, message).join(','); 423 | var data = Crypto.encrypt(key.secret, message, tags); 424 | return '=?shadowcrypt-' + fingerprint + '?' + data + '?' + tags + '?='; 425 | } 426 | }; 427 | 428 | Codec.decode = function (fingerprint, data, tags) { 429 | var key = Crypto.getKey(fingerprint); 430 | return Crypto.decrypt(key.secret, data, tags); 431 | }; 432 | 433 | var Rewriter = { 434 | FAST_FAIL_QUERY: '=?shadowcrypt-', 435 | HIGHLIGHT_COLORS: [ 436 | 'rgba(51,153,153,0.125)', 437 | 'rgba(51,102,153,0.125)', 438 | 'rgba(102,102,153,0.125)', 439 | 'rgba(173,73,119,0.125)', 440 | 'rgba(209,174,74,0.125)', 441 | 'rgba(153,102,51,0.125)', 442 | 'rgba(102,102,102,0.125)' 443 | ] 444 | }; 445 | 446 | Rewriter.fastFail = function (text) { 447 | var index = text.indexOf(Rewriter.FAST_FAIL_QUERY); 448 | if (index === -1) return true; 449 | Codec.CODE_PATTERN.lastIndex = index; 450 | return false; 451 | }; 452 | 453 | Rewriter.checkBlacklist = function (node) { 454 | if (!node) return false; 455 | if (node.nodeType === Document.ELEMENT_NODE) { 456 | if ('shadowcryptReplaced' in node) return true; 457 | if ('shadowcryptUpdateContent' in node) return true; 458 | if (node.tagName.toLowerCase() === 'textarea') return true; 459 | } 460 | return Rewriter.checkBlacklist(node.parentNode); 461 | }; 462 | 463 | Rewriter.checkRangeEndpoints = function (range) { 464 | var startElement = range.startContainer; 465 | if (startElement.nodeType !== Document.ELEMENT_NODE) startElement = startElement.parentNode; 466 | var endElement = range.endContainer; 467 | if (endElement.nodeType !== Document.ELEMENT_NODE) endElement = endElement.parentNode; 468 | return startElement === endElement; 469 | }; 470 | 471 | Rewriter.findCodes = function (impl, node) { 472 | // caveat: textContent includes comments and processing instructions 473 | var text = node.textContent; 474 | if (Rewriter.fastFail(text)) return null; 475 | var codes = []; 476 | var scanner = new Scanner(impl, node); 477 | var match; 478 | while (match = Codec.CODE_PATTERN.exec(text)) { 479 | try { 480 | var range = impl.createRange(); 481 | scanner.setStart(range, match.index); 482 | if (Rewriter.checkBlacklist(range.startContainer)) continue; 483 | var key = Crypto.getKey(match[1]); 484 | var messageText = Codec.decode(match[1], match[2], match[3]); 485 | var messageNode; 486 | if (match[3]) { 487 | var tags = Tags.readLinks(impl, scanner, text, match); 488 | messageNode = Tags.insertLinks(impl, messageText, tags); 489 | } else { 490 | messageNode = impl.createTextNode(messageText); 491 | } 492 | scanner.setEnd(range, match.index + match[0].length); 493 | scanner.sink(range, true); 494 | if (!Rewriter.checkRangeEndpoints(range)) throw new Error('aborting suspicious range'); 495 | codes.push([range, key, messageNode]); 496 | } catch (e) { 497 | console.warn(e); 498 | } 499 | } 500 | return codes; 501 | }; 502 | 503 | Rewriter.repaceCodes = function (impl, codes) { 504 | for (var i = 0; i < codes.length; i++) { 505 | var range = codes[i][0]; 506 | var key = codes[i][1]; 507 | var messageNode = codes[i][2]; 508 | // caveat: this doesn't work in 509 | var span = impl.createElement('span'); 510 | span.shadowcryptReplaced = true; 511 | range.surroundContents(span); 512 | var shadowRoot = span.createShadowRoot(); 513 | shadowRoot.applyAuthorStyles = true; 514 | shadowRoot.resetStyleInheritance = false; 515 | var highlight = impl.createElement('span'); 516 | highlight.style.backgroundColor = Rewriter.HIGHLIGHT_COLORS[key.color]; 517 | highlight.appendChild(messageNode); 518 | shadowRoot.appendChild(highlight); 519 | Content.deleteProp(span, 'shadowRoot'); 520 | // we'll need to prevent olderShadowRoot when it gets implemented 521 | } 522 | }; 523 | 524 | Rewriter.rewriteMarkup = function (impl, node) { 525 | var codes = Rewriter.findCodes(impl, node); 526 | if (codes) Rewriter.repaceCodes(impl, codes); 527 | }; 528 | 529 | Rewriter.replacer = function (code, fingerprint, tags, data) { 530 | try { 531 | return Codec.decode(fingerprint, tags, data); 532 | } catch (e) { 533 | console.warn(e); 534 | return code; 535 | } 536 | }; 537 | 538 | Rewriter.processString = function (str) { 539 | return str.replace(Codec.CODE_PATTERN, Rewriter.replacer); 540 | }; 541 | 542 | var Widgets = { 543 | WIDGET_SELECTOR: 'input,textarea,[contenteditable],iframe', 544 | rules: null, 545 | adapters: {} 546 | }; 547 | 548 | Widgets.AbstractAdapter = function (e) { 549 | this.node = e; 550 | }; 551 | 552 | Widgets.Encrypted = function (e, o) { 553 | Widgets.AbstractAdapter.call(this, e); 554 | if ('mode' in o) { 555 | if (o.mode in Tags.modes) { 556 | this.mode = Tags.modes[o.mode]; 557 | } else { 558 | console.error('mode %s is not defined (%s)', o.mode, e); 559 | } 560 | } 561 | if ('off' in o) { 562 | this.fingerprint = null; 563 | } 564 | }; 565 | Widgets.Encrypted.prototype = Object.create(Widgets.AbstractAdapter.prototype); 566 | Widgets.Encrypted.prototype.constructor = Widgets.Encrypted; 567 | 568 | Widgets.Encrypted.prototype.mode = Tags.modes.links; 569 | Widgets.Encrypted.prototype.fingerprint = null; 570 | 571 | Widgets.Encrypted.prototype.encrypt = function (s) { 572 | if (this.fingerprint === null) return s; 573 | return Codec.encode(this.mode, this.fingerprint, s); 574 | }; 575 | 576 | Widgets.Encrypted.prototype.decrypt = function (s) { 577 | return Rewriter.processString(s); 578 | }; 579 | 580 | Widgets.Encrypted.prototype.refreshEncryption = function () { 581 | // abstract 582 | }; 583 | 584 | Widgets.Encrypted.prototype.setFingerprint = function (fingerprint) { 585 | this.fingerprint = fingerprint; 586 | this.refreshEncryption(); 587 | }; 588 | 589 | Widgets.Encrypted.prototype.setMode = function (mode) { 590 | this.mode = mode; 591 | this.refreshEncryption(); 592 | }; 593 | 594 | Widgets.Delegated = function (e, o) { 595 | Widgets.Encrypted.call(this, e, o); 596 | var impl = this.node.ownerDocument; 597 | this.shadowContent = impl.createDocumentFragment(); 598 | this.delegate = impl.createElement(this.delegateTagName); 599 | this.node.addEventListener('focus', this.onFocus.bind(this)); 600 | }; 601 | Widgets.Delegated.prototype = Object.create(Widgets.Encrypted.prototype); 602 | Widgets.Delegated.prototype.constructor = Widgets.Delegated; 603 | 604 | // a bug prevents <textarea> from being a shadow host, so allow something else to be 605 | Widgets.Delegated.prototype.getShadowHost = function () { 606 | return this.node; 607 | }; 608 | 609 | Widgets.Delegated.prototype.getCleartext = function () { 610 | return this.delegate.value; 611 | }; 612 | 613 | Widgets.Delegated.prototype.sideloadCleartext = function (v) { 614 | this.delegate.value = v; 615 | this.refreshEncryption(); 616 | }; 617 | 618 | Widgets.Delegated.prototype.synthesizeChange = function () { 619 | this.node.dispatchEvent(new Event('input')); 620 | this.node.dispatchEvent(new Event('change')); 621 | }; 622 | 623 | Widgets.Delegated.prototype.applyHostStyles = function (dst, src) { 624 | switch (src.display) { 625 | case 'inline': 626 | case 'inline-block': 627 | case 'inline-table': 628 | case 'inline-grid': 629 | dst.display = 'inline-flex'; 630 | break; 631 | case 'block': 632 | case 'table': 633 | case 'grid': 634 | dst.display = 'flex'; 635 | break; 636 | case 'none': 637 | dst.display = 'none'; 638 | break; 639 | } 640 | switch (src.position) { 641 | case 'static': 642 | dst.position = 'relative'; 643 | break; 644 | } 645 | }; 646 | 647 | Widgets.Delegated.prototype.activateDelegate = function () { 648 | var impl = this.node.ownerDocument; 649 | var hadFocus = impl.activeElement === this.node; 650 | var style = impl.defaultView.getComputedStyle(this.node); 651 | var shadowHost = this.getShadowHost(); 652 | shadowHost.shadowcryptInputEarly = this.onInputEarly.bind(this); 653 | shadowHost.shadowcryptHandlePrivateEvent = this.handlePrivateEvent.bind(this); 654 | this.applyHostStyles(shadowHost.style, style); 655 | var shadowRoot = shadowHost.createShadowRoot(); 656 | Content.deleteProp(shadowHost, 'shadowRoot'); 657 | shadowRoot.applyAuthorStyles = false; 658 | shadowRoot.resetStyleInheritance = false; 659 | shadowRoot.appendChild(this.shadowContent); 660 | this.shadowContent = null; 661 | if (hadFocus) this.delegate.focus(); 662 | }; 663 | 664 | Widgets.Delegated.prototype.onFocus = function (e) { 665 | this.delegate.focus(); 666 | }; 667 | 668 | Widgets.Delegated.prototype.onInputEarly = function (e) { 669 | this.refreshEncryption(); 670 | }; 671 | 672 | Widgets.Delegated.prototype.handlePrivateEvent = function (e) { 673 | if (e.type === 'keydown') { 674 | if (e.keyCode == 32 && e.ctrlKey) { // Ctrl+Space 675 | if (this.fingerprint === null) { 676 | this.setFingerprint(Widgets.Encrypted.prototype.fingerprint); 677 | } else { 678 | this.setFingerprint(null); 679 | } 680 | this.synthesizeChange(); 681 | e.preventDefault(); 682 | return true; 683 | } else if (e.keyCode == 192 && e.ctrlKey) { // Ctrl+Backtick 684 | if (this.fingerprint !== null) { 685 | var key = Crypto.keys[this.fingerprint]; 686 | var clear = window.prompt(key.passphrase, this.getCleartext()); 687 | if (clear !== null) { 688 | this.sideloadCleartext(clear); 689 | this.synthesizeChange(); 690 | } 691 | e.preventDefault(); 692 | } 693 | return true; 694 | } 695 | } 696 | return true; 697 | }; 698 | 699 | Widgets.KeyChanger = function (e, o) { 700 | Widgets.Delegated.call(this, e, o); 701 | if (!Widgets.KeyChanger.initialized) Widgets.KeyChanger.init(); 702 | 703 | var impl = this.node.ownerDocument; 704 | var style = impl.createElement('style'); 705 | style.textContent = Widgets.KeyChanger.css; 706 | this.shadowContent.appendChild(style); 707 | this.wrapper = Widgets.KeyChanger.appendDiv(impl, this.shadowContent, 'wrapper'); 708 | this.delegate.className = 'delegate'; 709 | this.wrapper.appendChild(this.delegate); 710 | this.ui = Widgets.KeyChanger.appendDiv(impl, this.wrapper, 'ui'); 711 | var modal = Widgets.KeyChanger.appendDiv(impl, this.ui, 'ui-modal'); 712 | modal.addEventListener('click', this.clickModal.bind(this)); 713 | var background = Widgets.KeyChanger.appendDiv(impl, this.ui, 'ui-background'); 714 | var labelWrapper = Widgets.KeyChanger.appendDiv(impl, this.ui, 'label-wrapper'); 715 | this.label = Widgets.KeyChanger.appendDiv(impl, labelWrapper, 'label'); 716 | var ring = Widgets.KeyChanger.appendDiv(impl, this.ui, 'ring'); 717 | var lock = Widgets.KeyChanger.appendDiv(impl, this.ui, 'lock'); 718 | lock.addEventListener('click', this.clickLock.bind(this)); 719 | 720 | this.keyCount = 0; 721 | this.keyElements = []; 722 | this.keyNameElements = []; 723 | for (var fingerprint in Crypto.keys) { 724 | var key = Crypto.keys[fingerprint]; 725 | var keyWrapper = Widgets.KeyChanger.appendDiv(impl, ring, 'key-wrapper unlocked'); 726 | var keyNameElement = Widgets.KeyChanger.appendDiv(impl, keyWrapper, 'key-name color-' + key.color); 727 | keyNameElement.textContent = key.name; 728 | this.keyNameElements.push(keyNameElement); 729 | var keyElement = Widgets.KeyChanger.appendDiv(impl, keyWrapper, 'key color-' + key.color); 730 | keyElement.style.transform = 'rotate(150deg)'; 731 | this.keyElements.push(keyElement); 732 | keyWrapper.addEventListener('mouseenter', this.enterKeyWrapper.bind(this, this.keyCount, fingerprint)); 733 | keyWrapper.addEventListener('mouseleave', this.leaveKeyWrapper.bind(this, this.keyCount, fingerprint)); 734 | keyWrapper.addEventListener('click', this.clickKeyWrapper.bind(this, this.keyCount, fingerprint)); 735 | this.keyCount++; 736 | } 737 | 738 | this.keySpacing = Math.max(10, 50 - 5 * this.keyCount); 739 | this.extraSpacing = Math.max(0, 30 - this.keySpacing); 740 | var keyRange = (this.keyCount - 1) * this.keySpacing; 741 | this.keyOffsetStart = -0.5 * keyRange; 742 | this.keyNamesStart = 22 + this.keyOffsetStart; 743 | this.positionKeyNames(); 744 | 745 | var unlock = Widgets.KeyChanger.appendDiv(impl, ring, 'key-name unlock'); 746 | unlock.textContent = 'Unlock'; 747 | unlock.addEventListener('click', this.clickUnlock.bind(this)); 748 | 749 | this.keySelectionVisible = false; 750 | this.refreshState(); 751 | }; 752 | Widgets.KeyChanger.prototype = Object.create(Widgets.Delegated.prototype); 753 | Widgets.KeyChanger.prototype.constructor = Widgets.KeyChanger; 754 | 755 | Widgets.KeyChanger.initialized = false; 756 | Widgets.KeyChanger.css = null; 757 | 758 | Widgets.KeyChanger.appendDiv = function (impl, container, className) { 759 | var div = impl.createElement('div'); 760 | div.className = className; 761 | container.appendChild(div); 762 | return div; 763 | }; 764 | 765 | Widgets.KeyChanger.init = function (impl) { 766 | Widgets.KeyChanger.css = 767 | '.wrapper{display:flex;flex:auto;}\r\n' + 768 | '.delegate{display:block;flex:auto;margin:0;border:medium none;padding:0;background:transparent;font:inherit;color:inherit;outline:1px solid transparent;outline-offset:0;resize:none;}\r\n' + 769 | '.delegate:focus{outline-width:2px;}\r\n' + 770 | '.ui{position:absolute;bottom:0.625em;right:20px;}\r\n' + 771 | '.key-ui.ui{z-index:1;}\r\n' + 772 | '.ui-background{position:absolute;width:600px;height:600px;left:-300px;top:-300px;background-image:radial-gradient(closest-side,white 0%,rgba(255,255,255,0.3) 50%,rgba(255,255,255,0) 100%);transition:all ease-in-out 0.2s 0s;opacity:0;visibility:hidden;}\r\n' + 773 | '.key-ui .ui-background{opacity:1;visibility:visible;}\r\n' + 774 | '.ui-modal{position:fixed;top:0;left:0;bottom:0;right:0;background-color:white;transition:all ease-in-out 0.2s 0s;opacity:0;visibility:hidden;}\r\n' + 775 | '.key-ui .ui-modal{opacity:0.5;visibility:visible;}\r\n' + 776 | '.label-wrapper{position:absolute;top:12px;transition:all ease-in-out 0.2s 0s;opacity:0;visibility:hidden;}\r\n' + 777 | '.ui:hover .label-wrapper{opacity:1;visibility:visible;}\r\n' + 778 | '.ui.key-ui .label-wrapper{opacity:0;visibility:hidden;}\r\n' + 779 | '.label{position:relative;left:-50%;border:1px solid #cccccc;padding:3px;background-color:white;font:10px sans-serif;white-space:nowrap;}\r\n' + 780 | '.wrapper.unlocked .label{display:none;}\r\n' + 781 | '.ring{position:absolute;left:-34px;top:-34px;border:2px solid #999999;border-radius:64px;width:64px;height:64px;transition:all ease-in-out 0.2s 0s;transform-origin:50% 50%;transform:scale(0,0);opacity:0;}\r\n' + 782 | '.key-ui .ring{transform:scale(1,1);opacity:1;}\r\n' + 783 | '.key{width:40px;height:25px;background-image:url(' + chrome.extension.getURL('Spritesheet-01.png') + ');}\r\n' + 784 | '.ring .key{position:absolute;left:55px;top:20px;transition:all ease-in-out 0.2s 0s;transform-origin:-23px 50%;cursor:pointer;}\r\n' + 785 | '.key-name{position:absolute;padding:3px;font:500 10px sans-serif;white-space:nowrap;cursor:pointer;transition:all ease-in-out 0.2s 0s;opacity:0.8;}\r\n' + 786 | '.key-wrapper:hover .key-name,.key-name.unlock:hover{opacity:1;transform:scale(1.2,1.2);}\r\n' + 787 | '.key-name.unlock{top:75px;left:12px;color:dimgray;}\r\n' + 788 | '.lock{position:absolute;bottom:-20px;left:-20px;width:40px;height:40px;background:-160px -120px url(' + chrome.extension.getURL('Spritesheet-01.png') + ');cursor:pointer;}\r\n' + 789 | '.lock:hover,.key-ui .lock{opacity:1;}\r\n' + 790 | '\r\n' + 791 | '.key.color-1{background-position:0 -25px;}\r\n' + 792 | '.key.color-2{background-position:0 -50px;}\r\n' + 793 | '.key.color-3{background-position:0 -75px;}\r\n' + 794 | '.key.color-4{background-position:0 -100px;}\r\n' + 795 | '.key.color-5{background-position:0 -125px;}\r\n' + 796 | '.key.color-6{background-position:0 -150px;}\r\n' + 797 | '.wrapper.locked-color-0 .lock{background-position:-120px 0;}\r\n' + 798 | '.wrapper.locked-color-1 .lock{background-position:-120px -40px;}\r\n' + 799 | '.wrapper.locked-color-2 .lock{background-position:-120px -80px;}\r\n' + 800 | '.wrapper.locked-color-3 .lock{background-position:-120px -120px;}\r\n' + 801 | '.wrapper.locked-color-4 .lock{background-position:-160px 0;}\r\n' + 802 | '.wrapper.locked-color-5 .lock{background-position:-160px -40px;}\r\n' + 803 | '.wrapper.locked-color-6 .lock{background-position:-160px -80px;}\r\n' + 804 | '.wrapper.locked-color-0 .label,.key-name.color-0{color:#339999;}\r\n' + 805 | '.wrapper.locked-color-1 .label,.key-name.color-1{color:#336699;}\r\n' + 806 | '.wrapper.locked-color-2 .label,.key-name.color-2{color:#666699;}\r\n' + 807 | '.wrapper.locked-color-3 .label,.key-name.color-3{color:#ad4977;}\r\n' + 808 | '.wrapper.locked-color-4 .label,.key-name.color-4{color:#d1ae4a;}\r\n' + 809 | '.wrapper.locked-color-5 .label,.key-name.color-5{color:#996633;}\r\n' + 810 | '.wrapper.locked-color-6 .label,.key-name.color-6{color:#666666;}\r\n' + 811 | '.wrapper.locked-color-0 .delegate{outline-color:#339999;}\r\n' + 812 | '.wrapper.locked-color-1 .delegate{outline-color:#336699;}\r\n' + 813 | '.wrapper.locked-color-2 .delegate{outline-color:#666699;}\r\n' + 814 | '.wrapper.locked-color-3 .delegate{outline-color:#ad4977;}\r\n' + 815 | '.wrapper.locked-color-4 .delegate{outline-color:#d1ae4a;}\r\n' + 816 | '.wrapper.locked-color-5 .delegate{outline-color:#996633;}\r\n' + 817 | '.wrapper.locked-color-6 .delegate{outline-color:#666666;}\r\n' /* + 818 | '.wrapper.locked-color-0 .delegate:focus{box-shadow:inset 0 0 5px #339999;}\r\n' + 819 | '.wrapper.locked-color-1 .delegate:focus{box-shadow:inset 0 0 5px #336699;}\r\n' + 820 | '.wrapper.locked-color-2 .delegate:focus{box-shadow:inset 0 0 5px #666699;}\r\n' + 821 | '.wrapper.locked-color-3 .delegate:focus{box-shadow:inset 0 0 5px #ad4977;}\r\n' + 822 | '.wrapper.locked-color-4 .delegate:focus{box-shadow:inset 0 0 5px #d1ae4a;}\r\n' + 823 | '.wrapper.locked-color-5 .delegate:focus{box-shadow:inset 0 0 5px #996633;}\r\n' + 824 | '.wrapper.locked-color-6 .delegate:focus{box-shadow:inset 0 0 5px #666666;}\r\n' */; 825 | }; 826 | 827 | Widgets.KeyChanger.prototype.refreshState = function () { 828 | if (this.fingerprint === null) { 829 | this.wrapper.className = 'wrapper unlocked'; 830 | this.label.textContent = ''; 831 | } else { 832 | var key = Crypto.keys[this.fingerprint]; 833 | this.wrapper.className = 'wrapper locked-color-' + key.color; 834 | this.label.textContent = key.name + ': ' + key.passphrase; 835 | } 836 | }; 837 | 838 | Widgets.KeyChanger.prototype.setFingerprint = function (fingerprint) { 839 | Widgets.Encrypted.prototype.setFingerprint.call(this, fingerprint); 840 | this.refreshState(); 841 | }; 842 | 843 | Widgets.KeyChanger.prototype.positionKeyNames = function () { 844 | for (var i = 0; i < this.keyCount; i++) { 845 | var top = this.keyNamesStart + this.keySpacing * i; 846 | var rotation = (this.keyOffsetStart + i * this.keySpacing) / 180 * Math.PI; 847 | var left = 40 * Math.cos(rotation) + 60; 848 | this.keyNameElements[i].style.top = top + 'px'; 849 | this.keyNameElements[i].style.left = left + 'px'; 850 | } 851 | }; 852 | 853 | Widgets.KeyChanger.prototype.rotateKeys = function (option) { 854 | for (var i = 0; i < this.keyCount; i++) { 855 | var rotation; 856 | if (option === 'collapsed') { 857 | rotation = 150; 858 | } else { 859 | rotation = this.keyOffsetStart + this.keySpacing * i; 860 | if (option !== 'uniform') { 861 | if (i < option) rotation -= this.extraSpacing; 862 | else if (i > option) rotation += this.extraSpacing; 863 | } 864 | } 865 | this.keyElements[i].style.transform = 'rotate(' + rotation + 'deg)'; 866 | } 867 | }; 868 | 869 | Widgets.KeyChanger.prototype.hideKeySelection = function () { 870 | this.ui.classList.remove('key-ui'); 871 | this.rotateKeys('collapsed'); 872 | this.keySelectionVisible = false; 873 | }; 874 | 875 | Widgets.KeyChanger.prototype.showKeySelection = function () { 876 | this.ui.classList.add('key-ui'); 877 | this.rotateKeys('uniform'); 878 | this.keySelectionVisible = true; 879 | }; 880 | 881 | Widgets.KeyChanger.prototype.clickModal = function (e) { 882 | this.hideKeySelection(); 883 | e.stopPropagation(); 884 | e.preventDefault(); 885 | }; 886 | 887 | Widgets.KeyChanger.prototype.clickLock = function (e) { 888 | if (this.keySelectionVisible) this.hideKeySelection(); 889 | else this.showKeySelection(); 890 | e.stopPropagation(); 891 | e.preventDefault(); 892 | }; 893 | 894 | Widgets.KeyChanger.prototype.enterKeyWrapper = function (i, fingerprint, e) { 895 | if (this.keySelectionVisible) this.rotateKeys(i); 896 | }; 897 | 898 | Widgets.KeyChanger.prototype.leaveKeyWrapper = function (i, fingerprint, e) { 899 | if (this.keySelectionVisible) this.rotateKeys('uniform'); 900 | }; 901 | 902 | Widgets.KeyChanger.prototype.clickKeyWrapper = function (i, fingerprint, e) { 903 | this.setFingerprint(fingerprint); 904 | this.hideKeySelection(); 905 | e.stopPropagation(); 906 | e.preventDefault(); 907 | }; 908 | 909 | Widgets.KeyChanger.prototype.clickUnlock = function (e) { 910 | this.setFingerprint(null); 911 | this.hideKeySelection(); 912 | e.stopPropagation(); 913 | e.preventDefault(); 914 | }; 915 | 916 | Widgets.adapters.Input = function (e, o) { 917 | Widgets.KeyChanger.call(this, e, o); 918 | this.setValue = Content.shimProp(this.node, 'value', this.node.value, this.onValueSet.bind(this)); 919 | 920 | this.delegate.value = this.decrypt(this.node.value); 921 | this.delegate.addEventListener('change', this.onChange.bind(this), true); 922 | 923 | this.activateDelegate(); 924 | }; 925 | Widgets.adapters.Input.prototype = Object.create(Widgets.KeyChanger.prototype); 926 | Widgets.adapters.Input.prototype.constructor = Widgets.adapters.Input; 927 | 928 | Widgets.adapters.Input.prototype.delegateTagName = 'input'; 929 | 930 | Widgets.adapters.Input.prototype.refreshEncryption = function () { 931 | var plain = this.delegate.value; 932 | var cipher = this.encrypt(plain); 933 | this.node.value = cipher; 934 | this.setValue(cipher); 935 | }; 936 | 937 | Widgets.adapters.Input.prototype.onValueSet = function (v) { 938 | var cipher = v; 939 | var plain = this.decrypt(cipher); 940 | this.node.value = cipher; 941 | this.delegate.value = plain; 942 | }; 943 | 944 | Widgets.adapters.Input.prototype.onChange = function (e) { 945 | var event = new Event('change'); 946 | this.node.dispatchEvent(event); 947 | }; 948 | 949 | Widgets.adapters.Input.prototype.handlePrivateEvent = function (e) { 950 | if (e.keyCode === 13) { 951 | if (!e.defaultPrevented && this.node.form) { 952 | if (e.type === 'keydown') { 953 | var event = new Event('submit'); 954 | this.node.form.dispatchEvent(event); 955 | // caveat: doesn't take into account form* attributes 956 | this.node.form.submit(); 957 | } 958 | } 959 | return false; 960 | } 961 | return Widgets.Delegated.prototype.handlePrivateEvent.call(this, e); 962 | }; 963 | 964 | Widgets.adapters.TextArea = function (e, o) { 965 | Widgets.KeyChanger.call(this, e, o); 966 | this.setValue = Content.shimProp(this.node, 'value', this.node.value, this.onValueSet.bind(this)); 967 | 968 | this.delegate.value = this.decrypt(this.node.value); 969 | this.delegate.addEventListener('change', this.onChange.bind(this)); 970 | 971 | this.activateDelegate(); 972 | }; 973 | Widgets.adapters.TextArea.prototype = Object.create(Widgets.KeyChanger.prototype); 974 | Widgets.adapters.TextArea.prototype.constructor = Widgets.adapters.TextArea; 975 | 976 | Widgets.adapters.TextArea.simpleStyles = [ 977 | 'visibility', 978 | 'top', 979 | 'left', 980 | 'bottom', 981 | 'right', 982 | 'float', 983 | 'clear', 984 | 'zIndex', 985 | 'boxSizing', 986 | 'margin', 987 | 'border', 988 | 'padding', 989 | 'boxShadow', 990 | 'width', 991 | 'height', 992 | 'background', 993 | 'font', 994 | 'color' 995 | ]; 996 | 997 | Widgets.adapters.TextArea.prototype.delegateTagName = 'textarea'; 998 | 999 | Widgets.adapters.TextArea.prototype.getShadowHost = function () { 1000 | var impl = this.node.ownerDocument; 1001 | var parent = impl.createElement('div'); 1002 | this.node.parentNode.replaceChild(parent, this.node); 1003 | parent.appendChild(this.node); 1004 | return parent; 1005 | }; 1006 | 1007 | Widgets.adapters.TextArea.prototype.applyHostStyles = function (dst, src) { 1008 | Widgets.Delegated.prototype.applyHostStyles.call(this, dst, src); 1009 | for (var i = 0; i < Widgets.adapters.TextArea.simpleStyles.length; i++) { 1010 | var name = Widgets.adapters.TextArea.simpleStyles[i]; 1011 | dst[name] = src[name]; 1012 | } 1013 | }; 1014 | 1015 | Widgets.adapters.TextArea.prototype.refreshEncryption = function () { 1016 | var plain = this.delegate.value; 1017 | var cipher = this.encrypt(plain); 1018 | this.node.value = cipher; 1019 | this.setValue(cipher); 1020 | }; 1021 | 1022 | Widgets.adapters.TextArea.prototype.onValueSet = function (v) { 1023 | var cipher = v; 1024 | var plain = this.decrypt(cipher); 1025 | this.node.value = cipher; 1026 | this.delegate.value = plain; 1027 | }; 1028 | 1029 | Widgets.adapters.TextArea.prototype.onInputEarly = function (e) { 1030 | Widgets.Delegated.prototype.onInputEarly.call(this, e); 1031 | e.stopPropagation(); 1032 | var event = new Event('input'); 1033 | this.node.dispatchEvent(event); 1034 | }; 1035 | 1036 | Widgets.adapters.TextArea.prototype.onChange = function (e) { 1037 | var event = new Event('change'); 1038 | this.node.dispatchEvent(event); 1039 | }; 1040 | 1041 | Widgets.adapters.TextArea.prototype.handlePrivateEvent = function (e) { 1042 | var event = new KeyboardEvent(e.type, {}); 1043 | this.node.dispatchEvent(event); 1044 | if (e.keyCode == 13) return false; 1045 | return Widgets.Delegated.prototype.handlePrivateEvent.call(this, e); 1046 | }; 1047 | 1048 | Widgets.adapters.ContentEditable = function (e, o) { 1049 | Widgets.KeyChanger.call(this, e, o); 1050 | this.node.shadowcryptUpdateContent = this.updateContent.bind(this); 1051 | 1052 | this.delegate.value = this.decrypt(Compat.getInnerText(this.node)); 1053 | 1054 | var impl = this.node.ownerDocument; 1055 | var innerTextReflector = impl.createElement('content'); 1056 | var invisible = impl.createElement('div'); 1057 | invisible.style.cssText = 'position:absolute;width:1px;height:1px;overflow:hidden;opacity:0;'; 1058 | invisible.appendChild(innerTextReflector); 1059 | this.shadowContent.appendChild(invisible); 1060 | 1061 | this.activateDelegate(); 1062 | }; 1063 | Widgets.adapters.ContentEditable.prototype = Object.create(Widgets.KeyChanger.prototype); 1064 | Widgets.adapters.ContentEditable.prototype.constructor = Widgets.adapters.ContentEditable; 1065 | 1066 | Widgets.adapters.ContentEditable.prototype.delegateTagName = 'textarea'; 1067 | 1068 | Widgets.adapters.ContentEditable.prototype.refreshEncryption = function () { 1069 | var plain = this.delegate.value; 1070 | var cipher = this.encrypt(plain); 1071 | this.node.textContent = cipher; 1072 | }; 1073 | 1074 | Widgets.adapters.ContentEditable.prototype.updateContent = function () { 1075 | // caveat: this is stuck with textContent, since innerText uses the composed tree 1076 | var cipher = this.node.textContent; 1077 | var plain = this.decrypt(cipher); 1078 | this.delegate.value = plain; 1079 | }; 1080 | 1081 | Widgets.adapters.IFrame = function (e, o) { 1082 | Widgets.AbstractAdapter.call(this, e); 1083 | e.addEventListener('load', this.onLoad.bind(this)); 1084 | this.onLoad(null); 1085 | }; 1086 | Widgets.adapters.IFrame.prototype = Object.create(Widgets.AbstractAdapter.prototype); 1087 | Widgets.adapters.IFrame.prototype.constructor = Widgets.adapters.IFrame; 1088 | 1089 | Widgets.adapters.IFrame.prototype.onLoad = function () { 1090 | try { 1091 | // test access first 1092 | this.node.contentDocument; 1093 | Content.propagate(this.node); 1094 | Widgets.init(this.node.contentWindow); 1095 | Observer.init(this.node.contentDocument); 1096 | } catch (e) { 1097 | // console.warn(e); // %%% 1098 | } 1099 | }; 1100 | 1101 | Widgets.init = function (win) { 1102 | win.addEventListener('input', Widgets.onInputEarly, true); 1103 | win.addEventListener('keydown', Widgets.onInterceptKey, true); 1104 | win.addEventListener('keyup', Widgets.onInterceptKey, true); 1105 | win.addEventListener('keypress', Widgets.onInterceptKey, true); 1106 | }; 1107 | 1108 | Widgets.onInputEarly = function (e) { 1109 | if ('shadowcryptInputEarly' in e.target) { 1110 | e.target.shadowcryptInputEarly(e); 1111 | } 1112 | }; 1113 | 1114 | Widgets.onInterceptKey = function (e) { 1115 | if ('shadowcryptHandlePrivateEvent' in e.target) { 1116 | var shouldStop = e.target.shadowcryptHandlePrivateEvent(e); 1117 | if (shouldStop) e.stopImmediatePropagation(); 1118 | } 1119 | }; 1120 | 1121 | Widgets.createAdapter = function (node, rule) { 1122 | var tag = node.tagName.toLowerCase(); 1123 | if (tag === 'input') { 1124 | if (node.type === 'text') { 1125 | // TODO: more heuristics 1126 | return new Widgets.adapters.Input(node, rule); 1127 | } 1128 | } else if (tag === 'textarea') { 1129 | return new Widgets.adapters.TextArea(node, rule); 1130 | } else if (tag === 'iframe') { 1131 | return new Widgets.adapters.IFrame(node, rule); 1132 | } else { 1133 | if (node.contentEditable === 'true') { 1134 | return new Widgets.adapters.ContentEditable(node, rule); 1135 | } 1136 | } 1137 | return null; 1138 | }; 1139 | 1140 | Widgets.updateContent = function (node) { 1141 | if (!node) return; 1142 | if (node.nodeType === Document.ELEMENT_NODE) { 1143 | if ('shadowcryptUpdateContent' in node) { 1144 | node.shadowcryptUpdateContent(); 1145 | return; 1146 | } 1147 | } 1148 | Widgets.updateContent(node.parentNode); 1149 | }; 1150 | 1151 | Widgets.onAdd = function (node) { 1152 | if ('shadowcryptSeenWidget' in node) return; 1153 | var rule = Widgets.findRule(node); 1154 | if (!('noShim' in rule)) { 1155 | var adapter = Widgets.createAdapter(node, rule); 1156 | if (adapter !== null) node.shadowcryptSeenWidget = true; 1157 | } 1158 | }; 1159 | 1160 | Widgets.findRule = function (node) { 1161 | for (var i = 0; i < Widgets.rules.length; i++) { 1162 | var rule = Widgets.rules[i]; 1163 | if (Compat.matches(node, rule.selector)) return rule; 1164 | } 1165 | return {}; 1166 | }; 1167 | 1168 | var Observer = { 1169 | OPTIONS: { 1170 | attributes: true, 1171 | childList: true, 1172 | characterData: true, 1173 | subtree: true 1174 | }, 1175 | observer: null 1176 | }; 1177 | 1178 | Observer.onAttributes = function (target, attributeName) { 1179 | // console.log('attributes', target, attributeName); // %%% 1180 | if (attributeName === 'contenteditable' && target.contentEditable === 'true') Widgets.onAdd(target); 1181 | }; 1182 | 1183 | Observer.onCharacterData = function (target) { 1184 | // console.log('characterData', target, target.nodeValue); // %%% 1185 | Widgets.updateContent(target); 1186 | }; 1187 | 1188 | Observer.onChildList = function (target) { 1189 | Widgets.updateContent(target); 1190 | }; 1191 | 1192 | Observer.onAddedNode = function (impl, target, addedNode) { 1193 | // console.log('addedNode', target, addedNode); // %%% 1194 | if (addedNode.nodeType === Document.ELEMENT_NODE) { 1195 | var widgets = addedNode.querySelectorAll(Widgets.WIDGET_SELECTOR); 1196 | for (var i = 0; i < widgets.length; i++) { 1197 | Widgets.onAdd(widgets[i]); 1198 | } 1199 | Widgets.onAdd(addedNode); 1200 | } 1201 | Rewriter.rewriteMarkup(impl, addedNode); 1202 | }; 1203 | 1204 | Observer.callback = function (mutationRecords, observer) { 1205 | for (var i = 0; i < mutationRecords.length; i++) { 1206 | var mutationRecord = mutationRecords[i]; 1207 | var target = mutationRecord.target; 1208 | var impl = target.ownerDocument; 1209 | switch (mutationRecord.type) { 1210 | case 'attributes': 1211 | Observer.onAttributes(mutationRecord.target, mutationRecord.attributeName); 1212 | break; 1213 | case 'characterData': 1214 | if (!target.ownerDocument.contains(target)) continue; 1215 | Observer.onCharacterData(target); 1216 | break; 1217 | case 'childList': 1218 | Observer.onChildList(target); 1219 | var addedNodes = mutationRecord.addedNodes; 1220 | for (var j = 0; j < addedNodes.length; j++) { 1221 | var addedNode = addedNodes[j]; 1222 | if (!addedNode.ownerDocument.contains(addedNode)) continue; 1223 | Observer.onAddedNode(impl, target, addedNode); 1224 | } 1225 | break; 1226 | } 1227 | } 1228 | }; 1229 | 1230 | Observer.init = function (doc) { 1231 | if (doc.head) Observer.onAddedNode(doc, doc.documentElement, doc.head); 1232 | if (doc.body) Observer.onAddedNode(doc, doc.documentElement, doc.body); 1233 | Observer.observer = new MutationObserver(Observer.callback); 1234 | Observer.observer.observe(doc.documentElement, Observer.OPTIONS); 1235 | }; 1236 | 1237 | var Startup = { 1238 | name: null 1239 | }; 1240 | 1241 | Startup.init = function () { 1242 | Startup.name = 'origin-' + window.location.origin; 1243 | chrome.storage.sync.get(Startup.name, Startup.onGet); 1244 | }; 1245 | 1246 | Startup.onGet = function (items) { 1247 | if (!(Startup.name in items)) return; 1248 | var site = items[Startup.name]; 1249 | Crypto.keys = site.keys; 1250 | Widgets.Encrypted.prototype.fingerprint = site.defaultFingerprint; 1251 | Widgets.rules = Startup.filterRules(site.rules); 1252 | 1253 | Content.init(); 1254 | Widgets.init(window); 1255 | Observer.init(document); 1256 | }; 1257 | 1258 | Startup.filterRules = function (rules) { 1259 | var applicable = []; 1260 | var url = window.location.href; 1261 | for (var i = 0; i < rules.length; i++) { 1262 | var rule = rules[i]; 1263 | rule.urlPattern = new RegExp(rule.urlPattern); 1264 | if (rule.urlPattern.test(url)) applicable.push(rule); 1265 | } 1266 | return applicable; 1267 | }; 1268 | 1269 | Startup.init(); 1270 | -------------------------------------------------------------------------------- /ext/jquery/jquery-2.1.0.min.js: -------------------------------------------------------------------------------- 1 | /*! jQuery v2.1.0 | (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="".trim,l={},m=a.document,n="2.1.0",o=function(a,b){return new o.fn.init(a,b)},p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};o.fn=o.prototype={jquery:n,constructor:o,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=o.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return o.each(this,a,b)},map:function(a){return this.pushStack(o.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},o.extend=o.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||o.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&&(o.isPlainObject(d)||(e=o.isArray(d)))?(e?(e=!1,f=c&&o.isArray(c)?c:[]):f=c&&o.isPlainObject(c)?c:{},g[b]=o.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},o.extend({expando:"jQuery"+(n+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===o.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return a-parseFloat(a)>=0},isPlainObject:function(a){if("object"!==o.type(a)||a.nodeType||o.isWindow(a))return!1;try{if(a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(b){return!1}return!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=o.trim(a),a&&(1===a.indexOf("use strict")?(b=m.createElement("script"),b.text=a,m.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?"":k.call(a)},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?o.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),o.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||o.guid++,f):void 0},now:Date.now,support:l}),o.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=o.type(a);return"function"===c||o.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="sizzle"+-new Date,t=a.document,u=0,v=0,w=eb(),x=eb(),y=eb(),z=function(a,b){return a===b&&(j=!0),0},A="undefined",B=1<<31,C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=D.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},J="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",K="[\\x20\\t\\r\\n\\f]",L="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",M=L.replace("w","w#"),N="\\["+K+"*("+L+")"+K+"*(?:([*^$|!~]?=)"+K+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+M+")|)|)"+K+"*\\]",O=":("+L+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+N.replace(3,8)+")*)|.*)\\)|)",P=new RegExp("^"+K+"+|((?:^|[^\\\\])(?:\\\\.)*)"+K+"+$","g"),Q=new RegExp("^"+K+"*,"+K+"*"),R=new RegExp("^"+K+"*([>+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(O),U=new RegExp("^"+M+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L.replace("w","w*")+")"),ATTR:new RegExp("^"+N),PSEUDO:new RegExp("^"+O),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=/'|\\/g,ab=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),bb=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)};try{G.apply(D=H.call(t.childNodes),t.childNodes),D[t.childNodes.length].nodeType}catch(cb){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function db(a,b,d,e){var f,g,h,i,j,m,p,q,u,v;if((b?b.ownerDocument||b:t)!==l&&k(b),b=b||l,d=d||[],!a||"string"!=typeof a)return d;if(1!==(i=b.nodeType)&&9!==i)return[];if(n&&!e){if(f=Z.exec(a))if(h=f[1]){if(9===i){if(g=b.getElementById(h),!g||!g.parentNode)return d;if(g.id===h)return d.push(g),d}else if(b.ownerDocument&&(g=b.ownerDocument.getElementById(h))&&r(b,g)&&g.id===h)return d.push(g),d}else{if(f[2])return G.apply(d,b.getElementsByTagName(a)),d;if((h=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(h)),d}if(c.qsa&&(!o||!o.test(a))){if(q=p=s,u=b,v=9===i&&a,1===i&&"object"!==b.nodeName.toLowerCase()){m=ob(a),(p=b.getAttribute("id"))?q=p.replace(_,"\\$&"):b.setAttribute("id",q),q="[id='"+q+"'] ",j=m.length;while(j--)m[j]=q+pb(m[j]);u=$.test(a)&&mb(b.parentNode)||b,v=m.join(",")}if(v)try{return G.apply(d,u.querySelectorAll(v)),d}catch(w){}finally{p||b.removeAttribute("id")}}}return xb(a.replace(P,"$1"),b,d,e)}function eb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function fb(a){return a[s]=!0,a}function gb(a){var b=l.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function hb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function ib(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||B)-(~a.sourceIndex||B);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function jb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function kb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function lb(a){return fb(function(b){return b=+b,fb(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 mb(a){return a&&typeof a.getElementsByTagName!==A&&a}c=db.support={},f=db.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},k=db.setDocument=function(a){var b,e=a?a.ownerDocument||a:t,g=e.defaultView;return e!==l&&9===e.nodeType&&e.documentElement?(l=e,m=e.documentElement,n=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){k()},!1):g.attachEvent&&g.attachEvent("onunload",function(){k()})),c.attributes=gb(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=gb(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(e.getElementsByClassName)&&gb(function(a){return a.innerHTML="<div class='a'></div><div class='a i'></div>",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=gb(function(a){return m.appendChild(a).id=s,!e.getElementsByName||!e.getElementsByName(s).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==A&&n){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){var c=typeof a.getAttributeNode!==A&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==A?b.getElementsByTagName(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 typeof b.getElementsByClassName!==A&&n?b.getElementsByClassName(a):void 0},p=[],o=[],(c.qsa=Y.test(e.querySelectorAll))&&(gb(function(a){a.innerHTML="<select t=''><option selected=''></option></select>",a.querySelectorAll("[t^='']").length&&o.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||o.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll(":checked").length||o.push(":checked")}),gb(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&o.push("name"+K+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||o.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),o.push(",.*:")})),(c.matchesSelector=Y.test(q=m.webkitMatchesSelector||m.mozMatchesSelector||m.oMatchesSelector||m.msMatchesSelector))&&gb(function(a){c.disconnectedMatch=q.call(a,"div"),q.call(a,"[s!='']:x"),p.push("!=",O)}),o=o.length&&new RegExp(o.join("|")),p=p.length&&new RegExp(p.join("|")),b=Y.test(m.compareDocumentPosition),r=b||Y.test(m.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},z=b?function(a,b){if(a===b)return j=!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===e||a.ownerDocument===t&&r(t,a)?-1:b===e||b.ownerDocument===t&&r(t,b)?1:i?I.call(i,a)-I.call(i,b):0:4&d?-1:1)}:function(a,b){if(a===b)return j=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],k=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:i?I.call(i,a)-I.call(i,b):0;if(f===g)return ib(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)k.unshift(c);while(h[d]===k[d])d++;return d?ib(h[d],k[d]):h[d]===t?-1:k[d]===t?1:0},e):l},db.matches=function(a,b){return db(a,null,null,b)},db.matchesSelector=function(a,b){if((a.ownerDocument||a)!==l&&k(a),b=b.replace(S,"='$1']"),!(!c.matchesSelector||!n||p&&p.test(b)||o&&o.test(b)))try{var d=q.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return db(b,l,null,[a]).length>0},db.contains=function(a,b){return(a.ownerDocument||a)!==l&&k(a),r(a,b)},db.attr=function(a,b){(a.ownerDocument||a)!==l&&k(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!n):void 0;return void 0!==f?f:c.attributes||!n?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},db.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},db.uniqueSort=function(a){var b,d=[],e=0,f=0;if(j=!c.detectDuplicates,i=!c.sortStable&&a.slice(0),a.sort(z),j){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return i=null,a},e=db.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=db.selectors={cacheLength:50,createPseudo:fb,match:V,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(ab,bb),a[3]=(a[4]||a[5]||"").replace(ab,bb),"~="===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]||db.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]&&db.error(a[0]),a},PSEUDO:function(a){var b,c=!a[5]&&a[2];return V.CHILD.test(a[0])?null:(a[3]&&void 0!==a[4]?a[2]=a[4]:c&&T.test(c)&&(b=ob(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(ab,bb).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=w[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&w(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==A&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=db.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+" ").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(),t=!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&&t){k=q[s]||(q[s]={}),j=k[a]||[],n=j[0]===u&&j[1],m=j[0]===u&&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]=[u,n,m];break}}else if(t&&(j=(b[s]||(b[s]={}))[a])&&j[0]===u)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&&(t&&((l[s]||(l[s]={}))[a]=[u,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()]||db.error("unsupported pseudo: "+a);return e[s]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?fb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:fb(function(a){var b=[],c=[],d=g(a.replace(P,"$1"));return d[s]?fb(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),!c.pop()}}),has:fb(function(a){return function(b){return db(a,b).length>0}}),contains:fb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:fb(function(a){return U.test(a||"")||db.error("unsupported lang: "+a),a=a.replace(ab,bb).toLowerCase(),function(b){var c;do if(c=n?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===m},focus:function(a){return a===l.activeElement&&(!l.hasFocus||l.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 X.test(a.nodeName)},input:function(a){return W.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:lb(function(){return[0]}),last:lb(function(a,b){return[b-1]}),eq:lb(function(a,b,c){return[0>c?c+b:c]}),even:lb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:lb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:lb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:lb(function(a,b,c){for(var d=0>c?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=jb(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=kb(b);function nb(){}nb.prototype=d.filters=d.pseudos,d.setFilters=new nb;function ob(a,b){var c,e,f,g,h,i,j,k=x[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){(!c||(e=Q.exec(h)))&&(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=R.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(P," ")}),h=h.slice(c.length));for(g in d.filter)!(e=V[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?db.error(a):x(a,i).slice(0)}function pb(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function qb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=v++;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=[u,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[s]||(b[s]={}),(h=i[d])&&h[0]===u&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function rb(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 sb(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 tb(a,b,c,d,e,f){return d&&!d[s]&&(d=tb(d)),e&&!e[s]&&(e=tb(e,f)),fb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||wb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:sb(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=sb(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?I.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=sb(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ub(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],i=g||d.relative[" "],j=g?1:0,k=qb(function(a){return a===b},i,!0),l=qb(function(a){return I.call(b,a)>-1},i,!0),m=[function(a,c,d){return!g&&(d||c!==h)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>j;j++)if(c=d.relative[a[j].type])m=[qb(rb(m),c)];else{if(c=d.filter[a[j].type].apply(null,a[j].matches),c[s]){for(e=++j;f>e;e++)if(d.relative[a[e].type])break;return tb(j>1&&rb(m),j>1&&pb(a.slice(0,j-1).concat({value:" "===a[j-2].type?"*":""})).replace(P,"$1"),c,e>j&&ub(a.slice(j,e)),f>e&&ub(a=a.slice(e)),f>e&&pb(a))}m.push(c)}return rb(m)}function vb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,i,j,k){var m,n,o,p=0,q="0",r=f&&[],s=[],t=h,v=f||e&&d.find.TAG("*",k),w=u+=null==t?1:Math.random()||.1,x=v.length;for(k&&(h=g!==l&&g);q!==x&&null!=(m=v[q]);q++){if(e&&m){n=0;while(o=a[n++])if(o(m,g,i)){j.push(m);break}k&&(u=w)}c&&((m=!o&&m)&&p--,f&&r.push(m))}if(p+=q,c&&q!==p){n=0;while(o=b[n++])o(r,s,g,i);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=E.call(j));s=sb(s)}G.apply(j,s),k&&!f&&s.length>0&&p+b.length>1&&db.uniqueSort(j)}return k&&(u=w,h=t),r};return c?fb(f):f}g=db.compile=function(a,b){var c,d=[],e=[],f=y[a+" "];if(!f){b||(b=ob(a)),c=b.length;while(c--)f=ub(b[c]),f[s]?d.push(f):e.push(f);f=y(a,vb(e,d))}return f};function wb(a,b,c){for(var d=0,e=b.length;e>d;d++)db(a,b[d],c);return c}function xb(a,b,e,f){var h,i,j,k,l,m=ob(a);if(!f&&1===m.length){if(i=m[0]=m[0].slice(0),i.length>2&&"ID"===(j=i[0]).type&&c.getById&&9===b.nodeType&&n&&d.relative[i[1].type]){if(b=(d.find.ID(j.matches[0].replace(ab,bb),b)||[])[0],!b)return e;a=a.slice(i.shift().value.length)}h=V.needsContext.test(a)?0:i.length;while(h--){if(j=i[h],d.relative[k=j.type])break;if((l=d.find[k])&&(f=l(j.matches[0].replace(ab,bb),$.test(i[0].type)&&mb(b.parentNode)||b))){if(i.splice(h,1),a=f.length&&pb(i),!a)return G.apply(e,f),e;break}}}return g(a,m)(f,b,!n,e,$.test(a)&&mb(b.parentNode)||b),e}return c.sortStable=s.split("").sort(z).join("")===s,c.detectDuplicates=!!j,k(),c.sortDetached=gb(function(a){return 1&a.compareDocumentPosition(l.createElement("div"))}),gb(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||hb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&gb(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||hb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),gb(function(a){return null==a.getAttribute("disabled")})||hb(J,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),db}(a);o.find=t,o.expr=t.selectors,o.expr[":"]=o.expr.pseudos,o.unique=t.uniqueSort,o.text=t.getText,o.isXMLDoc=t.isXML,o.contains=t.contains;var u=o.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(o.isFunction(b))return o.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return o.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return o.filter(b,a,c);b=o.filter(b,a)}return o.grep(a,function(a){return g.call(b,a)>=0!==c})}o.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?o.find.matchesSelector(d,a)?[d]:[]:o.find.matches(a,o.grep(b,function(a){return 1===a.nodeType}))},o.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(o(a).filter(function(){for(b=0;c>b;b++)if(o.contains(e[b],this))return!0}));for(b=0;c>b;b++)o.find(a,e[b],d);return d=this.pushStack(c>1?o.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)?o(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=o.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 o?b[0]:b,o.merge(this,o.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:m,!0)),v.test(c[1])&&o.isPlainObject(b))for(c in b)o.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=m.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=m,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):o.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(o):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),o.makeArray(a,this))};A.prototype=o.fn,y=o(m);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};o.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&&o(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}}),o.fn.extend({has:function(a){var b=o(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(o.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?o(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&&o.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?o.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(o(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(o.unique(o.merge(this.get(),o(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}o.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return o.dir(a,"parentNode")},parentsUntil:function(a,b,c){return o.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return o.dir(a,"nextSibling")},prevAll:function(a){return o.dir(a,"previousSibling")},nextUntil:function(a,b,c){return o.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return o.dir(a,"previousSibling",c)},siblings:function(a){return o.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return o.sibling(a.firstChild)},contents:function(a){return a.contentDocument||o.merge([],a.childNodes)}},function(a,b){o.fn[a]=function(c,d){var e=o.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=o.filter(d,e)),this.length>1&&(C[a]||o.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return o.each(a.match(E)||[],function(a,c){b[c]=!0}),b}o.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):o.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){o.each(b,function(b,c){var d=o.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&&o.each(arguments,function(a,b){var c;while((c=o.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?o.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},o.extend({Deferred:function(a){var b=[["resolve","done",o.Callbacks("once memory"),"resolved"],["reject","fail",o.Callbacks("once memory"),"rejected"],["notify","progress",o.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return o.Deferred(function(c){o.each(b,function(b,f){var g=o.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&o.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?o.extend(a,d):d}},e={};return d.pipe=d.then,o.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&&o.isFunction(a.promise)?e:0,g=1===f?a:o.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]&&o.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;o.fn.ready=function(a){return o.ready.promise().done(a),this},o.extend({isReady:!1,readyWait:1,holdReady:function(a){a?o.readyWait++:o.ready(!0)},ready:function(a){(a===!0?--o.readyWait:o.isReady)||(o.isReady=!0,a!==!0&&--o.readyWait>0||(H.resolveWith(m,[o]),o.fn.trigger&&o(m).trigger("ready").off("ready")))}});function I(){m.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),o.ready()}o.ready.promise=function(b){return H||(H=o.Deferred(),"complete"===m.readyState?setTimeout(o.ready):(m.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},o.ready.promise();var J=o.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===o.type(c)){e=!0;for(h in c)o.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,o.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(o(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};o.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=o.expando+Math.random()}K.uid=1,K.accepts=o.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,o.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(o.isEmptyObject(f))o.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,o.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{o.isArray(b)?d=b.concat(b.map(o.camelCase)):(e=o.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!o.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)?o.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}o.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){return M.access(a,b,c)},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)}}),o.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; 3 | while(c--)d=g[c].name,0===d.indexOf("data-")&&(d=o.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=o.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)})}}),o.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||o.isArray(c)?d=L.access(a,b,o.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=o.queue(a,b),d=c.length,e=c.shift(),f=o._queueHooks(a,b),g=function(){o.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:o.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),o.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?o.queue(this[0],a):void 0===b?this:this.each(function(){var c=o.queue(this,a,b);o._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&o.dequeue(this,a)})},dequeue:function(a){return this.each(function(){o.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=o.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=L.get(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var Q=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,R=["Top","Right","Bottom","Left"],S=function(a,b){return a=b||a,"none"===o.css(a,"display")||!o.contains(a.ownerDocument,a)},T=/^(?:checkbox|radio)$/i;!function(){var a=m.createDocumentFragment(),b=a.appendChild(m.createElement("div"));b.innerHTML="<input type='radio' checked='checked' name='t'/>",l.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="<textarea>x</textarea>",l.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";l.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return m.activeElement}catch(a){}}o.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=o.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof o!==U&&o.event.triggered!==b.type?o.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],n=q=h[1],p=(h[2]||"").split(".").sort(),n&&(l=o.event.special[n]||{},n=(e?l.delegateType:l.bindType)||n,l=o.event.special[n]||{},k=o.extend({type:n,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&o.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[n])||(m=i[n]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(n,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),o.event.global[n]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,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])||[],n=q=h[1],p=(h[2]||"").split(".").sort(),n){l=o.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=i[n]||[],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||o.removeEvent(a,n,r.handle),delete i[n])}else for(n in i)o.event.remove(a,n+b[j],c,d,!0);o.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,p=[d||m],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||m,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+o.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[o.expando]?b:new o.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]:o.makeArray(c,[b]),n=o.event.special[q]||{},e||!n.trigger||n.trigger.apply(d,c)!==!1)){if(!e&&!n.noBubble&&!o.isWindow(d)){for(i=n.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||m)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:n.bindType||q,l=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),l&&l.apply(g,c),l=k&&g[k],l&&l.apply&&o.acceptData(g)&&(b.result=l.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||n._default&&n._default.apply(p.pop(),c)!==!1||!o.acceptData(d)||k&&o.isFunction(d[q])&&!o.isWindow(d)&&(h=d[k],h&&(d[k]=null),o.event.triggered=q,d[q](),o.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=o.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=o.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=o.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=((o.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?o(e,this).index(i)>=0:o.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h<b.length&&g.push({elem:this,handlers:b.slice(h)}),g},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return null==a.which&&(a.which=null!=b.charCode?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,b){var c,d,e,f=b.button;return null==a.pageX&&null!=b.clientX&&(c=a.target.ownerDocument||m,d=c.documentElement,e=c.body,a.pageX=b.clientX+(d&&d.scrollLeft||e&&e.scrollLeft||0)-(d&&d.clientLeft||e&&e.clientLeft||0),a.pageY=b.clientY+(d&&d.scrollTop||e&&e.scrollTop||0)-(d&&d.clientTop||e&&e.clientTop||0)),a.which||void 0===f||(a.which=1&f?1:2&f?3:4&f?2:0),a}},fix:function(a){if(a[o.expando])return a;var b,c,d,e=a.type,f=a,g=this.fixHooks[e];g||(this.fixHooks[e]=g=W.test(e)?this.mouseHooks:V.test(e)?this.keyHooks:{}),d=g.props?this.props.concat(g.props):this.props,a=new o.Event(f),b=d.length;while(b--)c=d[b],a[c]=f[c];return a.target||(a.target=m),3===a.target.nodeType&&(a.target=a.target.parentNode),g.filter?g.filter(a,f):a},special:{load:{noBubble:!0},focus:{trigger:function(){return this!==_()&&this.focus?(this.focus(),!1):void 0},delegateType:"focusin"},blur:{trigger:function(){return this===_()&&this.blur?(this.blur(),!1):void 0},delegateType:"focusout"},click:{trigger:function(){return"checkbox"===this.type&&this.click&&o.nodeName(this,"input")?(this.click(),!1):void 0},_default:function(a){return o.nodeName(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&(a.originalEvent.returnValue=a.result)}}},simulate:function(a,b,c,d){var e=o.extend(new o.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?o.event.trigger(e,null,b):o.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},o.removeEvent=function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)},o.Event=function(a,b){return this instanceof o.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.getPreventDefault&&a.getPreventDefault()?Z:$):this.type=a,b&&o.extend(this,b),this.timeStamp=a&&a.timeStamp||o.now(),void(this[o.expando]=!0)):new o.Event(a,b)},o.Event.prototype={isDefaultPrevented:$,isPropagationStopped:$,isImmediatePropagationStopped:$,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=Z,a&&a.preventDefault&&a.preventDefault()},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=Z,a&&a.stopPropagation&&a.stopPropagation()},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=Z,this.stopPropagation()}},o.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){o.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return(!e||e!==d&&!o.contains(d,e))&&(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),l.focusinBubbles||o.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){o.event.simulate(b,a.target,o.event.fix(a),!0)};o.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=L.access(d,b);e||d.addEventListener(a,c,!0),L.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=L.access(d,b)-1;e?L.access(d,b,e):(d.removeEventListener(a,c,!0),L.remove(d,b))}}}),o.fn.extend({on:function(a,b,c,d,e){var f,g;if("object"==typeof a){"string"!=typeof b&&(c=c||b,b=void 0);for(g in a)this.on(g,b,c,a[g],e);return this}if(null==c&&null==d?(d=b,c=b=void 0):null==d&&("string"==typeof b?(d=c,c=void 0):(d=c,c=b,b=void 0)),d===!1)d=$;else if(!d)return this;return 1===e&&(f=d,d=function(a){return o().off(a),f.apply(this,arguments)},d.guid=f.guid||(f.guid=o.guid++)),this.each(function(){o.event.add(this,a,d,c,b)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,o(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return(b===!1||"function"==typeof b)&&(c=b,b=void 0),c===!1&&(c=$),this.each(function(){o.event.remove(this,a,c,b)})},trigger:function(a,b){return this.each(function(){o.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];return c?o.event.trigger(a,b,c,!0):void 0}});var ab=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/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*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ib={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_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 o.nodeName(a,"table")&&o.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++)o.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=o.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&&o.nodeName(a,b)?o.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)}o.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=o.contains(a.ownerDocument,a);if(!(l.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||o.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,n=a.length;n>m;m++)if(e=a[m],e||0===e)if("object"===o.type(e))o.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1></$2>")+h[2],j=h[0];while(j--)f=f.lastChild;o.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===o.inArray(e,d))&&(i=o.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,g,h=o.event.special,i=0;void 0!==(c=a[i]);i++){if(o.acceptData(c)&&(f=c[L.expando],f&&(b=L.cache[f]))){if(d=Object.keys(b.events||{}),d.length)for(g=0;void 0!==(e=d[g]);g++)h[e]?o.event.remove(c,e):o.removeEvent(c,e,b.handle);L.cache[f]&&delete L.cache[f]}delete M.cache[c[M.expando]]}}}),o.fn.extend({text:function(a){return J(this,function(a){return void 0===a?o.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?o.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||o.cleanData(ob(c)),c.parentNode&&(b&&o.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&&(o.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 o.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1></$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(o.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,o.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,k=this.length,m=this,n=k-1,p=a[0],q=o.isFunction(p);if(q||k>1&&"string"==typeof p&&!l.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(k&&(c=o.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=o.map(ob(c,"script"),kb),g=f.length;k>j;j++)h=c,j!==n&&(h=o.clone(h,!0,!0),g&&o.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,o.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&o.contains(i,h)&&(h.src?o._evalUrl&&o._evalUrl(h.src):o.globalEval(h.textContent.replace(hb,"")))}return this}}),o.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){o.fn[a]=function(a){for(var c,d=[],e=o(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),o(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d=o(c.createElement(b)).appendTo(c.body),e=a.getDefaultComputedStyle?a.getDefaultComputedStyle(d[0]).display:o.css(d[0],"display");return d.detach(),e}function tb(a){var b=m,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||o("<iframe frameborder='0' width='0' height='0'/>")).appendTo(b.documentElement),b=qb[0].contentDocument,b.write(),b.close(),c=sb(a,b),qb.detach()),rb[a]=c),c}var ub=/^margin/,vb=new RegExp("^("+Q+")(?!px)[a-z%]+$","i"),wb=function(a){return a.ownerDocument.defaultView.getComputedStyle(a,null)};function xb(a,b,c){var d,e,f,g,h=a.style;return c=c||wb(a),c&&(g=c.getPropertyValue(b)||c[b]),c&&(""!==g||o.contains(a.ownerDocument,a)||(g=o.style(a,b)),vb.test(g)&&ub.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0!==g?g+"":g}function yb(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d="padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box",e=m.documentElement,f=m.createElement("div"),g=m.createElement("div");g.style.backgroundClip="content-box",g.cloneNode(!0).style.backgroundClip="",l.clearCloneStyle="content-box"===g.style.backgroundClip,f.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",f.appendChild(g);function h(){g.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%",e.appendChild(f);var d=a.getComputedStyle(g,null);b="1%"!==d.top,c="4px"===d.width,e.removeChild(f)}a.getComputedStyle&&o.extend(l,{pixelPosition:function(){return h(),b},boxSizingReliable:function(){return null==c&&h(),c},reliableMarginRight:function(){var b,c=g.appendChild(m.createElement("div"));return c.style.cssText=g.style.cssText=d,c.style.marginRight=c.style.width="0",g.style.width="1px",e.appendChild(f),b=!parseFloat(a.getComputedStyle(c,null).marginRight),e.removeChild(f),g.innerHTML="",b}})}(),o.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var zb=/^(none|table(?!-c[ea]).+)/,Ab=new RegExp("^("+Q+")(.*)$","i"),Bb=new RegExp("^([+-])=("+Q+")","i"),Cb={position:"absolute",visibility:"hidden",display:"block"},Db={letterSpacing:0,fontWeight:400},Eb=["Webkit","O","Moz","ms"];function Fb(a,b){if(b in a)return b;var c=b[0].toUpperCase()+b.slice(1),d=b,e=Eb.length;while(e--)if(b=Eb[e]+c,b in a)return b;return d}function Gb(a,b,c){var d=Ab.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Hb(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=o.css(a,c+R[f],!0,e)),d?("content"===c&&(g-=o.css(a,"padding"+R[f],!0,e)),"margin"!==c&&(g-=o.css(a,"border"+R[f]+"Width",!0,e))):(g+=o.css(a,"padding"+R[f],!0,e),"padding"!==c&&(g+=o.css(a,"border"+R[f]+"Width",!0,e)));return g}function Ib(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=wb(a),g="border-box"===o.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=xb(a,b,f),(0>e||null==e)&&(e=a.style[b]),vb.test(e))return e;d=g&&(l.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Hb(a,b,c||(g?"border":"content"),d,f)+"px"}function Jb(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=L.get(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&S(d)&&(f[g]=L.access(d,"olddisplay",tb(d.nodeName)))):f[g]||(e=S(d),(c&&"none"!==c||!e)&&L.set(d,"olddisplay",e?c:o.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}o.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=xb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=o.camelCase(b),i=a.style;return b=o.cssProps[h]||(o.cssProps[h]=Fb(i,h)),g=o.cssHooks[b]||o.cssHooks[h],void 0===c?g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b]:(f=typeof c,"string"===f&&(e=Bb.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(o.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||o.cssNumber[h]||(c+="px"),l.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),g&&"set"in g&&void 0===(c=g.set(a,c,d))||(i[b]="",i[b]=c)),void 0)}},css:function(a,b,c,d){var e,f,g,h=o.camelCase(b);return b=o.cssProps[h]||(o.cssProps[h]=Fb(a.style,h)),g=o.cssHooks[b]||o.cssHooks[h],g&&"get"in g&&(e=g.get(a,!0,c)),void 0===e&&(e=xb(a,b,d)),"normal"===e&&b in Db&&(e=Db[b]),""===c||c?(f=parseFloat(e),c===!0||o.isNumeric(f)?f||0:e):e}}),o.each(["height","width"],function(a,b){o.cssHooks[b]={get:function(a,c,d){return c?0===a.offsetWidth&&zb.test(o.css(a,"display"))?o.swap(a,Cb,function(){return Ib(a,b,d)}):Ib(a,b,d):void 0},set:function(a,c,d){var e=d&&wb(a);return Gb(a,c,d?Hb(a,b,d,"border-box"===o.css(a,"boxSizing",!1,e),e):0)}}}),o.cssHooks.marginRight=yb(l.reliableMarginRight,function(a,b){return b?o.swap(a,{display:"inline-block"},xb,[a,"marginRight"]):void 0}),o.each({margin:"",padding:"",border:"Width"},function(a,b){o.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+R[d]+b]=f[d]||f[d-2]||f[0];return e}},ub.test(a)||(o.cssHooks[a+b].set=Gb)}),o.fn.extend({css:function(a,b){return J(this,function(a,b,c){var d,e,f={},g=0;if(o.isArray(b)){for(d=wb(a),e=b.length;e>g;g++)f[b[g]]=o.css(a,b[g],!1,d);return f}return void 0!==c?o.style(a,b,c):o.css(a,b)},a,b,arguments.length>1)},show:function(){return Jb(this,!0)},hide:function(){return Jb(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){S(this)?o(this).show():o(this).hide()})}});function Kb(a,b,c,d,e){return new Kb.prototype.init(a,b,c,d,e)}o.Tween=Kb,Kb.prototype={constructor:Kb,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(o.cssNumber[c]?"":"px")},cur:function(){var a=Kb.propHooks[this.prop];return a&&a.get?a.get(this):Kb.propHooks._default.get(this)},run:function(a){var b,c=Kb.propHooks[this.prop];return this.pos=b=this.options.duration?o.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Kb.propHooks._default.set(this),this}},Kb.prototype.init.prototype=Kb.prototype,Kb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=o.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){o.fx.step[a.prop]?o.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[o.cssProps[a.prop]]||o.cssHooks[a.prop])?o.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Kb.propHooks.scrollTop=Kb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},o.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},o.fx=Kb.prototype.init,o.fx.step={};var Lb,Mb,Nb=/^(?:toggle|show|hide)$/,Ob=new RegExp("^(?:([+-])=|)("+Q+")([a-z%]*)$","i"),Pb=/queueHooks$/,Qb=[Vb],Rb={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=Ob.exec(b),f=e&&e[3]||(o.cssNumber[a]?"":"px"),g=(o.cssNumber[a]||"px"!==f&&+d)&&Ob.exec(o.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,o.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function Sb(){return setTimeout(function(){Lb=void 0}),Lb=o.now()}function Tb(a,b){var c,d=0,e={height:a};for(b=b?1:0;4>d;d+=2-b)c=R[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function Ub(a,b,c){for(var d,e=(Rb[b]||[]).concat(Rb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function Vb(a,b,c){var d,e,f,g,h,i,j,k=this,l={},m=a.style,n=a.nodeType&&S(a),p=L.get(a,"fxshow");c.queue||(h=o._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,k.always(function(){k.always(function(){h.unqueued--,o.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[m.overflow,m.overflowX,m.overflowY],j=o.css(a,"display"),"none"===j&&(j=tb(a.nodeName)),"inline"===j&&"none"===o.css(a,"float")&&(m.display="inline-block")),c.overflow&&(m.overflow="hidden",k.always(function(){m.overflow=c.overflow[0],m.overflowX=c.overflow[1],m.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],Nb.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(n?"hide":"show")){if("show"!==e||!p||void 0===p[d])continue;n=!0}l[d]=p&&p[d]||o.style(a,d)}if(!o.isEmptyObject(l)){p?"hidden"in p&&(n=p.hidden):p=L.access(a,"fxshow",{}),f&&(p.hidden=!n),n?o(a).show():k.done(function(){o(a).hide()}),k.done(function(){var b;L.remove(a,"fxshow");for(b in l)o.style(a,b,l[b])});for(d in l)g=Ub(n?p[d]:0,d,k),d in p||(p[d]=g.start,n&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function Wb(a,b){var c,d,e,f,g;for(c in a)if(d=o.camelCase(c),e=b[d],f=a[c],o.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=o.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function Xb(a,b,c){var d,e,f=0,g=Qb.length,h=o.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=Lb||Sb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:o.extend({},b),opts:o.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:Lb||Sb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=o.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(Wb(k,j.opts.specialEasing);g>f;f++)if(d=Qb[f].call(j,a,k,j.opts))return d;return o.map(k,Ub,j),o.isFunction(j.opts.start)&&j.opts.start.call(a,j),o.fx.timer(o.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}o.Animation=o.extend(Xb,{tweener:function(a,b){o.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],Rb[c]=Rb[c]||[],Rb[c].unshift(b)},prefilter:function(a,b){b?Qb.unshift(a):Qb.push(a)}}),o.speed=function(a,b,c){var d=a&&"object"==typeof a?o.extend({},a):{complete:c||!c&&b||o.isFunction(a)&&a,duration:a,easing:c&&b||b&&!o.isFunction(b)&&b};return d.duration=o.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in o.fx.speeds?o.fx.speeds[d.duration]:o.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){o.isFunction(d.old)&&d.old.call(this),d.queue&&o.dequeue(this,d.queue)},d},o.fn.extend({fadeTo:function(a,b,c,d){return this.filter(S).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=o.isEmptyObject(a),f=o.speed(b,c,d),g=function(){var b=Xb(this,o.extend({},a),f);(e||L.get(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=o.timers,g=L.get(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&Pb.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&o.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=L.get(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=o.timers,g=d?d.length:0;for(c.finish=!0,o.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),o.each(["toggle","show","hide"],function(a,b){var c=o.fn[b];o.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(Tb(b,!0),a,d,e)}}),o.each({slideDown:Tb("show"),slideUp:Tb("hide"),slideToggle:Tb("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){o.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),o.timers=[],o.fx.tick=function(){var a,b=0,c=o.timers;for(Lb=o.now();b<c.length;b++)a=c[b],a()||c[b]!==a||c.splice(b--,1);c.length||o.fx.stop(),Lb=void 0},o.fx.timer=function(a){o.timers.push(a),a()?o.fx.start():o.timers.pop()},o.fx.interval=13,o.fx.start=function(){Mb||(Mb=setInterval(o.fx.tick,o.fx.interval))},o.fx.stop=function(){clearInterval(Mb),Mb=null},o.fx.speeds={slow:600,fast:200,_default:400},o.fn.delay=function(a,b){return a=o.fx?o.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},function(){var a=m.createElement("input"),b=m.createElement("select"),c=b.appendChild(m.createElement("option"));a.type="checkbox",l.checkOn=""!==a.value,l.optSelected=c.selected,b.disabled=!0,l.optDisabled=!c.disabled,a=m.createElement("input"),a.value="t",a.type="radio",l.radioValue="t"===a.value}();var Yb,Zb,$b=o.expr.attrHandle;o.fn.extend({attr:function(a,b){return J(this,o.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){o.removeAttr(this,a)})}}),o.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===U?o.prop(a,b,c):(1===f&&o.isXMLDoc(a)||(b=b.toLowerCase(),d=o.attrHooks[b]||(o.expr.match.bool.test(b)?Zb:Yb)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=o.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void o.removeAttr(a,b))},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=o.propFix[c]||c,o.expr.match.bool.test(c)&&(a[d]=!1),a.removeAttribute(c)},attrHooks:{type:{set:function(a,b){if(!l.radioValue&&"radio"===b&&o.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),Zb={set:function(a,b,c){return b===!1?o.removeAttr(a,c):a.setAttribute(c,c),c}},o.each(o.expr.match.bool.source.match(/\w+/g),function(a,b){var c=$b[b]||o.find.attr;$b[b]=function(a,b,d){var e,f; 4 | return d||(f=$b[b],$b[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,$b[b]=f),e}});var _b=/^(?:input|select|textarea|button)$/i;o.fn.extend({prop:function(a,b){return J(this,o.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[o.propFix[a]||a]})}}),o.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!o.isXMLDoc(a),f&&(b=o.propFix[b]||b,e=o.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){return a.hasAttribute("tabindex")||_b.test(a.nodeName)||a.href?a.tabIndex:-1}}}}),l.optSelected||(o.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null}}),o.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){o.propFix[this.toLowerCase()]=this});var ac=/[\t\r\n\f]/g;o.fn.extend({addClass:function(a){var b,c,d,e,f,g,h="string"==typeof a&&a,i=0,j=this.length;if(o.isFunction(a))return this.each(function(b){o(this).addClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=o.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0===arguments.length||"string"==typeof a&&a,i=0,j=this.length;if(o.isFunction(a))return this.each(function(b){o(this).removeClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?o.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(o.isFunction(a)?function(c){o(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=o(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===U||"boolean"===c)&&(this.className&&L.set(this,"__className__",this.className),this.className=this.className||a===!1?"":L.get(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(ac," ").indexOf(b)>=0)return!0;return!1}});var bc=/\r/g;o.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=o.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,o(this).val()):a,null==e?e="":"number"==typeof e?e+="":o.isArray(e)&&(e=o.map(e,function(a){return null==a?"":a+""})),b=o.valHooks[this.type]||o.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=o.valHooks[e.type]||o.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(bc,""):null==c?"":c)}}}),o.extend({valHooks:{select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(l.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&o.nodeName(c.parentNode,"optgroup"))){if(b=o(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=o.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=o.inArray(o(d).val(),f)>=0)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),o.each(["radio","checkbox"],function(){o.valHooks[this]={set:function(a,b){return o.isArray(b)?a.checked=o.inArray(o(a).val(),b)>=0:void 0}},l.checkOn||(o.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})}),o.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){o.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),o.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var cc=o.now(),dc=/\?/;o.parseJSON=function(a){return JSON.parse(a+"")},o.parseXML=function(a){var b,c;if(!a||"string"!=typeof a)return null;try{c=new DOMParser,b=c.parseFromString(a,"text/xml")}catch(d){b=void 0}return(!b||b.getElementsByTagName("parsererror").length)&&o.error("Invalid XML: "+a),b};var ec,fc,gc=/#.*$/,hc=/([?&])_=[^&]*/,ic=/^(.*?):[ \t]*([^\r\n]*)$/gm,jc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,kc=/^(?:GET|HEAD)$/,lc=/^\/\//,mc=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,nc={},oc={},pc="*/".concat("*");try{fc=location.href}catch(qc){fc=m.createElement("a"),fc.href="",fc=fc.href}ec=mc.exec(fc.toLowerCase())||[];function rc(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(o.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function sc(a,b,c,d){var e={},f=a===oc;function g(h){var i;return e[h]=!0,o.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function tc(a,b){var c,d,e=o.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&o.extend(!0,a,d),a}function uc(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function vc(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}o.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:fc,type:"GET",isLocal:jc.test(ec[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":pc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":o.parseJSON,"text xml":o.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?tc(tc(a,o.ajaxSettings),b):tc(o.ajaxSettings,a)},ajaxPrefilter:rc(nc),ajaxTransport:rc(oc),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=o.ajaxSetup({},b),l=k.context||k,m=k.context&&(l.nodeType||l.jquery)?o(l):o.event,n=o.Deferred(),p=o.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!f){f={};while(b=ic.exec(e))f[b[1].toLowerCase()]=b[2]}b=f[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?e:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return c&&c.abort(b),x(0,b),this}};if(n.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||fc)+"").replace(gc,"").replace(lc,ec[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=o.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(h=mc.exec(k.url.toLowerCase()),k.crossDomain=!(!h||h[1]===ec[1]&&h[2]===ec[2]&&(h[3]||("http:"===h[1]?"80":"443"))===(ec[3]||("http:"===ec[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=o.param(k.data,k.traditional)),sc(nc,k,b,v),2===t)return v;i=k.global,i&&0===o.active++&&o.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!kc.test(k.type),d=k.url,k.hasContent||(k.data&&(d=k.url+=(dc.test(d)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=hc.test(d)?d.replace(hc,"$1_="+cc++):d+(dc.test(d)?"&":"?")+"_="+cc++)),k.ifModified&&(o.lastModified[d]&&v.setRequestHeader("If-Modified-Since",o.lastModified[d]),o.etag[d]&&v.setRequestHeader("If-None-Match",o.etag[d])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+pc+"; q=0.01":""):k.accepts["*"]);for(j in k.headers)v.setRequestHeader(j,k.headers[j]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(j in{success:1,error:1,complete:1})v[j](k[j]);if(c=sc(oc,k,b,v)){v.readyState=1,i&&m.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,c.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,f,h){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),c=void 0,e=h||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,f&&(u=uc(k,v,f)),u=vc(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(o.lastModified[d]=w),w=v.getResponseHeader("etag"),w&&(o.etag[d]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?n.resolveWith(l,[r,x,v]):n.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,i&&m.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),i&&(m.trigger("ajaxComplete",[v,k]),--o.active||o.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return o.get(a,b,c,"json")},getScript:function(a,b){return o.get(a,void 0,b,"script")}}),o.each(["get","post"],function(a,b){o[b]=function(a,c,d,e){return o.isFunction(c)&&(e=e||d,d=c,c=void 0),o.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),o.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){o.fn[b]=function(a){return this.on(b,a)}}),o._evalUrl=function(a){return o.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},o.fn.extend({wrapAll:function(a){var b;return o.isFunction(a)?this.each(function(b){o(this).wrapAll(a.call(this,b))}):(this[0]&&(b=o(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this)},wrapInner:function(a){return this.each(o.isFunction(a)?function(b){o(this).wrapInner(a.call(this,b))}:function(){var b=o(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=o.isFunction(a);return this.each(function(c){o(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){o.nodeName(this,"body")||o(this).replaceWith(this.childNodes)}).end()}}),o.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0},o.expr.filters.visible=function(a){return!o.expr.filters.hidden(a)};var wc=/%20/g,xc=/\[\]$/,yc=/\r?\n/g,zc=/^(?:submit|button|image|reset|file)$/i,Ac=/^(?:input|select|textarea|keygen)/i;function Bc(a,b,c,d){var e;if(o.isArray(b))o.each(b,function(b,e){c||xc.test(a)?d(a,e):Bc(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==o.type(b))d(a,b);else for(e in b)Bc(a+"["+e+"]",b[e],c,d)}o.param=function(a,b){var c,d=[],e=function(a,b){b=o.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=o.ajaxSettings&&o.ajaxSettings.traditional),o.isArray(a)||a.jquery&&!o.isPlainObject(a))o.each(a,function(){e(this.name,this.value)});else for(c in a)Bc(c,a[c],b,e);return d.join("&").replace(wc,"+")},o.fn.extend({serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=o.prop(this,"elements");return a?o.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!o(this).is(":disabled")&&Ac.test(this.nodeName)&&!zc.test(a)&&(this.checked||!T.test(a))}).map(function(a,b){var c=o(this).val();return null==c?null:o.isArray(c)?o.map(c,function(a){return{name:b.name,value:a.replace(yc,"\r\n")}}):{name:b.name,value:c.replace(yc,"\r\n")}}).get()}}),o.ajaxSettings.xhr=function(){try{return new XMLHttpRequest}catch(a){}};var Cc=0,Dc={},Ec={0:200,1223:204},Fc=o.ajaxSettings.xhr();a.ActiveXObject&&o(a).on("unload",function(){for(var a in Dc)Dc[a]()}),l.cors=!!Fc&&"withCredentials"in Fc,l.ajax=Fc=!!Fc,o.ajaxTransport(function(a){var b;return l.cors||Fc&&!a.crossDomain?{send:function(c,d){var e,f=a.xhr(),g=++Cc;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)f.setRequestHeader(e,c[e]);b=function(a){return function(){b&&(delete Dc[g],b=f.onload=f.onerror=null,"abort"===a?f.abort():"error"===a?d(f.status,f.statusText):d(Ec[f.status]||f.status,f.statusText,"string"==typeof f.responseText?{text:f.responseText}:void 0,f.getAllResponseHeaders()))}},f.onload=b(),f.onerror=b("error"),b=Dc[g]=b("abort"),f.send(a.hasContent&&a.data||null)},abort:function(){b&&b()}}:void 0}),o.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return o.globalEval(a),a}}}),o.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),o.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(d,e){b=o("<script>").prop({async:!0,charset:a.scriptCharset,src:a.url}).on("load error",c=function(a){b.remove(),c=null,a&&e("error"===a.type?404:200,a.type)}),m.head.appendChild(b[0])},abort:function(){c&&c()}}}});var Gc=[],Hc=/(=)\?(?=&|$)|\?\?/;o.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Gc.pop()||o.expando+"_"+cc++;return this[a]=!0,a}}),o.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(Hc.test(b.url)?"url":"string"==typeof b.data&&!(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&Hc.test(b.data)&&"data");return h||"jsonp"===b.dataTypes[0]?(e=b.jsonpCallback=o.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(Hc,"$1"+e):b.jsonp!==!1&&(b.url+=(dc.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||o.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,Gc.push(e)),g&&o.isFunction(f)&&f(g[0]),g=f=void 0}),"script"):void 0}),o.parseHTML=function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||m;var d=v.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=o.buildFragment([a],b,e),e&&e.length&&o(e).remove(),o.merge([],d.childNodes))};var Ic=o.fn.load;o.fn.load=function(a,b,c){if("string"!=typeof a&&Ic)return Ic.apply(this,arguments);var d,e,f,g=this,h=a.indexOf(" ");return h>=0&&(d=a.slice(h),a=a.slice(0,h)),o.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(e="POST"),g.length>0&&o.ajax({url:a,type:e,dataType:"html",data:b}).done(function(a){f=arguments,g.html(d?o("<div>").append(o.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,f||[a.responseText,b,a])}),this},o.expr.filters.animated=function(a){return o.grep(o.timers,function(b){return a===b.elem}).length};var Jc=a.document.documentElement;function Kc(a){return o.isWindow(a)?a:9===a.nodeType&&a.defaultView}o.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=o.css(a,"position"),l=o(a),m={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=o.css(a,"top"),i=o.css(a,"left"),j=("absolute"===k||"fixed"===k)&&(f+i).indexOf("auto")>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),o.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(m.top=b.top-h.top+g),null!=b.left&&(m.left=b.left-h.left+e),"using"in b?b.using.call(a,m):l.css(m)}},o.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){o.offset.setOffset(this,a,b)});var b,c,d=this[0],e={top:0,left:0},f=d&&d.ownerDocument;if(f)return b=f.documentElement,o.contains(b,d)?(typeof d.getBoundingClientRect!==U&&(e=d.getBoundingClientRect()),c=Kc(f),{top:e.top+c.pageYOffset-b.clientTop,left:e.left+c.pageXOffset-b.clientLeft}):e},position:function(){if(this[0]){var a,b,c=this[0],d={top:0,left:0};return"fixed"===o.css(c,"position")?b=c.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),o.nodeName(a[0],"html")||(d=a.offset()),d.top+=o.css(a[0],"borderTopWidth",!0),d.left+=o.css(a[0],"borderLeftWidth",!0)),{top:b.top-d.top-o.css(c,"marginTop",!0),left:b.left-d.left-o.css(c,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||Jc;while(a&&!o.nodeName(a,"html")&&"static"===o.css(a,"position"))a=a.offsetParent;return a||Jc})}}),o.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(b,c){var d="pageYOffset"===c;o.fn[b]=function(e){return J(this,function(b,e,f){var g=Kc(b);return void 0===f?g?g[c]:b[e]:void(g?g.scrollTo(d?a.pageXOffset:f,d?f:a.pageYOffset):b[e]=f)},b,e,arguments.length,null)}}),o.each(["top","left"],function(a,b){o.cssHooks[b]=yb(l.pixelPosition,function(a,c){return c?(c=xb(a,b),vb.test(c)?o(a).position()[b]+"px":c):void 0})}),o.each({Height:"height",Width:"width"},function(a,b){o.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){o.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return J(this,function(b,c,d){var e;return o.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?o.css(b,c,g):o.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),o.fn.size=function(){return this.length},o.fn.andSelf=o.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return o});var Lc=a.jQuery,Mc=a.$;return o.noConflict=function(b){return a.$===o&&(a.$=Mc),b&&a.jQuery===o&&(a.jQuery=Lc),o},typeof b===U&&(a.jQuery=a.$=o),o}); 5 | --------------------------------------------------------------------------------