├── .gitignore ├── Actions-system-run-icon.png ├── README.md ├── cache └── README.md ├── close.png ├── convert.pl ├── docker ├── Dockerfile ├── Makefile ├── health.sh └── start-lpn.sh ├── images └── ui-icons_222222_256x240.png ├── jquery-ui.min.css ├── jquery-ui.min.js ├── jquery.min.js ├── local.pl ├── lpn-daemon.pl ├── lpn.css ├── lpn.js ├── lpn_reds2.css ├── proxy.pl ├── testing-version.png ├── tint20.png └── upstart └── lpn-proxy.conf /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | cache 3 | log 4 | -------------------------------------------------------------------------------- /Actions-system-run-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn-swish-proxy/f6fe70ccee6d03d1589135428865469a916e19c3/Actions-system-run-icon.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LPN proxy server 2 | 3 | This repository provides the SWI-Prolog sources for a proxy server for 4 | [Learn Prolog Now!](http://www.learnprolognow.org/) which rewrites the 5 | sources to embed [SWISH](https://swish.swi-prolog.org/), the SWI-Prolog 6 | web shell. The modified version of Learn Prolog Now is hosted at 7 | [lpn.swi-prolog.org](http://lpn.swi-prolog.org) 8 | 9 | The current version is merely a proof of concept. It identifies verbatim 10 | environments in the Learn Prolog Now HTML and classifies these as source 11 | code or example queries. It notably is not (yet) very good at 12 | discovering the relations between source fragments. Most of the 13 | infrastructure to improve on that is already in place: sources and 14 | queries are parsed and analysed for predicates they implement and 15 | require. 16 | 17 | ## Prerequisites 18 | 19 | You will need to install **SWI Prolog version 7 or greater** for this to 20 | work. To check, run this: 21 | 22 | % swipl --version 23 | 24 | ## Run locally 25 | 26 | % swipl proxy.pl 27 | ?- server(8080). 28 | 29 | ## Use local server at port 8000 rather than www.learnprolognow.org: 30 | 31 | % swipl proxy.pl 32 | ?- local. 33 | ?- server(8080). 34 | 35 | ## Use local SWISH at port 3050 rather than swish.swi-prolog.org 36 | 37 | ?- local_swish(3050). 38 | 39 | ## Run as daemon 40 | 41 | As current user 42 | 43 | % ./daemon.pl --port=8080 44 | 45 | As defined user 46 | 47 | % sudo -u www-data ./daemon.pl --port=8080 48 | 49 | Or on port 80: 50 | 51 | % sudo ./daemon.pl --user=www-data 52 | 53 | ## Enable caching 54 | 55 | Create a directory `cache` and make sure it is writeable by the server. 56 | If no such diretory exists, all pages are fetched dynamically. 57 | 58 | % mkdir cache 59 | % sudo chgrp www-data cache 60 | % sudo chmod g+w cache 61 | 62 | -------------------------------------------------------------------------------- /cache/README.md: -------------------------------------------------------------------------------- 1 | This document is just because git doesn't seem happy 2 | adding empty directories, and the cache directory needs 3 | to exist. -------------------------------------------------------------------------------- /close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn-swish-proxy/f6fe70ccee6d03d1589135428865469a916e19c3/close.png -------------------------------------------------------------------------------- /convert.pl: -------------------------------------------------------------------------------- 1 | :- module(convert_lpn, 2 | [ convert_lpn/2, % +In, +Out 3 | local_swish/1 % +Port 4 | ]). 5 | :- use_module(library(sgml)). 6 | :- use_module(library(sgml_write)). 7 | :- use_module(library(http/html_write)). 8 | :- use_module(library(lists)). 9 | :- use_module(library(debug)). 10 | :- use_module(library(apply)). 11 | :- use_module(library(pairs)). 12 | :- use_module(library(dcg/basics)). 13 | :- use_module(library(settings)). 14 | :- use_module(library(ordsets)). 15 | :- use_module(library(xpath)). 16 | 17 | :- setting(swish, atom, 18 | 'https://swish.swi-prolog.org/', 19 | 'SWISH server url'). 20 | 21 | local_swish(Port) :- 22 | format(atom(SWISH), 'http://localhost:~w/', [Port]), 23 | set_setting(swish, SWISH). 24 | 25 | :- debug(lpn(convert)). 26 | :- debug(lpn(_)). 27 | 28 | %% convert_lpn(+In:Stream, +Out:stream) is det 29 | % 30 | % SWISHize In as it's copied to Out 31 | % 32 | convert_lpn(In, Out) :- 33 | % the \+ \+ enforces determinacy 34 | \+ \+ convert_lpn2(In, Out). 35 | 36 | %% convert_lpn2(+In:Stream, +Out:stream) is nondet 37 | % 38 | % SWISHize In as it's copied to Out 39 | % 40 | % Method used is to read in via load_html, which creates 41 | % a tree structure DOM, convert parts of the DOM that 42 | % are to be SWISHized - @see convert_dom/2 and convert/2 43 | % 44 | convert_lpn2(In, Out) :- 45 | load_html(In, DOM, 46 | [ syntax_errors(quiet), 47 | max_errors(-1) 48 | ]), 49 | convert_dom(DOM, DOM1), 50 | classify_sources(DOM1), 51 | ( is_stream(Out) 52 | -> html_write(Out, DOM1, []) 53 | ; setup_call_cleanup( 54 | open(Out, write, Stream), 55 | html_write(Stream, DOM1, []), 56 | close(Stream)) 57 | ). 58 | 59 | %% convert_dom(+DOM0, -DOM) is semidet 60 | % 61 | % convert a DOM or sub-DOM 62 | % if convert/2 can convert it, then it's a 63 | % structure to be modified. If not, we recursively 64 | % try to convert 65 | convert_dom(DOM0, DOM) :- 66 | convert(DOM0, DOM), !. 67 | convert_dom(CDATA0, CDATA) :- 68 | atom(CDATA0), !, 69 | CDATA = CDATA0. 70 | convert_dom([], []). 71 | convert_dom([H0|T0], [H|T]) :- 72 | convert_dom(H0, H), 73 | convert_dom(T0, T). 74 | convert_dom(element(E,A,C0), element(E,A,C)) :- 75 | convert_dom(C0,C). 76 | 77 | %% convert(+DOM0, -DOM) is semidet. 78 | % 79 | % This preforms three steps: 80 | % 81 | % - Extend the head with our dependencies 82 | % - Extend the body to call the `swish` jQuery plugin 83 | % - Classify sources in `fancyvrb` environments (verbatim) 84 | % 85 | % 'fancyvrb' is a class in the original sources 86 | 87 | convert(element(head, Args, C0), 88 | element(head, Args, 89 | [ element(meta, [charset='UTF-8'], []), 90 | element(link, [href='lpn.css', rel=stylesheet], []), 91 | element(link, [href='jquery-ui.min.css', rel=stylesheet], []), 92 | element(script, [src='jquery.min.js'], []), 93 | element(script, [src='jquery-ui.min.js'], []), 94 | element(script, [src='lpn.js'], []) 95 | | C 96 | ])) :- !, 97 | convert_dom(C0, C). 98 | convert(element(body, Args, C0), 99 | element(body, Args, C)) :- !, 100 | convert_dom(C0, C1), 101 | setting(swish, SWISH), 102 | format(string(Script), 103 | '$(function() { $(".swish").LPN({swish:"~w"}); });', [SWISH]), 104 | append(C1, 105 | [ element(script, [], [Script]) 106 | ], C). 107 | convert(element(ol, Attrs0, C0), 108 | element(ol, Attrs, C1)) :- 109 | query_list(C0), !, 110 | convert_dom(C0, C1), 111 | dom_add_class(Attrs0, 'swish query-list', Attrs). 112 | convert(element(div, Attrs, []), 113 | element(div, Attrs, C)) :- 114 | memberchk(class=coloredbar, Attrs), !, 115 | C = {|html|| 116 |
117 | This version of Learn Prolog Now! embeds 118 | SWISH, 119 | SWI-Prolog for SHaring. 120 | The current version rewrites the Learn Prolog Now! HTML on the fly, recognising 121 | source code and example queries. It is not yet good at recognising the relations 122 | between source code fragments and queries. Also Learn Prolog Now! needs some 123 | updating to be more compatible with SWI-Prolog. All sources are on GitHub: 124 | 125 |
126 | LearnPrologNow 127 | 128 | 129 | 130 | LPN SWISH Proxy 131 | 132 | 133 | 134 | SWISH 135 | 136 | 137 |
138 |
139 | |}. 140 | 141 | 142 | convert(element(div, Attrs0, C0), 143 | element(div, Attrs, C1)) :- 144 | memberchk(class=newtheorem, Attrs0), 145 | xpath_chk(element(div, Attrs0, C0), p/span, Span), 146 | xpath_chk(Span, //strong(text), 'Exercise'), !, 147 | convert_dom(C0, C1), 148 | dom_add_class(Attrs0, 'swish exercise', Attrs). 149 | convert(element(div, Attrs0, C0), Source) :- 150 | select(class=fancyvrb, Attrs0, Attrs), 151 | ( convert_source(C0, String) 152 | -> put_attr(Source, 'LPN', 153 | verb{text:String, 154 | attributes:Attrs, 155 | element:Source}) 156 | ; debug(lpn(convert), 'Failed to convert ~p', [C0]), 157 | fail 158 | ). 159 | 160 | dom_add_class(Attrs0, Class, Attrs) :- 161 | select(class=Class0, Attrs0, Attrs1), !, 162 | atomic_list_concat([Class0, Class], ' ', NewClass), 163 | Attrs = [class=NewClass|Attrs1]. 164 | dom_add_class(Attrs0, Class, [class=Class|Attrs0]). 165 | 166 | %% convert_source(+Content, -String) is det. 167 | % 168 | % Get the source text from the `fancyvrb` div 169 | 170 | convert_source(Content, Text) :- 171 | phrase(content_text(Content), Fragments), 172 | atomics_to_string(Fragments, Text0), 173 | remove_leading_spaces(Text0, Text). 174 | 175 | content_text(CDATA) --> 176 | { atom(CDATA), !, 177 | split_string(CDATA, " \t\n", " \t\n", Parts), 178 | atomics_to_string(Parts, " ", Text0), 179 | string_codes(Text0, Codes0), 180 | maplist(back_to_ascii, Codes0, Codes), 181 | string_codes(Text, Codes) 182 | }, !, 183 | [ Text ]. 184 | content_text([]) --> []. 185 | content_text([H|T]) --> 186 | content_text(H), 187 | content_text(T). 188 | content_text(element(br, _, _)) --> !, 189 | ['\n']. 190 | content_text(element(_, _, Content)) --> 191 | content_text(Content). 192 | 193 | back_to_ascii(0x00A0, 0'\s) :- !. % ' 194 | back_to_ascii(0x2019, 0'\') :- !. % Unicode right single quote 195 | back_to_ascii(X, X). 196 | 197 | %% remove_leading_spaces(+In, -Out) 198 | 199 | remove_leading_spaces(In, Out) :- 200 | split_string(In, "\n", "", Lines), 201 | maplist(leading_spaces, Lines, LeadingPerLine), 202 | min_list(LeadingPerLine, Leading), 203 | length(List, Leading), 204 | maplist(=(32), List), 205 | string_codes(LeadingStr, List), 206 | maplist(string_concat(LeadingStr), Stripped, Lines), !, 207 | atomics_to_string(Stripped, "\n", Out). 208 | remove_leading_spaces(In, In). 209 | 210 | leading_spaces(Line, Count) :- 211 | leading_spaces(Line, 0, Count). 212 | 213 | leading_spaces(Line, N, Count) :- 214 | sub_string(Line, N, 1, _, " "), !, 215 | N2 is N+1, 216 | leading_spaces(Line, N2, Count). 217 | leading_spaces(_, N, N). 218 | 219 | 220 | %% classify_sources(+DOM1) is det. 221 | % 222 | % Classify the sources we found on the page. Sources are 223 | % attributed variables holding the attribute =LPN= and value a 224 | % dict. We want to make the following inferences: 225 | % 226 | % - Which fragments contain source code? 227 | % - Valid Prolog terms without "?-" 228 | % - Which fragments contain queries? 229 | % - One or more "?- Term." sequences 230 | % - Indentify relations between source code 231 | % - S1 follows S2 and is part of S2 232 | % - No need to make C1 executable (highlighted documentation) 233 | % - S1 implements the same predicates S2 234 | % - Might have do do with alternatives 235 | % - S1 requires S2. 236 | % - Indentify queries 237 | % - Query needs only built-ins 238 | % - Query needs sources S1, S2, ... 239 | 240 | classify_sources(DOM) :- 241 | term_attvars(DOM, Vars), 242 | pre_classify_verbs(Vars), 243 | id_source_highlights(Vars), 244 | id_queries(Vars), 245 | id_variants(Vars), 246 | % id_depends(Vars), 247 | maplist(bind, Vars). 248 | 249 | pre_classify_verbs([]). 250 | pre_classify_verbs([V|T0]) :- 251 | get_lpn(V, H), 252 | pre_classify_source(H.text, Content, Terms, Class), 253 | xref_terms(Terms, XREF), 254 | H1 = H.put(content, Content), 255 | ( Class == verbatim 256 | -> bind(H1, [class=verbatim]) 257 | ; set_lpn(V, H1.put(_{terms:Terms, xref:XREF, class:Class})) 258 | ), 259 | pre_classify_verbs(T0). 260 | 261 | get_lpn(Var, Dict) :- get_attr(Var, 'LPN', Dict). 262 | set_lpn(Var, Dict) :- put_attr(Var, 'LPN', Dict). 263 | 264 | put_lpn(Var, New) :- 265 | get_lpn(Var, Dict0), 266 | set_lpn(Var, Dict0.put(New)). 267 | put_lpn(Var, Key, Value) :- 268 | get_lpn(Var, Dict0), 269 | set_lpn(Var, Dict0.put(Key, Value)). 270 | 271 | bind(Var) :- 272 | get_lpn(Var, Dict), !, 273 | final_class(Dict.class, Class), 274 | bind(Dict, [class=Class]). 275 | bind(_). 276 | 277 | final_class(source, 'source swish') :- !. 278 | final_class(Class, Class). 279 | 280 | bind(Dict, Attrs) :- 281 | del_attr(Dict.element, 'LPN'), 282 | append(Attrs, Dict.attributes, AllAttrs), 283 | Dict.element = element(pre, AllAttrs, Dict.content). 284 | 285 | has_class(Class, V) :- 286 | get_lpn(V, Dict), 287 | Class == Dict.class. 288 | 289 | add_class(V, Class) :- 290 | get_lpn(V, Dict), 291 | atomic_list_concat([Dict.class, Class], ' ', NewClass), 292 | set_lpn(V, Dict.put(class, NewClass)). 293 | 294 | set_class(V, Class) :- 295 | get_lpn(V, Dict), 296 | set_lpn(V, Dict.put(class, Class)). 297 | 298 | elem_id(Elem, ID) :- % add an id if there is none? 299 | get_lpn(Elem, Dict), 300 | memberchk(id=ID, Dict.attributes). 301 | 302 | add_attr(V, Name, Value) :- 303 | get_lpn(V, Dict), 304 | set_lpn(V, Dict.put(attributes, [Name=Value|Dict.attributes])). 305 | 306 | %% id_source_highlights(+Vars) 307 | % 308 | % Identify source fragments that are highlights of previous 309 | % source fragments. Such fragments form a sub-list. 310 | 311 | id_source_highlights(Vars) :- 312 | source_highlights(Vars, -). 313 | 314 | source_highlights([], _). 315 | source_highlights([H|T], C) :- 316 | has_class(source, H), !, 317 | ( C == (-) 318 | -> source_highlights(T, H) 319 | ; highlight_of(H, C) 320 | -> add_class(H, highlight), 321 | source_highlights(T, C) 322 | ; source_highlights(T, H) 323 | ). 324 | source_highlights([_|T], C) :- 325 | source_highlights(T, C). 326 | 327 | %% highlight_of(+Highlight, +Source) 328 | % 329 | % True if Highlight is a consequtive sublist of Source. Note that 330 | % we must use a variant check for the sublist rather than plain 331 | % unification. 332 | 333 | highlight_of(H, S) :- 334 | get_lpn(H, HD), 335 | get_lpn(S, SD), 336 | sub_list(HD.terms, SD.terms), 337 | debug(lpn(highlight), '~w is highlight of ~w', [HD.text, SD.text]). 338 | 339 | sub_list(Sub, List) :- 340 | length(Sub, Len), 341 | length(Sub2, Len), 342 | append(Sub2, _, SubV), 343 | append(_, SubV, List), 344 | Sub =@= Sub2, !. 345 | 346 | %% id_queries(+Vars) is det. 347 | % 348 | % Classify source fragments that are in fact queries. This is the 349 | % case if they consists of only a single term and this term can be 350 | % executed in the context of preceeding (?) sources. 351 | 352 | id_queries(Vars) :- 353 | id_queries(Vars, []). 354 | 355 | id_queries([], _). 356 | id_queries([H|T], SL) :- 357 | ( has_class(source, H) 358 | -> true 359 | ; has_class(maybe_query, H) 360 | ), 361 | get_lpn(H, Dict), 362 | Dict.terms = [Query], 363 | xref_terms([?-Query], xref{called:Called}), 364 | can_run_in(Called, SL, _Used), !, 365 | make_query(H, Called), 366 | id_queries(T, SL). 367 | id_queries([H|T], SL) :- 368 | has_class(source, H), !, 369 | id_queries(T, [H|SL]). 370 | id_queries([H|T], SL) :- 371 | has_class(maybe_query, H), !, 372 | set_class(H, verbatim), 373 | bind(H), 374 | id_queries(T, [H|SL]). 375 | id_queries([_|T], SL) :- 376 | id_queries(T, SL). 377 | 378 | make_query(V, Called) :- 379 | get_lpn(V, Dict), 380 | debug(lpn(query), 'Source seems query: ~w', [Dict.text]), 381 | [Query] = Dict.terms, 382 | string_concat("?- ", Dict.text, Text0), 383 | ensure_fullstop(Text0, Text), 384 | Content = ["", element(span, [class='swish query guessed'], [Text])], 385 | set_lpn(V, Dict.put(_{content:Content, 386 | text:Text, 387 | class:query, 388 | terms:[?-Query], 389 | xref:xref{called:Called} 390 | })). 391 | 392 | ensure_fullstop(Text, Text) :- 393 | split_string(Text, "", " \t\n", [Trimmed]), 394 | sub_string(Trimmed, _, _, 0, "."), !. 395 | ensure_fullstop(Text0, Text) :- 396 | string_concat(Text0, ".", Text). 397 | 398 | %% can_run_in(+Called, +Sources, -UseSources) is semidet. 399 | % 400 | % True if Called can run with Sources, where UseSources is the 401 | % subset of Sources that is actually used. 402 | 403 | can_run_in(Called, Sources, Used) :- 404 | exclude(built_in, Called, Required), 405 | include(references(Required), Sources, Used), 406 | maplist(provides, Used, ProvidesSuper), 407 | append(ProvidesSuper, Provides), 408 | sort(Provides, ProvidesSet), 409 | ord_subset(Required, ProvidesSet). 410 | 411 | built_in(Name/Arity) :- 412 | functor(Head, Name, Arity), 413 | predicate_property(Head, built_in). 414 | 415 | references(Required, Source) :- 416 | provides(Source, Provides), 417 | ord_intersect(Required, Provides). 418 | 419 | provides(Source, Provides) :- 420 | get_lpn(Source, Dict), 421 | ( Defined = Dict.xref.get(defined) 422 | -> Provides = Defined 423 | ; Provides = [] 424 | ). 425 | 426 | %% id_variants(+Vars) 427 | % 428 | % Identify that one source fragment is the variant of another. We 429 | % want to test that the source fragments provide the same set of 430 | % predicates. That is basically Defined\Called, but the status of 431 | % recursive predicates is unclear. Possibly we should evaluate 432 | % that in the context of the queries? 433 | % 434 | % Found variants are indicated in two ways: 435 | % 436 | % - They get an HTML attribute 'data-variant-id' with a unique 437 | % id. 438 | % - The dict gets a key =variants=, which is a dict with keys 439 | % =before= and =after= 440 | 441 | id_variants(Vars) :- 442 | include(has_class(source), Vars, Sources), 443 | map_list_to_pairs(exports, Sources, ExportTagged), 444 | group_pairs_by_key(ExportTagged, ByExport), 445 | tag_variants(ByExport, 0). 446 | 447 | exports(Source, ExportPIs) :- 448 | get_lpn(Source, Dict), 449 | XREF = Dict.xref, 450 | ( exclude(built_in, XREF.get(called), Required) 451 | -> true 452 | ; Required = [] 453 | ), 454 | ( Defined = XREF.get(defined) 455 | -> true 456 | ; Defined = [] 457 | ), 458 | ord_intersection(Required, Defined, Recursive), 459 | ord_subtract(Defined, Required, NeededPIs), 460 | ord_union(Recursive, NeededPIs, ExportPIs). 461 | 462 | tag_variants([], _). 463 | tag_variants([_-[]|T], Id) :- !, 464 | tag_variants(T, Id). 465 | tag_variants([_-Group|T], Id0) :- 466 | succ(Id0, Id), 467 | atom_concat('group-', Id, GroupID), 468 | debug(lpn(variant), 'Variant group ~q: ~p', [GroupID, Group]), 469 | tag_variants(Group, [], GroupID), 470 | tag_variants(T, Id). 471 | 472 | tag_variants([], _, _). 473 | tag_variants([H|T], Before, ID) :- 474 | add_attr(H, 'data-variant-id', ID), 475 | put_lpn(H, variants, variants{before:Before,after:T}), 476 | tag_variants(T, [H|Before], ID). 477 | 478 | head_pi(Head, Head/0) :- 479 | atom(Head), !. 480 | head_pi(Head, Name/Arity) :- 481 | compound_name_arity(Head, Name, Arity). 482 | 483 | %% id_depends(+Vars) 484 | % 485 | % Find source dependencies. A source depends on another if it 486 | % requires predicates that are provided by another. 487 | % 488 | % note: I suspect Jan never got this working - Annie 489 | % 490 | 491 | id_depends(Vars) :- 492 | include(has_class(source), Vars, Sources), 493 | compound_name_arguments(Array, a, Sources), 494 | findall(dep(Depends,On,Preds), 495 | depends(Array, Depends, On, Preds), __Triples). 496 | 497 | depends(Array, Depends, On, Preds) :- 498 | arg(Depends, Array, VD), 499 | arg(On, Array, VO), 500 | On \== Depends, 501 | get_lpn(VD, DependsData), 502 | get_lpn(VO, OnData), 503 | ord_intersection(DependsData.xref.get(required), 504 | OnData.xref.get(defined), Preds), 505 | Preds \== []. 506 | 507 | 508 | %% pre_classify_source(+String, -Content, -Terms, -Class) is det. 509 | % 510 | % Pre classification of a source fragment. Class is one of 511 | % =source=, =query= or =verbatim=. Terms is a list of Prolog terms 512 | % found. 513 | 514 | pre_classify_source(C, [C], Terms, source) :- 515 | source_terms(C, Terms), 516 | Terms \= [?-_|_], 517 | xref_terms(Terms, XREF), 518 | \+ ( member(Defined, XREF.get(defined)), 519 | forbidden_defined(Defined) 520 | ), !. 521 | pre_classify_source(C, Queries, Terms, query) :- 522 | string_codes(C, Codes), 523 | phrase(queries(Queries, Terms), Codes), 524 | \+ (Queries = [S], string(S)), !. % did annotate something. 525 | pre_classify_source(C, [C], [Term], maybe_query) :- 526 | catch(term_string(Term, C), _, fail), 527 | \+ noquery(Term). 528 | pre_classify_source(C, [C], [], verbatim). 529 | 530 | forbidden_defined('/'/2). 531 | forbidden_defined('='/2). 532 | 533 | %% noquery(+Term) 534 | % 535 | % Term is not a sensible query. 536 | 537 | noquery(Var) :- var(Var), !. 538 | noquery([_|_]) :- !, fail. 539 | noquery(NotCallable) :- \+ callable(NotCallable), !, fail. 540 | noquery(X) :- answer_term(X), !. 541 | noquery(Name/Arity) :- atom(Name), integer(Arity). 542 | 543 | answer_term(Var) :- var(Var), !, fail. 544 | answer_term(Var = _Value) :- var(Var), !. 545 | answer_term((A;B)) :- answer_term(A), answer_term(B). 546 | 547 | 548 | queries([Lead, element(span, [class='swish query'], [Query])|More], 549 | [(?- Term)|Terms]) --> 550 | here(Start), string(_), here(SQ), 551 | "?-", whites, string(S), ".", here(EQ), peek_ws, 552 | { string_codes(QS, S), 553 | catch(term_string(Term, QS), _, fail), !, 554 | string_between(Start, SQ, Lead), 555 | string_between(SQ, EQ, Query) 556 | }, 557 | queries(More, Terms). 558 | queries([Rest], []) --> 559 | string(Codes), \+ [_], !, 560 | { string_codes(Rest, Codes) }. 561 | 562 | peek_ws, [C] --> [C], {ws(C)}, !. 563 | peek_ws --> \+ [_]. 564 | 565 | ws(0'\s). 566 | ws(0'\t). 567 | ws(0'\n). 568 | 569 | here(T,T,T). 570 | 571 | string_between(Start, End, String) :- 572 | diff_codes(Start, End, Codes), 573 | string_codes(String, Codes). 574 | 575 | diff_codes(Start, End, Empty) :- 576 | Start == End, !, 577 | Empty = []. 578 | diff_codes([H|T0], End, [H|T]) :- 579 | diff_codes(T0, End, T). 580 | 581 | 582 | %% source_terms(+Text, -Terms) is semidet. 583 | % 584 | % True when Terms is a list of terms represented in Text. Fails if 585 | % there are syntax errors. 586 | 587 | source_terms(Text, Terms) :- 588 | catch(setup_call_cleanup( 589 | open_codes_stream(Text, Stream), 590 | read_stream_to_terms(Stream, Terms), 591 | close(Stream)), 592 | error(syntax_error(_), _), 593 | fail). 594 | 595 | read_stream_to_terms(Stream, Terms) :- 596 | read(Stream, T0), 597 | read_stream_to_terms(T0, Stream, Terms). 598 | 599 | read_stream_to_terms(Term, _, []) :- 600 | Term == end_of_file, !. 601 | read_stream_to_terms(Term, Stream, [Term|Rest]) :- 602 | read(Stream, T0), 603 | read_stream_to_terms(T0, Stream, Rest). 604 | 605 | %% query_list(+ContentList) is semidet. 606 | % 607 | % True if ContentList is a
  • list which consist of mostly 608 | % query-like terms. 609 | 610 | query_list(ContentList) :- 611 | partition(query_element, ContentList, Queries, NonQueries), 612 | length(Queries, QLen), 613 | length(NonQueries, NQLen), 614 | QLen >= NQLen. 615 | 616 | query_element(Element) :- 617 | convert_source(Element, String), 618 | catch(term_string(Term, String), _, fail), 619 | \+ noquery(Term). 620 | 621 | 622 | /******************************* 623 | * XREF * 624 | *******************************/ 625 | 626 | %% xref_terms(+Terms, -XRef:dict) is det. 627 | % 628 | % Cross-reference a list of terms, returning a dict that contains: 629 | % 630 | % - defined:OrdSetOfPI 631 | % - called:OrdSetOfPI 632 | % - required:OrdSetOfPI 633 | % - error:SetOfErrorTerms 634 | % 635 | % Note that XRef.required is XRef.called \ built-in \XRef.defined. 636 | 637 | xref_terms(Terms, Result) :- 638 | phrase(xref_terms(Terms), Pairs), 639 | keysort(Pairs, Sorted), 640 | group_pairs_by_key(Sorted, Grouped), 641 | maplist(value_to_set, Grouped, GroupedSets), 642 | dict_pairs(Result0, xref, GroupedSets), 643 | ( exclude(built_in, Result0.get(called), Called), 644 | ord_subtract(Called, Result0.get(defined), Required), 645 | Required \== [] 646 | -> Result = Result0.put(required, Required) 647 | ; Result = Result0 648 | ). 649 | 650 | value_to_set(error-List, error-Set) :- !, 651 | variant_set(List, Set). 652 | value_to_set(Key-HeadList, Key-PISet) :- 653 | maplist(head_pi, HeadList, PIList), 654 | sort(PIList, PISet). 655 | 656 | variant_set(List, Set) :- 657 | list_to_set(List, Set1), 658 | remove_variants(Set1, Set). 659 | 660 | remove_variants([], []). 661 | remove_variants([H|T0], [H|T]) :- 662 | skip_variants(T0, H, T1), 663 | remove_variants(T1, T). 664 | 665 | skip_variants([H|T0], V, T) :- 666 | H =@= V, !, 667 | skip_variants(T0, V, T). 668 | skip_variants(L, _, L). 669 | 670 | 671 | xref_terms([]) --> []. 672 | xref_terms([H|T]) --> xref_term(H), xref_terms(T). 673 | 674 | xref_term(Var) --> 675 | { var(Var) }, !. 676 | xref_term((Head :- Body)) --> !, 677 | xref_head(Head), 678 | xref_body(Body). 679 | xref_term((Head --> Body)) --> !, 680 | xref_dcg_head(Head), 681 | xref_dcg_body(Body). 682 | xref_term((:- Body)) --> !, 683 | xref_body(Body). 684 | xref_term((?- Body)) --> !, 685 | xref_body(Body). 686 | xref_term(Head) --> 687 | xref_head(Head). 688 | 689 | xref_head(Term) --> { atom(Term) }, !, [defined-Term]. 690 | xref_head(Term) --> { compound(Term), !, generalize(Term,Gen) }, [defined-Gen]. 691 | xref_head(Term) --> [ error-type_error(callable, Term) ]. 692 | 693 | xref_body(Term) --> { var(Term) }, !. 694 | xref_body(Term) --> 695 | { predicate_property(user:Term, meta_predicate(Meta)), !, 696 | generalize(Term, Called), 697 | Term =.. [_|Args], 698 | Meta =.. [_|Specs] 699 | }, 700 | [ called-Called ], 701 | xref_meta(Specs, Args). 702 | xref_body(Term) --> { atom(Term) }, !, [called-Term]. 703 | xref_body(Term) --> { compound(Term), !, generalize(Term,Gen) }, [called-Gen]. 704 | xref_body(Term) --> [ error-type_error(callable, Term) ]. 705 | 706 | xref_meta([], []) --> []. 707 | xref_meta([S|ST], [A|AT]) --> 708 | xref_meta1(S, A), 709 | xref_meta(ST, AT). 710 | 711 | xref_meta1(0, A) --> !, 712 | xref_body(A). 713 | xref_meta1(^, A0) --> !, 714 | { strip_existential(A0, A) }, 715 | xref_body(A). 716 | xref_meta1(N, A0) --> 717 | { integer(N), N > 0, !, 718 | extend(A0, N, A) 719 | }, 720 | xref_body(A). 721 | xref_meta1(_, _) --> []. 722 | 723 | 724 | xref_dcg_head(Var) --> 725 | { var(Var) }, !, 726 | [ error-instantiation_error(Var) ]. 727 | xref_dcg_head((A,B)) --> 728 | { is_list(B) }, !, 729 | xref_dcg_head(A). 730 | xref_dcg_head(Term) --> 731 | { atom(Term), !, 732 | functor(Head, Term, 2) 733 | }, 734 | [ defined-Head ]. 735 | xref_dcg_head(Term) --> 736 | { compound(Term), !, 737 | compound_name_arity(Term, Name, Arity0), 738 | Arity is Arity0+2, 739 | compound_name_arity(Gen, Name, Arity) 740 | }, 741 | [ defined-Gen ]. 742 | xref_dcg_head(Term) --> 743 | [ error-type_error(callable, Term) ]. 744 | 745 | xref_dcg_body(Body) --> 746 | { var(Body) }, !. 747 | xref_dcg_body(Body) --> 748 | { dcg_control(Body, Called) }, !, 749 | xref_dcg_body_list(Called). 750 | xref_dcg_body(Terminal) --> 751 | { is_list(Terminal) ; string(Terminal) }, !. 752 | xref_dcg_body(Term) --> 753 | { atom(Term), !, 754 | functor(Head, Term, 2) 755 | }, 756 | [ called-Head ]. 757 | xref_dcg_body(Term) --> 758 | { compound(Term), !, 759 | compound_name_arity(Term, Name, Arity0), 760 | Arity is Arity0+2, 761 | compound_name_arity(Gen, Name, Arity) 762 | }, 763 | [ called-Gen ]. 764 | xref_dcg_body(Term) --> 765 | [ error-type_error(callable, Term) ]. 766 | 767 | dcg_control((A,B), [A,B]). 768 | dcg_control((A;B), [A,B]). 769 | dcg_control((A->B), [A,B]). 770 | dcg_control((A*->B), [A,B]). 771 | dcg_control(\+(A), [A]). 772 | 773 | xref_dcg_body_list([]) --> []. 774 | xref_dcg_body_list([H|T]) --> xref_dcg_body(H), xref_dcg_body_list(T). 775 | 776 | strip_existential(T0, T) :- 777 | ( var(T0) 778 | -> T = T0 779 | ; T0 = _^T1 780 | -> strip_existential(T1, T) 781 | ; T = T0 782 | ). 783 | 784 | extend(T0, N, T) :- 785 | atom(T0), !, 786 | length(Args, N), 787 | T =.. [T0|Args]. 788 | extend(T0, N, T) :- 789 | compound(T0), 790 | compound_name_arguments(T0, Name, Args0), 791 | length(Extra, N), 792 | append(Args0, Extra, Args), 793 | compound_name_arguments(T, Name, Args). 794 | 795 | generalize(Compound, Gen) :- 796 | compound_name_arity(Compound, Name, Arity), 797 | compound_name_arity(Gen, Name, Arity). 798 | 799 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM swipl 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | locales \ 5 | curl 6 | 7 | RUN sed -i -e 's/# en_GB.UTF-8 UTF-8/en_GB.UTF-8 UTF-8/' /etc/locale.gen && \ 8 | locale-gen 9 | ENV LC_ALL en_GB.UTF-8 10 | ENV LANG en_GB.UTF-8 11 | ENV LANGUAGE en_GB:en 12 | 13 | COPY --from=lpn . /lpn 14 | 15 | # Running 16 | 17 | copy health.sh health.sh 18 | HEALTHCHECK --interval=30s --timeout=2m --start-period=1m CMD /health.sh 19 | 20 | COPY start-lpn.sh start-lpn.sh 21 | 22 | ENTRYPOINT ["/start-lpn.sh"] 23 | -------------------------------------------------------------------------------- /docker/Makefile: -------------------------------------------------------------------------------- 1 | RESTART=--restart unless-stopped 2 | VOLUME=$(shell pwd)/data 3 | PORT=3060 4 | 5 | PUBLISH=--publish=${PORT}:3060 6 | DOPTS=${PUBLISH} 7 | IMG=lpn 8 | SRV=lpn 9 | 10 | all: 11 | @echo "Targets" 12 | @echo 13 | @echo "image Build the plweb image" 14 | @echo "install Run the image (detached)" 15 | @echo "run Run the image (interactive)" 16 | @echo "restart Stop and restart the image" 17 | 18 | image:: 19 | docker build --build-context lpn=.. -t $(IMG) . 20 | 21 | install: 22 | docker run --name=$(SRV) -d ${RESTART} ${DOPTS} $(IMG) 23 | 24 | run: 25 | docker run -it --rm ${DOPTS} $(IMG) 26 | 27 | stop: 28 | docker stop $(SRV) 29 | 30 | restart: 31 | -docker stop $(SRV) 32 | -docker rm $(SRV) 33 | make install 34 | 35 | bash: 36 | docker run -it ${DOPTS} $(IMG) --bash 37 | 38 | -------------------------------------------------------------------------------- /docker/health.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | exec &> health.log 3 | 4 | check() 5 | { auth= 6 | if [ -r health.auth ]; then 7 | auth="$(cat health.auth)" 8 | fi 9 | curl --fail -s --retry 3 --max-time 5 \ 10 | http://localhost:3060/health 11 | } 12 | 13 | stop() 14 | { pid=1 15 | echo "Health check failed. Killing swish with SIGTERM" 16 | kill -s TERM 1 $pid 17 | timeout 10 tail --pid=$pid -f /dev/null 18 | if [ $? == 124 ]; then 19 | echo "Gracefull termination failed. Trying QUIT" 20 | kill -s QUIT $pid 21 | timeout 10 tail --pid=$pid -f /dev/null 22 | if [ $? == 124 ]; then 23 | echo "QUIT failed. Trying KILL" 24 | kill -s KILL $pid 25 | fi 26 | fi 27 | echo "Done" 28 | } 29 | 30 | starting() 31 | { if [ -f /var/run/epoch ]; then 32 | epoch=$(cat /var/run/epoch) 33 | running=$(($(date "+%s") - $epoch)) 34 | [ $running -gt 60 ] || return 1 35 | fi 36 | echo "Starting, so not killing" 37 | return 0 38 | } 39 | 40 | check || starting || stop 41 | 42 | -------------------------------------------------------------------------------- /docker/start-lpn.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Start script for the PlWeb docker 4 | # 5 | # This script is started in /srv/cliopatria. 6 | 7 | start=--no-fork 8 | udaemon=daemon 9 | 10 | date "+%s" > /var/run/epoch 11 | 12 | if [ -t 0 ] ; then 13 | start=--interactive 14 | fi 15 | 16 | ## Make the server stop on signals sent from the health.sh. Process 17 | ## 1 only accepts signals for which there is an installed signal 18 | ## handler. We cannot install a signal handler for SIGKILL and 19 | ## therefore forcefully killing that even works in the case of 20 | ## deadlocks does not work. We run the server in another pid 21 | ## to work around this issue. 22 | 23 | stop() 24 | { echo "signal = $1; child = $child_pid" 25 | 26 | kill -s $1 $child_pid 27 | timeout 10 tail --pid=$child_pid -f /dev/null 28 | if [ $? == 124 ]; then 29 | echo "Gracefull termination failed. Killing" 30 | kill -s KILL $child_pid 31 | fi 32 | 33 | exit 1 34 | } 35 | 36 | hangup() 37 | { echo "child = $child_pid" 38 | kill -s HUP $child_pid 39 | } 40 | 41 | trap "stop TERM" SIGTERM 42 | trap "stop QUIT" SIGQUIT 43 | trap "hangup" SIGHUP 44 | 45 | cd /lpn 46 | mkdir -p log cache 47 | chown -R $udaemon log cache 48 | swipl lpn-daemon.pl --user=$udaemon --port=3060 $start & 49 | child_pid=$! 50 | 51 | stat=129 52 | while [ $stat = 129 ]; do 53 | wait -f $child_pid 54 | stat=$? 55 | done 56 | -------------------------------------------------------------------------------- /images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn-swish-proxy/f6fe70ccee6d03d1589135428865469a916e19c3/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /jquery-ui.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.11.2 - 2014-10-24 2 | * http://jqueryui.com 3 | * Includes: core.css, resizable.css, theme.css 4 | * To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Trebuchet%20MS%2CTahoma%2CVerdana%2CArial%2Csans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=f6a828&bgTextureHeader=gloss_wave&bgImgOpacityHeader=35&borderColorHeader=e78f08&fcHeader=ffffff&iconColorHeader=ffffff&bgColorContent=eeeeee&bgTextureContent=highlight_soft&bgImgOpacityContent=100&borderColorContent=dddddd&fcContent=333333&iconColorContent=222222&bgColorDefault=f6f6f6&bgTextureDefault=glass&bgImgOpacityDefault=100&borderColorDefault=cccccc&fcDefault=1c94c4&iconColorDefault=ef8c08&bgColorHover=fdf5ce&bgTextureHover=glass&bgImgOpacityHover=100&borderColorHover=fbcb09&fcHover=c77405&iconColorHover=ef8c08&bgColorActive=ffffff&bgTextureActive=glass&bgImgOpacityActive=65&borderColorActive=fbd850&fcActive=eb8f00&iconColorActive=ef8c08&bgColorHighlight=ffe45c&bgTextureHighlight=highlight_soft&bgImgOpacityHighlight=75&borderColorHighlight=fed22f&fcHighlight=363636&iconColorHighlight=228ef1&bgColorError=b81900&bgTextureError=diagonals_thick&bgImgOpacityError=18&borderColorError=cd0a0a&fcError=ffffff&iconColorError=ffd27a&bgColorOverlay=666666&bgTextureOverlay=diagonals_thick&bgImgOpacityOverlay=20&opacityOverlay=50&bgColorShadow=000000&bgTextureShadow=flat&bgImgOpacityShadow=10&opacityShadow=20&thicknessShadow=5px&offsetTopShadow=-5px&offsetLeftShadow=-5px&cornerRadiusShadow=5px 5 | * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */ 6 | 7 | .ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-clearfix{min-height:0}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:0.1px;display:block;-ms-touch-action:none;touch-action:none}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.ui-widget{font-family:Trebuchet MS,Tahoma,Verdana,Arial,sans-serif;font-size:1.1em}.ui-widget .ui-widget{font-size:1em}.ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button{font-family:Trebuchet MS,Tahoma,Verdana,Arial,sans-serif;font-size:1em}.ui-widget-content{border:1px solid #ddd;background:#eee url("images/ui-bg_highlight-soft_100_eeeeee_1x100.png") 50% top repeat-x;color:#333}.ui-widget-content a{color:#333}.ui-widget-header{border:1px solid #e78f08;background:#f6a828 url("images/ui-bg_gloss-wave_35_f6a828_500x100.png") 50% 50% repeat-x;color:#fff;font-weight:bold}.ui-widget-header a{color:#fff}.ui-state-default,.ui-widget-content .ui-state-default,.ui-widget-header .ui-state-default{border:1px solid #ccc;background:#f6f6f6 url("images/ui-bg_glass_100_f6f6f6_1x400.png") 50% 50% repeat-x;font-weight:bold;color:#1c94c4}.ui-state-default a,.ui-state-default a:link,.ui-state-default a:visited{color:#1c94c4;text-decoration:none}.ui-state-hover,.ui-widget-content .ui-state-hover,.ui-widget-header .ui-state-hover,.ui-state-focus,.ui-widget-content .ui-state-focus,.ui-widget-header .ui-state-focus{border:1px solid #fbcb09;background:#fdf5ce url("images/ui-bg_glass_100_fdf5ce_1x400.png") 50% 50% repeat-x;font-weight:bold;color:#c77405}.ui-state-hover a,.ui-state-hover a:hover,.ui-state-hover a:link,.ui-state-hover a:visited,.ui-state-focus a,.ui-state-focus a:hover,.ui-state-focus a:link,.ui-state-focus a:visited{color:#c77405;text-decoration:none}.ui-state-active,.ui-widget-content .ui-state-active,.ui-widget-header .ui-state-active{border:1px solid #fbd850;background:#fff url("images/ui-bg_glass_65_ffffff_1x400.png") 50% 50% repeat-x;font-weight:bold;color:#eb8f00}.ui-state-active a,.ui-state-active a:link,.ui-state-active a:visited{color:#eb8f00;text-decoration:none}.ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state-highlight{border:1px solid #fed22f;background:#ffe45c url("images/ui-bg_highlight-soft_75_ffe45c_1x100.png") 50% top repeat-x;color:#363636}.ui-state-highlight a,.ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a{color:#363636}.ui-state-error,.ui-widget-content .ui-state-error,.ui-widget-header .ui-state-error{border:1px solid #cd0a0a;background:#b81900 url("images/ui-bg_diagonals-thick_18_b81900_40x40.png") 50% 50% repeat;color:#fff}.ui-state-error a,.ui-widget-content .ui-state-error a,.ui-widget-header .ui-state-error a{color:#fff}.ui-state-error-text,.ui-widget-content .ui-state-error-text,.ui-widget-header .ui-state-error-text{color:#fff}.ui-priority-primary,.ui-widget-content .ui-priority-primary,.ui-widget-header .ui-priority-primary{font-weight:bold}.ui-priority-secondary,.ui-widget-content .ui-priority-secondary,.ui-widget-header .ui-priority-secondary{opacity:.7;filter:Alpha(Opacity=70);font-weight:normal}.ui-state-disabled,.ui-widget-content .ui-state-disabled,.ui-widget-header .ui-state-disabled{opacity:.35;filter:Alpha(Opacity=35);background-image:none}.ui-state-disabled .ui-icon{filter:Alpha(Opacity=35)}.ui-icon{width:16px;height:16px}.ui-icon,.ui-widget-content .ui-icon{background-image:url("images/ui-icons_222222_256x240.png")}.ui-widget-header .ui-icon{background-image:url("images/ui-icons_ffffff_256x240.png")}.ui-state-default .ui-icon{background-image:url("images/ui-icons_ef8c08_256x240.png")}.ui-state-hover .ui-icon,.ui-state-focus .ui-icon{background-image:url("images/ui-icons_ef8c08_256x240.png")}.ui-state-active .ui-icon{background-image:url("images/ui-icons_ef8c08_256x240.png")}.ui-state-highlight .ui-icon{background-image:url("images/ui-icons_228ef1_256x240.png")}.ui-state-error .ui-icon,.ui-state-error-text .ui-icon{background-image:url("images/ui-icons_ffd27a_256x240.png")}.ui-icon-blank{background-position:16px 16px}.ui-icon-carat-1-n{background-position:0 0}.ui-icon-carat-1-ne{background-position:-16px 0}.ui-icon-carat-1-e{background-position:-32px 0}.ui-icon-carat-1-se{background-position:-48px 0}.ui-icon-carat-1-s{background-position:-64px 0}.ui-icon-carat-1-sw{background-position:-80px 0}.ui-icon-carat-1-w{background-position:-96px 0}.ui-icon-carat-1-nw{background-position:-112px 0}.ui-icon-carat-2-n-s{background-position:-128px 0}.ui-icon-carat-2-e-w{background-position:-144px 0}.ui-icon-triangle-1-n{background-position:0 -16px}.ui-icon-triangle-1-ne{background-position:-16px -16px}.ui-icon-triangle-1-e{background-position:-32px -16px}.ui-icon-triangle-1-se{background-position:-48px -16px}.ui-icon-triangle-1-s{background-position:-64px -16px}.ui-icon-triangle-1-sw{background-position:-80px -16px}.ui-icon-triangle-1-w{background-position:-96px -16px}.ui-icon-triangle-1-nw{background-position:-112px -16px}.ui-icon-triangle-2-n-s{background-position:-128px -16px}.ui-icon-triangle-2-e-w{background-position:-144px -16px}.ui-icon-arrow-1-n{background-position:0 -32px}.ui-icon-arrow-1-ne{background-position:-16px -32px}.ui-icon-arrow-1-e{background-position:-32px -32px}.ui-icon-arrow-1-se{background-position:-48px -32px}.ui-icon-arrow-1-s{background-position:-64px -32px}.ui-icon-arrow-1-sw{background-position:-80px -32px}.ui-icon-arrow-1-w{background-position:-96px -32px}.ui-icon-arrow-1-nw{background-position:-112px -32px}.ui-icon-arrow-2-n-s{background-position:-128px -32px}.ui-icon-arrow-2-ne-sw{background-position:-144px -32px}.ui-icon-arrow-2-e-w{background-position:-160px -32px}.ui-icon-arrow-2-se-nw{background-position:-176px -32px}.ui-icon-arrowstop-1-n{background-position:-192px -32px}.ui-icon-arrowstop-1-e{background-position:-208px -32px}.ui-icon-arrowstop-1-s{background-position:-224px -32px}.ui-icon-arrowstop-1-w{background-position:-240px -32px}.ui-icon-arrowthick-1-n{background-position:0 -48px}.ui-icon-arrowthick-1-ne{background-position:-16px -48px}.ui-icon-arrowthick-1-e{background-position:-32px -48px}.ui-icon-arrowthick-1-se{background-position:-48px -48px}.ui-icon-arrowthick-1-s{background-position:-64px -48px}.ui-icon-arrowthick-1-sw{background-position:-80px -48px}.ui-icon-arrowthick-1-w{background-position:-96px -48px}.ui-icon-arrowthick-1-nw{background-position:-112px -48px}.ui-icon-arrowthick-2-n-s{background-position:-128px -48px}.ui-icon-arrowthick-2-ne-sw{background-position:-144px -48px}.ui-icon-arrowthick-2-e-w{background-position:-160px -48px}.ui-icon-arrowthick-2-se-nw{background-position:-176px -48px}.ui-icon-arrowthickstop-1-n{background-position:-192px -48px}.ui-icon-arrowthickstop-1-e{background-position:-208px -48px}.ui-icon-arrowthickstop-1-s{background-position:-224px -48px}.ui-icon-arrowthickstop-1-w{background-position:-240px -48px}.ui-icon-arrowreturnthick-1-w{background-position:0 -64px}.ui-icon-arrowreturnthick-1-n{background-position:-16px -64px}.ui-icon-arrowreturnthick-1-e{background-position:-32px -64px}.ui-icon-arrowreturnthick-1-s{background-position:-48px -64px}.ui-icon-arrowreturn-1-w{background-position:-64px -64px}.ui-icon-arrowreturn-1-n{background-position:-80px -64px}.ui-icon-arrowreturn-1-e{background-position:-96px -64px}.ui-icon-arrowreturn-1-s{background-position:-112px -64px}.ui-icon-arrowrefresh-1-w{background-position:-128px -64px}.ui-icon-arrowrefresh-1-n{background-position:-144px -64px}.ui-icon-arrowrefresh-1-e{background-position:-160px -64px}.ui-icon-arrowrefresh-1-s{background-position:-176px -64px}.ui-icon-arrow-4{background-position:0 -80px}.ui-icon-arrow-4-diag{background-position:-16px -80px}.ui-icon-extlink{background-position:-32px -80px}.ui-icon-newwin{background-position:-48px -80px}.ui-icon-refresh{background-position:-64px -80px}.ui-icon-shuffle{background-position:-80px -80px}.ui-icon-transfer-e-w{background-position:-96px -80px}.ui-icon-transferthick-e-w{background-position:-112px -80px}.ui-icon-folder-collapsed{background-position:0 -96px}.ui-icon-folder-open{background-position:-16px -96px}.ui-icon-document{background-position:-32px -96px}.ui-icon-document-b{background-position:-48px -96px}.ui-icon-note{background-position:-64px -96px}.ui-icon-mail-closed{background-position:-80px -96px}.ui-icon-mail-open{background-position:-96px -96px}.ui-icon-suitcase{background-position:-112px -96px}.ui-icon-comment{background-position:-128px -96px}.ui-icon-person{background-position:-144px -96px}.ui-icon-print{background-position:-160px -96px}.ui-icon-trash{background-position:-176px -96px}.ui-icon-locked{background-position:-192px -96px}.ui-icon-unlocked{background-position:-208px -96px}.ui-icon-bookmark{background-position:-224px -96px}.ui-icon-tag{background-position:-240px -96px}.ui-icon-home{background-position:0 -112px}.ui-icon-flag{background-position:-16px -112px}.ui-icon-calendar{background-position:-32px -112px}.ui-icon-cart{background-position:-48px -112px}.ui-icon-pencil{background-position:-64px -112px}.ui-icon-clock{background-position:-80px -112px}.ui-icon-disk{background-position:-96px -112px}.ui-icon-calculator{background-position:-112px -112px}.ui-icon-zoomin{background-position:-128px -112px}.ui-icon-zoomout{background-position:-144px -112px}.ui-icon-search{background-position:-160px -112px}.ui-icon-wrench{background-position:-176px -112px}.ui-icon-gear{background-position:-192px -112px}.ui-icon-heart{background-position:-208px -112px}.ui-icon-star{background-position:-224px -112px}.ui-icon-link{background-position:-240px -112px}.ui-icon-cancel{background-position:0 -128px}.ui-icon-plus{background-position:-16px -128px}.ui-icon-plusthick{background-position:-32px -128px}.ui-icon-minus{background-position:-48px -128px}.ui-icon-minusthick{background-position:-64px -128px}.ui-icon-close{background-position:-80px -128px}.ui-icon-closethick{background-position:-96px -128px}.ui-icon-key{background-position:-112px -128px}.ui-icon-lightbulb{background-position:-128px -128px}.ui-icon-scissors{background-position:-144px -128px}.ui-icon-clipboard{background-position:-160px -128px}.ui-icon-copy{background-position:-176px -128px}.ui-icon-contact{background-position:-192px -128px}.ui-icon-image{background-position:-208px -128px}.ui-icon-video{background-position:-224px -128px}.ui-icon-script{background-position:-240px -128px}.ui-icon-alert{background-position:0 -144px}.ui-icon-info{background-position:-16px -144px}.ui-icon-notice{background-position:-32px -144px}.ui-icon-help{background-position:-48px -144px}.ui-icon-check{background-position:-64px -144px}.ui-icon-bullet{background-position:-80px -144px}.ui-icon-radio-on{background-position:-96px -144px}.ui-icon-radio-off{background-position:-112px -144px}.ui-icon-pin-w{background-position:-128px -144px}.ui-icon-pin-s{background-position:-144px -144px}.ui-icon-play{background-position:0 -160px}.ui-icon-pause{background-position:-16px -160px}.ui-icon-seek-next{background-position:-32px -160px}.ui-icon-seek-prev{background-position:-48px -160px}.ui-icon-seek-end{background-position:-64px -160px}.ui-icon-seek-start{background-position:-80px -160px}.ui-icon-seek-first{background-position:-80px -160px}.ui-icon-stop{background-position:-96px -160px}.ui-icon-eject{background-position:-112px -160px}.ui-icon-volume-off{background-position:-128px -160px}.ui-icon-volume-on{background-position:-144px -160px}.ui-icon-power{background-position:0 -176px}.ui-icon-signal-diag{background-position:-16px -176px}.ui-icon-signal{background-position:-32px -176px}.ui-icon-battery-0{background-position:-48px -176px}.ui-icon-battery-1{background-position:-64px -176px}.ui-icon-battery-2{background-position:-80px -176px}.ui-icon-battery-3{background-position:-96px -176px}.ui-icon-circle-plus{background-position:0 -192px}.ui-icon-circle-minus{background-position:-16px -192px}.ui-icon-circle-close{background-position:-32px -192px}.ui-icon-circle-triangle-e{background-position:-48px -192px}.ui-icon-circle-triangle-s{background-position:-64px -192px}.ui-icon-circle-triangle-w{background-position:-80px -192px}.ui-icon-circle-triangle-n{background-position:-96px -192px}.ui-icon-circle-arrow-e{background-position:-112px -192px}.ui-icon-circle-arrow-s{background-position:-128px -192px}.ui-icon-circle-arrow-w{background-position:-144px -192px}.ui-icon-circle-arrow-n{background-position:-160px -192px}.ui-icon-circle-zoomin{background-position:-176px -192px}.ui-icon-circle-zoomout{background-position:-192px -192px}.ui-icon-circle-check{background-position:-208px -192px}.ui-icon-circlesmall-plus{background-position:0 -208px}.ui-icon-circlesmall-minus{background-position:-16px -208px}.ui-icon-circlesmall-close{background-position:-32px -208px}.ui-icon-squaresmall-plus{background-position:-48px -208px}.ui-icon-squaresmall-minus{background-position:-64px -208px}.ui-icon-squaresmall-close{background-position:-80px -208px}.ui-icon-grip-dotted-vertical{background-position:0 -224px}.ui-icon-grip-dotted-horizontal{background-position:-16px -224px}.ui-icon-grip-solid-vertical{background-position:-32px -224px}.ui-icon-grip-solid-horizontal{background-position:-48px -224px}.ui-icon-gripsmall-diagonal-se{background-position:-64px -224px}.ui-icon-grip-diagonal-se{background-position:-80px -224px}.ui-corner-all,.ui-corner-top,.ui-corner-left,.ui-corner-tl{border-top-left-radius:4px}.ui-corner-all,.ui-corner-top,.ui-corner-right,.ui-corner-tr{border-top-right-radius:4px}.ui-corner-all,.ui-corner-bottom,.ui-corner-left,.ui-corner-bl{border-bottom-left-radius:4px}.ui-corner-all,.ui-corner-bottom,.ui-corner-right,.ui-corner-br{border-bottom-right-radius:4px}.ui-widget-overlay{background:#666 url("images/ui-bg_diagonals-thick_20_666666_40x40.png") 50% 50% repeat;opacity:.5;filter:Alpha(Opacity=50)}.ui-widget-shadow{margin:-5px 0 0 -5px;padding:5px;background:#000 url("images/ui-bg_flat_10_000000_40x100.png") 50% 50% repeat-x;opacity:.2;filter:Alpha(Opacity=20);border-radius:5px} -------------------------------------------------------------------------------- /jquery-ui.min.js: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.11.2 - 2014-10-24 2 | * http://jqueryui.com 3 | * Includes: core.js, widget.js, mouse.js, resizable.js 4 | * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */ 5 | 6 | (function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e(jQuery)})(function(e){function t(t,s){var n,a,o,r=t.nodeName.toLowerCase();return"area"===r?(n=t.parentNode,a=n.name,t.href&&a&&"map"===n.nodeName.toLowerCase()?(o=e("img[usemap='#"+a+"']")[0],!!o&&i(o)):!1):(/input|select|textarea|button|object/.test(r)?!t.disabled:"a"===r?t.href||s:s)&&i(t)}function i(t){return e.expr.filters.visible(t)&&!e(t).parents().addBack().filter(function(){return"hidden"===e.css(this,"visibility")}).length}e.ui=e.ui||{},e.extend(e.ui,{version:"1.11.2",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),e.fn.extend({scrollParent:function(t){var i=this.css("position"),s="absolute"===i,n=t?/(auto|scroll|hidden)/:/(auto|scroll)/,a=this.parents().filter(function(){var t=e(this);return s&&"static"===t.css("position")?!1:n.test(t.css("overflow")+t.css("overflow-y")+t.css("overflow-x"))}).eq(0);return"fixed"!==i&&a.length?a:e(this[0].ownerDocument||document)},uniqueId:function(){var e=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++e)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&e(this).removeAttr("id")})}}),e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(i){return!!e.data(i,t)}}):function(t,i,s){return!!e.data(t,s[3])},focusable:function(i){return t(i,!isNaN(e.attr(i,"tabindex")))},tabbable:function(i){var s=e.attr(i,"tabindex"),n=isNaN(s);return(n||s>=0)&&t(i,!n)}}),e("").outerWidth(1).jquery||e.each(["Width","Height"],function(t,i){function s(t,i,s,a){return e.each(n,function(){i-=parseFloat(e.css(t,"padding"+this))||0,s&&(i-=parseFloat(e.css(t,"border"+this+"Width"))||0),a&&(i-=parseFloat(e.css(t,"margin"+this))||0)}),i}var n="Width"===i?["Left","Right"]:["Top","Bottom"],a=i.toLowerCase(),o={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+i]=function(t){return void 0===t?o["inner"+i].call(this):this.each(function(){e(this).css(a,s(this,t)+"px")})},e.fn["outer"+i]=function(t,n){return"number"!=typeof t?o["outer"+i].call(this,t):this.each(function(){e(this).css(a,s(this,t,!0,n)+"px")})}}),e.fn.addBack||(e.fn.addBack=function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}),e("").data("a-b","a").removeData("a-b").data("a-b")&&(e.fn.removeData=function(t){return function(i){return arguments.length?t.call(this,e.camelCase(i)):t.call(this)}}(e.fn.removeData)),e.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),e.fn.extend({focus:function(t){return function(i,s){return"number"==typeof i?this.each(function(){var t=this;setTimeout(function(){e(t).focus(),s&&s.call(t)},i)}):t.apply(this,arguments)}}(e.fn.focus),disableSelection:function(){var e="onselectstart"in document.createElement("div")?"selectstart":"mousedown";return function(){return this.bind(e+".ui-disableSelection",function(e){e.preventDefault()})}}(),enableSelection:function(){return this.unbind(".ui-disableSelection")},zIndex:function(t){if(void 0!==t)return this.css("zIndex",t);if(this.length)for(var i,s,n=e(this[0]);n.length&&n[0]!==document;){if(i=n.css("position"),("absolute"===i||"relative"===i||"fixed"===i)&&(s=parseInt(n.css("zIndex"),10),!isNaN(s)&&0!==s))return s;n=n.parent()}return 0}}),e.ui.plugin={add:function(t,i,s){var n,a=e.ui[t].prototype;for(n in s)a.plugins[n]=a.plugins[n]||[],a.plugins[n].push([i,s[n]])},call:function(e,t,i,s){var n,a=e.plugins[t];if(a&&(s||e.element[0].parentNode&&11!==e.element[0].parentNode.nodeType))for(n=0;a.length>n;n++)e.options[a[n][0]]&&a[n][1].apply(e.element,i)}};var s=0,n=Array.prototype.slice;e.cleanData=function(t){return function(i){var s,n,a;for(a=0;null!=(n=i[a]);a++)try{s=e._data(n,"events"),s&&s.remove&&e(n).triggerHandler("remove")}catch(o){}t(i)}}(e.cleanData),e.widget=function(t,i,s){var n,a,o,r,h={},l=t.split(".")[0];return t=t.split(".")[1],n=l+"-"+t,s||(s=i,i=e.Widget),e.expr[":"][n.toLowerCase()]=function(t){return!!e.data(t,n)},e[l]=e[l]||{},a=e[l][t],o=e[l][t]=function(e,t){return this._createWidget?(arguments.length&&this._createWidget(e,t),void 0):new o(e,t)},e.extend(o,a,{version:s.version,_proto:e.extend({},s),_childConstructors:[]}),r=new i,r.options=e.widget.extend({},r.options),e.each(s,function(t,s){return e.isFunction(s)?(h[t]=function(){var e=function(){return i.prototype[t].apply(this,arguments)},n=function(e){return i.prototype[t].apply(this,e)};return function(){var t,i=this._super,a=this._superApply;return this._super=e,this._superApply=n,t=s.apply(this,arguments),this._super=i,this._superApply=a,t}}(),void 0):(h[t]=s,void 0)}),o.prototype=e.widget.extend(r,{widgetEventPrefix:a?r.widgetEventPrefix||t:t},h,{constructor:o,namespace:l,widgetName:t,widgetFullName:n}),a?(e.each(a._childConstructors,function(t,i){var s=i.prototype;e.widget(s.namespace+"."+s.widgetName,o,i._proto)}),delete a._childConstructors):i._childConstructors.push(o),e.widget.bridge(t,o),o},e.widget.extend=function(t){for(var i,s,a=n.call(arguments,1),o=0,r=a.length;r>o;o++)for(i in a[o])s=a[o][i],a[o].hasOwnProperty(i)&&void 0!==s&&(t[i]=e.isPlainObject(s)?e.isPlainObject(t[i])?e.widget.extend({},t[i],s):e.widget.extend({},s):s);return t},e.widget.bridge=function(t,i){var s=i.prototype.widgetFullName||t;e.fn[t]=function(a){var o="string"==typeof a,r=n.call(arguments,1),h=this;return a=!o&&r.length?e.widget.extend.apply(null,[a].concat(r)):a,o?this.each(function(){var i,n=e.data(this,s);return"instance"===a?(h=n,!1):n?e.isFunction(n[a])&&"_"!==a.charAt(0)?(i=n[a].apply(n,r),i!==n&&void 0!==i?(h=i&&i.jquery?h.pushStack(i.get()):i,!1):void 0):e.error("no such method '"+a+"' for "+t+" widget instance"):e.error("cannot call methods on "+t+" prior to initialization; "+"attempted to call method '"+a+"'")}):this.each(function(){var t=e.data(this,s);t?(t.option(a||{}),t._init&&t._init()):e.data(this,s,new i(a,this))}),h}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
    ",options:{disabled:!1,create:null},_createWidget:function(t,i){i=e(i||this.defaultElement||this)[0],this.element=e(i),this.uuid=s++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=e(),this.hoverable=e(),this.focusable=e(),i!==this&&(e.data(i,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===i&&this.destroy()}}),this.document=e(i.style?i.ownerDocument:i.document||i),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(t,i){var s,n,a,o=t;if(0===arguments.length)return e.widget.extend({},this.options);if("string"==typeof t)if(o={},s=t.split("."),t=s.shift(),s.length){for(n=o[t]=e.widget.extend({},this.options[t]),a=0;s.length-1>a;a++)n[s[a]]=n[s[a]]||{},n=n[s[a]];if(t=s.pop(),1===arguments.length)return void 0===n[t]?null:n[t];n[t]=i}else{if(1===arguments.length)return void 0===this.options[t]?null:this.options[t];o[t]=i}return this._setOptions(o),this},_setOptions:function(e){var t;for(t in e)this._setOption(t,e[t]);return this},_setOption:function(e,t){return this.options[e]=t,"disabled"===e&&(this.widget().toggleClass(this.widgetFullName+"-disabled",!!t),t&&(this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus"))),this},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_on:function(t,i,s){var n,a=this;"boolean"!=typeof t&&(s=i,i=t,t=!1),s?(i=n=e(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),e.each(s,function(s,o){function r(){return t||a.options.disabled!==!0&&!e(this).hasClass("ui-state-disabled")?("string"==typeof o?a[o]:o).apply(a,arguments):void 0}"string"!=typeof o&&(r.guid=o.guid=o.guid||r.guid||e.guid++);var h=s.match(/^([\w:-]*)\s*(.*)$/),l=h[1]+a.eventNamespace,u=h[2];u?n.delegate(u,l,r):i.bind(l,r)})},_off:function(t,i){i=(i||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,t.unbind(i).undelegate(i),this.bindings=e(this.bindings.not(t).get()),this.focusable=e(this.focusable.not(t).get()),this.hoverable=e(this.hoverable.not(t).get())},_delay:function(e,t){function i(){return("string"==typeof e?s[e]:e).apply(s,arguments)}var s=this;return setTimeout(i,t||0)},_hoverable:function(t){this.hoverable=this.hoverable.add(t),this._on(t,{mouseenter:function(t){e(t.currentTarget).addClass("ui-state-hover")},mouseleave:function(t){e(t.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(t){this.focusable=this.focusable.add(t),this._on(t,{focusin:function(t){e(t.currentTarget).addClass("ui-state-focus")},focusout:function(t){e(t.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(t,i,s){var n,a,o=this.options[t];if(s=s||{},i=e.Event(i),i.type=(t===this.widgetEventPrefix?t:this.widgetEventPrefix+t).toLowerCase(),i.target=this.element[0],a=i.originalEvent)for(n in a)n in i||(i[n]=a[n]);return this.element.trigger(i,s),!(e.isFunction(o)&&o.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},e.each({show:"fadeIn",hide:"fadeOut"},function(t,i){e.Widget.prototype["_"+t]=function(s,n,a){"string"==typeof n&&(n={effect:n});var o,r=n?n===!0||"number"==typeof n?i:n.effect||i:t;n=n||{},"number"==typeof n&&(n={duration:n}),o=!e.isEmptyObject(n),n.complete=a,n.delay&&s.delay(n.delay),o&&e.effects&&e.effects.effect[r]?s[t](n):r!==t&&s[r]?s[r](n.duration,n.easing,a):s.queue(function(i){e(this)[t](),a&&a.call(s[0]),i()})}}),e.widget;var a=!1;e(document).mouseup(function(){a=!1}),e.widget("ui.mouse",{version:"1.11.2",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var t=this;this.element.bind("mousedown."+this.widgetName,function(e){return t._mouseDown(e)}).bind("click."+this.widgetName,function(i){return!0===e.data(i.target,t.widgetName+".preventClickEvent")?(e.removeData(i.target,t.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&this.document.unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(t){if(!a){this._mouseMoved=!1,this._mouseStarted&&this._mouseUp(t),this._mouseDownEvent=t;var i=this,s=1===t.which,n="string"==typeof this.options.cancel&&t.target.nodeName?e(t.target).closest(this.options.cancel).length:!1;return s&&!n&&this._mouseCapture(t)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){i.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(t)!==!1,!this._mouseStarted)?(t.preventDefault(),!0):(!0===e.data(t.target,this.widgetName+".preventClickEvent")&&e.removeData(t.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(e){return i._mouseMove(e)},this._mouseUpDelegate=function(e){return i._mouseUp(e)},this.document.bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),t.preventDefault(),a=!0,!0)):!0}},_mouseMove:function(t){if(this._mouseMoved){if(e.ui.ie&&(!document.documentMode||9>document.documentMode)&&!t.button)return this._mouseUp(t);if(!t.which)return this._mouseUp(t)}return(t.which||t.button)&&(this._mouseMoved=!0),this._mouseStarted?(this._mouseDrag(t),t.preventDefault()):(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,t)!==!1,this._mouseStarted?this._mouseDrag(t):this._mouseUp(t)),!this._mouseStarted)},_mouseUp:function(t){return this.document.unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,t.target===this._mouseDownEvent.target&&e.data(t.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(t)),a=!1,!1},_mouseDistanceMet:function(e){return Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),e.widget("ui.resizable",e.ui.mouse,{version:"1.11.2",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_num:function(e){return parseInt(e,10)||0},_isNumber:function(e){return!isNaN(parseInt(e,10))},_hasScroll:function(t,i){if("hidden"===e(t).css("overflow"))return!1;var s=i&&"left"===i?"scrollLeft":"scrollTop",n=!1;return t[s]>0?!0:(t[s]=1,n=t[s]>0,t[s]=0,n)},_create:function(){var t,i,s,n,a,o=this,r=this.options;if(this.element.addClass("ui-resizable"),e.extend(this,{_aspectRatio:!!r.aspectRatio,aspectRatio:r.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:r.helper||r.ghost||r.animate?r.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)&&(this.element.wrap(e("
    ").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.resizable("instance")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize()),this.handles=r.handles||(e(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),t=this.handles.split(","),this.handles={},i=0;t.length>i;i++)s=e.trim(t[i]),a="ui-resizable-"+s,n=e("
    "),n.css({zIndex:r.zIndex}),"se"===s&&n.addClass("ui-icon ui-icon-gripsmall-diagonal-se"),this.handles[s]=".ui-resizable-"+s,this.element.append(n);this._renderAxis=function(t){var i,s,n,a;t=t||this.element;for(i in this.handles)this.handles[i].constructor===String&&(this.handles[i]=this.element.children(this.handles[i]).first().show()),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)&&(s=e(this.handles[i],this.element),a=/sw|ne|nw|se|n|s/.test(i)?s.outerHeight():s.outerWidth(),n=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join(""),t.css(n,a),this._proportionallyResize()),e(this.handles[i]).length},this._renderAxis(this.element),this._handles=e(".ui-resizable-handle",this.element).disableSelection(),this._handles.mouseover(function(){o.resizing||(this.className&&(n=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),o.axis=n&&n[1]?n[1]:"se")}),r.autoHide&&(this._handles.hide(),e(this.element).addClass("ui-resizable-autohide").mouseenter(function(){r.disabled||(e(this).removeClass("ui-resizable-autohide"),o._handles.show())}).mouseleave(function(){r.disabled||o.resizing||(e(this).addClass("ui-resizable-autohide"),o._handles.hide())})),this._mouseInit()},_destroy:function(){this._mouseDestroy();var t,i=function(t){e(t).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(i(this.element),t=this.element,this.originalElement.css({position:t.css("position"),width:t.outerWidth(),height:t.outerHeight(),top:t.css("top"),left:t.css("left")}).insertAfter(t),t.remove()),this.originalElement.css("resize",this.originalResizeStyle),i(this.originalElement),this},_mouseCapture:function(t){var i,s,n=!1;for(i in this.handles)s=e(this.handles[i])[0],(s===t.target||e.contains(s,t.target))&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(t){var i,s,n,a=this.options,o=this.element;return this.resizing=!0,this._renderProxy(),i=this._num(this.helper.css("left")),s=this._num(this.helper.css("top")),a.containment&&(i+=e(a.containment).scrollLeft()||0,s+=e(a.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:i,top:s},this.size=this._helper?{width:this.helper.width(),height:this.helper.height()}:{width:o.width(),height:o.height()},this.originalSize=this._helper?{width:o.outerWidth(),height:o.outerHeight()}:{width:o.width(),height:o.height()},this.sizeDiff={width:o.outerWidth()-o.width(),height:o.outerHeight()-o.height()},this.originalPosition={left:i,top:s},this.originalMousePosition={left:t.pageX,top:t.pageY},this.aspectRatio="number"==typeof a.aspectRatio?a.aspectRatio:this.originalSize.width/this.originalSize.height||1,n=e(".ui-resizable-"+this.axis).css("cursor"),e("body").css("cursor","auto"===n?this.axis+"-resize":n),o.addClass("ui-resizable-resizing"),this._propagate("start",t),!0},_mouseDrag:function(t){var i,s,n=this.originalMousePosition,a=this.axis,o=t.pageX-n.left||0,r=t.pageY-n.top||0,h=this._change[a];return this._updatePrevProperties(),h?(i=h.apply(this,[t,o,r]),this._updateVirtualBoundaries(t.shiftKey),(this._aspectRatio||t.shiftKey)&&(i=this._updateRatio(i,t)),i=this._respectSize(i,t),this._updateCache(i),this._propagate("resize",t),s=this._applyChanges(),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),e.isEmptyObject(s)||(this._updatePrevProperties(),this._trigger("resize",t,this.ui()),this._applyChanges()),!1):!1},_mouseStop:function(t){this.resizing=!1;var i,s,n,a,o,r,h,l=this.options,u=this;return this._helper&&(i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),n=s&&this._hasScroll(i[0],"left")?0:u.sizeDiff.height,a=s?0:u.sizeDiff.width,o={width:u.helper.width()-a,height:u.helper.height()-n},r=parseInt(u.element.css("left"),10)+(u.position.left-u.originalPosition.left)||null,h=parseInt(u.element.css("top"),10)+(u.position.top-u.originalPosition.top)||null,l.animate||this.element.css(e.extend(o,{top:h,left:r})),u.helper.height(u.size.height),u.helper.width(u.size.width),this._helper&&!l.animate&&this._proportionallyResize()),e("body").css("cursor","auto"),this.element.removeClass("ui-resizable-resizing"),this._propagate("stop",t),this._helper&&this.helper.remove(),!1},_updatePrevProperties:function(){this.prevPosition={top:this.position.top,left:this.position.left},this.prevSize={width:this.size.width,height:this.size.height}},_applyChanges:function(){var e={};return this.position.top!==this.prevPosition.top&&(e.top=this.position.top+"px"),this.position.left!==this.prevPosition.left&&(e.left=this.position.left+"px"),this.size.width!==this.prevSize.width&&(e.width=this.size.width+"px"),this.size.height!==this.prevSize.height&&(e.height=this.size.height+"px"),this.helper.css(e),e},_updateVirtualBoundaries:function(e){var t,i,s,n,a,o=this.options;a={minWidth:this._isNumber(o.minWidth)?o.minWidth:0,maxWidth:this._isNumber(o.maxWidth)?o.maxWidth:1/0,minHeight:this._isNumber(o.minHeight)?o.minHeight:0,maxHeight:this._isNumber(o.maxHeight)?o.maxHeight:1/0},(this._aspectRatio||e)&&(t=a.minHeight*this.aspectRatio,s=a.minWidth/this.aspectRatio,i=a.maxHeight*this.aspectRatio,n=a.maxWidth/this.aspectRatio,t>a.minWidth&&(a.minWidth=t),s>a.minHeight&&(a.minHeight=s),a.maxWidth>i&&(a.maxWidth=i),a.maxHeight>n&&(a.maxHeight=n)),this._vBoundaries=a},_updateCache:function(e){this.offset=this.helper.offset(),this._isNumber(e.left)&&(this.position.left=e.left),this._isNumber(e.top)&&(this.position.top=e.top),this._isNumber(e.height)&&(this.size.height=e.height),this._isNumber(e.width)&&(this.size.width=e.width)},_updateRatio:function(e){var t=this.position,i=this.size,s=this.axis;return this._isNumber(e.height)?e.width=e.height*this.aspectRatio:this._isNumber(e.width)&&(e.height=e.width/this.aspectRatio),"sw"===s&&(e.left=t.left+(i.width-e.width),e.top=null),"nw"===s&&(e.top=t.top+(i.height-e.height),e.left=t.left+(i.width-e.width)),e},_respectSize:function(e){var t=this._vBoundaries,i=this.axis,s=this._isNumber(e.width)&&t.maxWidth&&t.maxWidthe.width,o=this._isNumber(e.height)&&t.minHeight&&t.minHeight>e.height,r=this.originalPosition.left+this.originalSize.width,h=this.position.top+this.size.height,l=/sw|nw|w/.test(i),u=/nw|ne|n/.test(i);return a&&(e.width=t.minWidth),o&&(e.height=t.minHeight),s&&(e.width=t.maxWidth),n&&(e.height=t.maxHeight),a&&l&&(e.left=r-t.minWidth),s&&l&&(e.left=r-t.maxWidth),o&&u&&(e.top=h-t.minHeight),n&&u&&(e.top=h-t.maxHeight),e.width||e.height||e.left||!e.top?e.width||e.height||e.top||!e.left||(e.left=null):e.top=null,e},_getPaddingPlusBorderDimensions:function(e){for(var t=0,i=[],s=[e.css("borderTopWidth"),e.css("borderRightWidth"),e.css("borderBottomWidth"),e.css("borderLeftWidth")],n=[e.css("paddingTop"),e.css("paddingRight"),e.css("paddingBottom"),e.css("paddingLeft")];4>t;t++)i[t]=parseInt(s[t],10)||0,i[t]+=parseInt(n[t],10)||0;return{height:i[0]+i[2],width:i[1]+i[3]}},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var e,t=0,i=this.helper||this.element;this._proportionallyResizeElements.length>t;t++)e=this._proportionallyResizeElements[t],this.outerDimensions||(this.outerDimensions=this._getPaddingPlusBorderDimensions(e)),e.css({height:i.height()-this.outerDimensions.height||0,width:i.width()-this.outerDimensions.width||0})},_renderProxy:function(){var t=this.element,i=this.options;this.elementOffset=t.offset(),this._helper?(this.helper=this.helper||e("
    "),this.helper.addClass(this._helper).css({width:this.element.outerWidth()-1,height:this.element.outerHeight()-1,position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++i.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element},_change:{e:function(e,t){return{width:this.originalSize.width+t}},w:function(e,t){var i=this.originalSize,s=this.originalPosition;return{left:s.left+t,width:i.width-t}},n:function(e,t,i){var s=this.originalSize,n=this.originalPosition;return{top:n.top+i,height:s.height-i}},s:function(e,t,i){return{height:this.originalSize.height+i}},se:function(t,i,s){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[t,i,s]))},sw:function(t,i,s){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[t,i,s]))},ne:function(t,i,s){return e.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[t,i,s]))},nw:function(t,i,s){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[t,i,s]))}},_propagate:function(t,i){e.ui.plugin.call(this,t,[i,this.ui()]),"resize"!==t&&this._trigger(t,i,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),e.ui.plugin.add("resizable","animate",{stop:function(t){var i=e(this).resizable("instance"),s=i.options,n=i._proportionallyResizeElements,a=n.length&&/textarea/i.test(n[0].nodeName),o=a&&i._hasScroll(n[0],"left")?0:i.sizeDiff.height,r=a?0:i.sizeDiff.width,h={width:i.size.width-r,height:i.size.height-o},l=parseInt(i.element.css("left"),10)+(i.position.left-i.originalPosition.left)||null,u=parseInt(i.element.css("top"),10)+(i.position.top-i.originalPosition.top)||null;i.element.animate(e.extend(h,u&&l?{top:u,left:l}:{}),{duration:s.animateDuration,easing:s.animateEasing,step:function(){var s={width:parseInt(i.element.css("width"),10),height:parseInt(i.element.css("height"),10),top:parseInt(i.element.css("top"),10),left:parseInt(i.element.css("left"),10)};n&&n.length&&e(n[0]).css({width:s.width,height:s.height}),i._updateCache(s),i._propagate("resize",t)}})}}),e.ui.plugin.add("resizable","containment",{start:function(){var t,i,s,n,a,o,r,h=e(this).resizable("instance"),l=h.options,u=h.element,d=l.containment,c=d instanceof e?d.get(0):/parent/.test(d)?u.parent().get(0):d;c&&(h.containerElement=e(c),/document/.test(d)||d===document?(h.containerOffset={left:0,top:0},h.containerPosition={left:0,top:0},h.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight}):(t=e(c),i=[],e(["Top","Right","Left","Bottom"]).each(function(e,s){i[e]=h._num(t.css("padding"+s))}),h.containerOffset=t.offset(),h.containerPosition=t.position(),h.containerSize={height:t.innerHeight()-i[3],width:t.innerWidth()-i[1]},s=h.containerOffset,n=h.containerSize.height,a=h.containerSize.width,o=h._hasScroll(c,"left")?c.scrollWidth:a,r=h._hasScroll(c)?c.scrollHeight:n,h.parentData={element:c,left:s.left,top:s.top,width:o,height:r}))},resize:function(t){var i,s,n,a,o=e(this).resizable("instance"),r=o.options,h=o.containerOffset,l=o.position,u=o._aspectRatio||t.shiftKey,d={top:0,left:0},c=o.containerElement,p=!0;c[0]!==document&&/static/.test(c.css("position"))&&(d=h),l.left<(o._helper?h.left:0)&&(o.size.width=o.size.width+(o._helper?o.position.left-h.left:o.position.left-d.left),u&&(o.size.height=o.size.width/o.aspectRatio,p=!1),o.position.left=r.helper?h.left:0),l.top<(o._helper?h.top:0)&&(o.size.height=o.size.height+(o._helper?o.position.top-h.top:o.position.top),u&&(o.size.width=o.size.height*o.aspectRatio,p=!1),o.position.top=o._helper?h.top:0),n=o.containerElement.get(0)===o.element.parent().get(0),a=/relative|absolute/.test(o.containerElement.css("position")),n&&a?(o.offset.left=o.parentData.left+o.position.left,o.offset.top=o.parentData.top+o.position.top):(o.offset.left=o.element.offset().left,o.offset.top=o.element.offset().top),i=Math.abs(o.sizeDiff.width+(o._helper?o.offset.left-d.left:o.offset.left-h.left)),s=Math.abs(o.sizeDiff.height+(o._helper?o.offset.top-d.top:o.offset.top-h.top)),i+o.size.width>=o.parentData.width&&(o.size.width=o.parentData.width-i,u&&(o.size.height=o.size.width/o.aspectRatio,p=!1)),s+o.size.height>=o.parentData.height&&(o.size.height=o.parentData.height-s,u&&(o.size.width=o.size.height*o.aspectRatio,p=!1)),p||(o.position.left=o.prevPosition.left,o.position.top=o.prevPosition.top,o.size.width=o.prevSize.width,o.size.height=o.prevSize.height)},stop:function(){var t=e(this).resizable("instance"),i=t.options,s=t.containerOffset,n=t.containerPosition,a=t.containerElement,o=e(t.helper),r=o.offset(),h=o.outerWidth()-t.sizeDiff.width,l=o.outerHeight()-t.sizeDiff.height;t._helper&&!i.animate&&/relative/.test(a.css("position"))&&e(this).css({left:r.left-n.left-s.left,width:h,height:l}),t._helper&&!i.animate&&/static/.test(a.css("position"))&&e(this).css({left:r.left-n.left-s.left,width:h,height:l})}}),e.ui.plugin.add("resizable","alsoResize",{start:function(){var t=e(this).resizable("instance"),i=t.options,s=function(t){e(t).each(function(){var t=e(this);t.data("ui-resizable-alsoresize",{width:parseInt(t.width(),10),height:parseInt(t.height(),10),left:parseInt(t.css("left"),10),top:parseInt(t.css("top"),10)})})};"object"!=typeof i.alsoResize||i.alsoResize.parentNode?s(i.alsoResize):i.alsoResize.length?(i.alsoResize=i.alsoResize[0],s(i.alsoResize)):e.each(i.alsoResize,function(e){s(e)})},resize:function(t,i){var s=e(this).resizable("instance"),n=s.options,a=s.originalSize,o=s.originalPosition,r={height:s.size.height-a.height||0,width:s.size.width-a.width||0,top:s.position.top-o.top||0,left:s.position.left-o.left||0},h=function(t,s){e(t).each(function(){var t=e(this),n=e(this).data("ui-resizable-alsoresize"),a={},o=s&&s.length?s:t.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(o,function(e,t){var i=(n[t]||0)+(r[t]||0);i&&i>=0&&(a[t]=i||null)}),t.css(a)})};"object"!=typeof n.alsoResize||n.alsoResize.nodeType?h(n.alsoResize):e.each(n.alsoResize,function(e,t){h(e,t)})},stop:function(){e(this).removeData("resizable-alsoresize")}}),e.ui.plugin.add("resizable","ghost",{start:function(){var t=e(this).resizable("instance"),i=t.options,s=t.size;t.ghost=t.originalElement.clone(),t.ghost.css({opacity:.25,display:"block",position:"relative",height:s.height,width:s.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass("string"==typeof i.ghost?i.ghost:""),t.ghost.appendTo(t.helper)},resize:function(){var t=e(this).resizable("instance");t.ghost&&t.ghost.css({position:"relative",height:t.size.height,width:t.size.width})},stop:function(){var t=e(this).resizable("instance");t.ghost&&t.helper&&t.helper.get(0).removeChild(t.ghost.get(0))}}),e.ui.plugin.add("resizable","grid",{resize:function(){var t,i=e(this).resizable("instance"),s=i.options,n=i.size,a=i.originalSize,o=i.originalPosition,r=i.axis,h="number"==typeof s.grid?[s.grid,s.grid]:s.grid,l=h[0]||1,u=h[1]||1,d=Math.round((n.width-a.width)/l)*l,c=Math.round((n.height-a.height)/u)*u,p=a.width+d,f=a.height+c,m=s.maxWidth&&p>s.maxWidth,g=s.maxHeight&&f>s.maxHeight,v=s.minWidth&&s.minWidth>p,y=s.minHeight&&s.minHeight>f;s.grid=h,v&&(p+=l),y&&(f+=u),m&&(p-=l),g&&(f-=u),/^(se|s|e)$/.test(r)?(i.size.width=p,i.size.height=f):/^(ne)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.top=o.top-c):/^(sw)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.left=o.left-d):((0>=f-u||0>=p-l)&&(t=i._getPaddingPlusBorderDimensions(this)),f-u>0?(i.size.height=f,i.position.top=o.top-c):(f=u-t.height,i.size.height=f,i.position.top=o.top+a.height-f),p-l>0?(i.size.width=p,i.position.left=o.left-d):(p=u-t.height,i.size.width=p,i.position.left=o.left+a.width-p))}}),e.ui.resizable}); -------------------------------------------------------------------------------- /jquery.min.js: -------------------------------------------------------------------------------- 1 | /*! jQuery v2.1.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */ 2 | !function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.1",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+O+"))|)"+M+"*\\]",Q=":("+N+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+P+")*)|.*)\\)|)",R=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),S=new RegExp("^"+M+"*,"+M+"*"),T=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),V=new RegExp(Q),W=new RegExp("^"+O+"$"),X={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+Q),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+L+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{I.apply(F=J.call(v.childNodes),v.childNodes),F[v.childNodes.length].nodeType}catch(eb){I={apply:F.length?function(a,b){H.apply(a,J.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],!a||"string"!=typeof a)return d;if(1!==(k=b.nodeType)&&9!==k)return[];if(p&&!e){if(f=_.exec(a))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return I.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return I.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=9===k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+qb(o[l]);w=ab.test(a)&&ob(b.parentNode)||b,x=o.join(",")}if(x)try{return I.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function gb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function hb(a){return a[u]=!0,a}function ib(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function jb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function kb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||D)-(~a.sourceIndex||D);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function lb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function nb(a){return hb(function(b){return b=+b,hb(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 ob(a){return a&&typeof a.getElementsByTagName!==C&&a}c=fb.support={},f=fb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fb.setDocument=function(a){var b,e=a?a.ownerDocument||a:v,g=e.defaultView;return e!==n&&9===e.nodeType&&e.documentElement?(n=e,o=e.documentElement,p=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){m()},!1):g.attachEvent&&g.attachEvent("onunload",function(){m()})),c.attributes=ib(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ib(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(e.getElementsByClassName)&&ib(function(a){return a.innerHTML="
    ",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=ib(function(a){return o.appendChild(a).id=u,!e.getElementsByName||!e.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==C&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c=typeof a.getAttributeNode!==C&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==C?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!==C&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(e.querySelectorAll))&&(ib(function(a){a.innerHTML="",a.querySelectorAll("[msallowclip^='']").length&&q.push("[*^$]="+M+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+M+"*(?:value|"+L+")"),a.querySelectorAll(":checked").length||q.push(":checked")}),ib(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+M+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ib(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",Q)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===v&&t(v,a)?-1:b===e||b.ownerDocument===v&&t(v,b)?1:k?K.call(k,a)-K.call(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],i=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:k?K.call(k,a)-K.call(k,b):0;if(f===g)return kb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?kb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},e):n},fb.matches=function(a,b){return fb(a,null,null,b)},fb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fb(b,n,null,[a]).length>0},fb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&E.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fb.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=fb.selectors={cacheLength:50,createPseudo:hb,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fb.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]&&fb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+M+")"+a+"("+M+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==C&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fb.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(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?hb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=K.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:hb(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?hb(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:hb(function(a){return function(b){return fb(a,b).length>0}}),contains:hb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:hb(function(a){return W.test(a||"")||fb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:nb(function(){return[0]}),last:nb(function(a,b){return[b-1]}),eq:nb(function(a,b,c){return[0>c?c+b:c]}),even:nb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:nb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:nb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:nb(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function rb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function sb(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 tb(a,b,c){for(var d=0,e=b.length;e>d;d++)fb(a,b[d],c);return c}function ub(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 vb(a,b,c,d,e,f){return d&&!d[u]&&(d=vb(d)),e&&!e[u]&&(e=vb(e,f)),hb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||tb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ub(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ub(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?K.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ub(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):I.apply(g,r)})}function wb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=rb(function(a){return a===b},h,!0),l=rb(function(a){return K.call(b,a)>-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>i;i++)if(c=d.relative[a[i].type])m=[rb(sb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return vb(i>1&&sb(m),i>1&&qb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&wb(a.slice(i,e)),f>e&&wb(a=a.slice(e)),f>e&&qb(a))}m.push(c)}return sb(m)}function xb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=G.call(i));s=ub(s)}I.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&fb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?hb(f):f}return h=fb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xb(e,d)),f.selector=a}return f},i=fb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&ob(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qb(j),!a)return I.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&ob(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ib(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ib(function(a){return a.innerHTML="
    ","#"===a.firstChild.getAttribute("href")})||jb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ib(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||jb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ib(function(a){return null==a.getAttribute("disabled")})||jb(L,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fb}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return g.call(b,a)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;c>b;b++)if(n.contains(e[b],this))return!0}));for(b=0;c>b;b++)n.find(a,e[b],d);return d=this.pushStack(c>1?n.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:l,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=l.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=l,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};A.prototype=n.fn,y=n(l);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(n(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(C[a]||n.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return n.each(a.match(E)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&n.each(arguments,function(a,b){var c;while((c=n.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(H.resolveWith(l,[n]),n.fn.triggerHandler&&(n(l).triggerHandler("ready"),n(l).off("ready"))))}});function I(){l.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),n.ready()}n.ready.promise=function(b){return H||(H=n.Deferred(),"complete"===l.readyState?setTimeout(n.ready):(l.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},n.ready.promise();var J=n.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)n.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};n.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=n.expando+Math.random()}K.uid=1,K.accepts=n.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,n.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(n.isEmptyObject(f))n.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!n.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){return M.access(a,b,c)},removeData:function(a,b){M.remove(a,b) 3 | },_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthx",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},e||!o.trigger||o.trigger.apply(d,c)!==!1)){if(!e&&!o.noBubble&&!n.isWindow(d)){for(i=o.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||l)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:o.bindType||q,m=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),m&&m.apply(g,c),m=k&&g[k],m&&m.apply&&n.acceptData(g)&&(b.result=m.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!n.acceptData(d)||k&&n.isFunction(d[q])&&!n.isWindow(d)&&(h=d[k],h&&(d[k]=null),n.event.triggered=q,d[q](),n.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>=0:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h]*)\/>/gi,bb=/<([\w:]+)/,cb=/<|&#?\w+;/,db=/<(?:script|style|link)/i,eb=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/^$|\/(?:java|ecma)script/i,gb=/^true\/(.*)/,hb=/^\s*\s*$/g,ib={option:[1,""],thead:[1,"","
    "],col:[2,"","
    "],tr:[2,"","
    "],td:[3,"","
    "],_default:[0,"",""]};ib.optgroup=ib.option,ib.tbody=ib.tfoot=ib.colgroup=ib.caption=ib.thead,ib.th=ib.td;function jb(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function kb(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function lb(a){var b=gb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function mb(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function nb(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=n.extend({},h),M.set(b,i))}}function ob(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function pb(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}n.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=ob(h),f=ob(a),d=0,e=f.length;e>d;d++)pb(f[d],g[d]);if(b)if(c)for(f=f||ob(a),g=g||ob(h),d=0,e=f.length;e>d;d++)nb(f[d],g[d]);else nb(a,h);return g=ob(h,"script"),g.length>0&&mb(g,!i&&ob(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,o=a.length;o>m;m++)if(e=a[m],e||0===e)if("object"===n.type(e))n.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1>")+h[2],j=h[0];while(j--)f=f.lastChild;n.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===n.inArray(e,d))&&(i=n.contains(e.ownerDocument,e),f=ob(k.appendChild(e),"script"),i&&mb(f),c)){j=0;while(e=f[j++])fb.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f=n.event.special,g=0;void 0!==(c=a[g]);g++){if(n.acceptData(c)&&(e=c[L.expando],e&&(b=L.cache[e]))){if(b.events)for(d in b.events)f[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);L.cache[e]&&delete L.cache[e]}delete M.cache[c[M.expando]]}}}),n.fn.extend({text:function(a){return J(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(ob(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&mb(ob(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(ob(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(ob(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(ob(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,m=this,o=l-1,p=a[0],q=n.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&eb.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(c=n.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=n.map(ob(c,"script"),kb),g=f.length;l>j;j++)h=c,j!==o&&(h=n.clone(h,!0,!0),g&&n.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,n.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&n.contains(i,h)&&(h.src?n._evalUrl&&n._evalUrl(h.src):n.globalEval(h.textContent.replace(hb,"")))}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),n(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d,e=n(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:n.css(e[0],"display");return e.detach(),f}function tb(a){var b=l,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||n(""); 127 | 128 | data.swish = $(content.join("")) 129 | .hide() 130 | .insertAfter(elem); 131 | elem.parent() 132 | .css("height", "300px") 133 | .resizable({handles:'s'}); 134 | elem.hide(400); 135 | data.swish.show(400, function() { elem.parent().addClass("swish"); }); 136 | 137 | currentSWISHElem = elem; 138 | } 139 | } 140 | 141 | /** 142 | * @returns {String} Query text, which starts with ?- and ends in .\n 143 | */ 144 | function makeQuery(text) { 145 | text = text.trim().replace(/\s\s+/g, " "); 146 | if ( ! /^\?-/.test(text) ) 147 | text = "?- "+text; 148 | if ( ! /\.$/.test(text) ) 149 | text = text + "."; 150 | 151 | return text+"\n"; 152 | } 153 | 154 | /** 155 | * 156 | * 157 | * @class LPN 158 | * @tutorial jquery-doc 159 | * @memberOf $.fn 160 | * @param {String|Object} [method] Either a method name or the jQuery 161 | * plugin initialization object. 162 | * @param [...] Zero or more arguments passed to the jQuery `method` 163 | */ 164 | 165 | $.fn.LPN = function(method) { 166 | if ( methods[method] ) { 167 | return methods[method] 168 | .apply(this, Array.prototype.slice.call(arguments, 1)); 169 | } else if ( typeof method === 'object' || !method ) { 170 | return methods._init.apply(this, arguments); 171 | } else { 172 | $.error('Method ' + method + ' does not exist on jQuery.' + pluginName); 173 | } 174 | }; 175 | }(jQuery)); 176 | 177 | 178 | /******************************* 179 | * CHEAP MODAL * 180 | *******************************/ 181 | 182 | var modal = (function() { 183 | var method = {}, 184 | $overlay, 185 | $modal, 186 | $content, 187 | $close; 188 | 189 | // Center the modal in the viewport 190 | method.center = function () { 191 | var top, left; 192 | 193 | top = Math.max(window.innerHeight - $modal.outerHeight(), 0) / 2; 194 | left = Math.max(window.innerWidth - $modal.outerWidth(), 0) / 2; 195 | 196 | $modal.css({ top:top + $(window).scrollTop(), 197 | left:left + $(window).scrollLeft() 198 | }); 199 | }; 200 | 201 | // Open the modal 202 | method.open = function (settings) { 203 | $content.empty().append(settings.content); 204 | 205 | $modal.css({ width: settings.width || 'auto', 206 | height: settings.height || 'auto' 207 | }); 208 | 209 | method.center(); 210 | $(window).bind('resize.modal', method.center); 211 | $modal.show(); 212 | $overlay.show(); 213 | }; 214 | 215 | // Close the modal 216 | method.close = function () { 217 | $modal.hide(); 218 | $overlay.hide(); 219 | $content.empty(); 220 | $(window).unbind('resize.modal'); 221 | }; 222 | 223 | // Generate the HTML and add it to the document 224 | $overlay = $('
    '); 225 | $modal = $(''); 226 | $content = $('
    '); 227 | $close = $('close'); 228 | 229 | $modal.hide(); 230 | $overlay.hide(); 231 | $modal.append($content, $close); 232 | 233 | $(document).ready(function() { 234 | $('body').append($overlay, $modal); 235 | }); 236 | 237 | $close.click(function(e) { 238 | e.preventDefault(); 239 | method.close(); 240 | }); 241 | 242 | return method; 243 | 244 | }()); 245 | -------------------------------------------------------------------------------- /lpn_reds2.css: -------------------------------------------------------------------------------- 1 | 2 | body { 3 | background-color:#ffffff; 4 | min-width: 500pt; 5 | } 6 | 7 | 8 | div.coloredbar { 9 | background-color:#ffcc33; 10 | margin:0pt; 11 | padding:10pt; 12 | height:50pt; 13 | } 14 | 15 | div.lpnheader { 16 | background-color:#ffcc33; 17 | margin:0pt; 18 | padding:10pt; 19 | text-align:left; 20 | font-family:Helvetica,sans-serif; 21 | font-size:300%; 22 | } 23 | 24 | .lpnheader a { 25 | color:black; 26 | font-family:Helvetica,sans-serif; 27 | text-decoration:none; 28 | } 29 | 30 | div.authorbar { 31 | background-color:#ff9900; 32 | margin:0pt; 33 | padding:7pt; 34 | text-align:right; 35 | font-family:Helvetica,sans-serif; 36 | font-size:100%; 37 | } 38 | 39 | .authorbar a { 40 | color:black; 41 | font-family:Helvetica,sans-serif; 42 | text-decoration:none; 43 | } 44 | 45 | div.navbar { 46 | float:left; 47 | background-color:#990000; 48 | color:#ffffff; 49 | width:150pt; 50 | %overflow:hidden; 51 | margin:0pt; 52 | height:400pt; 53 | padding-top:20pt; 54 | font-family:Helvetica,sans-serif; 55 | } 56 | 57 | .navbar ul { 58 | margin-left:0pt; 59 | padding-left:0pt; 60 | } 61 | 62 | .navbar li { 63 | list-style:none; 64 | margin:10pt 0pt 10pt 8pt; 65 | } 66 | 67 | .navbar li li { 68 | margin:3pt 0pt 3pt 15pt; 69 | font-size:90%; 70 | } 71 | 72 | div.content { 73 | padding:20pt; 74 | padding-left:10pt; 75 | margin-left:170pt; 76 | font-family:Helvetica,sans-serif; 77 | font-size:80%; 78 | overflow:visible; 79 | } 80 | 81 | .content td { 82 | font-size:80%; 83 | } 84 | 85 | div.foot { 86 | clear:both; 87 | padding-top:10pt; 88 | font-family:Helvetica,sans-serif; 89 | font-size:80%; 90 | } 91 | 92 | div.tracker { 93 | float:right; 94 | width:50pt; 95 | } 96 | 97 | .content a { 98 | color:#990000; %black; 99 | } 100 | 101 | .content h1 { 102 | color:#ff9900; 103 | } 104 | 105 | .navbar a { 106 | color:#ffffff; 107 | font-family:Helvetica,sans-serif; 108 | text-decoration:none; 109 | } 110 | 111 | div.newsbox { 112 | float:right; 113 | width:180pt; 114 | border:3px solid #ff9900; %#990000; 115 | padding:10px; 116 | margin-right:-10pt; 117 | margin-left:20pt; 118 | margin-bottom:20pt; 119 | } 120 | 121 | div.newsbar { 122 | width:180pt; 123 | background-color:#ff9900; %#990000; 124 | padding:10px; 125 | margin: -10px; 126 | margin-bottom: 10px; 127 | color:#ffffff; 128 | font-size:150%; 129 | } 130 | 131 | .emph { 132 | color:#990000; 133 | } 134 | 135 | pre { 136 | font-size:130%; 137 | overflow:visible; 138 | } 139 | 140 | span.code{ 141 | font-family:'courier'; 142 | } -------------------------------------------------------------------------------- /proxy.pl: -------------------------------------------------------------------------------- 1 | :- module(lpn_proxy, 2 | [ local_lpn/1, % +Port 3 | server/1 % +Port 4 | ]). 5 | :- use_module(convert). 6 | :- use_module(library(option)). 7 | :- use_module(library(settings)). 8 | :- use_module(library(http/thread_httpd)). 9 | :- use_module(library(http/http_dispatch)). 10 | :- use_module(library(http/http_server_files)). 11 | :- use_module(library(http/http_open)). 12 | :- use_module(library(http/http_error)). 13 | :- use_module(library(aggregate)). 14 | :- use_module(library(apply)). 15 | :- use_module(library(uri)). 16 | :- use_module(library(http/http_json)). 17 | :- use_module(library(http/http_stream)). 18 | 19 | /** Learn Prolog Now proxy 20 | 21 | This module implements a simple proxy that rewrites LPN to link to SWISH 22 | 23 | Overall what this does: 24 | 25 | Say there's some HTML page on web 26 | with prolog code examples in it 27 | 28 | This program serves that web page on the port specified in server, 29 | at the same relative URI as the source, 30 | 31 | so, if the original is at 32 | https://www.learnprolognow.org/lpnpage.php?pagetype=html&pageid=lpn-htmlse1 33 | and we started the proxy by consulting this file and querying 34 | server(4000). then we can see the same page at 35 | 36 | http://localhost:4000/lpnpage.php?pagetype=html&pageid=lpn-htmlse1 37 | 38 | BUT, this program modifies anything it sees as a Prolog code example in 39 | the original page to be a SWISH console in the process. 40 | 41 | Additionally, this program serves a few helper files needed by the 42 | SWISH console. 43 | 44 | It makes a lot of assumptions about what the website it's proxying is 45 | like, both in URI structure and in what prolog code will look like. 46 | That's OK, it's just to proxy a single site. 47 | 48 | */ 49 | 50 | % the location lpn is where files like lpn.css that are needed 51 | % to swish-ize are located 52 | user:file_search_path(lpn, .). 53 | % I'd expect this directory to be in the source tree 54 | % but it's not there. I've now checked it in. 55 | user:file_search_path(lpn_cache, lpn(cache)). 56 | 57 | % by 'location from which we proxy' he means the location 58 | % we get the original, un-swishized html pages from 59 | % this defines a setting named lpn_home, like most settings, 60 | % used for configuration 61 | :- setting(lpn_home, atom, 62 | % 'https://www.learnprolognow.org', 63 | 'https://www.let.rug.nl/bos/lpn/', 64 | 'The location from which we proxy'). 65 | 66 | % a convenience predicate to override where you get the 67 | % LPN HTML pages from. 68 | local_lpn(Port) :- 69 | format(atom(URL), 'http://localhost:~w', [Port]), 70 | set_setting(lpn_home, URL). 71 | 72 | % this defines the handlers. 73 | % redirect bare http://localhost:4000/ type request to 74 | % the root of the lpn pages 75 | :- http_handler('/', http_redirect(moved_temporary, 76 | '/lpnpage.php?pageid=online'), []). 77 | % this serves all the little extra files like lpn.js, lpn.css etc. 78 | :- http_handler('/', serve_files_in_directory(lpn), [prefix]). 79 | % this is where the meat of the action is, anything that goes to 80 | % lpnpage.php is responded to by the predicate lpn/1 81 | :- http_handler('/lpnpage.php', lpn, []). 82 | % this serves some more of the support structure 83 | % any URI that starts /html/ is served by the predicate pics 84 | :- http_handler('/html/', pics, [prefix]). 85 | 86 | server(Port) :- 87 | http_server(http_dispatch, 88 | [ port(Port) 89 | ]). 90 | 91 | % this is where the fun happens. We SWISH-ize everything served by 92 | % /lpnpage.php 93 | lpn(Request) :- 94 | % get the PageID from the request 95 | option(request_uri(URI), Request), 96 | pageid(URI, PageID), 97 | check_file(lpn_cache(PageID)), 98 | ( absolute_file_name(lpn_cache(PageID), Path, 99 | [access(read), file_errors(fail)]) 100 | -> reply_from_file(Path) % if its in the cache SWISHize and send it 101 | ; absolute_file_name(lpn_cache(PageID), Path, 102 | [access(write), file_errors(fail)]) 103 | -> download(URI, Path), % otherwise download, SWISHize and send it 104 | reply_from_file(Path) 105 | ; setting(lpn_home, LPNHome), % and if we cant cache, SWISHize inline 106 | atom_concat(LPNHome, URI, Source), % as it comes from source 107 | setup_call_cleanup( 108 | http_open(Source, In, [connection('Keep-alive')]), 109 | reply_from_stream(In), 110 | close(In)) 111 | ). 112 | 113 | %% pageid(+URI, -PageID) is semidet 114 | % 115 | % succeeds binding PageID to the value associated with the pageid 116 | % key in the query string 117 | % or fails if thats impossible 118 | % URI must be an atom, codes, or a string 119 | % 120 | pageid(URI, PageID) :- 121 | uri_components(URI, Components), 122 | uri_data(search, Components, Search), 123 | nonvar(Search), 124 | uri_query_components(Search, Query), 125 | memberchk(pageid=PageID, Query). 126 | 127 | %% reply_from_file(+Path:text) is det 128 | % 129 | % given an abstract file path SWISHize it and 130 | % send as httpResponse 131 | % 132 | reply_from_file(Path) :- 133 | setup_call_cleanup( 134 | open(Path, read, In), 135 | reply_from_stream(In), 136 | close(In)). 137 | 138 | % Ensure that File is inside ./cache 139 | check_file(File) :- 140 | absolute_file_name('./cache', Reserved), 141 | absolute_file_name(File, Tried), 142 | sub_atom(Tried, 0, _, _, Reserved). 143 | 144 | % I think this just proxies the request normal fashion, 145 | % caching as it goes but doesn't swish-ize 146 | pics(Request) :- 147 | option(path_info(Rest), Request), 148 | check_file(lpn_cache(Rest)), 149 | ( absolute_file_name(lpn_cache(Rest), _, 150 | [access(read), file_errors(fail)]) 151 | -> http_reply_file(lpn_cache(Rest), [], Request) 152 | ; absolute_file_name(lpn_cache(Rest), Path, 153 | [access(write), file_errors(fail)]) 154 | -> option(request_uri(URI), Request), 155 | download(URI, Path), 156 | http_reply_file(lpn_cache(Rest), [], Request) 157 | ; option(request_uri(URI), Request), 158 | setting(lpn_home, LPNHome), 159 | atom_concat(LPNHome, URI, Source), 160 | setup_call_cleanup( 161 | http_open(Source, In, [connection('Keep-alive'),header(content_type, Type)]), 162 | ( format('Content-type: ~w~n~n', [Type]), 163 | copy_stream_data(In, current_output) 164 | ), 165 | close(In)) 166 | ). 167 | 168 | %% download(+URI:text, +Path:text) is det 169 | % 170 | % change the source domain for the current URI 171 | % to lpn_home and download that into the file 172 | % Path 173 | % 174 | download(URI, Path) :- 175 | setting(lpn_home, LPNHome), 176 | atom_concat(LPNHome, URI, Source), 177 | setup_call_cleanup( 178 | http_open(Source, In, [connection('Keep-alive')]), 179 | setup_call_cleanup( 180 | open(Path, write, Out, [type(binary)]), 181 | copy_stream_data(In, Out), 182 | close(Out)), 183 | close(In)). 184 | 185 | %% reply_from_stream(+In:stream) is det 186 | % 187 | % read the input stream In, SWISH-ize it, 188 | % and send as the httpresponse 189 | reply_from_stream(In) :- 190 | format('Content-type: text/html~n~n'), 191 | convert_lpn(In, current_output). 192 | 193 | :- if(exists_source(library(http/http_server_health))). 194 | :- use_module(library(http/http_server_health)). 195 | :- set_setting_default(http:cors, [*]). 196 | :- else. 197 | 198 | % serve /health 199 | :- http_handler('/health', health, []). 200 | 201 | %% health(+Request) 202 | % 203 | % HTTP handler that replies with the overall health of the server 204 | 205 | health(_Request) :- 206 | get_server_health(Health), 207 | reply_json(Health). 208 | 209 | get_server_health(Health) :- 210 | findall(Key-Value, health(Key, Value), Pairs), 211 | dict_pairs(Health, health, Pairs). 212 | 213 | health(up, true). 214 | health(uptime, Time) :- 215 | get_time(Now), 216 | ( http_server_property(_, start_time(StartTime)) 217 | -> Time is round(Now - StartTime) 218 | ). 219 | health(requests, RequestCount) :- 220 | cgi_statistics(requests(RequestCount)). 221 | health(bytes_sent, BytesSent) :- 222 | cgi_statistics(bytes_sent(BytesSent)). 223 | health(open_files, Streams) :- 224 | aggregate_all(count, N, stream_property(_, file_no(N)), Streams). 225 | health(loadavg, LoadAVG) :- 226 | catch(setup_call_cleanup( 227 | open('/proc/loadavg', read, In), 228 | read_string(In, _, String), 229 | close(In)), 230 | _, fail), 231 | split_string(String, " ", " ", [One,Five,Fifteen|_]), 232 | maplist(number_string, LoadAVG, [One,Five,Fifteen]). 233 | :- if(current_predicate(malloc_property/1)). 234 | health(heap, json{inuse:InUse, size:Size}) :- 235 | malloc_property('generic.current_allocated_bytes'(InUse)), 236 | malloc_property('generic.heap_size'(Size)). 237 | :- endif. 238 | :- endif. % not library(http/http_server_health) 239 | -------------------------------------------------------------------------------- /testing-version.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn-swish-proxy/f6fe70ccee6d03d1589135428865469a916e19c3/testing-version.png -------------------------------------------------------------------------------- /tint20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LearnPrologNow/lpn-swish-proxy/f6fe70ccee6d03d1589135428865469a916e19c3/tint20.png -------------------------------------------------------------------------------- /upstart/lpn-proxy.conf: -------------------------------------------------------------------------------- 1 | # demo - SWI-Prolog demo server 2 | # 3 | # The SWI-Prologdemo server 4 | 5 | description "LPN proxy server" 6 | 7 | start on runlevel [2345] 8 | stop on runlevel [!2345] 9 | 10 | respawn 11 | respawn limit 5 60 12 | umask 022 13 | 14 | console log 15 | chdir /home/swish/src/lpn-swish-proxy 16 | 17 | script 18 | export LANG=en_US.utf8 19 | ./lpn-daemon.pl --no-fork --port=4040 --user=www-data --pidfile=/var/run/lpn.pid --workers=16 --syslog=lpn-proxy 20 | end script 21 | --------------------------------------------------------------------------------