1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | import QtQuick 2.0
|
24 | import Ubuntu.Components.Popups 0.1
|
25 | import Ubuntu.Components 0.1
|
26 | import com.canonical.Oxide 1.0
|
27 |
|
28 | Rectangle {
|
29 | anchors.fill: parent
|
30 | id: inappbrowser
|
31 | property string url1
|
32 | Rectangle {
|
33 | border.color: "black"
|
34 | width: parent.width
|
35 | height: urlEntry.height
|
36 | color: "gray"
|
37 | TextInput {
|
38 | id: urlEntry
|
39 | width: parent.width - closeButton.width
|
40 | text: url1
|
41 | activeFocusOnPress: false
|
42 | }
|
43 | Image {
|
44 | id: closeButton
|
45 | width: height
|
46 | x: parent.width - width
|
47 | height: parent.height
|
48 | source: "close.png"
|
49 | MouseArea {
|
50 | anchors.fill: parent
|
51 | onClicked: {
|
52 | root.exec("InAppBrowser", "close", [0, 0])
|
53 | }
|
54 | }
|
55 | }
|
56 | }
|
57 |
|
58 | property string usContext: "oxide://main-world/2"
|
59 |
|
60 | function executeJS(scId, code) {
|
61 | var req = _view.rootFrame.sendMessage(usContext, "EXECUTE", {code: code});
|
62 |
|
63 | req.onreply = function(response) {
|
64 | var code = 'cordova.callback(' + scId + ', JSON.parse(\'' + JSON.stringify(response.result) + '\'))';
|
65 | console.warn(code);
|
66 | cordova.javaScriptExecNeeded(code);
|
67 | console.warn("RESP:" + JSON.stringify(response));
|
68 | };
|
69 | }
|
70 |
|
71 | WebView {
|
72 | width: parent.width
|
73 | y: urlEntry.height
|
74 | height: parent.height - y
|
75 | url: url1
|
76 | id: _view
|
77 | onLoadingStateChanged: {
|
78 | root.exec("InAppBrowser", "loadFinished", [_view.loading])
|
79 | }
|
80 | context: WebContext {
|
81 | id: webcontext
|
82 |
|
83 | userScripts: [
|
84 | UserScript {
|
85 | context: usContext
|
86 | emulateGreasemonkey: true
|
87 | url: "InAppBrowser_escapeScript.js"
|
88 | }
|
89 | ]
|
90 | }
|
91 | }
|
92 | }
|