1
2
3
4
5
6
7
8
9
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
(function _wk_plugin() {
// Check if we are running in WKWebView
if (!window.webkit || !window.webkit.messageHandlers) {
return;
}
// Initialize Ionic
window.Ionic = window.Ionic || {};
function normalizeURL(url) {
<<<<<<< HEAD
if (!url) {
return url;
}
if (!url.startsWith("file://")) {
return url;
}
url = url.substr(7); // len("file://") == 7
if (url.length == 0 || url[0] !== '/') { // ensure the new URL starts with /
url = '/' + url;
}
return 'http://localhost:8080' + url;
}
if (typeof window.wkRewriteURL === 'undefined') {
window.wkRewriteURL = function (url) {
console.warn('wkRewriteURL is deprecated, use normalizeURL instead');
return normalizeURL(url);
=======
console.warn('normalizeURL is deprecated, use window.Ionic.WebView.convertFileSrc');
return window.Ionic.WebView.convertFileSrc(url);
}
if (typeof window.wkRewriteURL === 'undefined') {
window.wkRewriteURL = function (url) {
console.warn('wkRewriteURL is deprecated, use window.Ionic.WebView.convertFileSrc instead');
return window.Ionic.WebView.convertFileSrc(url);
>>>>>>> jeshi
}
}
window.Ionic.normalizeURL = normalizeURL;
<<<<<<< HEAD
var xhrPrototype = window.XMLHttpRequest.prototype;
var originalOpen = xhrPrototype.open;
xhrPrototype.open = function _wk_open(method, url) {
arguments[1] = normalizeURL(url);
originalOpen.apply(this, arguments);
}
console.debug("XHR polyfill injected!");
=======
>>>>>>> jeshi
var stopScrollHandler = window.webkit.messageHandlers.stopScroll;
if (!stopScrollHandler) {
console.error('Can not find stopScroll handler');
return;
}
var stopScrollFunc = null;
var stopScroll = {
stop: function stop(callback) {
if (!stopScrollFunc) {
stopScrollFunc = callback;
stopScrollHandler.postMessage('');
}
},
fire: function fire() {
stopScrollFunc && stopScrollFunc();
stopScrollFunc = null;
},
cancel: function cancel() {
stopScrollFunc = null;
}
};
window.Ionic.StopScroll = stopScroll;
// deprecated
window.IonicStopScroll = stopScroll;
console.debug("Ionic Stop Scroll injected!");
})();