@@ -19,6 +19,48 @@ import "../ext/qml_messaging.js" as Messaging
19
19
property alias url: webview .url
20
20
property alias webView: webview
21
21
22
+ property var cleanPath: false
23
+ property var open : function (url ) {
24
+ if (! window .cleanPath ) {
25
+ var uri = url;
26
+ if (! / . * \:\/\/ . * / .test (uri)) {
27
+ uri = " http://" + uri;
28
+ }
29
+
30
+ var reg = / (^ https? \:\/\/ (?:www\. )? )([a-zA-Z0-9 _\- ] * \. eth)(. * )/
31
+
32
+ if (reg .test (uri)) {
33
+ uri .replace (reg, function (match , pre , domain , path ) {
34
+ uri = pre;
35
+
36
+ var lookup = eth .lookupDomain (domain .substring (0 , domain .length - 4 ));
37
+ var ip = [];
38
+ for (var i = 0 , l = lookup .length ; i < l; i++ ) {
39
+ ip .push (lookup .charCodeAt (i))
40
+ }
41
+
42
+ if (ip .length != 0 ) {
43
+ uri += lookup;
44
+ } else {
45
+ uri += domain;
46
+ }
47
+
48
+ uri += path;
49
+ });
50
+ }
51
+
52
+ window .cleanPath = true ;
53
+
54
+ webview .url = uri;
55
+
56
+ // uriNav.text = uri.text.replace(/(^https?\:\/\/(?:www\.)?)([a-zA-Z0-9_\-]*\.\w{2,3})(.*)/, "$1$2<span style='color:#CCC'>$3</span>");
57
+ uriNav .text = uri;
58
+ } else {
59
+ // Prevent inf loop.
60
+ window .cleanPath = false ;
61
+ }
62
+ }
63
+
22
64
Component .onCompleted : {
23
65
webview .url = " http://etherian.io"
24
66
}
@@ -103,43 +145,9 @@ import "../ext/qml_messaging.js" as Messaging
103
145
top: navBar .bottom
104
146
}
105
147
106
- property var cleanPath: false
148
+ // property var cleanPath: false
107
149
onNavigationRequested: {
108
- if (! this .cleanPath ) {
109
- var uri = request .url .toString ();
110
- if (! / . * \:\/\/ . * / .test (uri)) {
111
- uri = " http://" + uri;
112
- }
113
-
114
- var reg = / (^ https? \:\/\/ (?:www\. )? )([a-zA-Z0-9 _\- ] * \. eth)(. * )/
115
-
116
- if (reg .test (uri)) {
117
- uri .replace (reg, function (match , pre , domain , path ) {
118
- uri = pre;
119
-
120
- var lookup = eth .lookupDomain (domain .substring (0 , domain .length - 4 ));
121
- var ip = [];
122
- for (var i = 0 , l = lookup .length ; i < l; i++ ) {
123
- ip .push (lookup .charCodeAt (i))
124
- }
125
-
126
- if (ip .length != 0 ) {
127
- uri += lookup;
128
- } else {
129
- uri += domain;
130
- }
131
-
132
- uri += path;
133
- });
134
- }
135
-
136
- this .cleanPath = true ;
137
-
138
- webview .url = uri;
139
- } else {
140
- // Prevent inf loop.
141
- this .cleanPath = false ;
142
- }
150
+ window .open (request .url .toString ());
143
151
}
144
152
145
153
function sendMessage (data ) {
0 commit comments