Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.41 KB | None | 0 0
  1. <?xml version='1.0' encoding='utf-8'?>
  2. <widget id="foo" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
  3. <name>foo</name>
  4. <description>
  5. foo
  6. </description>
  7. <author email="dev@cordova.apache.org" href="http://cordova.io">
  8.  
  9. </author>
  10. <content src="index.html" />
  11. <plugin name="cordova-plugin-whitelist"/>
  12. <access origin="*" />
  13. <allow-intent href="*" />
  14. <allow-navigation href="*" />
  15. <access origin="*" />
  16. <platform name="android">
  17. <allow-intent href="market:*" />
  18. <access origin="*" />
  19. <allow-intent href="*" />
  20. <allow-navigation href="*" />
  21. </platform>
  22. <platform name="ios">
  23. <allow-intent href="itms:*" />
  24. <allow-intent href="itms-apps:*" />
  25. </platform>
  26. <engine name="android"/>
  27. <plugin name="cordova-plugin-inappbrowser"/>
  28.  
  29. <!DOCTYPE html>
  30. <!--
  31. Licensed to the Apache Software Foundation (ASF) under one
  32. or more contributor license agreements. See the NOTICE file
  33. distributed with this work for additional information
  34. regarding copyright ownership. The ASF licenses this file
  35. to you under the Apache License, Version 2.0 (the
  36. "License"); you may not use this file except in compliance
  37. with the License. You may obtain a copy of the License at
  38.  
  39.  
  40. http://www.apache.org/licenses/LICENSE-2.0
  41.  
  42.  
  43. Unless required by applicable law or agreed to in writing,
  44. software distributed under the License is distributed on an
  45. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46. KIND, either express or implied. See the License for the
  47. specific language governing permissions and limitations
  48. under the License.
  49. -->
  50. <html>
  51. <head>
  52. <!--
  53. Customize this policy to fit your own app's needs. For more guidance, see:
  54. https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
  55. Some notes:
  56. * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
  57. * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
  58. * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
  59. * Enable inline JS: add 'unsafe-inline' to default-src
  60. -->
  61. <!-- <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *"> -->
  62. <meta http-equiv="Content-Security-Policy" content="default-src 'self' * ws://localhost:35729 data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *;script-src 'self' localhost:35729 'unsafe-eval' 'unsafe-inline';">
  63. <meta name="format-detection" content="telephone=no">
  64. <meta name="msapplication-tap-highlight" content="no">
  65. <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
  66. <link rel="stylesheet" type="text/css" href="css/index.css">
  67. <title>Hello World</title>
  68. </head>
  69. <body>
  70. <center><div class="">
  71. <div id="deviceready" class="row col s12">
  72. <h1>foo</h1>
  73. <div class="input-field col s8">
  74. <input type="text" id="addr" name="addr" placeholder="Adresse">
  75. </div>
  76. <div class="input-field col s4">
  77. <input type="text" id="port" placeholder="port">
  78. </div>
  79. <div class="input-field col s12">
  80. <input type="text" id="name" placeholder="Nom d'utilisateur">
  81. </div>
  82. <div class="input-field col s12">
  83. <input type="password" id="pswd" placeholder="Mot de passe">
  84. </div>
  85. <button id="button_test" class="waves-effect waves-light btn blue lighten-1" value="tester">tester</button>
  86. <button id="button_start" class="waves-effect waves-light btn blue lighten-1" value="commencer">commencer</button>
  87. </div>
  88. <div id="result"></div>
  89. <div id="window-iframe"></div>
  90. </div></center>
  91. <script type="text/javascript" src="cordova.js"></script>
  92. <script type="text/javascript" src="js/jquery.min.js"></script>
  93. <script type="text/javascript" src="js/index.js"></script>
  94. </body>
  95.  
  96. /*
  97. * Licensed to the Apache Software Foundation (ASF) under one
  98. * or more contributor license agreements. See the NOTICE file
  99. * distributed with this work for additional information
  100. * regarding copyright ownership. The ASF licenses this file
  101. * to you under the Apache License, Version 2.0 (the
  102. * "License"); you may not use this file except in compliance
  103. * with the License. You may obtain a copy of the License at
  104. *
  105. * http://www.apache.org/licenses/LICENSE-2.0
  106. *
  107. * Unless required by applicable law or agreed to in writing,
  108. * software distributed under the License is distributed on an
  109. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  110. * KIND, either express or implied. See the License for the
  111. * specific language governing permissions and limitations
  112. * under the License.
  113. */
  114.  
  115.  
  116.  
  117.  
  118. var app = {
  119. // Application Constructor
  120. initialize: function() {
  121. this.bindEvents();
  122. },
  123. // Bind Event Listeners
  124. //
  125. // Bind any events that are required on startup. Common events are:
  126. // 'load', 'deviceready', 'offline', and 'online'.
  127. bindEvents: function() {
  128. document.addEventListener('deviceready', this.onDeviceReady, false);
  129. },
  130. // deviceready Event Handler
  131. //
  132. // The scope of 'this' is the event. In order to call the 'receivedEvent'
  133. // function, we must explicitly call 'app.receivedEvent(...);'
  134. onDeviceReady: function() {
  135. app.receivedEvent('deviceready');
  136. },
  137. // Update DOM on a Received Event
  138. receivedEvent: function(id) {
  139. var parentElement = document.getElementById(id);
  140. var listeningElement = parentElement.querySelector('.listening');
  141. var receivedElement = parentElement.querySelector('.received');
  142.  
  143.  
  144. listeningElement.setAttribute('style', 'display:none;');
  145. receivedElement.setAttribute('style', 'display:block;');
  146.  
  147.  
  148. console.log('Received Event: ' + id);
  149. }
  150. };
  151.  
  152.  
  153. function debug(string){
  154. $("#result").html($("#result").html()+"</br>"+string);
  155. }
  156.  
  157.  
  158. debug("ready");
  159.  
  160.  
  161. document.getElementById("button_test").addEventListener("click", test);
  162. document.getElementById("button_start").addEventListener("click", start);
  163.  
  164.  
  165. document.getElementById("addr").value = localStorage.getItem("address");
  166. document.getElementById("port").value = localStorage.getItem("port");
  167. document.getElementById("name").value = localStorage.getItem("username");
  168. document.getElementById("pswd").value = localStorage.getItem("password");
  169.  
  170.  
  171. function test(){
  172. debug("connecting...");
  173. console.log("connecting...");
  174. addr = document.getElementById("addr").value;
  175. port = document.getElementById("port").value;
  176. username = document.getElementById("name").value;
  177. password = document.getElementById("pswd").value;
  178.  
  179.  
  180. url_req = "http://www.lemonde.fr/";
  181. // url_req = 'http://'+addr+':'+port;//'/actions.php?do=auth&login='+username+'&password='+password;
  182. debug("connecting...to->"+url_req)
  183. $.ajax({
  184. url: url_req,
  185. timeout: 30000,
  186. success: function(data, status, xhr) {
  187. debug("ajax sucess");
  188. console.log(data);
  189. data = JSON.parse(data);
  190. if(data.return == "success"){
  191. $("#result").html("OK");
  192. } else {
  193. debug("page return fail");
  194. $("#result").html(data.error);
  195. }
  196. },
  197. error: function (xhr, ajaxOptions, thrownError) {
  198. debug("error->"+thrownError);
  199. }
  200. });
  201. localStorage.setItem("address", addr);
  202. localStorage.setItem("port", port);
  203. localStorage.setItem("username", username);
  204. localStorage.setItem("password", password);
  205. }
  206.  
  207.  
  208. function start(){
  209. addr = document.getElementById("addr").value;
  210. port = document.getElementById("port").value;
  211. username = document.getElementById("name").value;
  212. password = document.getElementById("pswd").value;
  213. $("#window-iframe").html("<iframe src='http://www.lemonde.fr/' width='800px' height='600px'></iframe>");
  214. //var ref = window.open('http://www.lemonde.fr/', '_blank', 'location=yes');
  215. }
  216.  
  217.  
  218. app.initialize();
  219.  
  220. <?xml version='1.0' encoding='utf-8'?>
  221. <manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="foo" xmlns:android="http://schemas.android.com/apk/res/android">
  222. <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
  223. <uses-permission android:name="android.permission.INTERNET" />
  224. <application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
  225. <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
  226. <intent-filter android:label="@string/launcher_name">
  227. <action android:name="android.intent.action.MAIN" />
  228. <category android:name="android.intent.category.LAUNCHER" />
  229. </intent-filter>
  230. </activity>
  231. </application>
  232. <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23" />
  233. <uses-permission android:name="android.permission.INTERNET" />
  234. <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  235. <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  236. </manifest>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement