@@ -17,31 +17,12 @@ const handler = (options) => {
17
17
18
18
//const disalledUrl = /^((https?:\/\/))/i
19
19
20
+ /*
20
21
let windowInterval
21
-
22
22
const generateInterval = () => {
23
- windowInterval = setInterval ( ( ) => {
24
- //console.log(webview.src, global.p3x.onenote.root.p3x.onenote.location)
25
-
26
- /*
27
- ipc.send('p3x-debug', {
28
- 'new-window': webview.src,
29
- allowed: allowedUrlRegex.test(webview.src)
30
- })
31
- */
32
-
33
- /*
34
- if (!allowedUrlRegex.test(webview.src)) {
35
- p3x.onenote.ui.overlay.show({
36
- message: p3x.onenote.lang.label.disallowedContent
37
- })
38
- } else {
39
- p3x.onenote.ui.overlay.hide()
40
- }
41
- */
42
-
43
-
23
+ windowInterval = setInterval(() => {
44
24
if (global.p3x.onenote.root && global.p3x.onenote.root.p3x.onenote.location !== webview.src) {
25
+ console.log('changed the url via interval', webview.src)
45
26
p3x.onenote.wait.angular(() => {
46
27
global.p3x.onenote.root.p3x.onenote.location = webview.src
47
28
global.p3x.onenote.data.url = webview.src
@@ -61,6 +42,7 @@ const handler = (options) => {
61
42
generateInterval()
62
43
}
63
44
})
45
+ */
64
46
65
47
/*
66
48
webview.addEventListener('did-stop-loading', function(event) {
@@ -82,25 +64,34 @@ const handler = (options) => {
82
64
});
83
65
*/
84
66
85
- webview . addEventListener ( 'did-navigate' , function ( event , url ) {
86
- /*
87
- ipc.send('p3x-debug', {
88
- 'did-navigate': event,
89
- url: url,
67
+ for ( let eventName of [ 'did-navigate' , 'did-navigate-in-page' ] ) {
68
+ webview . addEventListener ( eventName , function ( event , url ) {
69
+ /*
70
+ ipc.send('p3x-debug', {
71
+ 'did-navigate': event,
72
+ url: url,
73
+ });
74
+ */
75
+ console . log ( `changed the url via ${ eventName } ` , webview . src )
76
+
77
+ global . p3x . onenote . data . url = webview . src ;
78
+ ipc . send ( 'p3x-onenote-save' , global . p3x . onenote . data ) ;
79
+
80
+ p3x . onenote . wait . angular ( ( ) => {
81
+ global . p3x . onenote . root . p3x . onenote . location = webview . src
82
+ global . p3x . onenote . root . $digest ( )
83
+ } )
84
+
90
85
} ) ;
91
- */
86
+
87
+
88
+ }
92
89
93
- global . p3x . onenote . data . url = webview . src ;
94
- ipc . send ( 'p3x-onenote-save' , global . p3x . onenote . data ) ;
90
+
95
91
96
- p3x . onenote . wait . angular ( ( ) => {
97
- global . p3x . onenote . root . p3x . onenote . location = webview . src
98
- global . p3x . onenote . root . $digest ( )
99
- } )
100
92
101
- } ) ;
102
93
103
- webview . addEventListener ( " dom-ready" , event => {
94
+ webview . addEventListener ( ' dom-ready' , event => {
104
95
//TODO Remove this once https://github.com/electron/electron/issues/14474 is fixed
105
96
webview . blur ( ) ;
106
97
webview . focus ( ) ;
@@ -114,8 +105,11 @@ const handler = (options) => {
114
105
115
106
} ) ;
116
107
108
+ /*
117
109
webview.addEventListener('new-window', function (event) {
118
110
111
+ console.log('new-window', event.url)
112
+
119
113
event.preventDefault()
120
114
//p3x.onenote.toast.action(p3x.onenote.lang.label.unknownLink)
121
115
@@ -134,41 +128,30 @@ const handler = (options) => {
134
128
}
135
129
})
136
130
}
137
-
138
- //;
139
-
140
- /*
141
- ipc.send('p3x-debug', {
142
- 'new-window': event.url,
143
- allowed: allowedUrlRegex.test(event.url)
144
- })
145
- */
146
-
147
- //console.log(event.url)
148
- /*
149
- if (allowedUrlRegex2.test(event.url)) {
150
- // https://onedrive.live.com/redir?resid=3B992A1F2BEDFFA7%21955&page=Edit
151
- const urlParts = event.url.match(allowedUrlRegex2)
152
- /*
153
- ipc.send('p3x-debug', {
154
- urlParts: urlParts
155
- })
156
- */
157
- /*
158
- p3x.onenote.toast.action(p3x.onenote.lang.redirecting)
159
- webview.src = `https://onedrive.live.com/redir?resid=${urlParts[1]}%21955&page=Edit`;
160
- } else
161
- */
162
- /*
163
- if (allowedUrlRegex.test(event.url) || allowedUrlRegex2.test(event.url)) {
164
- p3x.onenote.toast.action(p3x.onenote.lang.redirecting)
165
- webview.src = event.url;
166
- } else {
167
- shell.openExternal(event.url);
168
- }
169
- */
170
131
});
132
+ */
171
133
134
+ /*
135
+ for(let event of [
136
+ 'did-finish-load',
137
+ 'did-frame-finish-load',
138
+ 'did-start-loading',
139
+ 'page-title-updated',
140
+ 'will-navigate',
141
+ 'did-start-navigation',
142
+ 'did-redirect-navigation',
143
+ 'did-navigate',
144
+ 'did-frame-navigate',
145
+ 'did-navigate-in-page',
146
+ 'update-target-url',
147
+ ]) {
148
+ webview.addEventListener(event, function(eventData) {
149
+ if (eventData.url) {
150
+ console.log(event, event.url)
151
+ }
152
+ })
153
+ }
154
+ */
172
155
173
156
}
174
157
0 commit comments