1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript.host.event;
16
17 import org.htmlunit.corejs.javascript.ScriptableObject;
18 import org.htmlunit.javascript.JavaScriptEngine;
19 import org.htmlunit.javascript.configuration.JsxClass;
20 import org.htmlunit.javascript.configuration.JsxConstructor;
21 import org.htmlunit.javascript.configuration.JsxGetter;
22
23
24
25
26
27
28
29
30
31
32 @JsxClass
33 public class HashChangeEvent extends Event {
34
35 private String oldURL_ = "";
36 private String newURL_ = "";
37
38
39
40
41 public HashChangeEvent() {
42 super("");
43 }
44
45
46
47
48
49
50
51
52
53 public HashChangeEvent(final EventTarget target, final String type,
54 final String oldURL, final String newURL) {
55 super(target, type);
56 oldURL_ = oldURL;
57 newURL_ = newURL;
58
59 setBubbles(false);
60 setCancelable(false);
61 }
62
63
64
65
66 @Override
67 @JsxConstructor
68 public void jsConstructor(final String type, final ScriptableObject details) {
69 super.jsConstructor(type, details);
70
71 String oldURL = "";
72 String newURL = "";
73 if (details != null && !JavaScriptEngine.isUndefined(details)) {
74 oldURL = (String) details.get("oldURL");
75 newURL = (String) details.get("newURL");
76 }
77 oldURL_ = oldURL;
78 newURL_ = newURL;
79 }
80
81
82
83
84
85 @JsxGetter
86 public String getOldURL() {
87 return oldURL_;
88 }
89
90
91
92
93
94 @JsxGetter
95 public String getNewURL() {
96 return newURL_;
97 }
98 }