task : tasks) {
99 | try {
100 | task.get();
101 | } catch (InterruptedException | ExecutionException e) {
102 | throw new SstkException("Service error.", e);
103 | }
104 | }
105 | }
106 |
107 | @Override
108 | public void close() throws Exception {
109 | resourceDownloadService.shutdown();
110 | resourceDownloadService.awaitTermination(GlobalConfig.SERVICE_TIMEOUT, TimeUnit.MILLISECONDS);
111 | pageService.shutdown();
112 | pageService.awaitTermination(GlobalConfig.SERVICE_TIMEOUT, TimeUnit.MILLISECONDS);
113 | LOGGER.debug("Service stoped.");
114 | }
115 |
116 | private static void usage() {
117 | String usage = "Usage:java -Dfile.encoding=utf-8 -jar SimpleSendToKindle.jar http://xxx1.xxx.xx http:xxx2.xxx.xx ...";
118 | LOGGER.debug(usage);
119 | report("Missing parameter.");
120 | }
121 |
122 | private static void report(String msg) {
123 | OutputStream stdout = System.out;
124 | try {
125 | stdout.write(msg.getBytes("UTF-8"));
126 | } catch (IOException e) {
127 | LOGGER.error("write msg to standard io error.", e);
128 | }
129 | }
130 |
131 | public static void main(String[] args) {
132 | if (args.length == 0) {
133 | usage();
134 | return;
135 | }
136 | try (Service service = new Service()) {
137 | service.launch(args);
138 | report("Successed!");
139 | } catch (Throwable e) {
140 | LOGGER.error("Service error.", e);
141 | report("Error occurred!");
142 | }
143 | }
144 |
145 | }
146 |
--------------------------------------------------------------------------------
/src/main/java/so/zjd/sstk/SstkException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 zhanjindong. All rights reserved.
3 | */
4 | package so.zjd.sstk;
5 |
6 | /**
7 | *
8 | * sstk custom exception.
9 | *
10 | * @author jdzhan,2014-12-14
11 | *
12 | */
13 | public class SstkException extends RuntimeException {
14 |
15 | private static final long serialVersionUID = 2661720921334730612L;
16 |
17 | public SstkException(String message, Throwable cause) {
18 | super(message, cause);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/so/zjd/sstk/util/HttpHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 zhanjindong. All rights reserved.
3 | */
4 | package so.zjd.sstk.util;
5 |
6 | import java.io.BufferedReader;
7 | import java.io.IOException;
8 | import java.io.InputStream;
9 | import java.io.InputStreamReader;
10 | import java.io.OutputStream;
11 | import java.net.HttpURLConnection;
12 | import java.net.URL;
13 |
14 | /**
15 | *
16 | * Http helper.
17 | *
18 | * @author jdzhan,2014-12-6
19 | *
20 | */
21 | public class HttpHelper {
22 |
23 | public static StringBuilder download(String url, int timeout) throws IOException {
24 | return download(url, timeout, "UTF-8");
25 | }
26 |
27 | public static StringBuilder download(String url, int timeout, String encoding) throws IOException {
28 |
29 | HttpURLConnection urlConnection = null;
30 | InputStream is = null;
31 | StringBuilder result = new StringBuilder();
32 |
33 | try {
34 | urlConnection = cretateConnection("GET", url, timeout);
35 | is = urlConnection.getInputStream();
36 | result.append(new String(IOUtils.read(is)));
37 | } finally {
38 | close(is);
39 | close(urlConnection);
40 | }
41 | return result;
42 | }
43 |
44 | public static boolean download(String url, int timeout, OutputStream os) throws IOException {
45 | return download(url, timeout, "UTF-8", os);
46 | }
47 |
48 | public static boolean download(String url, int timeout, String encoding, OutputStream os) throws IOException {
49 | HttpURLConnection urlConnection = null;
50 | InputStream is = null;
51 | BufferedReader br = null;
52 |
53 | try {
54 | url = url.replace(" ", "%20");
55 | urlConnection = cretateConnection("GET", url, timeout);
56 | is = urlConnection.getInputStream();
57 | IOUtils.write(is, os);
58 | } finally {
59 | close(br);
60 | close(is);
61 | close(urlConnection);
62 | }
63 | return true;
64 | }
65 |
66 | private static HttpURLConnection cretateConnection(String method, String reqString, int timeout) throws IOException {
67 | URL url = new URL(reqString);
68 | HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
69 | urlConnection.setReadTimeout(timeout);
70 | urlConnection.setConnectTimeout(timeout);
71 |
72 | // disguise chrome
73 | urlConnection
74 | .addRequestProperty("User-Agent",
75 | "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36");
76 |
77 | urlConnection.setRequestMethod(method); // request method, default
78 | // GET
79 | if (method.equals("POST")) {
80 | urlConnection.setUseCaches(false); // Post can not user cache
81 | urlConnection.setDoOutput(true); // set output from urlconn
82 | urlConnection.setDoInput(true); // set input from urlconn
83 | }
84 | return urlConnection;
85 | }
86 |
87 | private static void close(BufferedReader br) {
88 | if (br != null) {
89 | try {
90 | br.close();
91 | } catch (IOException e) {
92 | // ignored
93 | }
94 | }
95 | }
96 |
97 | private static void close(InputStream is) {
98 | if (is != null) {
99 | try {
100 | is.close();
101 | } catch (IOException e) {
102 | // ignored
103 | }
104 | }
105 | }
106 |
107 | private static void close(HttpURLConnection conn) {
108 | if (conn != null) {
109 | conn.disconnect();
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/src/main/java/so/zjd/sstk/util/IOUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 zhanjindong. All rights reserved.
3 | */
4 | package so.zjd.sstk.util;
5 |
6 | import java.io.ByteArrayInputStream;
7 | import java.io.ByteArrayOutputStream;
8 | import java.io.File;
9 | import java.io.FileInputStream;
10 | import java.io.FileNotFoundException;
11 | import java.io.FileOutputStream;
12 | import java.io.FileWriter;
13 | import java.io.IOException;
14 | import java.io.InputStream;
15 | import java.io.InputStreamReader;
16 | import java.io.OutputStream;
17 | import java.io.Reader;
18 | import java.io.UnsupportedEncodingException;
19 | import java.io.Writer;
20 |
21 | import org.apache.commons.io.output.FileWriterWithEncoding;
22 |
23 | /**
24 | *
25 | * Provide some I/O operations.
26 | *
27 | * @author jdzhan,2014-12-6
28 | *
29 | */
30 | public final class IOUtils {
31 |
32 | private IOUtils() {
33 | }
34 |
35 | /**
36 | * 读文件。
37 | *
38 | * @param filepath
39 | * 文件路径
40 | * @param charset
41 | * 字符编码
42 | * @param bufferSize
43 | * buffer
44 | * @return 文件内容
45 | */
46 | public static String read(String filepath, String charset, int bufferSize) {
47 | File file = new File(filepath);
48 | return read(file, charset, bufferSize);
49 | }
50 |
51 | /**
52 | * 读文件。
53 | *
54 | * @param filepath
55 | * 文件路径
56 | * @param charset
57 | * 字符编码
58 | * @param bufferSize
59 | * buffer
60 | * @return 文件内容
61 | */
62 | public static String read(String filepath, String charset) {
63 | File file = new File(filepath);
64 | return read(file, charset, 1024);
65 | }
66 |
67 | /**
68 | * 读文件。
69 | *
70 | * @param file
71 | * 文件
72 | * @param charset
73 | * 字符编码
74 | * @return String 文件内容
75 | */
76 | public static String read(File file, String charset, int bufferSize) {
77 | InputStream inputStream = null;
78 | InputStreamReader inputStreamReader = null;
79 |
80 | try {
81 | inputStream = new FileInputStream(file);
82 | inputStreamReader = new InputStreamReader(inputStream, charset);
83 |
84 | int length = 0;
85 | char[] buffer = new char[bufferSize];
86 | StringBuilder result = new StringBuilder();
87 |
88 | while ((length = inputStreamReader.read(buffer, 0, bufferSize)) > -1) {
89 | result.append(buffer, 0, length);
90 | }
91 |
92 | return result.toString();
93 | } catch (IOException e) {
94 | throw new RuntimeException(e);
95 | } finally {
96 | close(inputStreamReader);
97 | close(inputStream);
98 | }
99 | }
100 |
101 | /**
102 | * 逐行读取文件。
103 | *
104 | * @param stream
105 | * 文件流{@link InputStream}
106 | * @return 字节数组
107 | * @throws IOException
108 | */
109 | public static byte[] readLine(InputStream stream) throws IOException {
110 | int b = -1;
111 | ByteArrayOutputStream bos = new ByteArrayOutputStream(4096);
112 |
113 | while ((b = stream.read()) != -1) {
114 | String ls = SeparatorUtils.getLineSeparator();
115 | if (ls.equals("\r\n") || ls.equals("\n")) {// WIN & UNIX-like
116 | if (b == '\n') {
117 | bos.write(b);
118 | break;
119 | }
120 | } else {// MAC
121 | if (b == '\r') {
122 | bos.write(b);
123 | break;
124 | }
125 | }
126 |
127 | bos.write(b);
128 | }
129 |
130 | return bos.toByteArray();
131 | }
132 |
133 | /**
134 | *
135 | * 读取文件。
136 | *
137 | * @param input
138 | * 文件流
139 | * @return 字节数组
140 | * @throws IOException
141 | */
142 | public static byte[] read(InputStream input) throws IOException {
143 | return org.apache.commons.io.IOUtils.toByteArray(input);
144 | }
145 |
146 | /**
147 | * @param file
148 | * @return
149 | * @throws FileNotFoundException
150 | * @throws IOException
151 | */
152 | public static byte[] read(File file) throws FileNotFoundException, IOException {
153 | FileInputStream fs = null;
154 | try {
155 | fs = new FileInputStream(file);
156 | return read(fs);
157 | } finally {
158 | close(fs);
159 | }
160 | }
161 |
162 | /**
163 | * @param filepath
164 | * @return
165 | * @throws FileNotFoundException
166 | * @throws IOException
167 | */
168 | public static byte[] read(String filepath) throws FileNotFoundException, IOException {
169 | File file = new File(filepath);
170 | return read(file);
171 | }
172 |
173 | /**
174 | * 向文件写入内容,如果文件不存在则创建。
175 | *
176 | * @param file
177 | * @param content
178 | * @param charset
179 | * - 字符编码
180 | * @param append
181 | * - 如果为true则追加在文件的后面,否则覆盖整个文件。
182 | * @throws IOException
183 | */
184 | public static void write(File file, String content, String charset, boolean append) throws IOException {
185 |
186 | FileWriterWithEncoding fileWriter = null;
187 | try {
188 |
189 | fileWriter = new FileWriterWithEncoding(file, charset, append);
190 | fileWriter.write(content);
191 |
192 | } finally {
193 | close(fileWriter);
194 | }
195 | }
196 |
197 | /**
198 | * @param filepath
199 | * @param content
200 | * @param charset
201 | * @param append
202 | * @throws IOException
203 | */
204 | public static void write(String filepath, String content, String charset, boolean append) throws IOException {
205 | File file = new File(filepath);
206 | write(file, content, charset, append);
207 | }
208 |
209 | /**
210 | * @param file
211 | * @param content
212 | * @param append
213 | * @throws IOException
214 | */
215 | public static void write(File file, String content, boolean append) throws IOException {
216 |
217 | FileWriter fileWriter = null;
218 | try {
219 |
220 | fileWriter = new FileWriter(file, append);
221 | fileWriter.write(content);
222 | } finally {
223 | close(fileWriter);
224 | }
225 | }
226 |
227 | /**
228 | * @param filepath
229 | * @param content
230 | * @param append
231 | * @throws IOException
232 | */
233 | public static void write(String filepath, String content, boolean append) throws IOException {
234 | File file = new File(filepath);
235 | write(file, content, append);
236 | }
237 |
238 | /**
239 | *
240 | * 向文件末尾追加一行内容。
241 | *
242 | * @param file
243 | * @param line
244 | * @param charset
245 | * @throws IOException
246 | */
247 | public static void writeLine(File file, String line, String charset) throws IOException {
248 | write(file, SeparatorUtils.getLineSeparator() + line, charset, true);
249 | }
250 |
251 | /**
252 | * @param filepath
253 | * @param line
254 | * @param charset
255 | * @throws IOException
256 | */
257 | public static void writeLine(String filepath, String line, String charset) throws IOException {
258 | write(filepath, SeparatorUtils.getLineSeparator() + line, charset, true);
259 | }
260 |
261 | /**
262 | *
263 | * 向文件末尾追加一行内容。
264 | *
265 | * @param file
266 | * @param line
267 | * @param charset
268 | * @throws IOException
269 | */
270 | public static void writeLine(File file, String line) throws IOException {
271 | write(file, SeparatorUtils.getLineSeparator() + line, true);
272 | }
273 |
274 | /**
275 | * @param filepath
276 | * @param line
277 | * @throws IOException
278 | */
279 | public static void writeLine(String filepath, String line) throws IOException {
280 | write(filepath, SeparatorUtils.getLineSeparator() + line, true);
281 | }
282 |
283 | /**
284 | * 将输入的字符串转换为文件输出,默认为UTF-8编码
285 | *
286 | *
287 | * @author chen.chen.9, 2014-3-28
288 | *
289 | *
290 | * @param input
291 | * 输入字符串
292 | * @param file
293 | * 输出文件
294 | * @throws IOException
295 | * @throws FileNotFoundException
296 | * @throws UnsupportedEncodingException
297 | */
298 | public static void write(String input, File file) throws UnsupportedEncodingException, FileNotFoundException,
299 | IOException {
300 | FileOutputStream os = null;
301 | try {
302 | os = new FileOutputStream(file);
303 | write(input, os);
304 | } finally {
305 | close(os);
306 | }
307 |
308 | }
309 |
310 | /**
311 | * 将输入的字符串转换为输出流,默认为UTF-8编码
312 | *
313 | *
314 | * @author chen.chen.9, 2014-3-20
315 | * @param input
316 | * 输入字符串
317 | * @param outputStream
318 | * {@link OutputStream}
319 | * @throws IOException
320 | * @throws UnsupportedEncodingException
321 | */
322 | public static void write(String input, OutputStream outputStream) throws UnsupportedEncodingException, IOException {
323 | write(input, outputStream, "UTF-8");
324 | }
325 |
326 | /**
327 | * 将输入的字符串转换为输出流
328 | *
329 | *
330 | * @author chen.chen.9, 2014-3-20
331 | * @param input
332 | * {@link InputStream}
333 | * @param outputStream
334 | * {@link OutputStream}
335 | * @throws IOException
336 | * @throws UnsupportedEncodingException
337 | */
338 | public static void write(String input, OutputStream outputStream, String encoding)
339 | throws UnsupportedEncodingException, IOException {
340 | ByteArrayInputStream bais = null;
341 | try {
342 | bais = new ByteArrayInputStream(input.getBytes(encoding));
343 | write(bais, outputStream);
344 | } finally {
345 | close(bais);
346 | }
347 |
348 | }
349 |
350 | /**
351 | * 将IO输入流写入输出流
352 | *
353 | *
354 | * @author chen.chen.9, 2014-3-20
355 | * @param inputStream
356 | * {@link InputStream}
357 | * @param outputStream
358 | * {@link OutputStream}
359 | * @throws IOException
360 | */
361 | public static void write(InputStream inputStream, OutputStream outputStream) throws IOException {
362 | org.apache.commons.io.IOUtils.write(read(inputStream), outputStream);
363 | }
364 |
365 | /**
366 | * @param file
367 | * @return
368 | * @throws IOException
369 | */
370 | public static OutputStream openOutputStream(File file) throws IOException {
371 | return new FileOutputStream(file);
372 | }
373 |
374 | /**
375 | * @param f1
376 | * @param f2
377 | * @throws IOException
378 | */
379 | public static void copy(String f1, String f2) throws IOException {
380 | copy(new File(f1), new File(f2), true);
381 | }
382 |
383 | /**
384 | * @param src
385 | * @param tgt
386 | * @throws IOException
387 | */
388 | public static boolean copy(File f1, File f2, boolean b) throws IOException {
389 | if (f1 == null) {
390 | throw new NullPointerException("Source must not be null");
391 | }
392 |
393 | if (f2 == null) {
394 | throw new NullPointerException("Destination must not be null");
395 | }
396 |
397 | if (!f1.exists() || !f1.isFile()) {
398 | throw new IOException(f1.getAbsolutePath() + " must be a file !");
399 | }
400 |
401 | if (f1.getCanonicalPath().equals(f2.getCanonicalPath())) {
402 | throw new IOException("Source '" + f1 + "' and destination '" + f2 + "' are the same");
403 | }
404 |
405 | if (f2.getParentFile() != null && !f2.getParentFile().exists() && !f2.getParentFile().mkdirs()) {
406 | throw new IOException("Destination '" + f2 + "' directory cannot be created");
407 | }
408 |
409 | if (f2.exists() && !f2.canWrite()) {
410 | throw new IOException("Destination '" + f2 + "' exists but is read-only");
411 | }
412 |
413 | FileInputStream fin = null;
414 | FileOutputStream fos = null;
415 |
416 | try {
417 | fin = new FileInputStream(f1.getAbsolutePath());
418 | fos = new FileOutputStream(f2.getAbsolutePath());
419 | copy(fin, fos);
420 | } finally {
421 | if (fin != null) {
422 | try {
423 | fin.close();
424 | } catch (IOException e) {
425 | }
426 | }
427 |
428 | if (fos != null) {
429 | try {
430 | fos.close();
431 | } catch (IOException e) {
432 | }
433 | }
434 | }
435 |
436 | if (b) {
437 | return f2.setLastModified(f1.lastModified());
438 | }
439 |
440 | return true;
441 | }
442 |
443 | /**
444 | * @param inputStream
445 | * @param file
446 | * @throws IOException
447 | */
448 | public static void copy(InputStream inputStream, File file) throws IOException {
449 | if (inputStream != null) {
450 | OutputStream outputStream = null;
451 |
452 | try {
453 | outputStream = IOUtils.openOutputStream(file);
454 |
455 | IOUtils.copy(inputStream, outputStream);
456 | } finally {
457 | IOUtils.close(outputStream);
458 | }
459 | } else {
460 | throw new IOException("inputStream is null !");
461 | }
462 | }
463 |
464 | /**
465 | *
466 | * @param file
467 | * @param out
468 | * @throws IOException
469 | */
470 | public static void copy(File file, OutputStream out) throws IOException {
471 | FileInputStream fin = null;
472 |
473 | try {
474 | fin = new FileInputStream(file);
475 |
476 | copy(fin, out);
477 | } finally {
478 | close(fin);
479 | }
480 | }
481 |
482 | /**
483 | * @param inputStream
484 | * @param outputStream
485 | * @throws IOException
486 | */
487 | public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException {
488 | copy(inputStream, outputStream, 4096);
489 | }
490 |
491 | /**
492 | * @param inputStream
493 | * @param outputStream
494 | * @param bufferSize
495 | * @throws IOException
496 | */
497 | public static void copy(InputStream inputStream, OutputStream outputStream, int bufferSize) throws IOException {
498 | int length = 0;
499 | byte[] bytes = new byte[Math.max(bufferSize, 4096)];
500 |
501 | while ((length = inputStream.read(bytes)) > -1) {
502 | outputStream.write(bytes, 0, length);
503 | }
504 |
505 | outputStream.flush();
506 | }
507 |
508 | /**
509 | * @param inputStream
510 | * @param outputStream
511 | * @param bufferSize
512 | * @param size
513 | * @throws IOException
514 | */
515 | public static void copy(InputStream inputStream, OutputStream outputStream, int bufferSize, long size)
516 | throws IOException {
517 | if (size > 0) {
518 | int readBytes = 0;
519 | long count = size;
520 | int length = Math.min(bufferSize, (int) (size));
521 | byte[] buffer = new byte[length];
522 |
523 | while (count > 0) {
524 | if (count > length) {
525 | readBytes = inputStream.read(buffer, 0, length);
526 | } else {
527 | readBytes = inputStream.read(buffer, 0, (int) count);
528 | }
529 |
530 | if (readBytes > 0) {
531 | outputStream.write(buffer, 0, readBytes);
532 | count -= readBytes;
533 | } else {
534 | break;
535 | }
536 | }
537 |
538 | outputStream.flush();
539 | }
540 | }
541 |
542 | /**
543 | * @param reader
544 | * @param writer
545 | * @throws IOException
546 | */
547 | public static void copy(Reader reader, Writer writer) throws IOException {
548 | copy(reader, writer, 4096);
549 | }
550 |
551 | /**
552 | * @param reader
553 | * @param writer
554 | * @param bufferSize
555 | * @throws IOException
556 | */
557 | public static void copy(Reader reader, Writer writer, int bufferSize) throws IOException {
558 | int len = 0;
559 | int buf = Math.max(bufferSize, 4096);
560 | char[] chars = new char[buf];
561 |
562 | while ((len = reader.read(chars)) > -1) {
563 | writer.write(chars, 0, len);
564 | }
565 |
566 | writer.flush();
567 | }
568 |
569 | /**
570 | * @param inputStream
571 | * @return byte[]
572 | * @throws IOException
573 | */
574 | public static byte[] toByteArray(InputStream inputStream) throws IOException {
575 | ByteArrayOutputStream bos = new ByteArrayOutputStream(8192);
576 | copy(inputStream, bos);
577 | return bos.toByteArray();
578 | }
579 |
580 | /**
581 | * @param inputStream
582 | * @return ByteArrayInputStream
583 | * @throws IOException
584 | */
585 | public static ByteArrayInputStream toByteArrayInputStream(InputStream inputStream) throws IOException {
586 | return new ByteArrayInputStream(toByteArray(inputStream));
587 | }
588 |
589 | /**
590 | * @param resource
591 | */
592 | public static void close(java.io.Closeable resource) {
593 | if (resource != null) {
594 | try {
595 | resource.close();
596 | } catch (IOException e) {
597 | }
598 | }
599 | }
600 |
601 | /**
602 | * InputStream
603 | *
604 | * @param ins
605 | * - java.io.InputStream
606 | *
607 | */
608 | public static void close(InputStream ins) {
609 | if (ins != null) {
610 | try {
611 | ins.close();
612 | } catch (IOException e) {
613 | // ignore
614 | }
615 | }
616 | }
617 |
618 | /**
619 | * OutputStream
620 | *
621 | * @param out
622 | * java.io.OutputStream
623 | *
624 | */
625 | public static void close(OutputStream out) {
626 | if (out != null) {
627 | try {
628 | out.close();
629 | } catch (IOException e) {
630 | // ignore
631 | }
632 | }
633 | }
634 |
635 | /**
636 | * BufferedReader
637 | *
638 | * @param buf
639 | * java.io.Reader
640 | */
641 | public static void close(Reader reader) {
642 | if (reader != null) {
643 | try {
644 | reader.close();
645 | } catch (IOException e) {
646 | // ignore
647 | }
648 | }
649 | }
650 |
651 | /**
652 | * BufferedReader
653 | *
654 | * @param buf
655 | * java.io.Reader
656 | */
657 | public static void close(Writer writer) {
658 | if (writer != null) {
659 | try {
660 | writer.close();
661 | } catch (IOException e) {
662 | // ignore
663 | }
664 | }
665 | }
666 | }
667 |
--------------------------------------------------------------------------------
/src/main/java/so/zjd/sstk/util/MailSender.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 zhanjindong. All rights reserved.
3 | */
4 | package so.zjd.sstk.util;
5 |
6 | import java.io.UnsupportedEncodingException;
7 | import java.util.Properties;
8 |
9 | import javax.activation.DataHandler;
10 | import javax.activation.DataSource;
11 | import javax.activation.FileDataSource;
12 | import javax.mail.Address;
13 | import javax.mail.Authenticator;
14 | import javax.mail.MessagingException;
15 | import javax.mail.PasswordAuthentication;
16 | import javax.mail.Session;
17 | import javax.mail.Transport;
18 | import javax.mail.internet.InternetAddress;
19 | import javax.mail.internet.MimeBodyPart;
20 | import javax.mail.internet.MimeMessage;
21 | import javax.mail.internet.MimeMultipart;
22 | import javax.mail.internet.MimeUtility;
23 |
24 | import org.apache.commons.io.FilenameUtils;
25 | import org.apache.commons.lang.StringUtils;
26 | import org.slf4j.Logger;
27 | import org.slf4j.LoggerFactory;
28 |
29 | /**
30 | *
31 | * Mail send helper class via smpt protocol.
32 | *
33 | * @author jdzhan,2014-12-6
34 | *
35 | */
36 | public class MailSender {
37 |
38 | private static final Logger LOGGER = LoggerFactory.getLogger(MailSender.class);
39 | private Properties config;
40 |
41 | public MailSender(Properties config) {
42 | this.config = config;
43 | }
44 |
45 | public void sendFrom(String subject, String filePath) {
46 | if (StringUtils.isEmpty(filePath)) {
47 | throw new IllegalArgumentException("the arg:filePath can not be null or empty");
48 | }
49 |
50 | LOGGER.debug("sending mail from path: " + filePath);
51 | MailUtil.send(subject, filePath, config);
52 | }
53 |
54 | private static class MailUtil {
55 | public static void send(String subject, String filePath, final Properties config) {
56 | Session session = Session.getInstance(config, new Authenticator() {
57 | @Override
58 | protected PasswordAuthentication getPasswordAuthentication() {
59 | return new PasswordAuthentication(config.getProperty("mail.userName"), config
60 | .getProperty("mail.password"));
61 | }
62 | });
63 |
64 | try {
65 | MimeMessage mimeMessage = new MimeMessage(session);
66 | mimeMessage.setSubject(subject, "UTF-8");
67 | mimeMessage.setFrom(new InternetAddress(config.getProperty("mail.from")));
68 | mimeMessage.setReplyTo(new Address[] { new InternetAddress(config.getProperty("mail.from")) });
69 | mimeMessage.setRecipients(MimeMessage.RecipientType.TO,
70 | InternetAddress.parse(config.getProperty("mail.to")));
71 |
72 | MimeMultipart mimeMultipart = new MimeMultipart("mixed");
73 | MimeBodyPart attch1 = new MimeBodyPart();
74 | mimeMultipart.addBodyPart(attch1);
75 | mimeMessage.setContent(mimeMultipart);
76 |
77 | DataSource ds1 = new FileDataSource(filePath);
78 | DataHandler dataHandler1 = new DataHandler(ds1);
79 | attch1.setDataHandler(dataHandler1);
80 | attch1.setFileName(MimeUtility.encodeText(FilenameUtils.getName(filePath)));
81 |
82 | mimeMessage.saveChanges();
83 |
84 | Transport.send(mimeMessage);
85 | } catch (MessagingException e) {
86 | throw new RuntimeException("MessagingException", e);
87 | } catch (UnsupportedEncodingException e) {
88 | throw new RuntimeException("UnsupportedEncodingException", e);
89 | }
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/src/main/java/so/zjd/sstk/util/PathUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 zhanjindong. All rights reserved.
3 | */
4 | package so.zjd.sstk.util;
5 |
6 | import java.io.File;
7 | import java.io.IOException;
8 | import java.io.UnsupportedEncodingException;
9 | import java.net.MalformedURLException;
10 | import java.net.URISyntaxException;
11 | import java.net.URL;
12 | import java.util.LinkedList;
13 | import java.util.List;
14 | import java.util.regex.Matcher;
15 | import java.util.regex.Pattern;
16 |
17 | import org.apache.commons.lang.StringUtils;
18 |
19 | /**
20 | * 文件路径工具类
21 | *
22 | *
23 | * @author jdzhan
24 | * @date 2014-3-19
25 | */
26 | public class PathUtils {
27 |
28 | /**
29 | * Normalize the path by suppressing sequences like "path/.." and inner
30 | * simple dots.
31 | *
32 | * The result is convenient for path comparison. For other uses, notice that
33 | * Windows separators ("\") are replaced by simple slashes.
34 | *
35 | * @param path
36 | * the original path
37 | * @return the normalized path
38 | */
39 | public static String cleanPath(String path) {
40 | if (StringUtils.isEmpty(path)) {
41 | return null;
42 | }
43 |
44 | // ClassLoader.getResource读取打包成jar内的路径。by jdzhan 2014-08-27
45 | if (path.startsWith("jar:file")) {
46 | path = cleanJarPath(path);
47 | }
48 |
49 | String pathToUse = StringUtils.replace(path, ResourceConstants.WINDOWS_FOLDER_SEPARATOR.getValue(),
50 | ResourceConstants.FOLDER_SEPARATOR.getValue());
51 |
52 | // Strip prefix from path to analyze, to not treat it as part of the
53 | // first path element. This is necessary to correctly parse paths like
54 | // "file:core/../core/io/Resource.class", where the ".." should just
55 | // strip the first "core" directory while keeping the "file:" prefix.
56 | int prefixIndex = pathToUse.indexOf(":");
57 | String prefix = "";
58 | if (prefixIndex != -1) {
59 | prefix = pathToUse.substring(0, prefixIndex + 1);
60 | pathToUse = pathToUse.substring(prefixIndex + 1);
61 | }
62 | if (pathToUse.startsWith(ResourceConstants.FOLDER_SEPARATOR.getValue())) {
63 | prefix = prefix + ResourceConstants.FOLDER_SEPARATOR.getValue();
64 | pathToUse = pathToUse.substring(1);
65 | }
66 |
67 | String[] pathArray = StringUtils.split(pathToUse, ResourceConstants.FOLDER_SEPARATOR.getValue());
68 | List pathElements = new LinkedList();
69 | int tops = 0;
70 |
71 | for (int i = pathArray.length - 1; i >= 0; i--) {
72 | String element = pathArray[i];
73 | if (ResourceConstants.CURRENT_PATH.getValue().equals(element)) {
74 | // Points to current directory - drop it.
75 | } else if (ResourceConstants.TOP_PATH.getValue().equals(element)) {
76 | // Registering top path found.
77 | tops++;
78 | } else {
79 | if (tops > 0) {
80 | // Merging path element with element corresponding to top
81 | // path.
82 | tops--;
83 | } else {
84 | // Normal path element found.
85 | pathElements.add(0, element);
86 | }
87 | }
88 | }
89 |
90 | // Remaining top paths need to be retained.
91 | for (int i = 0; i < tops; i++) {
92 | pathElements.add(0, ResourceConstants.TOP_PATH.getValue());
93 | }
94 |
95 | return prefix + StringUtils.join(pathElements, ResourceConstants.FOLDER_SEPARATOR.getValue());
96 | }
97 |
98 | /**
99 | *
100 | * 当打包成jar包后,通过class.getResource
或
101 | * ClassLoader.getResource
获取路径会类似这样:
102 | * jar:file:/c:/myapp/myapp.jar!/path...清理后为:file:/c:/myapp/path...
103 | *
104 | * @author jdzhan,2014-8-27
105 | *
106 | * @param original
107 | * @return
108 | */
109 | public static String cleanJarPath(String original) {
110 | // jar:file:/tmp/jdzhan/test.jar!/config/dbaccess/mysql
111 | original = original.substring(4);
112 | int index = original.indexOf("!");
113 | String left = original.substring(0, index);
114 | String right = original.substring(index + 1);
115 | index = left.lastIndexOf("/");
116 | left = left.substring(0, index);
117 | return left + right;
118 |
119 | }
120 |
121 | /**
122 | * Normalize the path by suppressing sequences like "path/.." and inner
123 | * simple dots.
124 | *
125 | * The result is convenient for path comparison. For other uses, notice that
126 | * Windows separators ("\") are replaced by simple slashes.
127 | *
128 | * @param originalUrl
129 | * the url with original path
130 | * @return the url with normalized path
131 | * @throws MalformedURLException
132 | * @throws URISyntaxException
133 | */
134 | public static URL cleanPath(URL originalUrl) throws MalformedURLException, URISyntaxException {
135 | String path = originalUrl.toString();
136 | if (StringUtils.isEmpty(path)) {
137 | return null;
138 | }
139 | URL curl = new URL(cleanPath(path));
140 | // curl.toURI().getPath()获取正确显示的中文路径。
141 | return new URL(curl.getProtocol(), curl.getHost(), curl.toURI().getPath());
142 | }
143 |
144 | /**
145 | *
146 | * 获取平台相关的绝对路径。
147 | *
148 | * windows下的路径分割符为"\",Unix*下为"/"。
149 | *
150 | * @author jdzhan,2014-7-28
151 | *
152 | * @param originalUrl
153 | * URL
154 | * @return 绝对路径
155 | */
156 | public static String getRealPath(URL originalUrl) {
157 | String fs = SeparatorUtils.getFileSeparator();
158 | String file = originalUrl.getFile();
159 | if (fs.equals("\\")) {
160 | return file.replace("/", fs);
161 | }
162 |
163 | return file;
164 | }
165 |
166 | /**
167 | *
168 | * 获取平台相关的绝对路径。
169 | *
170 | * @author jdzhan,2014-7-28
171 | *
172 | * @param locationPattern
173 | *
174 | * 0. 路径寻址前缀请参见{@link ResourceConstants}
175 | * 1. 使用file,classpath和classpath*做路径开头
176 | * 2. classpath寻址项目中的文件
177 | * 3. classpath*既寻址项目,也寻址jar包中的文件
178 | * 4. file寻址文件系统中的文件
179 | * 5. 默认是classpath 6.
180 | * 例如:classpath*:log/log4j.xml;file:/home/ydhl/
181 | * abc.sh;classpath:log/log4j.xml
182 | * @return 绝对路径
183 | * @throws IOException
184 | * @throws URISyntaxException
185 | */
186 | public static String getRealPath(String locationPattern) throws IOException, URISyntaxException {
187 | URL url = ResourceUtils.loadResource(locationPattern);
188 | return getRealPath(url);
189 | }
190 |
191 | /**
192 | *
193 | * 获取程序启动的classpath路径(文件系统),如果是jar包则返回jar包所在的目录路径。
194 | *
195 | *
196 | * @author jdzhan,2014-7-29
197 | *
198 | * @return
199 | * @throws UnsupportedEncodingException
200 | * @throws URISyntaxException
201 | */
202 | public static String getAppDir(Class> clazz) {
203 | File f;
204 | try {
205 | f = new File(getCodeLocation(clazz).toURI().getPath());
206 | return f.isFile() ? f.getParent() : f.getPath();
207 | } catch (URISyntaxException e) {
208 | throw new RuntimeException(e);
209 | }
210 |
211 | }
212 |
213 | /**
214 | * 获取代码所在的URL,即class文件所在的路径。
215 | *
216 | * NOTE:
217 | * war包返回:file:/path/my-app/calsses/
218 | * 打包jar包则返回:file:/path/my-app/my-app.jar.
219 | *
220 | * @author jdzhan,2014-8-27
221 | *
222 | * @return URL
223 | */
224 | public static URL getCodeLocation(Class> clazz) {
225 | URL codeLocation = null;
226 | // If CodeSource didn't work, Class.getResource
227 | // instead.
228 | URL r = clazz.getResource("");
229 | synchronized (r) {
230 | String s = r.toString();
231 | Pattern jrare = Pattern.compile("jar:\\s?(.*)!/.*");
232 | Matcher m = jrare.matcher(s);
233 | if (m.find()) { // the code is run from a jar file.
234 | s = m.group(1);
235 | } else {
236 | String p = clazz.getPackage().getName().replace('.', '/');
237 | s = s.substring(0, s.lastIndexOf(p));
238 | }
239 | try {
240 | codeLocation = new URL(s);
241 | } catch (MalformedURLException e) {
242 | throw new RuntimeException(e);
243 | }
244 | }
245 | return codeLocation;
246 | }
247 |
248 | }
249 |
--------------------------------------------------------------------------------
/src/main/java/so/zjd/sstk/util/PunctuationConstants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 zhanjindong. All rights reserved.
3 | */
4 | package so.zjd.sstk.util;
5 |
6 | public enum PunctuationConstants {
7 | /** 逗号 */
8 | COMMA(","),
9 |
10 | /** 分号 */
11 | SEMI_COLON(";"),
12 |
13 | /** 问号 */
14 | QUESTION_MARK("?"),
15 |
16 | /** 句号 */
17 | PERIOD("。"),
18 |
19 | /** 点 */
20 | POINT("."),
21 |
22 | /** 星 */
23 | STAR("*"),
24 |
25 | /** 冒号 */
26 | COLON(":");
27 |
28 | /** value */
29 | private String value;
30 |
31 | /**
32 | * constructor
33 | *
34 | * @param value
35 | * value
36 | */
37 | private PunctuationConstants(String value) {
38 | this.value = value;
39 | }
40 |
41 | /**
42 | * getter method
43 | *
44 | * @see PunctuationConstants#value
45 | * @return the value
46 | */
47 | public String getValue() {
48 | return value;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/so/zjd/sstk/util/RegexUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 zhanjindong. All rights reserved.
3 | */
4 | package so.zjd.sstk.util;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 | import java.util.regex.Matcher;
9 | import java.util.regex.Pattern;
10 |
11 | import org.apache.commons.lang.StringUtils;
12 |
13 | /**
14 | *
15 | * 封装一些常用的正则匹配操作。
16 | *
17 | *
18 | * @author jdzhan,2014-7-29
19 | *
20 | */
21 | public class RegexUtils {
22 |
23 | /** 手机号码 */
24 | private static final String CHN_MOBILE_PHONE = "^(1(([35][0-9])|(47)|(70)|(76)|(77)|(78)|[8][012356789]))\\d{8}$";
25 | /** 邮箱地址 */
26 | private static final String EMAIL = "(\\w|-)+@(\\w|\\.)+";
27 | /** IP地址 */
28 | private static final String IP = "(((1[0-9]{2}|(2[0-4][0-9]|25[0-5]))|[1-9]?[0-9])\\.){3}((1[0-9]{2}|(2[0-4][0-9]|25[0-5]))|[1-9]?[0-9])";
29 |
30 | /**
31 | *
32 | * 将整个输入串与模式匹配。
33 | *
34 | * @param regex
35 | * 正则表达式
36 | * @param input
37 | * 需要匹配的字符串
38 | * @param caseInsensitive
39 | * 是否忽略大小写
40 | * @return true 或 false
41 | */
42 | public static boolean match(String regex, String input, boolean caseInsensitive) {
43 | if (StringUtils.isEmpty(regex) || StringUtils.isEmpty(input))
44 | return false;
45 |
46 | Pattern pat = null;
47 | if (caseInsensitive) {
48 | pat = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
49 | } else {
50 | pat = Pattern.compile(regex);
51 | }
52 |
53 | Matcher m = pat.matcher(input);
54 | return m.matches();
55 | }
56 |
57 | /**
58 | *
59 | * 查找输入串中与模式匹配的所有子串。
60 | *
61 | * @param regex
62 | * 正则表达式
63 | * @param input
64 | * 输入的字符串
65 | * @param caseInsensitive
66 | * 是否忽略大小写
67 | * @return 匹配到的子串列表
68 | */
69 | public static List findAll(String regex, String input, boolean caseInsensitive) {
70 | List result = new ArrayList();
71 | if (StringUtils.isEmpty(regex) || StringUtils.isEmpty(input))
72 | return result;
73 |
74 | Pattern pat = null;
75 | if (caseInsensitive) {
76 | pat = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
77 | } else {
78 | pat = Pattern.compile(regex);
79 | }
80 |
81 | Matcher m = pat.matcher(input);
82 | while (m.find()) {
83 | result.add(m.group(0));
84 | }
85 | return result;
86 | }
87 |
88 | /**
89 | *
90 | * 用给定的模式去分割输入的字符串。
91 | *
92 | * @param regex
93 | * 正则表达式
94 | * @param input
95 | * 输入字符串
96 | * @param caseInsensitive
97 | * 是否忽略大小写
98 | * @return 分割后的数组
99 | */
100 | public static String[] split(String regex, String input, boolean caseInsensitive) {
101 | if (StringUtils.isEmpty(regex) || StringUtils.isEmpty(input))
102 | throw new IllegalArgumentException("regex and value can not be null or empty!");
103 |
104 | Pattern pat = null;
105 | if (caseInsensitive) {
106 | pat = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
107 | } else {
108 | pat = Pattern.compile(regex);
109 | }
110 |
111 | String[] result = pat.split(input);
112 |
113 | return result;
114 | }
115 |
116 | /**
117 | *
118 | * 替换输入字符串中所有匹配到的子串。
119 | *
120 | * @param regex
121 | * 正则表达式
122 | * @param input
123 | * 输入的字符串
124 | * @param replacement
125 | * 替换的字符串
126 | * @param caseInsensitive
127 | * 是否忽略大小写
128 | * @return 替换后的字符串
129 | */
130 | public static String replaceAll(String regex, String input, String replacement, boolean caseInsensitive) {
131 | if (StringUtils.isEmpty(regex) || StringUtils.isEmpty(input) || replacement == null)
132 | throw new IllegalArgumentException("regex,source and replace can not be empty or null!");
133 |
134 | Pattern pat = null;
135 | if (caseInsensitive) {
136 | pat = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
137 | } else {
138 | pat = Pattern.compile(regex);
139 | }
140 | Matcher m = pat.matcher(input);
141 | return m.replaceAll(replacement);
142 | }
143 |
144 | /**
145 | *
146 | * 验证字符串是否是IPv4格式。
147 | *
148 | * @param input
149 | * 输入的字符串
150 | * @return true 或 false
151 | */
152 | public static boolean isIPv4(String input) {
153 | return match(IP, input, false);
154 | }
155 |
156 | /**
157 | *
158 | * 验证字符串是否是电子邮箱地址格式。
159 | *
160 | * @param input
161 | * 输入的字符串
162 | * @return true 或 false
163 | */
164 | public static boolean isEmailAddress(String input) {
165 | return match(EMAIL, input, false);
166 | }
167 |
168 | /**
169 | *
170 | * 验证字符串是否是中国手机号码格式。
171 | *
172 | * @param input
173 | * 输入的字符串
174 | * @return true 或 false
175 | */
176 | public static boolean isCHNMobile(String input) {
177 | return match(CHN_MOBILE_PHONE, input, false);
178 | }
179 | }
180 |
--------------------------------------------------------------------------------
/src/main/java/so/zjd/sstk/util/ResourceConstants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 zhanjindong. All rights reserved.
3 | */
4 | package so.zjd.sstk.util;
5 |
6 | public enum ResourceConstants {
7 | /** 从项目和jar中读取资源的URL前缀 */
8 | CLASSPATH_ALL_URL_PREFIX("classpath*:"),
9 |
10 | /** 从项目中读取资源的URL前缀 */
11 | CLASSPATH_URL_PREFIX("classpath:"),
12 |
13 | /** 从文件系统中读取资源的URL前缀 */
14 | FILE_URL_PREFIX("file:"),
15 |
16 | /** 上层路径 */
17 | TOP_PATH(".."),
18 |
19 | /** 当前路径 */
20 | CURRENT_PATH("."),
21 |
22 | /** linux文件夹分隔符 */
23 | FOLDER_SEPARATOR("/"),
24 |
25 | /** windows文件分隔符 */
26 | WINDOWS_FOLDER_SEPARATOR("\\");
27 |
28 | private String value;
29 |
30 | private ResourceConstants(String value) {
31 | this.value = value;
32 | }
33 |
34 | public String getValue() {
35 | return value;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/so/zjd/sstk/util/ResourceUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 zhanjindong. All rights reserved.
3 | */
4 | package so.zjd.sstk.util;
5 |
6 | import java.io.File;
7 | import java.io.IOException;
8 | import java.net.MalformedURLException;
9 | import java.net.URISyntaxException;
10 | import java.net.URL;
11 | import java.util.Enumeration;
12 | import java.util.Iterator;
13 | import java.util.LinkedHashSet;
14 | import java.util.Set;
15 |
16 | import org.apache.commons.io.FileUtils;
17 | import org.apache.commons.io.filefilter.WildcardFileFilter;
18 | import org.apache.commons.lang.ArrayUtils;
19 | import org.apache.commons.lang.StringUtils;
20 |
21 | /**
22 | *
23 | * 文件路径寻址工具。
24 | *
25 | * @author jdzhan,2014-12-6
26 | *
27 | */
28 | public class ResourceUtils {
29 | /** 加锁工具 */
30 | private static final byte[] BYTES = new byte[0];
31 |
32 | /** {@link ClassLoader} */
33 | private static ClassLoader classLoader;
34 |
35 | public static URL loadResource(String locationPattern) throws IOException, URISyntaxException {
36 | URL[] urlArray = loadResources(locationPattern);
37 |
38 | return ArrayUtils.isEmpty(urlArray) ? null : urlArray[0];
39 | }
40 |
41 | /**
42 | * 从项目,jar或文件系统中读取指定路径的文件
43 | *
44 | *
45 | * @author chen.chen.9, 2014-3-19
46 | * @author jdzhan,支持file通配符*寻址
47 | * @param locationPattern
48 | *
49 | * 0. 路径寻址前缀请参见{@link ResourceConstants}
50 | * 1. 使用file,classpath和classpath*做路径开头
51 | * 2. classpath寻址项目中的文件
52 | * 3. classpath*既寻址项目,也寻址jar包中的文件
53 | * 4. file寻址文件系统中的文件
54 | * 5. 默认是classpath 6.
55 | * 例如:classpath*:log/log4j.xml;file:/home/ydhl/
56 | * abc.sh;classpath:log/log4j.xml
57 | * @return 以URL返回结果
58 | * @throws IOException
59 | * @throws URISyntaxException
60 | * 中文路径支持
61 | */
62 | public static URL[] loadResources(String locationPattern) throws IOException, URISyntaxException {
63 | if (locationPattern.startsWith(ResourceConstants.CLASSPATH_ALL_URL_PREFIX.getValue())) {
64 | return load1(locationPattern);
65 | } else if (locationPattern.startsWith(ResourceConstants.CLASSPATH_URL_PREFIX.getValue())) {
66 | return load2(locationPattern);
67 | } else if (locationPattern.startsWith(ResourceConstants.FILE_URL_PREFIX.getValue())) {
68 | return load3(locationPattern);
69 | } else {
70 | // 默认为文件系统路径。
71 | locationPattern = "file:" + locationPattern;
72 | return ResourceUtils.loadResources(locationPattern);
73 | }
74 | }
75 |
76 | private static URL[] load1(String locationPattern) throws IOException, URISyntaxException {
77 | String location = locationPattern.substring(ResourceConstants.CLASSPATH_ALL_URL_PREFIX.getValue().length());
78 | if (location.startsWith(ResourceConstants.FOLDER_SEPARATOR.getValue())) {
79 | location = location.substring(1);
80 | }
81 |
82 | Enumeration resourceUrls = getDefaultClassLoader().getResources(location);
83 | Set result = new LinkedHashSet(16);
84 | while (resourceUrls.hasMoreElements()) {
85 | URL url = resourceUrls.nextElement();
86 | result.add(PathUtils.cleanPath(url));
87 | }
88 | return result.toArray(new URL[result.size()]);
89 | }
90 |
91 | private static URL[] load2(String locationPattern) throws URISyntaxException, IOException {
92 | String location = locationPattern.substring(ResourceConstants.CLASSPATH_URL_PREFIX.getValue().length());
93 | if (location.startsWith(ResourceConstants.FOLDER_SEPARATOR.getValue())) {
94 | location = location.substring(1);
95 | }
96 |
97 | String cleanPath = PathUtils.cleanPath(location);
98 | // 只支持文件的通配符匹配,不支持文件夹的通配符匹配
99 | // 如需实现文件夹的通配符匹配,请参照spring.utils包,较复杂
100 | if (StringUtils.contains(cleanPath, PunctuationConstants.STAR.getValue())
101 | || StringUtils.contains(cleanPath, PunctuationConstants.QUESTION_MARK.getValue())) {
102 | String directoryPath = StringUtils.substringBeforeLast(locationPattern,
103 | ResourceConstants.FOLDER_SEPARATOR.getValue());
104 | File directory = new File(ResourceUtils.loadResource(directoryPath).toURI().getPath());
105 |
106 | String filePattern = StringUtils.substringAfter(cleanPath, ResourceConstants.FOLDER_SEPARATOR.getValue());
107 | while (filePattern.contains(ResourceConstants.FOLDER_SEPARATOR.getValue())) {
108 | filePattern = StringUtils.substringAfter(filePattern, ResourceConstants.FOLDER_SEPARATOR.getValue());
109 | }
110 |
111 | Set result = new LinkedHashSet(16);
112 | Iterator iterator = FileUtils.iterateFiles(directory, new WildcardFileFilter(filePattern), null);
113 | while (iterator.hasNext()) {
114 | result.add(iterator.next().toURI().toURL());
115 | }
116 |
117 | return result.toArray(new URL[result.size()]);
118 | } else {
119 | // a single resource with the given name
120 | URL url = getDefaultClassLoader().getResource(cleanPath);
121 | // if (url == null) {
122 | // throw new UnsupportedOperationException(cleanPath);
123 | // }
124 | return url == null ? null : new URL[] { PathUtils.cleanPath(url) };
125 | }
126 | }
127 |
128 | private static URL[] load3(String locationPattern) throws MalformedURLException {
129 | if (StringUtils.contains(locationPattern, PunctuationConstants.STAR.getValue())
130 | || StringUtils.contains(locationPattern, PunctuationConstants.QUESTION_MARK.getValue())) {
131 | String directoryPath = StringUtils.substringBeforeLast(locationPattern,
132 | ResourceConstants.FOLDER_SEPARATOR.getValue());
133 | directoryPath = StringUtils.substringAfter(directoryPath, ResourceConstants.FILE_URL_PREFIX.getValue());
134 | File directory = new File(directoryPath);
135 | String filePattern = StringUtils.substringAfter(locationPattern,
136 | ResourceConstants.FOLDER_SEPARATOR.getValue());
137 | while (filePattern.contains(ResourceConstants.FOLDER_SEPARATOR.getValue())) {
138 | filePattern = StringUtils.substringAfter(filePattern, ResourceConstants.FOLDER_SEPARATOR.getValue());
139 | }
140 |
141 | Set result = new LinkedHashSet(16);
142 | Iterator iterator = FileUtils.iterateFiles(directory, new WildcardFileFilter(filePattern), null);
143 | while (iterator.hasNext()) {
144 | result.add(iterator.next().toURI().toURL());
145 | }
146 |
147 | return result.toArray(new URL[result.size()]);
148 | } else {
149 | // a single resource with the given name
150 | URL url = new URL(locationPattern);
151 | return new File(url.getFile()).exists() ? new URL[] { url } : null;
152 | }
153 | }
154 |
155 | /**
156 | * 获取运行时classloader,首选线程上下文classloader,其次选择类classloader
157 | *
158 | *
159 | * @author chen.chen.9, 2014-3-20
160 | * @return {@link ClassLoader}
161 | */
162 | public static ClassLoader getDefaultClassLoader() {
163 | if (classLoader != null) {
164 | return classLoader;
165 | }
166 |
167 | synchronized (BYTES) {
168 | if (classLoader == null) {
169 | ClassLoader tempClassLoader = null;
170 | try {
171 | tempClassLoader = Thread.currentThread().getContextClassLoader();
172 | } catch (Exception ex) {
173 | // Cannot access thread context ClassLoader - falling back
174 | // to system class loader...
175 | }
176 |
177 | if (tempClassLoader == null) {
178 | // No thread context class loader -> use class loader of
179 | // this class.
180 | tempClassLoader = ResourceUtils.class.getClassLoader();
181 | }
182 |
183 | classLoader = tempClassLoader;
184 | }
185 | }
186 |
187 | return classLoader;
188 | }
189 | }
--------------------------------------------------------------------------------
/src/main/java/so/zjd/sstk/util/SeparatorUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2014 zhanjindong. All rights reserved.
3 | */
4 | package so.zjd.sstk.util;
5 |
6 | import java.util.Properties;
7 |
8 | /**
9 | *
10 | * Separators.
11 | *
12 | * @author jdzhan,2014-12-6
13 | *
14 | */
15 | public class SeparatorUtils {
16 |
17 | /* system properties to get separators */
18 | static final Properties PROPERTIES = new Properties(System.getProperties());
19 |
20 | /**
21 | * get line separator on current platform
22 | *
23 | * @return line separator
24 | */
25 | public static String getLineSeparator() {
26 | return PROPERTIES.getProperty("line.separator");
27 | }
28 |
29 | /**
30 | * get path separator on current platform
31 | *
32 | * @return path separator
33 | */
34 | public static String getPathSeparator() {
35 | return PROPERTIES.getProperty("path.separator");
36 | }
37 |
38 | /**
39 | * get file separator on current platform
40 | *
41 | * @return path separator
42 | */
43 | public static String getFileSeparator() {
44 | return PROPERTIES.getProperty("file.separator");
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/resources/SimpleSendToKindle.json:
--------------------------------------------------------------------------------
1 | {
2 | "name":"so.zjd.sstk",
3 | "description":"Simple Send to Kindle(by zjd.so)",
4 | "path":"startup.exe",//如果有必须用双引号
5 | "type":"stdio",
6 | "allowed_origins":[
7 | "chrome-extension://jnihbngmnjbmchfhcdfabofamnfcljaf/"
8 |
9 | ]
10 | }
--------------------------------------------------------------------------------
/src/main/resources/bin/kindlegen.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhanjindong/SimpleSendToKindle/e011dbbf57954ae855dde84a701a13f94d97af27/src/main/resources/bin/kindlegen.exe
--------------------------------------------------------------------------------
/src/main/resources/ext/chrome/jquery-2.0.0.min.js:
--------------------------------------------------------------------------------
1 | /*! jQuery v2.0.0 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
2 | //@ sourceMappingURL=jquery.min.map
3 | */
4 | (function(e,undefined){var t,n,r=typeof undefined,i=e.location,o=e.document,s=o.documentElement,a=e.jQuery,u=e.$,l={},c=[],f="2.0.0",p=c.concat,h=c.push,d=c.slice,g=c.indexOf,m=l.toString,y=l.hasOwnProperty,v=f.trim,x=function(e,n){return new x.fn.init(e,n,t)},b=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,w=/\S+/g,T=/^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,C=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,k=/^-ms-/,N=/-([\da-z])/gi,E=function(e,t){return t.toUpperCase()},S=function(){o.removeEventListener("DOMContentLoaded",S,!1),e.removeEventListener("load",S,!1),x.ready()};x.fn=x.prototype={jquery:f,constructor:x,init:function(e,t,n){var r,i;if(!e)return this;if("string"==typeof e){if(r="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:T.exec(e),!r||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof x?t[0]:t,x.merge(this,x.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:o,!0)),C.test(r[1])&&x.isPlainObject(t))for(r in t)x.isFunction(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return i=o.getElementById(r[2]),i&&i.parentNode&&(this.length=1,this[0]=i),this.context=o,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):x.isFunction(e)?n.ready(e):(e.selector!==undefined&&(this.selector=e.selector,this.context=e.context),x.makeArray(e,this))},selector:"",length:0,toArray:function(){return d.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=x.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return x.each(this,e,t)},ready:function(e){return x.ready.promise().done(e),this},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(x.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:h,sort:[].sort,splice:[].splice},x.fn.init.prototype=x.fn,x.extend=x.fn.extend=function(){var e,t,n,r,i,o,s=arguments[0]||{},a=1,u=arguments.length,l=!1;for("boolean"==typeof s&&(l=s,s=arguments[1]||{},a=2),"object"==typeof s||x.isFunction(s)||(s={}),u===a&&(s=this,--a);u>a;a++)if(null!=(e=arguments[a]))for(t in e)n=s[t],r=e[t],s!==r&&(l&&r&&(x.isPlainObject(r)||(i=x.isArray(r)))?(i?(i=!1,o=n&&x.isArray(n)?n:[]):o=n&&x.isPlainObject(n)?n:{},s[t]=x.extend(l,o,r)):r!==undefined&&(s[t]=r));return s},x.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),noConflict:function(t){return e.$===x&&(e.$=u),t&&e.jQuery===x&&(e.jQuery=a),x},isReady:!1,readyWait:1,holdReady:function(e){e?x.readyWait++:x.ready(!0)},ready:function(e){(e===!0?--x.readyWait:x.isReady)||(x.isReady=!0,e!==!0&&--x.readyWait>0||(n.resolveWith(o,[x]),x.fn.trigger&&x(o).trigger("ready").off("ready")))},isFunction:function(e){return"function"===x.type(e)},isArray:Array.isArray,isWindow:function(e){return null!=e&&e===e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[m.call(e)]||"object":typeof e},isPlainObject:function(e){if("object"!==x.type(e)||e.nodeType||x.isWindow(e))return!1;try{if(e.constructor&&!y.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}return!0},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||o;var r=C.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=x.buildFragment([e],t,i),i&&x(i).remove(),x.merge([],r.childNodes))},parseJSON:JSON.parse,parseXML:function(e){var t,n;if(!e||"string"!=typeof e)return null;try{n=new DOMParser,t=n.parseFromString(e,"text/xml")}catch(r){t=undefined}return(!t||t.getElementsByTagName("parsererror").length)&&x.error("Invalid XML: "+e),t},noop:function(){},globalEval:function(e){var t,n=eval;e=x.trim(e),e&&(1===e.indexOf("use strict")?(t=o.createElement("script"),t.text=e,o.head.appendChild(t).parentNode.removeChild(t)):n(e))},camelCase:function(e){return e.replace(k,"ms-").replace(N,E)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,s=j(e);if(n){if(s){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(s){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:function(e){return null==e?"":v.call(e)},makeArray:function(e,t){var n=t||[];return null!=e&&(j(Object(e))?x.merge(n,"string"==typeof e?[e]:e):h.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:g.call(t,e,n)},merge:function(e,t){var n=t.length,r=e.length,i=0;if("number"==typeof n)for(;n>i;i++)e[r++]=t[i];else while(t[i]!==undefined)e[r++]=t[i++];return e.length=r,e},grep:function(e,t,n){var r,i=[],o=0,s=e.length;for(n=!!n;s>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,s=j(e),a=[];if(s)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(a[a.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(a[a.length]=r);return p.apply([],a)},guid:1,proxy:function(e,t){var n,r,i;return"string"==typeof t&&(n=e[t],t=e,e=n),x.isFunction(e)?(r=d.call(arguments,2),i=function(){return e.apply(t||this,r.concat(d.call(arguments)))},i.guid=e.guid=e.guid||x.guid++,i):undefined},access:function(e,t,n,r,i,o,s){var a=0,u=e.length,l=null==n;if("object"===x.type(n)){i=!0;for(a in n)x.access(e,t,a,n[a],!0,o,s)}else if(r!==undefined&&(i=!0,x.isFunction(r)||(s=!0),l&&(s?(t.call(e,r),t=null):(l=t,t=function(e,t,n){return l.call(x(e),n)})),t))for(;u>a;a++)t(e[a],n,s?r:r.call(e[a],a,t(e[a],n)));return i?e:l?t.call(e):u?t(e[0],n):o},now:Date.now,swap:function(e,t,n,r){var i,o,s={};for(o in t)s[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=s[o];return i}}),x.ready.promise=function(t){return n||(n=x.Deferred(),"complete"===o.readyState?setTimeout(x.ready):(o.addEventListener("DOMContentLoaded",S,!1),e.addEventListener("load",S,!1))),n.promise(t)},x.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){l["[object "+t+"]"]=t.toLowerCase()});function j(e){var t=e.length,n=x.type(e);return x.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}t=x(o),function(e,undefined){var t,n,r,i,o,s,a,u,l,c,f,p,h,d,g,m,y="sizzle"+-new Date,v=e.document,b={},w=0,T=0,C=ot(),k=ot(),N=ot(),E=!1,S=function(){return 0},j=typeof undefined,D=1<<31,A=[],L=A.pop,q=A.push,H=A.push,O=A.slice,F=A.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},P="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",R="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",W=M.replace("w","w#"),$="\\["+R+"*("+M+")"+R+"*(?:([*^$|!~]?=)"+R+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+W+")|)|)"+R+"*\\]",B=":("+M+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+$.replace(3,8)+")*)|.*)\\)|)",I=RegExp("^"+R+"+|((?:^|[^\\\\])(?:\\\\.)*)"+R+"+$","g"),z=RegExp("^"+R+"*,"+R+"*"),_=RegExp("^"+R+"*([>+~]|"+R+")"+R+"*"),X=RegExp(R+"*[+~]"),U=RegExp("="+R+"*([^\\]'\"]*)"+R+"*\\]","g"),Y=RegExp(B),V=RegExp("^"+W+"$"),G={ID:RegExp("^#("+M+")"),CLASS:RegExp("^\\.("+M+")"),TAG:RegExp("^("+M.replace("w","w*")+")"),ATTR:RegExp("^"+$),PSEUDO:RegExp("^"+B),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+R+"*(even|odd|(([+-]|)(\\d*)n|)"+R+"*(?:([+-]|)"+R+"*(\\d+)|))"+R+"*\\)|)","i"),"boolean":RegExp("^(?:"+P+")$","i"),needsContext:RegExp("^"+R+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+R+"*((?:-\\d)?\\d*)"+R+"*\\)|)(?=[^-]|$)","i")},J=/^[^{]+\{\s*\[native \w/,Q=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,K=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,et=/'|\\/g,tt=/\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,nt=function(e,t){var n="0x"+t-65536;return n!==n?t:0>n?String.fromCharCode(n+65536):String.fromCharCode(55296|n>>10,56320|1023&n)};try{H.apply(A=O.call(v.childNodes),v.childNodes),A[v.childNodes.length].nodeType}catch(rt){H={apply:A.length?function(e,t){q.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function it(e){return J.test(e+"")}function ot(){var e,t=[];return e=function(n,i){return t.push(n+=" ")>r.cacheLength&&delete e[t.shift()],e[n]=i}}function st(e){return e[y]=!0,e}function at(e){var t=c.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function ut(e,t,n,r){var i,o,s,a,u,f,d,g,x,w;if((t?t.ownerDocument||t:v)!==c&&l(t),t=t||c,n=n||[],!e||"string"!=typeof e)return n;if(1!==(a=t.nodeType)&&9!==a)return[];if(p&&!r){if(i=Q.exec(e))if(s=i[1]){if(9===a){if(o=t.getElementById(s),!o||!o.parentNode)return n;if(o.id===s)return n.push(o),n}else if(t.ownerDocument&&(o=t.ownerDocument.getElementById(s))&&m(t,o)&&o.id===s)return n.push(o),n}else{if(i[2])return H.apply(n,t.getElementsByTagName(e)),n;if((s=i[3])&&b.getElementsByClassName&&t.getElementsByClassName)return H.apply(n,t.getElementsByClassName(s)),n}if(b.qsa&&(!h||!h.test(e))){if(g=d=y,x=t,w=9===a&&e,1===a&&"object"!==t.nodeName.toLowerCase()){f=gt(e),(d=t.getAttribute("id"))?g=d.replace(et,"\\$&"):t.setAttribute("id",g),g="[id='"+g+"'] ",u=f.length;while(u--)f[u]=g+mt(f[u]);x=X.test(e)&&t.parentNode||t,w=f.join(",")}if(w)try{return H.apply(n,x.querySelectorAll(w)),n}catch(T){}finally{d||t.removeAttribute("id")}}}return kt(e.replace(I,"$1"),t,n,r)}o=ut.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},l=ut.setDocument=function(e){var t=e?e.ownerDocument||e:v;return t!==c&&9===t.nodeType&&t.documentElement?(c=t,f=t.documentElement,p=!o(t),b.getElementsByTagName=at(function(e){return e.appendChild(t.createComment("")),!e.getElementsByTagName("*").length}),b.attributes=at(function(e){return e.className="i",!e.getAttribute("className")}),b.getElementsByClassName=at(function(e){return e.innerHTML="
",e.firstChild.className="i",2===e.getElementsByClassName("i").length}),b.sortDetached=at(function(e){return 1&e.compareDocumentPosition(c.createElement("div"))}),b.getById=at(function(e){return f.appendChild(e).id=y,!t.getElementsByName||!t.getElementsByName(y).length}),b.getById?(r.find.ID=function(e,t){if(typeof t.getElementById!==j&&p){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},r.filter.ID=function(e){var t=e.replace(tt,nt);return function(e){return e.getAttribute("id")===t}}):(r.find.ID=function(e,t){if(typeof t.getElementById!==j&&p){var n=t.getElementById(e);return n?n.id===e||typeof n.getAttributeNode!==j&&n.getAttributeNode("id").value===e?[n]:undefined:[]}},r.filter.ID=function(e){var t=e.replace(tt,nt);return function(e){var n=typeof e.getAttributeNode!==j&&e.getAttributeNode("id");return n&&n.value===t}}),r.find.TAG=b.getElementsByTagName?function(e,t){return typeof t.getElementsByTagName!==j?t.getElementsByTagName(e):undefined}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},r.find.CLASS=b.getElementsByClassName&&function(e,t){return typeof t.getElementsByClassName!==j&&p?t.getElementsByClassName(e):undefined},d=[],h=[],(b.qsa=it(t.querySelectorAll))&&(at(function(e){e.innerHTML="",e.querySelectorAll("[selected]").length||h.push("\\["+R+"*(?:value|"+P+")"),e.querySelectorAll(":checked").length||h.push(":checked")}),at(function(e){var t=c.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("t",""),e.querySelectorAll("[t^='']").length&&h.push("[*^$]="+R+"*(?:''|\"\")"),e.querySelectorAll(":enabled").length||h.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),h.push(",.*:")})),(b.matchesSelector=it(g=f.webkitMatchesSelector||f.mozMatchesSelector||f.oMatchesSelector||f.msMatchesSelector))&&at(function(e){b.disconnectedMatch=g.call(e,"div"),g.call(e,"[s!='']:x"),d.push("!=",B)}),h=h.length&&RegExp(h.join("|")),d=d.length&&RegExp(d.join("|")),m=it(f.contains)||f.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},S=f.compareDocumentPosition?function(e,n){if(e===n)return E=!0,0;var r=n.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(n);return r?1&r||!b.sortDetached&&n.compareDocumentPosition(e)===r?e===t||m(v,e)?-1:n===t||m(v,n)?1:u?F.call(u,e)-F.call(u,n):0:4&r?-1:1:e.compareDocumentPosition?-1:1}:function(e,n){var r,i=0,o=e.parentNode,s=n.parentNode,a=[e],l=[n];if(e===n)return E=!0,0;if(!o||!s)return e===t?-1:n===t?1:o?-1:s?1:u?F.call(u,e)-F.call(u,n):0;if(o===s)return lt(e,n);r=e;while(r=r.parentNode)a.unshift(r);r=n;while(r=r.parentNode)l.unshift(r);while(a[i]===l[i])i++;return i?lt(a[i],l[i]):a[i]===v?-1:l[i]===v?1:0},c):c},ut.matches=function(e,t){return ut(e,null,null,t)},ut.matchesSelector=function(e,t){if((e.ownerDocument||e)!==c&&l(e),t=t.replace(U,"='$1']"),!(!b.matchesSelector||!p||d&&d.test(t)||h&&h.test(t)))try{var n=g.call(e,t);if(n||b.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(r){}return ut(t,c,null,[e]).length>0},ut.contains=function(e,t){return(e.ownerDocument||e)!==c&&l(e),m(e,t)},ut.attr=function(e,t){(e.ownerDocument||e)!==c&&l(e);var n=r.attrHandle[t.toLowerCase()],i=n&&n(e,t,!p);return i===undefined?b.attributes||!p?e.getAttribute(t):(i=e.getAttributeNode(t))&&i.specified?i.value:null:i},ut.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},ut.uniqueSort=function(e){var t,n=[],r=0,i=0;if(E=!b.detectDuplicates,u=!b.sortStable&&e.slice(0),e.sort(S),E){while(t=e[i++])t===e[i]&&(r=n.push(i));while(r--)e.splice(n[r],1)}return e};function lt(e,t){var n=t&&e,r=n&&(~t.sourceIndex||D)-(~e.sourceIndex||D);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function ct(e,t,n){var r;return n?undefined:(r=e.getAttributeNode(t))&&r.specified?r.value:e[t]===!0?t.toLowerCase():null}function ft(e,t,n){var r;return n?undefined:r=e.getAttribute(t,"type"===t.toLowerCase()?1:2)}function pt(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function ht(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function dt(e){return st(function(t){return t=+t,st(function(n,r){var i,o=e([],n.length,t),s=o.length;while(s--)n[i=o[s]]&&(n[i]=!(r[i]=n[i]))})})}i=ut.getText=function(e){var t,n="",r=0,o=e.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=i(e)}else if(3===o||4===o)return e.nodeValue}else for(;t=e[r];r++)n+=i(t);return n},r=ut.selectors={cacheLength:50,createPseudo:st,match:G,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(tt,nt),e[3]=(e[4]||e[5]||"").replace(tt,nt),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||ut.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&ut.error(e[0]),e},PSEUDO:function(e){var t,n=!e[5]&&e[2];return G.CHILD.test(e[0])?null:(e[4]?e[2]=e[4]:n&&Y.test(n)&&(t=gt(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(tt,nt).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=C[e+" "];return t||(t=RegExp("(^|"+R+")"+e+"("+R+"|$)"))&&C(e,function(e){return t.test("string"==typeof e.className&&e.className||typeof e.getAttribute!==j&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=ut.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),s="last"!==e.slice(-4),a="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,p,h,d,g=o!==s?"nextSibling":"previousSibling",m=t.parentNode,v=a&&t.nodeName.toLowerCase(),x=!u&&!a;if(m){if(o){while(g){f=t;while(f=f[g])if(a?f.nodeName.toLowerCase()===v:1===f.nodeType)return!1;d=g="only"===e&&!d&&"nextSibling"}return!0}if(d=[s?m.firstChild:m.lastChild],s&&x){c=m[y]||(m[y]={}),l=c[e]||[],h=l[0]===w&&l[1],p=l[0]===w&&l[2],f=h&&m.childNodes[h];while(f=++h&&f&&f[g]||(p=h=0)||d.pop())if(1===f.nodeType&&++p&&f===t){c[e]=[w,h,p];break}}else if(x&&(l=(t[y]||(t[y]={}))[e])&&l[0]===w)p=l[1];else while(f=++h&&f&&f[g]||(p=h=0)||d.pop())if((a?f.nodeName.toLowerCase()===v:1===f.nodeType)&&++p&&(x&&((f[y]||(f[y]={}))[e]=[w,p]),f===t))break;return p-=i,p===r||0===p%r&&p/r>=0}}},PSEUDO:function(e,t){var n,i=r.pseudos[e]||r.setFilters[e.toLowerCase()]||ut.error("unsupported pseudo: "+e);return i[y]?i(t):i.length>1?(n=[e,e,"",t],r.setFilters.hasOwnProperty(e.toLowerCase())?st(function(e,n){var r,o=i(e,t),s=o.length;while(s--)r=F.call(e,o[s]),e[r]=!(n[r]=o[s])}):function(e){return i(e,0,n)}):i}},pseudos:{not:st(function(e){var t=[],n=[],r=s(e.replace(I,"$1"));return r[y]?st(function(e,t,n,i){var o,s=r(e,null,i,[]),a=e.length;while(a--)(o=s[a])&&(e[a]=!(t[a]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:st(function(e){return function(t){return ut(e,t).length>0}}),contains:st(function(e){return function(t){return(t.textContent||t.innerText||i(t)).indexOf(e)>-1}}),lang:st(function(e){return V.test(e||"")||ut.error("unsupported lang: "+e),e=e.replace(tt,nt).toLowerCase(),function(t){var n;do if(n=p?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===f},focus:function(e){return e===c.activeElement&&(!c.hasFocus||c.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!r.pseudos.empty(e)},header:function(e){return Z.test(e.nodeName)},input:function(e){return K.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:dt(function(){return[0]}),last:dt(function(e,t){return[t-1]}),eq:dt(function(e,t,n){return[0>n?n+t:n]}),even:dt(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:dt(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:dt(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:dt(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}};for(t in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})r.pseudos[t]=pt(t);for(t in{submit:!0,reset:!0})r.pseudos[t]=ht(t);function gt(e,t){var n,i,o,s,a,u,l,c=k[e+" "];if(c)return t?0:c.slice(0);a=e,u=[],l=r.preFilter;while(a){(!n||(i=z.exec(a)))&&(i&&(a=a.slice(i[0].length)||a),u.push(o=[])),n=!1,(i=_.exec(a))&&(n=i.shift(),o.push({value:n,type:i[0].replace(I," ")}),a=a.slice(n.length));for(s in r.filter)!(i=G[s].exec(a))||l[s]&&!(i=l[s](i))||(n=i.shift(),o.push({value:n,type:s,matches:i}),a=a.slice(n.length));if(!n)break}return t?a.length:a?ut.error(e):k(e,u).slice(0)}function mt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function yt(e,t,r){var i=t.dir,o=r&&"parentNode"===i,s=T++;return t.first?function(t,n,r){while(t=t[i])if(1===t.nodeType||o)return e(t,n,r)}:function(t,r,a){var u,l,c,f=w+" "+s;if(a){while(t=t[i])if((1===t.nodeType||o)&&e(t,r,a))return!0}else while(t=t[i])if(1===t.nodeType||o)if(c=t[y]||(t[y]={}),(l=c[i])&&l[0]===f){if((u=l[1])===!0||u===n)return u===!0}else if(l=c[i]=[f],l[1]=e(t,r,a)||n,l[1]===!0)return!0}}function vt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function xt(e,t,n,r,i){var o,s=[],a=0,u=e.length,l=null!=t;for(;u>a;a++)(o=e[a])&&(!n||n(o,r,i))&&(s.push(o),l&&t.push(a));return s}function bt(e,t,n,r,i,o){return r&&!r[y]&&(r=bt(r)),i&&!i[y]&&(i=bt(i,o)),st(function(o,s,a,u){var l,c,f,p=[],h=[],d=s.length,g=o||Ct(t||"*",a.nodeType?[a]:a,[]),m=!e||!o&&t?g:xt(g,p,e,a,u),y=n?i||(o?e:d||r)?[]:s:m;if(n&&n(m,y,a,u),r){l=xt(y,h),r(l,[],a,u),c=l.length;while(c--)(f=l[c])&&(y[h[c]]=!(m[h[c]]=f))}if(o){if(i||e){if(i){l=[],c=y.length;while(c--)(f=y[c])&&l.push(m[c]=f);i(null,y=[],l,u)}c=y.length;while(c--)(f=y[c])&&(l=i?F.call(o,f):p[c])>-1&&(o[l]=!(s[l]=f))}}else y=xt(y===s?y.splice(d,y.length):y),i?i(null,s,y,u):H.apply(s,y)})}function wt(e){var t,n,i,o=e.length,s=r.relative[e[0].type],u=s||r.relative[" "],l=s?1:0,c=yt(function(e){return e===t},u,!0),f=yt(function(e){return F.call(t,e)>-1},u,!0),p=[function(e,n,r){return!s&&(r||n!==a)||((t=n).nodeType?c(e,n,r):f(e,n,r))}];for(;o>l;l++)if(n=r.relative[e[l].type])p=[yt(vt(p),n)];else{if(n=r.filter[e[l].type].apply(null,e[l].matches),n[y]){for(i=++l;o>i;i++)if(r.relative[e[i].type])break;return bt(l>1&&vt(p),l>1&&mt(e.slice(0,l-1)).replace(I,"$1"),n,i>l&&wt(e.slice(l,i)),o>i&&wt(e=e.slice(i)),o>i&&mt(e))}p.push(n)}return vt(p)}function Tt(e,t){var i=0,o=t.length>0,s=e.length>0,u=function(u,l,f,p,h){var d,g,m,y=[],v=0,x="0",b=u&&[],T=null!=h,C=a,k=u||s&&r.find.TAG("*",h&&l.parentNode||l),N=w+=null==C?1:Math.random()||.1;for(T&&(a=l!==c&&l,n=i);null!=(d=k[x]);x++){if(s&&d){g=0;while(m=e[g++])if(m(d,l,f)){p.push(d);break}T&&(w=N,n=++i)}o&&((d=!m&&d)&&v--,u&&b.push(d))}if(v+=x,o&&x!==v){g=0;while(m=t[g++])m(b,y,l,f);if(u){if(v>0)while(x--)b[x]||y[x]||(y[x]=L.call(p));y=xt(y)}H.apply(p,y),T&&!u&&y.length>0&&v+t.length>1&&ut.uniqueSort(p)}return T&&(w=N,a=C),b};return o?st(u):u}s=ut.compile=function(e,t){var n,r=[],i=[],o=N[e+" "];if(!o){t||(t=gt(e)),n=t.length;while(n--)o=wt(t[n]),o[y]?r.push(o):i.push(o);o=N(e,Tt(i,r))}return o};function Ct(e,t,n){var r=0,i=t.length;for(;i>r;r++)ut(e,t[r],n);return n}function kt(e,t,n,i){var o,a,u,l,c,f=gt(e);if(!i&&1===f.length){if(a=f[0]=f[0].slice(0),a.length>2&&"ID"===(u=a[0]).type&&9===t.nodeType&&p&&r.relative[a[1].type]){if(t=(r.find.ID(u.matches[0].replace(tt,nt),t)||[])[0],!t)return n;e=e.slice(a.shift().value.length)}o=G.needsContext.test(e)?0:a.length;while(o--){if(u=a[o],r.relative[l=u.type])break;if((c=r.find[l])&&(i=c(u.matches[0].replace(tt,nt),X.test(a[0].type)&&t.parentNode||t))){if(a.splice(o,1),e=i.length&&mt(a),!e)return H.apply(n,i),n;break}}}return s(e,f)(i,t,!p,n,X.test(e)),n}r.pseudos.nth=r.pseudos.eq;function Nt(){}Nt.prototype=r.filters=r.pseudos,r.setFilters=new Nt,b.sortStable=y.split("").sort(S).join("")===y,l(),[0,0].sort(S),b.detectDuplicates=E,at(function(e){if(e.innerHTML="","#"!==e.firstChild.getAttribute("href")){var t="type|href|height|width".split("|"),n=t.length;while(n--)r.attrHandle[t[n]]=ft}}),at(function(e){if(null!=e.getAttribute("disabled")){var t=P.split("|"),n=t.length;while(n--)r.attrHandle[t[n]]=ct}}),x.find=ut,x.expr=ut.selectors,x.expr[":"]=x.expr.pseudos,x.unique=ut.uniqueSort,x.text=ut.getText,x.isXMLDoc=ut.isXML,x.contains=ut.contains}(e);var D={};function A(e){var t=D[e]={};return x.each(e.match(w)||[],function(e,n){t[n]=!0}),t}x.Callbacks=function(e){e="string"==typeof e?D[e]||A(e):x.extend({},e);var t,n,r,i,o,s,a=[],u=!e.once&&[],l=function(f){for(t=e.memory&&f,n=!0,s=i||0,i=0,o=a.length,r=!0;a&&o>s;s++)if(a[s].apply(f[0],f[1])===!1&&e.stopOnFalse){t=!1;break}r=!1,a&&(u?u.length&&l(u.shift()):t?a=[]:c.disable())},c={add:function(){if(a){var n=a.length;(function s(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&c.has(n)||a.push(n):n&&n.length&&"string"!==r&&s(n)})})(arguments),r?o=a.length:t&&(i=n,l(t))}return this},remove:function(){return a&&x.each(arguments,function(e,t){var n;while((n=x.inArray(t,a,n))>-1)a.splice(n,1),r&&(o>=n&&o--,s>=n&&s--)}),this},has:function(e){return e?x.inArray(e,a)>-1:!(!a||!a.length)},empty:function(){return a=[],o=0,this},disable:function(){return a=u=t=undefined,this},disabled:function(){return!a},lock:function(){return u=undefined,t||c.disable(),this},locked:function(){return!u},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],!a||n&&!u||(r?u.push(t):l(t)),this},fire:function(){return c.fireWith(this,arguments),this},fired:function(){return!!n}};return c},x.extend({Deferred:function(e){var t=[["resolve","done",x.Callbacks("once memory"),"resolved"],["reject","fail",x.Callbacks("once memory"),"rejected"],["notify","progress",x.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return x.Deferred(function(n){x.each(t,function(t,o){var s=o[0],a=x.isFunction(e[t])&&e[t];i[o[1]](function(){var e=a&&a.apply(this,arguments);e&&x.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[s+"With"](this===r?n.promise():this,a?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?x.extend(e,r):r}},i={};return r.pipe=r.then,x.each(t,function(e,o){var s=o[2],a=o[3];r[o[1]]=s.add,a&&s.add(function(){n=a},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=s.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=d.call(arguments),r=n.length,i=1!==r||e&&x.isFunction(e.promise)?r:0,o=1===i?e:x.Deferred(),s=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?d.call(arguments):r,n===a?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},a,u,l;if(r>1)for(a=Array(r),u=Array(r),l=Array(r);r>t;t++)n[t]&&x.isFunction(n[t].promise)?n[t].promise().done(s(t,l,n)).fail(o.reject).progress(s(t,u,a)):--i;return i||o.resolveWith(l,n),o.promise()}}),x.support=function(t){var n=o.createElement("input"),r=o.createDocumentFragment(),i=o.createElement("div"),s=o.createElement("select"),a=s.appendChild(o.createElement("option"));return n.type?(n.type="checkbox",t.checkOn=""!==n.value,t.optSelected=a.selected,t.reliableMarginRight=!0,t.boxSizingReliable=!0,t.pixelPosition=!1,n.checked=!0,t.noCloneChecked=n.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!a.disabled,n=o.createElement("input"),n.value="t",n.type="radio",t.radioValue="t"===n.value,n.setAttribute("checked","t"),n.setAttribute("name","t"),r.appendChild(n),t.checkClone=r.cloneNode(!0).cloneNode(!0).lastChild.checked,t.focusinBubbles="onfocusin"in e,i.style.backgroundClip="content-box",i.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===i.style.backgroundClip,x(function(){var n,r,s="padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box",a=o.getElementsByTagName("body")[0];a&&(n=o.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",a.appendChild(n).appendChild(i),i.innerHTML="",i.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%",x.swap(a,null!=a.style.zoom?{zoom:1}:{},function(){t.boxSizing=4===i.offsetWidth}),e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(i,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(i,null)||{width:"4px"}).width,r=i.appendChild(o.createElement("div")),r.style.cssText=i.style.cssText=s,r.style.marginRight=r.style.width="0",i.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),a.removeChild(n))}),t):t}({});var L,q,H=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,O=/([A-Z])/g;function F(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=x.expando+Math.random()}F.uid=1,F.accepts=function(e){return e.nodeType?1===e.nodeType||9===e.nodeType:!0},F.prototype={key:function(e){if(!F.accepts(e))return 0;var t={},n=e[this.expando];if(!n){n=F.uid++;try{t[this.expando]={value:n},Object.defineProperties(e,t)}catch(r){t[this.expando]=n,x.extend(e,t)}}return this.cache[n]||(this.cache[n]={}),n},set:function(e,t,n){var r,i=this.key(e),o=this.cache[i];if("string"==typeof t)o[t]=n;else if(x.isEmptyObject(o))this.cache[i]=t;else for(r in t)o[r]=t[r]},get:function(e,t){var n=this.cache[this.key(e)];return t===undefined?n:n[t]},access:function(e,t,n){return t===undefined||t&&"string"==typeof t&&n===undefined?this.get(e,t):(this.set(e,t,n),n!==undefined?n:t)},remove:function(e,t){var n,r,i=this.key(e),o=this.cache[i];if(t===undefined)this.cache[i]={};else{x.isArray(t)?r=t.concat(t.map(x.camelCase)):t in o?r=[t]:(r=x.camelCase(t),r=r in o?[r]:r.match(w)||[]),n=r.length;while(n--)delete o[r[n]]}},hasData:function(e){return!x.isEmptyObject(this.cache[e[this.expando]]||{})},discard:function(e){delete this.cache[this.key(e)]}},L=new F,q=new F,x.extend({acceptData:F.accepts,hasData:function(e){return L.hasData(e)||q.hasData(e)},data:function(e,t,n){return L.access(e,t,n)},removeData:function(e,t){L.remove(e,t)},_data:function(e,t,n){return q.access(e,t,n)},_removeData:function(e,t){q.remove(e,t)}}),x.fn.extend({data:function(e,t){var n,r,i=this[0],o=0,s=null;if(e===undefined){if(this.length&&(s=L.get(i),1===i.nodeType&&!q.get(i,"hasDataAttrs"))){for(n=i.attributes;n.length>o;o++)r=n[o].name,0===r.indexOf("data-")&&(r=x.camelCase(r.substring(5)),P(i,r,s[r]));q.set(i,"hasDataAttrs",!0)}return s}return"object"==typeof e?this.each(function(){L.set(this,e)}):x.access(this,function(t){var n,r=x.camelCase(e);if(i&&t===undefined){if(n=L.get(i,e),n!==undefined)return n;if(n=L.get(i,r),n!==undefined)return n;if(n=P(i,r,undefined),n!==undefined)return n}else this.each(function(){var n=L.get(this,r);L.set(this,r,t),-1!==e.indexOf("-")&&n!==undefined&&L.set(this,e,t)})},null,t,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){L.remove(this,e)})}});function P(e,t,n){var r;if(n===undefined&&1===e.nodeType)if(r="data-"+t.replace(O,"-$1").toLowerCase(),n=e.getAttribute(r),"string"==typeof n){try{n="true"===n?!0:"false"===n?!1:"null"===n?null:+n+""===n?+n:H.test(n)?JSON.parse(n):n}catch(i){}L.set(e,t,n)}else n=undefined;return n}x.extend({queue:function(e,t,n){var r;return e?(t=(t||"fx")+"queue",r=q.get(e,t),n&&(!r||x.isArray(n)?r=q.access(e,t,x.makeArray(n)):r.push(n)),r||[]):undefined},dequeue:function(e,t){t=t||"fx";var n=x.queue(e,t),r=n.length,i=n.shift(),o=x._queueHooks(e,t),s=function(){x.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),o.cur=i,i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,s,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return q.get(e,n)||q.access(e,n,{empty:x.Callbacks("once memory").add(function(){q.remove(e,[t+"queue",n])})})}}),x.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),n>arguments.length?x.queue(this[0],e):t===undefined?this:this.each(function(){var n=x.queue(this,e,t);
5 | x._queueHooks(this,e),"fx"===e&&"inprogress"!==n[0]&&x.dequeue(this,e)})},dequeue:function(e){return this.each(function(){x.dequeue(this,e)})},delay:function(e,t){return e=x.fx?x.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var n,r=1,i=x.Deferred(),o=this,s=this.length,a=function(){--r||i.resolveWith(o,[o])};"string"!=typeof e&&(t=e,e=undefined),e=e||"fx";while(s--)n=q.get(o[s],e+"queueHooks"),n&&n.empty&&(r++,n.empty.add(a));return a(),i.promise(t)}});var R,M,W=/[\t\r\n]/g,$=/\r/g,B=/^(?:input|select|textarea|button)$/i;x.fn.extend({attr:function(e,t){return x.access(this,x.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){x.removeAttr(this,e)})},prop:function(e,t){return x.access(this,x.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[x.propFix[e]||e]})},addClass:function(e){var t,n,r,i,o,s=0,a=this.length,u="string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).addClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];a>s;s++)if(n=this[s],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(W," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=x.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,s=0,a=this.length,u=0===arguments.length||"string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).removeClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];a>s;s++)if(n=this[s],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(W," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?x.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e,i="boolean"==typeof t;return x.isFunction(e)?this.each(function(n){x(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var o,s=0,a=x(this),u=t,l=e.match(w)||[];while(o=l[s++])u=i?u:!a.hasClass(o),a[u?"addClass":"removeClass"](o)}else(n===r||"boolean"===n)&&(this.className&&q.set(this,"__className__",this.className),this.className=this.className||e===!1?"":q.get(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(W," ").indexOf(t)>=0)return!0;return!1},val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=x.isFunction(e),this.each(function(n){var i,o=x(this);1===this.nodeType&&(i=r?e.call(this,n,o.val()):e,null==i?i="":"number"==typeof i?i+="":x.isArray(i)&&(i=x.map(i,function(e){return null==e?"":e+""})),t=x.valHooks[this.type]||x.valHooks[this.nodeName.toLowerCase()],t&&"set"in t&&t.set(this,i,"value")!==undefined||(this.value=i))});if(i)return t=x.valHooks[i.type]||x.valHooks[i.nodeName.toLowerCase()],t&&"get"in t&&(n=t.get(i,"value"))!==undefined?n:(n=i.value,"string"==typeof n?n.replace($,""):null==n?"":n)}}}),x.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,s=o?null:[],a=o?i+1:r.length,u=0>i?a:o?i:0;for(;a>u;u++)if(n=r[u],!(!n.selected&&u!==i||(x.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&x.nodeName(n.parentNode,"optgroup"))){if(t=x(n).val(),o)return t;s.push(t)}return s},set:function(e,t){var n,r,i=e.options,o=x.makeArray(t),s=i.length;while(s--)r=i[s],(r.selected=x.inArray(x(r).val(),o)>=0)&&(n=!0);return n||(e.selectedIndex=-1),o}}},attr:function(e,t,n){var i,o,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return typeof e.getAttribute===r?x.prop(e,t,n):(1===s&&x.isXMLDoc(e)||(t=t.toLowerCase(),i=x.attrHooks[t]||(x.expr.match.boolean.test(t)?M:R)),n===undefined?i&&"get"in i&&null!==(o=i.get(e,t))?o:(o=x.find.attr(e,t),null==o?undefined:o):null!==n?i&&"set"in i&&(o=i.set(e,n,t))!==undefined?o:(e.setAttribute(t,n+""),n):(x.removeAttr(e,t),undefined))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(w);if(o&&1===e.nodeType)while(n=o[i++])r=x.propFix[n]||n,x.expr.match.boolean.test(n)&&(e[r]=!1),e.removeAttribute(n)},attrHooks:{type:{set:function(e,t){if(!x.support.radioValue&&"radio"===t&&x.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{"for":"htmlFor","class":"className"},prop:function(e,t,n){var r,i,o,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return o=1!==s||!x.isXMLDoc(e),o&&(t=x.propFix[t]||t,i=x.propHooks[t]),n!==undefined?i&&"set"in i&&(r=i.set(e,n,t))!==undefined?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){return e.hasAttribute("tabindex")||B.test(e.nodeName)||e.href?e.tabIndex:-1}}}}),M={set:function(e,t,n){return t===!1?x.removeAttr(e,n):e.setAttribute(n,n),n}},x.each(x.expr.match.boolean.source.match(/\w+/g),function(e,t){var n=x.expr.attrHandle[t]||x.find.attr;x.expr.attrHandle[t]=function(e,t,r){var i=x.expr.attrHandle[t],o=r?undefined:(x.expr.attrHandle[t]=undefined)!=n(e,t,r)?t.toLowerCase():null;return x.expr.attrHandle[t]=i,o}}),x.support.optSelected||(x.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null}}),x.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){x.propFix[this.toLowerCase()]=this}),x.each(["radio","checkbox"],function(){x.valHooks[this]={set:function(e,t){return x.isArray(t)?e.checked=x.inArray(x(e).val(),t)>=0:undefined}},x.support.checkOn||(x.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var I=/^key/,z=/^(?:mouse|contextmenu)|click/,_=/^(?:focusinfocus|focusoutblur)$/,X=/^([^.]*)(?:\.(.+)|)$/;function U(){return!0}function Y(){return!1}function V(){try{return o.activeElement}catch(e){}}x.event={global:{},add:function(e,t,n,i,o){var s,a,u,l,c,f,p,h,d,g,m,y=q.get(e);if(y){n.handler&&(s=n,n=s.handler,o=s.selector),n.guid||(n.guid=x.guid++),(l=y.events)||(l=y.events={}),(a=y.handle)||(a=y.handle=function(e){return typeof x===r||e&&x.event.triggered===e.type?undefined:x.event.dispatch.apply(a.elem,arguments)},a.elem=e),t=(t||"").match(w)||[""],c=t.length;while(c--)u=X.exec(t[c])||[],d=m=u[1],g=(u[2]||"").split(".").sort(),d&&(p=x.event.special[d]||{},d=(o?p.delegateType:p.bindType)||d,p=x.event.special[d]||{},f=x.extend({type:d,origType:m,data:i,handler:n,guid:n.guid,selector:o,needsContext:o&&x.expr.match.needsContext.test(o),namespace:g.join(".")},s),(h=l[d])||(h=l[d]=[],h.delegateCount=0,p.setup&&p.setup.call(e,i,g,a)!==!1||e.addEventListener&&e.addEventListener(d,a,!1)),p.add&&(p.add.call(e,f),f.handler.guid||(f.handler.guid=n.guid)),o?h.splice(h.delegateCount++,0,f):h.push(f),x.event.global[d]=!0);e=null}},remove:function(e,t,n,r,i){var o,s,a,u,l,c,f,p,h,d,g,m=q.hasData(e)&&q.get(e);if(m&&(u=m.events)){t=(t||"").match(w)||[""],l=t.length;while(l--)if(a=X.exec(t[l])||[],h=g=a[1],d=(a[2]||"").split(".").sort(),h){f=x.event.special[h]||{},h=(r?f.delegateType:f.bindType)||h,p=u[h]||[],a=a[2]&&RegExp("(^|\\.)"+d.join("\\.(?:.*\\.|)")+"(\\.|$)"),s=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||a&&!a.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));s&&!p.length&&(f.teardown&&f.teardown.call(e,d,m.handle)!==!1||x.removeEvent(e,h,m.handle),delete u[h])}else for(h in u)x.event.remove(e,h+t[l],n,r,!0);x.isEmptyObject(u)&&(delete m.handle,q.remove(e,"events"))}},trigger:function(t,n,r,i){var s,a,u,l,c,f,p,h=[r||o],d=y.call(t,"type")?t.type:t,g=y.call(t,"namespace")?t.namespace.split("."):[];if(a=u=r=r||o,3!==r.nodeType&&8!==r.nodeType&&!_.test(d+x.event.triggered)&&(d.indexOf(".")>=0&&(g=d.split("."),d=g.shift(),g.sort()),c=0>d.indexOf(":")&&"on"+d,t=t[x.expando]?t:new x.Event(d,"object"==typeof t&&t),t.isTrigger=i?2:3,t.namespace=g.join("."),t.namespace_re=t.namespace?RegExp("(^|\\.)"+g.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=undefined,t.target||(t.target=r),n=null==n?[t]:x.makeArray(n,[t]),p=x.event.special[d]||{},i||!p.trigger||p.trigger.apply(r,n)!==!1)){if(!i&&!p.noBubble&&!x.isWindow(r)){for(l=p.delegateType||d,_.test(l+d)||(a=a.parentNode);a;a=a.parentNode)h.push(a),u=a;u===(r.ownerDocument||o)&&h.push(u.defaultView||u.parentWindow||e)}s=0;while((a=h[s++])&&!t.isPropagationStopped())t.type=s>1?l:p.bindType||d,f=(q.get(a,"events")||{})[t.type]&&q.get(a,"handle"),f&&f.apply(a,n),f=c&&a[c],f&&x.acceptData(a)&&f.apply&&f.apply(a,n)===!1&&t.preventDefault();return t.type=d,i||t.isDefaultPrevented()||p._default&&p._default.apply(h.pop(),n)!==!1||!x.acceptData(r)||c&&x.isFunction(r[d])&&!x.isWindow(r)&&(u=r[c],u&&(r[c]=null),x.event.triggered=d,r[d](),x.event.triggered=undefined,u&&(r[c]=u)),t.result}},dispatch:function(e){e=x.event.fix(e);var t,n,r,i,o,s=[],a=d.call(arguments),u=(q.get(this,"events")||{})[e.type]||[],l=x.event.special[e.type]||{};if(a[0]=e,e.delegateTarget=this,!l.preDispatch||l.preDispatch.call(this,e)!==!1){s=x.event.handlers.call(this,e,u),t=0;while((i=s[t++])&&!e.isPropagationStopped()){e.currentTarget=i.elem,n=0;while((o=i.handlers[n++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(o.namespace))&&(e.handleObj=o,e.data=o.data,r=((x.event.special[o.origType]||{}).handle||o.handler).apply(i.elem,a),r!==undefined&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return l.postDispatch&&l.postDispatch.call(this,e),e.result}},handlers:function(e,t){var n,r,i,o,s=[],a=t.delegateCount,u=e.target;if(a&&u.nodeType&&(!e.button||"click"!==e.type))for(;u!==this;u=u.parentNode||this)if(u.disabled!==!0||"click"!==e.type){for(r=[],n=0;a>n;n++)o=t[n],i=o.selector+" ",r[i]===undefined&&(r[i]=o.needsContext?x(i,this).index(u)>=0:x.find(i,this,null,[u]).length),r[i]&&r.push(o);r.length&&s.push({elem:u,handlers:r})}return t.length>a&&s.push({elem:this,handlers:t.slice(a)}),s},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,t){var n,r,i,s=t.button;return null==e.pageX&&null!=t.clientX&&(n=e.target.ownerDocument||o,r=n.documentElement,i=n.body,e.pageX=t.clientX+(r&&r.scrollLeft||i&&i.scrollLeft||0)-(r&&r.clientLeft||i&&i.clientLeft||0),e.pageY=t.clientY+(r&&r.scrollTop||i&&i.scrollTop||0)-(r&&r.clientTop||i&&i.clientTop||0)),e.which||s===undefined||(e.which=1&s?1:2&s?3:4&s?2:0),e}},fix:function(e){if(e[x.expando])return e;var t,n,r,i=e.type,o=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=z.test(i)?this.mouseHooks:I.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new x.Event(o),t=r.length;while(t--)n=r[t],e[n]=o[n];return 3===e.target.nodeType&&(e.target=e.target.parentNode),s.filter?s.filter(e,o):e},special:{load:{noBubble:!0},focus:{trigger:function(){return this!==V()&&this.focus?(this.focus(),!1):undefined},delegateType:"focusin"},blur:{trigger:function(){return this===V()&&this.blur?(this.blur(),!1):undefined},delegateType:"focusout"},click:{trigger:function(){return"checkbox"===this.type&&this.click&&x.nodeName(this,"input")?(this.click(),!1):undefined},_default:function(e){return x.nodeName(e.target,"a")}},beforeunload:{postDispatch:function(e){e.result!==undefined&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=x.extend(new x.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?x.event.trigger(i,null,t):x.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},x.removeEvent=function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)},x.Event=function(e,t){return this instanceof x.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.getPreventDefault&&e.getPreventDefault()?U:Y):this.type=e,t&&x.extend(this,t),this.timeStamp=e&&e.timeStamp||x.now(),this[x.expando]=!0,undefined):new x.Event(e,t)},x.Event.prototype={isDefaultPrevented:Y,isPropagationStopped:Y,isImmediatePropagationStopped:Y,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=U,e&&e.preventDefault&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=U,e&&e.stopPropagation&&e.stopPropagation()},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=U,this.stopPropagation()}},x.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){x.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return(!i||i!==r&&!x.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),x.support.focusinBubbles||x.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){x.event.simulate(t,e.target,x.event.fix(e),!0)};x.event.special[t]={setup:function(){0===n++&&o.addEventListener(e,r,!0)},teardown:function(){0===--n&&o.removeEventListener(e,r,!0)}}}),x.fn.extend({on:function(e,t,n,r,i){var o,s;if("object"==typeof e){"string"!=typeof t&&(n=n||t,t=undefined);for(s in e)this.on(s,t,n,e[s],i);return this}if(null==n&&null==r?(r=t,n=t=undefined):null==r&&("string"==typeof t?(r=n,n=undefined):(r=n,n=t,t=undefined)),r===!1)r=Y;else if(!r)return this;return 1===i&&(o=r,r=function(e){return x().off(e),o.apply(this,arguments)},r.guid=o.guid||(o.guid=x.guid++)),this.each(function(){x.event.add(this,e,r,n,t)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,t,n){var r,i;if(e&&e.preventDefault&&e.handleObj)return r=e.handleObj,x(e.delegateTarget).off(r.namespace?r.origType+"."+r.namespace:r.origType,r.selector,r.handler),this;if("object"==typeof e){for(i in e)this.off(i,t,e[i]);return this}return(t===!1||"function"==typeof t)&&(n=t,t=undefined),n===!1&&(n=Y),this.each(function(){x.event.remove(this,e,n,t)})},trigger:function(e,t){return this.each(function(){x.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];return n?x.event.trigger(e,t,n,!0):undefined}});var G=/^.[^:#\[\.,]*$/,J=x.expr.match.needsContext,Q={children:!0,contents:!0,next:!0,prev:!0};x.fn.extend({find:function(e){var t,n,r,i=this.length;if("string"!=typeof e)return t=this,this.pushStack(x(e).filter(function(){for(r=0;i>r;r++)if(x.contains(t[r],this))return!0}));for(n=[],r=0;i>r;r++)x.find(e,this[r],n);return n=this.pushStack(i>1?x.unique(n):n),n.selector=(this.selector?this.selector+" ":"")+e,n},has:function(e){var t=x(e,this),n=t.length;return this.filter(function(){var e=0;for(;n>e;e++)if(x.contains(this,t[e]))return!0})},not:function(e){return this.pushStack(Z(this,e||[],!0))},filter:function(e){return this.pushStack(Z(this,e||[],!1))},is:function(e){return!!e&&("string"==typeof e?J.test(e)?x(e,this.context).index(this[0])>=0:x.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){var n,r=0,i=this.length,o=[],s=J.test(e)||"string"!=typeof e?x(e,t||this.context):0;for(;i>r;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(11>n.nodeType&&(s?s.index(n)>-1:1===n.nodeType&&x.find.matchesSelector(n,e))){n=o.push(n);break}return this.pushStack(o.length>1?x.unique(o):o)},index:function(e){return e?"string"==typeof e?g.call(x(e),this[0]):g.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?x(e,t):x.makeArray(e&&e.nodeType?[e]:e),r=x.merge(this.get(),n);return this.pushStack(x.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function K(e,t){while((e=e[t])&&1!==e.nodeType);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return x.dir(e,"parentNode")},parentsUntil:function(e,t,n){return x.dir(e,"parentNode",n)},next:function(e){return K(e,"nextSibling")},prev:function(e){return K(e,"previousSibling")},nextAll:function(e){return x.dir(e,"nextSibling")},prevAll:function(e){return x.dir(e,"previousSibling")},nextUntil:function(e,t,n){return x.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return x.dir(e,"previousSibling",n)},siblings:function(e){return x.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return x.sibling(e.firstChild)},contents:function(e){return x.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:x.merge([],e.childNodes)}},function(e,t){x.fn[e]=function(n,r){var i=x.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=x.filter(r,i)),this.length>1&&(Q[e]||x.unique(i),"p"===e[0]&&i.reverse()),this.pushStack(i)}}),x.extend({filter:function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?x.find.matchesSelector(r,e)?[r]:[]:x.find.matches(e,x.grep(t,function(e){return 1===e.nodeType}))},dir:function(e,t,n){var r=[],i=n!==undefined;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&x(e).is(n))break;r.push(e)}return r},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function Z(e,t,n){if(x.isFunction(t))return x.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return x.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(G.test(t))return x.filter(t,e,n);t=x.filter(t,e)}return x.grep(e,function(e){return g.call(t,e)>=0!==n})}var et=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,tt=/<([\w:]+)/,nt=/<|?\w+;/,rt=/<(?:script|style|link)/i,it=/^(?:checkbox|radio)$/i,ot=/checked\s*(?:[^=]|=\s*.checked.)/i,st=/^$|\/(?:java|ecma)script/i,at=/^true\/(.*)/,ut=/^\s*\s*$/g,lt={option:[1,""],thead:[1,""],tr:[2,""],td:[3,""],_default:[0,"",""]};lt.optgroup=lt.option,lt.tbody=lt.tfoot=lt.colgroup=lt.caption=lt.col=lt.thead,lt.th=lt.td,x.fn.extend({text:function(e){return x.access(this,function(e){return e===undefined?x.text(this):this.empty().append((this[0]&&this[0].ownerDocument||o).createTextNode(e))},null,e,arguments.length)},append:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=ct(this,e);t.appendChild(e)}})},prepend:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=ct(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=e?x.filter(e,this):this,i=0;for(;null!=(n=r[i]);i++)t||1!==n.nodeType||x.cleanData(gt(n)),n.parentNode&&(t&&x.contains(n.ownerDocument,n)&&ht(gt(n,"script")),n.parentNode.removeChild(n));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++)1===e.nodeType&&(x.cleanData(gt(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return x.clone(this,e,t)})},html:function(e){return x.access(this,function(e){var t=this[0]||{},n=0,r=this.length;if(e===undefined&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!rt.test(e)&&!lt[(tt.exec(e)||["",""])[1].toLowerCase()]){e=e.replace(et,"<$1>$2>");try{for(;r>n;n++)t=this[n]||{},1===t.nodeType&&(x.cleanData(gt(t,!1)),t.innerHTML=e);t=0}catch(i){}}t&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=x.map(this,function(e){return[e.nextSibling,e.parentNode]}),t=0;return this.domManip(arguments,function(n){var r=e[t++],i=e[t++];i&&(x(this).remove(),i.insertBefore(n,r))},!0),t?this:this.remove()},detach:function(e){return this.remove(e,!0)},domManip:function(e,t,n){e=p.apply([],e);var r,i,o,s,a,u,l=0,c=this.length,f=this,h=c-1,d=e[0],g=x.isFunction(d);if(g||!(1>=c||"string"!=typeof d||x.support.checkClone)&&ot.test(d))return this.each(function(r){var i=f.eq(r);g&&(e[0]=d.call(this,r,i.html())),i.domManip(e,t,n)});if(c&&(r=x.buildFragment(e,this[0].ownerDocument,!1,!n&&this),i=r.firstChild,1===r.childNodes.length&&(r=i),i)){for(o=x.map(gt(r,"script"),ft),s=o.length;c>l;l++)a=r,l!==h&&(a=x.clone(a,!0,!0),s&&x.merge(o,gt(a,"script"))),t.call(this[l],a,l);if(s)for(u=o[o.length-1].ownerDocument,x.map(o,pt),l=0;s>l;l++)a=o[l],st.test(a.type||"")&&!q.access(a,"globalEval")&&x.contains(u,a)&&(a.src?x._evalUrl(a.src):x.globalEval(a.textContent.replace(ut,"")))}return this}}),x.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){x.fn[e]=function(e){var n,r=[],i=x(e),o=i.length-1,s=0;for(;o>=s;s++)n=s===o?this:this.clone(!0),x(i[s])[t](n),h.apply(r,n.get());return this.pushStack(r)}}),x.extend({clone:function(e,t,n){var r,i,o,s,a=e.cloneNode(!0),u=x.contains(e.ownerDocument,e);if(!(x.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||x.isXMLDoc(e)))for(s=gt(a),o=gt(e),r=0,i=o.length;i>r;r++)mt(o[r],s[r]);if(t)if(n)for(o=o||gt(e),s=s||gt(a),r=0,i=o.length;i>r;r++)dt(o[r],s[r]);else dt(e,a);return s=gt(a,"script"),s.length>0&&ht(s,!u&>(e,"script")),a},buildFragment:function(e,t,n,r){var i,o,s,a,u,l,c=0,f=e.length,p=t.createDocumentFragment(),h=[];for(;f>c;c++)if(i=e[c],i||0===i)if("object"===x.type(i))x.merge(h,i.nodeType?[i]:i);else if(nt.test(i)){o=o||p.appendChild(t.createElement("div")),s=(tt.exec(i)||["",""])[1].toLowerCase(),a=lt[s]||lt._default,o.innerHTML=a[1]+i.replace(et,"<$1>$2>")+a[2],l=a[0];while(l--)o=o.firstChild;x.merge(h,o.childNodes),o=p.firstChild,o.textContent=""}else h.push(t.createTextNode(i));p.textContent="",c=0;while(i=h[c++])if((!r||-1===x.inArray(i,r))&&(u=x.contains(i.ownerDocument,i),o=gt(p.appendChild(i),"script"),u&&ht(o),n)){l=0;while(i=o[l++])st.test(i.type||"")&&n.push(i)}return p},cleanData:function(e){var t,n,r,i=e.length,o=0,s=x.event.special;for(;i>o;o++){if(n=e[o],x.acceptData(n)&&(t=q.access(n)))for(r in t.events)s[r]?x.event.remove(n,r):x.removeEvent(n,r,t.handle);L.discard(n),q.discard(n)}},_evalUrl:function(e){return x.ajax({url:e,type:"GET",dataType:"text",async:!1,global:!1,success:x.globalEval})}});function ct(e,t){return x.nodeName(e,"table")&&x.nodeName(1===t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function ft(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function pt(e){var t=at.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function ht(e,t){var n=e.length,r=0;for(;n>r;r++)q.set(e[r],"globalEval",!t||q.get(t[r],"globalEval"))}function dt(e,t){var n,r,i,o,s,a,u,l;if(1===t.nodeType){if(q.hasData(e)&&(o=q.access(e),s=x.extend({},o),l=o.events,q.set(t,s),l)){delete s.handle,s.events={};for(i in l)for(n=0,r=l[i].length;r>n;n++)x.event.add(t,i,l[i][n])}L.hasData(e)&&(a=L.access(e),u=x.extend({},a),L.set(t,u))}}function gt(e,t){var n=e.getElementsByTagName?e.getElementsByTagName(t||"*"):e.querySelectorAll?e.querySelectorAll(t||"*"):[];return t===undefined||t&&x.nodeName(e,t)?x.merge([e],n):n}function mt(e,t){var n=t.nodeName.toLowerCase();"input"===n&&it.test(e.type)?t.checked=e.checked:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}x.fn.extend({wrapAll:function(e){var t;return x.isFunction(e)?this.each(function(t){x(this).wrapAll(e.call(this,t))}):(this[0]&&(t=x(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this)},wrapInner:function(e){return x.isFunction(e)?this.each(function(t){x(this).wrapInner(e.call(this,t))}):this.each(function(){var t=x(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=x.isFunction(e);return this.each(function(n){x(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){x.nodeName(this,"body")||x(this).replaceWith(this.childNodes)}).end()}});var yt,vt,xt=/^(none|table(?!-c[ea]).+)/,bt=/^margin/,wt=RegExp("^("+b+")(.*)$","i"),Tt=RegExp("^("+b+")(?!px)[a-z%]+$","i"),Ct=RegExp("^([+-])=("+b+")","i"),kt={BODY:"block"},Nt={position:"absolute",visibility:"hidden",display:"block"},Et={letterSpacing:0,fontWeight:400},St=["Top","Right","Bottom","Left"],jt=["Webkit","O","Moz","ms"];function Dt(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=jt.length;while(i--)if(t=jt[i]+n,t in e)return t;return r}function At(e,t){return e=t||e,"none"===x.css(e,"display")||!x.contains(e.ownerDocument,e)}function Lt(t){return e.getComputedStyle(t,null)}function qt(e,t){var n,r,i,o=[],s=0,a=e.length;for(;a>s;s++)r=e[s],r.style&&(o[s]=q.get(r,"olddisplay"),n=r.style.display,t?(o[s]||"none"!==n||(r.style.display=""),""===r.style.display&&At(r)&&(o[s]=q.access(r,"olddisplay",Pt(r.nodeName)))):o[s]||(i=At(r),(n&&"none"!==n||!i)&&q.set(r,"olddisplay",i?n:x.css(r,"display"))));for(s=0;a>s;s++)r=e[s],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[s]||"":"none"));return e}x.fn.extend({css:function(e,t){return x.access(this,function(e,t,n){var r,i,o={},s=0;if(x.isArray(t)){for(r=Lt(e),i=t.length;i>s;s++)o[t[s]]=x.css(e,t[s],!1,r);return o}return n!==undefined?x.style(e,t,n):x.css(e,t)},e,t,arguments.length>1)},show:function(){return qt(this,!0)},hide:function(){return qt(this)},toggle:function(e){var t="boolean"==typeof e;return this.each(function(){(t?e:At(this))?x(this).show():x(this).hide()})}}),x.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=yt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,s,a=x.camelCase(t),u=e.style;return t=x.cssProps[a]||(x.cssProps[a]=Dt(u,a)),s=x.cssHooks[t]||x.cssHooks[a],n===undefined?s&&"get"in s&&(i=s.get(e,!1,r))!==undefined?i:u[t]:(o=typeof n,"string"===o&&(i=Ct.exec(n))&&(n=(i[1]+1)*i[2]+parseFloat(x.css(e,t)),o="number"),null==n||"number"===o&&isNaN(n)||("number"!==o||x.cssNumber[a]||(n+="px"),x.support.clearCloneStyle||""!==n||0!==t.indexOf("background")||(u[t]="inherit"),s&&"set"in s&&(n=s.set(e,n,r))===undefined||(u[t]=n)),undefined)}},css:function(e,t,n,r){var i,o,s,a=x.camelCase(t);return t=x.cssProps[a]||(x.cssProps[a]=Dt(e.style,a)),s=x.cssHooks[t]||x.cssHooks[a],s&&"get"in s&&(i=s.get(e,!0,n)),i===undefined&&(i=yt(e,t,r)),"normal"===i&&t in Et&&(i=Et[t]),""===n||n?(o=parseFloat(i),n===!0||x.isNumeric(o)?o||0:i):i}}),yt=function(e,t,n){var r,i,o,s=n||Lt(e),a=s?s.getPropertyValue(t)||s[t]:undefined,u=e.style;return s&&(""!==a||x.contains(e.ownerDocument,e)||(a=x.style(e,t)),Tt.test(a)&&bt.test(t)&&(r=u.width,i=u.minWidth,o=u.maxWidth,u.minWidth=u.maxWidth=u.width=a,a=s.width,u.width=r,u.minWidth=i,u.maxWidth=o)),a};function Ht(e,t,n){var r=wt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function Ot(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,s=0;for(;4>o;o+=2)"margin"===n&&(s+=x.css(e,n+St[o],!0,i)),r?("content"===n&&(s-=x.css(e,"padding"+St[o],!0,i)),"margin"!==n&&(s-=x.css(e,"border"+St[o]+"Width",!0,i))):(s+=x.css(e,"padding"+St[o],!0,i),"padding"!==n&&(s+=x.css(e,"border"+St[o]+"Width",!0,i)));return s}function Ft(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Lt(e),s=x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=yt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Tt.test(i))return i;r=s&&(x.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+Ot(e,t,n||(s?"border":"content"),r,o)+"px"}function Pt(e){var t=o,n=kt[e];return n||(n=Rt(e,t),"none"!==n&&n||(vt=(vt||x("").css("cssText","display:block !important")).appendTo(t.documentElement),t=(vt[0].contentWindow||vt[0].contentDocument).document,t.write(""),t.close(),n=Rt(e,t),vt.detach()),kt[e]=n),n}function Rt(e,t){var n=x(t.createElement(e)).appendTo(t.body),r=x.css(n[0],"display");return n.remove(),r}x.each(["height","width"],function(e,t){x.cssHooks[t]={get:function(e,n,r){return n?0===e.offsetWidth&&xt.test(x.css(e,"display"))?x.swap(e,Nt,function(){return Ft(e,t,r)}):Ft(e,t,r):undefined},set:function(e,n,r){var i=r&&Lt(e);return Ht(e,n,r?Ot(e,t,r,x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,i),i):0)}}}),x(function(){x.support.reliableMarginRight||(x.cssHooks.marginRight={get:function(e,t){return t?x.swap(e,{display:"inline-block"},yt,[e,"marginRight"]):undefined}}),!x.support.pixelPosition&&x.fn.position&&x.each(["top","left"],function(e,t){x.cssHooks[t]={get:function(e,n){return n?(n=yt(e,t),Tt.test(n)?x(e).position()[t]+"px":n):undefined}}})}),x.expr&&x.expr.filters&&(x.expr.filters.hidden=function(e){return 0>=e.offsetWidth&&0>=e.offsetHeight},x.expr.filters.visible=function(e){return!x.expr.filters.hidden(e)}),x.each({margin:"",padding:"",border:"Width"},function(e,t){x.cssHooks[e+t]={expand:function(n){var r=0,i={},o="string"==typeof n?n.split(" "):[n];for(;4>r;r++)i[e+St[r]+t]=o[r]||o[r-2]||o[0];return i}},bt.test(e)||(x.cssHooks[e+t].set=Ht)});var Mt=/%20/g,Wt=/\[\]$/,$t=/\r?\n/g,Bt=/^(?:submit|button|image|reset|file)$/i,It=/^(?:input|select|textarea|keygen)/i;x.fn.extend({serialize:function(){return x.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=x.prop(this,"elements");return e?x.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!x(this).is(":disabled")&&It.test(this.nodeName)&&!Bt.test(e)&&(this.checked||!it.test(e))}).map(function(e,t){var n=x(this).val();return null==n?null:x.isArray(n)?x.map(n,function(e){return{name:t.name,value:e.replace($t,"\r\n")}}):{name:t.name,value:n.replace($t,"\r\n")}}).get()}}),x.param=function(e,t){var n,r=[],i=function(e,t){t=x.isFunction(t)?t():null==t?"":t,r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};if(t===undefined&&(t=x.ajaxSettings&&x.ajaxSettings.traditional),x.isArray(e)||e.jquery&&!x.isPlainObject(e))x.each(e,function(){i(this.name,this.value)});else for(n in e)zt(n,e[n],t,i);return r.join("&").replace(Mt,"+")};function zt(e,t,n,r){var i;if(x.isArray(t))x.each(t,function(t,i){n||Wt.test(e)?r(e,i):zt(e+"["+("object"==typeof i?t:"")+"]",i,n,r)});else if(n||"object"!==x.type(t))r(e,t);else for(i in t)zt(e+"["+i+"]",t[i],n,r)}x.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,t){x.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),x.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}});var _t,Xt,Ut=x.now(),Yt=/\?/,Vt=/#.*$/,Gt=/([?&])_=[^&]*/,Jt=/^(.*?):[ \t]*([^\r\n]*)$/gm,Qt=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Kt=/^(?:GET|HEAD)$/,Zt=/^\/\//,en=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,tn=x.fn.load,nn={},rn={},on="*/".concat("*");try{Xt=i.href}catch(sn){Xt=o.createElement("a"),Xt.href="",Xt=Xt.href}_t=en.exec(Xt.toLowerCase())||[];function an(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(w)||[];
6 | if(x.isFunction(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function un(e,t,n,r){var i={},o=e===rn;function s(a){var u;return i[a]=!0,x.each(e[a]||[],function(e,a){var l=a(t,n,r);return"string"!=typeof l||o||i[l]?o?!(u=l):undefined:(t.dataTypes.unshift(l),s(l),!1)}),u}return s(t.dataTypes[0])||!i["*"]&&s("*")}function ln(e,t){var n,r,i=x.ajaxSettings.flatOptions||{};for(n in t)t[n]!==undefined&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&x.extend(!0,e,r),e}x.fn.load=function(e,t,n){if("string"!=typeof e&&tn)return tn.apply(this,arguments);var r,i,o,s=this,a=e.indexOf(" ");return a>=0&&(r=e.slice(a),e=e.slice(0,a)),x.isFunction(t)?(n=t,t=undefined):t&&"object"==typeof t&&(i="POST"),s.length>0&&x.ajax({url:e,type:i,dataType:"html",data:t}).done(function(e){o=arguments,s.html(r?x("").append(x.parseHTML(e)).find(r):e)}).complete(n&&function(e,t){s.each(n,o||[e.responseText,t,e])}),this},x.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){x.fn[t]=function(e){return this.on(t,e)}}),x.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Xt,type:"GET",isLocal:Qt.test(_t[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":on,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":x.parseJSON,"text xml":x.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?ln(ln(e,x.ajaxSettings),t):ln(x.ajaxSettings,e)},ajaxPrefilter:an(nn),ajaxTransport:an(rn),ajax:function(e,t){"object"==typeof e&&(t=e,e=undefined),t=t||{};var n,r,i,o,s,a,u,l,c=x.ajaxSetup({},t),f=c.context||c,p=c.context&&(f.nodeType||f.jquery)?x(f):x.event,h=x.Deferred(),d=x.Callbacks("once memory"),g=c.statusCode||{},m={},y={},v=0,b="canceled",T={readyState:0,getResponseHeader:function(e){var t;if(2===v){if(!o){o={};while(t=Jt.exec(i))o[t[1].toLowerCase()]=t[2]}t=o[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===v?i:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return v||(e=y[n]=y[n]||e,m[e]=t),this},overrideMimeType:function(e){return v||(c.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>v)for(t in e)g[t]=[g[t],e[t]];else T.always(e[T.status]);return this},abort:function(e){var t=e||b;return n&&n.abort(t),k(0,t),this}};if(h.promise(T).complete=d.add,T.success=T.done,T.error=T.fail,c.url=((e||c.url||Xt)+"").replace(Vt,"").replace(Zt,_t[1]+"//"),c.type=t.method||t.type||c.method||c.type,c.dataTypes=x.trim(c.dataType||"*").toLowerCase().match(w)||[""],null==c.crossDomain&&(a=en.exec(c.url.toLowerCase()),c.crossDomain=!(!a||a[1]===_t[1]&&a[2]===_t[2]&&(a[3]||("http:"===a[1]?"80":"443"))===(_t[3]||("http:"===_t[1]?"80":"443")))),c.data&&c.processData&&"string"!=typeof c.data&&(c.data=x.param(c.data,c.traditional)),un(nn,c,t,T),2===v)return T;u=c.global,u&&0===x.active++&&x.event.trigger("ajaxStart"),c.type=c.type.toUpperCase(),c.hasContent=!Kt.test(c.type),r=c.url,c.hasContent||(c.data&&(r=c.url+=(Yt.test(r)?"&":"?")+c.data,delete c.data),c.cache===!1&&(c.url=Gt.test(r)?r.replace(Gt,"$1_="+Ut++):r+(Yt.test(r)?"&":"?")+"_="+Ut++)),c.ifModified&&(x.lastModified[r]&&T.setRequestHeader("If-Modified-Since",x.lastModified[r]),x.etag[r]&&T.setRequestHeader("If-None-Match",x.etag[r])),(c.data&&c.hasContent&&c.contentType!==!1||t.contentType)&&T.setRequestHeader("Content-Type",c.contentType),T.setRequestHeader("Accept",c.dataTypes[0]&&c.accepts[c.dataTypes[0]]?c.accepts[c.dataTypes[0]]+("*"!==c.dataTypes[0]?", "+on+"; q=0.01":""):c.accepts["*"]);for(l in c.headers)T.setRequestHeader(l,c.headers[l]);if(c.beforeSend&&(c.beforeSend.call(f,T,c)===!1||2===v))return T.abort();b="abort";for(l in{success:1,error:1,complete:1})T[l](c[l]);if(n=un(rn,c,t,T)){T.readyState=1,u&&p.trigger("ajaxSend",[T,c]),c.async&&c.timeout>0&&(s=setTimeout(function(){T.abort("timeout")},c.timeout));try{v=1,n.send(m,k)}catch(C){if(!(2>v))throw C;k(-1,C)}}else k(-1,"No Transport");function k(e,t,o,a){var l,m,y,b,w,C=t;2!==v&&(v=2,s&&clearTimeout(s),n=undefined,i=a||"",T.readyState=e>0?4:0,l=e>=200&&300>e||304===e,o&&(b=cn(c,T,o)),b=fn(c,b,T,l),l?(c.ifModified&&(w=T.getResponseHeader("Last-Modified"),w&&(x.lastModified[r]=w),w=T.getResponseHeader("etag"),w&&(x.etag[r]=w)),204===e?C="nocontent":304===e?C="notmodified":(C=b.state,m=b.data,y=b.error,l=!y)):(y=C,(e||!C)&&(C="error",0>e&&(e=0))),T.status=e,T.statusText=(t||C)+"",l?h.resolveWith(f,[m,C,T]):h.rejectWith(f,[T,C,y]),T.statusCode(g),g=undefined,u&&p.trigger(l?"ajaxSuccess":"ajaxError",[T,c,l?m:y]),d.fireWith(f,[T,C]),u&&(p.trigger("ajaxComplete",[T,c]),--x.active||x.event.trigger("ajaxStop")))}return T},getJSON:function(e,t,n){return x.get(e,t,n,"json")},getScript:function(e,t){return x.get(e,undefined,t,"script")}}),x.each(["get","post"],function(e,t){x[t]=function(e,n,r,i){return x.isFunction(n)&&(i=i||r,r=n,n=undefined),x.ajax({url:e,type:t,dataType:i,data:n,success:r})}});function cn(e,t,n){var r,i,o,s,a=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),r===undefined&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in a)if(a[i]&&a[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}s||(s=i)}o=o||s}return o?(o!==u[0]&&u.unshift(o),n[o]):undefined}function fn(e,t,n,r){var i,o,s,a,u,l={},c=e.dataTypes.slice();if(c[1])for(s in e.converters)l[s.toLowerCase()]=e.converters[s];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(s=l[u+" "+o]||l["* "+o],!s)for(i in l)if(a=i.split(" "),a[1]===o&&(s=l[u+" "+a[0]]||l["* "+a[0]])){s===!0?s=l[i]:l[i]!==!0&&(o=a[0],c.unshift(a[1]));break}if(s!==!0)if(s&&e["throws"])t=s(t);else try{t=s(t)}catch(f){return{state:"parsererror",error:s?f:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}x.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return x.globalEval(e),e}}}),x.ajaxPrefilter("script",function(e){e.cache===undefined&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),x.ajaxTransport("script",function(e){if(e.crossDomain){var t,n;return{send:function(r,i){t=x("
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/main/resources/ext/chrome/popup.js:
--------------------------------------------------------------------------------
1 | chrome.tabs.getSelected(null,function(tab) {
2 | var port = null;
3 | var nativeHostName = "so.zjd.sstk";
4 | port = chrome.runtime.connectNative(nativeHostName);
5 |
6 | port.onMessage.addListener(function(msg) {
7 | //console.log("Received " + msg);
8 | $("#message").text(msg.text);
9 | });
10 |
11 | port.onDisconnect.addListener(function onDisconnected(){
12 | //console.log("connetct native host failure:" + chrome.runtime.lastError.message);
13 | port = null;
14 | //$("#message").text("Finished!");
15 | });
16 |
17 | port.postMessage(encodeURI(tab.url))
18 |
19 | });
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/main/resources/log4j.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
8 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/main/resources/setup.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | reg add HKEY_CURRENT_USER\Software\Google\Chrome\NativeMessagingHosts\so.zjd.sstk /ve /t REG_SZ /d %~dp0\SimpleSendToKindle.json /f
3 |
--------------------------------------------------------------------------------
/src/main/resources/sstk.properties:
--------------------------------------------------------------------------------
1 | #整个服务的超时时间
2 | sstk.service.timeout = 120000
3 | #网页内容或图片的下载超时时间
4 | sstk.download.timeout = 15000
5 | #是否删除临时目录
6 | sstk.download.deleteTmpDir = false
7 |
8 | mail.smtp.starttls.enable=true
9 | mail.smtp.socketFactory.port=25
10 | mail.smtp.host=smtp.126.com
11 | mail.host=smtp.126.com
12 | mail.smtp.auth=true
13 | mail.transport.protocol=smtp
14 | mail.userName=ossp_mail_test
15 | mail.password=iflytek
16 | mail.from=ossp_mail_test@126.com
17 | mail.to=zhanjindong@kindle.cn
18 |
19 | #debug
20 | sstk.debug.sendMail = false
--------------------------------------------------------------------------------
/src/main/resources/startup.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhanjindong/SimpleSendToKindle/e011dbbf57954ae855dde84a701a13f94d97af27/src/main/resources/startup.exe
--------------------------------------------------------------------------------
/src/startup/Startup.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhanjindong/SimpleSendToKindle/e011dbbf57954ae855dde84a701a13f94d97af27/src/startup/Startup.cs
--------------------------------------------------------------------------------
/src/test/java/so/zjd/sstk/HttpTest.java:
--------------------------------------------------------------------------------
1 | package so.zjd.sstk;
2 |
3 | import java.io.FileOutputStream;
4 | import java.io.IOException;
5 | import java.io.OutputStream;
6 |
7 | import so.zjd.sstk.util.HttpHelper;
8 | import so.zjd.sstk.util.RegexUtils;
9 |
10 | public class HttpTest {
11 | public static void main(String[] args) throws IOException {
12 | String url = "http://www.cnblogs.com/guogangj/p/3235703.html";
13 | String content = HttpHelper.download(url, 5000, "utf-8").toString();
14 | System.out.println(content);
15 |
16 | OutputStream os = new FileOutputStream("d://test.html");
17 | //HttpHelper.download(url, 5000, "utf-8", os);
18 |
19 | StringBuilder sb = HttpHelper.download(url, 1000);
20 | System.out.println(sb.toString());
21 | os.write(sb.toString().getBytes("UTF-8"));
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/java/so/zjd/sstk/MailSenderTest.java:
--------------------------------------------------------------------------------
1 | package so.zjd.sstk;
2 |
3 | import java.io.FileInputStream;
4 | import java.util.Properties;
5 |
6 | import org.apache.log4j.xml.DOMConfigurator;
7 |
8 | import so.zjd.sstk.util.MailSender;
9 | import so.zjd.sstk.util.PathUtils;
10 |
11 | public class MailSenderTest {
12 |
13 | private static final String WORK_DIR = PathUtils.getAppDir(Service.class);
14 | private static final Properties CONFIGS = new Properties();
15 |
16 | static {
17 | try {
18 | DOMConfigurator.configure(PathUtils.getRealPath("classpath:log4j.xml"));
19 | CONFIGS.load(new FileInputStream(PathUtils.getRealPath("classpath:sstk.properties")));
20 | } catch (Exception e) {
21 | e.printStackTrace();
22 | }
23 | }
24 |
25 | public static void main(String[] args) {
26 | MailSender sender = new MailSender(CONFIGS);
27 | sender.sendFrom("simple send to kindle","d:\\error");
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/so/zjd/sstk/ProcessRelativeUrlTest.java:
--------------------------------------------------------------------------------
1 | package so.zjd.sstk;
2 |
3 | import junit.framework.TestCase;
4 |
5 | public class ProcessRelativeUrlTest extends TestCase {
6 | public static void main(String[] args) {
7 | String result = processRelativeUrl("http://redisbook1e.readthedocs.org/en/latest/preview/slowlog/content.html",
8 | ".././../_images/graphviz-496accb4258b0feb9fbc0503bb9ba49f16e4b6d9.png");
9 | System.out.println(result);
10 | }
11 |
12 | public void testRelativeUrl() {
13 | String pageUrl = "http://www.test.com/dir1/dir2/dir3/test.html";
14 |
15 | String imgUrl = "../test.png";
16 | String result = processRelativeUrl(pageUrl, imgUrl);
17 | assertEquals("http://www.test.com/dir1/dir2/test.png", result);
18 |
19 | imgUrl = "./test.png";
20 | result = processRelativeUrl(pageUrl, imgUrl);
21 | assertEquals("http://www.test.com/dir1/dir2/dir3/test.png", result);
22 |
23 | imgUrl = "/test.png";
24 | result = processRelativeUrl(pageUrl, imgUrl);
25 | assertEquals("http://www.test.com/test.png", result);
26 |
27 | imgUrl = "./../test.png";
28 | result = processRelativeUrl(pageUrl, imgUrl);
29 | assertEquals("http://www.test.com/dir1/dir2/test.png", result);
30 |
31 | imgUrl = "../../test.png";
32 | result = processRelativeUrl(pageUrl, imgUrl);
33 | assertEquals("http://www.test.com/dir1/test.png", result);
34 | }
35 |
36 | // ./images/mem/figure9.png
37 | // images/mem/figure9.png
38 | // /images/mem/figure9.png
39 | // ../../images/mem/figure9.png
40 | // page url:http://www.test.com/dir1/dir2/test.html
41 | private static String processRelativeUrl(String pageUrl, String url) {
42 | if (url.startsWith("http://")) {
43 | return url;
44 | }
45 | int relative = 0;
46 | int index = 0;
47 | if (url.startsWith("/")) {
48 | relative = -1;
49 | } else {
50 | while (true) {
51 | index = 0;
52 | if (url.startsWith("./")) {// 当前目录
53 | index = url.indexOf("./");
54 | url = url.substring(index + 2);
55 | continue;
56 | } else if (url.startsWith("../")) {// 上级目录
57 | relative++;
58 | index = url.indexOf("../");
59 | url = url.substring(index + 3);
60 | continue;
61 | } else {// 当前目录
62 | break;
63 | }
64 | }
65 | }
66 | if (relative == -1) {
67 | index = pageUrl.indexOf('/', 7);
68 | pageUrl = pageUrl.substring(0, index);
69 | url = url.substring(1);
70 | } else {
71 | for (int i = 0; i <= relative; i++) {
72 | index = pageUrl.lastIndexOf("/");
73 | if (index == -1) {
74 | break;
75 | }
76 | pageUrl = pageUrl.substring(0, index);
77 | }
78 | }
79 | url = pageUrl + "/" + url;
80 |
81 | return url;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/test/resources/log4j.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
8 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/src/test/resources/sstk.properties:
--------------------------------------------------------------------------------
1 | mail.smtp.starttls.enable=true
2 | mail.smtp.socketFactory.port=25
3 | mail.smtp.host=smtp.126.com
4 | mail.host=smtp.126.com
5 | mail.smtp.auth=true
6 | mail.transport.protocol=smtp
7 | mail.userName=ossp_mail_test
8 | mail.password=iflytek
9 | mail.from=ossp_mail_test@126.com
10 | mail.to=1072371828@qq.com
--------------------------------------------------------------------------------