cronapp-cordova-plugin-contentsync 4.4.0-RC.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/NOTICE +11 -0
- package/README.md +372 -0
- package/package-lock.json +1545 -0
- package/package.json +58 -0
- package/plugin.xml +93 -0
- package/sample/css/index.css +128 -0
- package/sample/img/logo.png +0 -0
- package/sample/index.html +47 -0
- package/sample/js/index.js +152 -0
- package/spec/helper/cordova.js +83 -0
- package/spec/index.spec.js +334 -0
- package/src/android/Sync.java +1102 -0
- package/src/browser/Sync.js +20 -0
- package/src/ios/ContentSync.h +74 -0
- package/src/ios/ContentSync.m +1002 -0
- package/src/ios/SSZipArchive.h +52 -0
- package/src/ios/SSZipArchive.m +540 -0
- package/src/ios/minizip/crypt.h +131 -0
- package/src/ios/minizip/ioapi.c +239 -0
- package/src/ios/minizip/ioapi.h +201 -0
- package/src/ios/minizip/mztools.c +284 -0
- package/src/ios/minizip/mztools.h +31 -0
- package/src/ios/minizip/unzip.c +2153 -0
- package/src/ios/minizip/unzip.h +437 -0
- package/src/ios/minizip/zip.c +2022 -0
- package/src/ios/minizip/zip.h +362 -0
- package/src/windows/SyncProxy.js +279 -0
- package/src/windows/ZipWinProj/PGZipInflate.cs +94 -0
- package/src/windows/ZipWinProj/Properties/AssemblyInfo.cs +30 -0
- package/src/windows/ZipWinProj/ZipWinProj.csproj +57 -0
- package/src/wp8/Sync.cs +746 -0
- package/src/wp8/Unzip.cs +481 -0
- package/tests/anyfile.txt +1 -0
- package/tests/archives/www1.zip +0 -0
- package/tests/archives/www2.zip +0 -0
- package/tests/package.json +11 -0
- package/tests/plugin.xml +22 -0
- package/tests/scripts/start-server.sh +2 -0
- package/tests/scripts/stop-server.sh +1 -0
- package/tests/tests.js +255 -0
- package/www/index.js +285 -0
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cronapp-cordova-plugin-contentsync",
|
|
3
|
+
"description": "Fetch and cache content for your PhoneGap app.",
|
|
4
|
+
"version": "4.4.0-RC.8",
|
|
5
|
+
"homepage": "https://github.com/CronApp/cronapp-cordova-plugin-contentsync#readme",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "jasmine-node --color spec",
|
|
8
|
+
"paramedic": "./tests/scripts/start-server.sh && cordova-paramedic --platform ios && ./tests/scripts/stop-server.sh"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git://github.com/CronApp/cronapp-cordova-plugin-contentsync.git"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/CronApp/cronapp-cordova-plugin-contentsync/issues"
|
|
16
|
+
},
|
|
17
|
+
"cordova": {
|
|
18
|
+
"id": "cronapp-cordova-plugin-contentsync",
|
|
19
|
+
"platforms": [
|
|
20
|
+
"ios",
|
|
21
|
+
"android",
|
|
22
|
+
"windows8",
|
|
23
|
+
"windows",
|
|
24
|
+
"wp8",
|
|
25
|
+
"browser",
|
|
26
|
+
"osx"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"ecosystem:cordova",
|
|
31
|
+
"ecosystem:phonegap",
|
|
32
|
+
"cordova-ios",
|
|
33
|
+
"cordova-android",
|
|
34
|
+
"cordova-windows8",
|
|
35
|
+
"cordova-windows",
|
|
36
|
+
"cordova-wp8",
|
|
37
|
+
"cordova-browser",
|
|
38
|
+
"cordova-osx"
|
|
39
|
+
],
|
|
40
|
+
"engines": [
|
|
41
|
+
{
|
|
42
|
+
"name": "cordova",
|
|
43
|
+
"version": ">=3.0.0"
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"author": "Adobe PhoneGap Team",
|
|
47
|
+
"license": "Apache-2.0",
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"jasmine-node": "1.14.5",
|
|
50
|
+
"pluginpub": "^0.0.9"
|
|
51
|
+
},
|
|
52
|
+
"resolutions": {
|
|
53
|
+
"minimatch": "~3.0.2",
|
|
54
|
+
"trim-newlines": "~3.0.1",
|
|
55
|
+
"dot-prop": "~4.2.1",
|
|
56
|
+
"growl": "~1.10.0"
|
|
57
|
+
}
|
|
58
|
+
}
|
package/plugin.xml
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cronapp-cordova-plugin-contentsync" version="4.4.0-RC.8">
|
|
3
|
+
<name>content-sync</name>
|
|
4
|
+
<description>Cronapp Content Sync Plugin</description>
|
|
5
|
+
<license/>
|
|
6
|
+
<keywords>phonegap,content sync</keywords>
|
|
7
|
+
<repo>https://github.com/CronApp/cronapp-cordova-plugin-contentsync</repo>
|
|
8
|
+
<issue>https://github.com/CronApp/cronapp-cordova-plugin-contentsync/issues</issue>
|
|
9
|
+
<js-module src="www/index.js" name="ContentSync">
|
|
10
|
+
<clobbers target="window.ContentSync"/>
|
|
11
|
+
<clobbers target="window.Zip"/>
|
|
12
|
+
<clobbers target="window.zip"/>
|
|
13
|
+
</js-module>
|
|
14
|
+
<platform name="android">
|
|
15
|
+
<config-file target="res/xml/config.xml" parent="/*">
|
|
16
|
+
<feature name="Sync">
|
|
17
|
+
<param name="android-package" value="com.adobe.phonegap.contentsync.Sync"/>
|
|
18
|
+
</feature>
|
|
19
|
+
<feature name="Zip">
|
|
20
|
+
<param name="android-package" value="com.adobe.phonegap.contentsync.Sync"/>
|
|
21
|
+
</feature>
|
|
22
|
+
</config-file>
|
|
23
|
+
<source-file src="src/android/Sync.java" target-dir="src/com/adobe/phonegap/contentsync"/>
|
|
24
|
+
</platform>
|
|
25
|
+
<platform name="browser">
|
|
26
|
+
<js-module src="src/browser/Sync.js" name="Sync">
|
|
27
|
+
<merges target="ContentSync"/>
|
|
28
|
+
</js-module>
|
|
29
|
+
</platform>
|
|
30
|
+
<platform name="wp8">
|
|
31
|
+
<config-file target="config.xml" parent="/*">
|
|
32
|
+
<feature name="Sync">
|
|
33
|
+
<param name="wp-package" value="Sync"/>
|
|
34
|
+
</feature>
|
|
35
|
+
</config-file>
|
|
36
|
+
<source-file src="src/wp8/Sync.cs"/>
|
|
37
|
+
<source-file src="src/wp8/Unzip.cs"/>
|
|
38
|
+
</platform>
|
|
39
|
+
<platform name="windows">
|
|
40
|
+
<js-module src="src/windows/SyncProxy.js" name="SyncProxy">
|
|
41
|
+
<runs/>
|
|
42
|
+
</js-module>
|
|
43
|
+
<framework src="src/windows/ZipWinProj/ZipWinProj.csproj" custom="true" type="projectReference"/>
|
|
44
|
+
</platform>
|
|
45
|
+
<platform name="ios">
|
|
46
|
+
<source-file src="src/ios/ContentSync.m"/>
|
|
47
|
+
<source-file src="src/ios/SSZipArchive.m" target-dir="minizip"/>
|
|
48
|
+
<source-file src="src/ios/minizip/zip.c" target-dir="minizip"/>
|
|
49
|
+
<source-file src="src/ios/minizip/unzip.c" target-dir="minizip"/>
|
|
50
|
+
<source-file src="src/ios/minizip/mztools.c" target-dir="minizip"/>
|
|
51
|
+
<source-file src="src/ios/minizip/ioapi.c" target-dir="minizip"/>
|
|
52
|
+
<header-file src="src/ios/ContentSync.h"/>
|
|
53
|
+
<header-file src="src/ios/SSZipArchive.h" target-dir="minizip"/>
|
|
54
|
+
<header-file src="src/ios/minizip/zip.h" target-dir="minizip"/>
|
|
55
|
+
<header-file src="src/ios/minizip/unzip.h" target-dir="minizip"/>
|
|
56
|
+
<header-file src="src/ios/minizip/mztools.h" target-dir="minizip"/>
|
|
57
|
+
<header-file src="src/ios/minizip/ioapi.h" target-dir="minizip"/>
|
|
58
|
+
<header-file src="src/ios/minizip/crypt.h" target-dir="minizip"/>
|
|
59
|
+
<config-file target="config.xml" parent="/*">
|
|
60
|
+
<feature name="Sync">
|
|
61
|
+
<param name="ios-package" value="ContentSync"/>
|
|
62
|
+
</feature>
|
|
63
|
+
<feature name="Zip">
|
|
64
|
+
<param name="ios-package" value="ContentSync"/>
|
|
65
|
+
</feature>
|
|
66
|
+
</config-file>
|
|
67
|
+
<framework src="libz.dylib"/>
|
|
68
|
+
</platform>
|
|
69
|
+
<platform name="osx">
|
|
70
|
+
<source-file src="src/ios/ContentSync.m"/>
|
|
71
|
+
<source-file src="src/ios/SSZipArchive.m" target-dir="minizip"/>
|
|
72
|
+
<source-file src="src/ios/minizip/zip.c" target-dir="minizip"/>
|
|
73
|
+
<source-file src="src/ios/minizip/unzip.c" target-dir="minizip"/>
|
|
74
|
+
<source-file src="src/ios/minizip/mztools.c" target-dir="minizip"/>
|
|
75
|
+
<source-file src="src/ios/minizip/ioapi.c" target-dir="minizip"/>
|
|
76
|
+
<header-file src="src/ios/ContentSync.h"/>
|
|
77
|
+
<header-file src="src/ios/SSZipArchive.h" target-dir="minizip"/>
|
|
78
|
+
<header-file src="src/ios/minizip/zip.h" target-dir="minizip"/>
|
|
79
|
+
<header-file src="src/ios/minizip/unzip.h" target-dir="minizip"/>
|
|
80
|
+
<header-file src="src/ios/minizip/mztools.h" target-dir="minizip"/>
|
|
81
|
+
<header-file src="src/ios/minizip/ioapi.h" target-dir="minizip"/>
|
|
82
|
+
<header-file src="src/ios/minizip/crypt.h" target-dir="minizip"/>
|
|
83
|
+
<config-file target="config.xml" parent="/*">
|
|
84
|
+
<feature name="Sync">
|
|
85
|
+
<param name="osx-package" value="ContentSync"/>
|
|
86
|
+
</feature>
|
|
87
|
+
<feature name="Zip">
|
|
88
|
+
<param name="osx-package" value="ContentSync"/>
|
|
89
|
+
</feature>
|
|
90
|
+
</config-file>
|
|
91
|
+
<framework src="libz.dylib"/>
|
|
92
|
+
</platform>
|
|
93
|
+
</plugin>
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
* {
|
|
20
|
+
-webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
body {
|
|
24
|
+
-webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */
|
|
25
|
+
-webkit-text-size-adjust: none; /* prevent webkit from resizing text to fit */
|
|
26
|
+
-webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */
|
|
27
|
+
background-color:#E4E4E4;
|
|
28
|
+
background-image:linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
|
|
29
|
+
background-image:-webkit-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
|
|
30
|
+
background-image:-ms-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
|
|
31
|
+
background-image:-webkit-gradient(
|
|
32
|
+
linear,
|
|
33
|
+
left top,
|
|
34
|
+
left bottom,
|
|
35
|
+
color-stop(0, #A7A7A7),
|
|
36
|
+
color-stop(0.51, #E4E4E4)
|
|
37
|
+
);
|
|
38
|
+
background-attachment:fixed;
|
|
39
|
+
font-family:'HelveticaNeue-Light', 'HelveticaNeue', Helvetica, Arial, sans-serif;
|
|
40
|
+
font-size:12px;
|
|
41
|
+
height:100%;
|
|
42
|
+
margin:0px;
|
|
43
|
+
padding:0px;
|
|
44
|
+
text-transform:uppercase;
|
|
45
|
+
width:100%;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* Portrait layout (default) */
|
|
49
|
+
.app {
|
|
50
|
+
background:url(../img/logo.png) no-repeat center top; /* 170px x 200px */
|
|
51
|
+
position:absolute; /* position in the center of the screen */
|
|
52
|
+
left:50%;
|
|
53
|
+
top:50%;
|
|
54
|
+
height:50px; /* text area height */
|
|
55
|
+
width:225px; /* text area width */
|
|
56
|
+
text-align:center;
|
|
57
|
+
padding:180px 0px 0px 0px; /* image height is 200px (bottom 20px are overlapped with text) */
|
|
58
|
+
margin:-115px 0px 0px -112px; /* offset vertical: half of image height and text area height */
|
|
59
|
+
/* offset horizontal: half of text area width */
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Landscape layout (with min-width) */
|
|
63
|
+
@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) {
|
|
64
|
+
.app {
|
|
65
|
+
background-position:left center;
|
|
66
|
+
padding:75px 0px 75px 170px; /* padding-top + padding-bottom + text area = image height */
|
|
67
|
+
margin:-90px 0px 0px -198px; /* offset vertical: half of image height */
|
|
68
|
+
/* offset horizontal: half of image width and text area width */
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
h1 {
|
|
73
|
+
font-size:24px;
|
|
74
|
+
font-weight:normal;
|
|
75
|
+
margin:0px;
|
|
76
|
+
overflow:visible;
|
|
77
|
+
padding:0px;
|
|
78
|
+
text-align:center;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.event {
|
|
82
|
+
border-radius:4px;
|
|
83
|
+
-webkit-border-radius:4px;
|
|
84
|
+
color:#FFFFFF;
|
|
85
|
+
font-size:12px;
|
|
86
|
+
margin:0px 30px;
|
|
87
|
+
padding:2px 0px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.event.listening {
|
|
91
|
+
background-color:#333333;
|
|
92
|
+
display:block;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.event.received {
|
|
96
|
+
background-color:#4B946A;
|
|
97
|
+
display:none;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@keyframes fade {
|
|
101
|
+
from { opacity: 1.0; }
|
|
102
|
+
50% { opacity: 0.4; }
|
|
103
|
+
to { opacity: 1.0; }
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@-webkit-keyframes fade {
|
|
107
|
+
from { opacity: 1.0; }
|
|
108
|
+
50% { opacity: 0.4; }
|
|
109
|
+
to { opacity: 1.0; }
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.blink {
|
|
113
|
+
animation:fade 3000ms infinite;
|
|
114
|
+
-webkit-animation:fade 3000ms infinite;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
#progressbar {
|
|
118
|
+
background-color: black;
|
|
119
|
+
border-radius: 13px; /* (height of inner div) / 2 + padding */
|
|
120
|
+
padding: 3px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
#progressbar > div {
|
|
124
|
+
background-color:#4B946A;
|
|
125
|
+
width: 0%; /* Adjust with JavaScript */
|
|
126
|
+
height: 20px;
|
|
127
|
+
border-radius: 10px;
|
|
128
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<!--
|
|
3
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
+
or more contributor license agreements. See the NOTICE file
|
|
5
|
+
distributed with this work for additional information
|
|
6
|
+
regarding copyright ownership. The ASF licenses this file
|
|
7
|
+
to you under the Apache License, Version 2.0 (the
|
|
8
|
+
"License"); you may not use this file except in compliance
|
|
9
|
+
with the License. You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing,
|
|
14
|
+
software distributed under the License is distributed on an
|
|
15
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
KIND, either express or implied. See the License for the
|
|
17
|
+
specific language governing permissions and limitations
|
|
18
|
+
under the License.
|
|
19
|
+
-->
|
|
20
|
+
<html>
|
|
21
|
+
<head>
|
|
22
|
+
<meta charset="utf-8" />
|
|
23
|
+
<meta name="format-detection" content="telephone=no" />
|
|
24
|
+
<meta name="msapplication-tap-highlight" content="no" />
|
|
25
|
+
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
|
|
26
|
+
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
|
|
27
|
+
<link rel="stylesheet" type="text/css" href="css/index.css" />
|
|
28
|
+
<title>Hello World</title>
|
|
29
|
+
</head>
|
|
30
|
+
<body>
|
|
31
|
+
<div class="app">
|
|
32
|
+
<h1>Apache Cordova</h1>
|
|
33
|
+
<div id="deviceready" class="blink">
|
|
34
|
+
<p class="event listening">Connecting to Device</p>
|
|
35
|
+
<p class="event received">Device is Ready</p>
|
|
36
|
+
<button id="syncBtn" type="button">Sync</button>
|
|
37
|
+
<button id="downloadExtractBtn" type="button">Download</button>
|
|
38
|
+
</div>
|
|
39
|
+
<div id="status"></div>
|
|
40
|
+
<div id="progressbar">
|
|
41
|
+
<div></div>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
<script type="text/javascript" src="cordova.js"></script>
|
|
45
|
+
<script type="text/javascript" src="js/index.js"></script>
|
|
46
|
+
</body>
|
|
47
|
+
</html>
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
var app = {
|
|
20
|
+
// Application Constructor
|
|
21
|
+
initialize: function() {
|
|
22
|
+
this.bindEvents();
|
|
23
|
+
},
|
|
24
|
+
// Bind Event Listeners
|
|
25
|
+
//
|
|
26
|
+
// Bind any events that are required on startup. Common events are:
|
|
27
|
+
// 'load', 'deviceready', 'offline', and 'online'.
|
|
28
|
+
bindEvents: function() {
|
|
29
|
+
document.addEventListener('deviceready', this.onDeviceReady, false);
|
|
30
|
+
},
|
|
31
|
+
// deviceready Event Handler
|
|
32
|
+
//
|
|
33
|
+
// The scope of 'this' is the event. In order to call the 'receivedEvent'
|
|
34
|
+
// function, we must explicitly call 'app.receivedEvent(...);'
|
|
35
|
+
onDeviceReady: function() {
|
|
36
|
+
app.receivedEvent('deviceready');
|
|
37
|
+
},
|
|
38
|
+
// Update DOM on a Received Event
|
|
39
|
+
receivedEvent: function(id) {
|
|
40
|
+
var parentElement = document.getElementById(id);
|
|
41
|
+
var listeningElement = parentElement.querySelector('.listening');
|
|
42
|
+
var receivedElement = parentElement.querySelector('.received');
|
|
43
|
+
|
|
44
|
+
listeningElement.setAttribute('style', 'display:none;');
|
|
45
|
+
receivedElement.setAttribute('style', 'display:block;');
|
|
46
|
+
|
|
47
|
+
console.log('Received Event: ' + id);
|
|
48
|
+
|
|
49
|
+
document.getElementById("syncBtn").onclick = this.sync;
|
|
50
|
+
document.getElementById("downloadExtractBtn").onclick = this.download;
|
|
51
|
+
|
|
52
|
+
var sync = ContentSync.sync({id: 'myapp', type: 'local'});
|
|
53
|
+
sync.on('complete', function(data) {
|
|
54
|
+
if(data.localPath) {
|
|
55
|
+
var url = "file://"+data.localPath + "/www/index.html";
|
|
56
|
+
alert('Sync complete ' + data + ' changing document.location ' + url );
|
|
57
|
+
//document.location = url;
|
|
58
|
+
ContentSync.loadUrl(url);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
sync.on('error', function(e) {
|
|
62
|
+
alert('no synced app. Loading main app');
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
setProgress: function(progress) {
|
|
67
|
+
if(progress.status) {
|
|
68
|
+
switch(progress.status) {
|
|
69
|
+
case 1:
|
|
70
|
+
document.getElementById('status').innerHTML = "Downloading...";
|
|
71
|
+
break;
|
|
72
|
+
case 2:
|
|
73
|
+
document.getElementById('status').innerHTML = "Extracting...";
|
|
74
|
+
break;
|
|
75
|
+
case 3:
|
|
76
|
+
document.getElementById('status').innerHTML = "Complete!";
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
document.getElementById('status').innerHTML = "";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if(progress.progress) {
|
|
83
|
+
var progressBar = document.getElementById('progressbar').children[0];
|
|
84
|
+
progressBar.style.width = progress.progress + '%';
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
sync: function() {
|
|
90
|
+
//var url = "https://github.com/timkim/zipTest/archive/master.zip";
|
|
91
|
+
var url = "http://localhost:8000/www.zip";
|
|
92
|
+
//var sync = ContentSync.sync({ src: url, id: 'myapp', type: 'merge', copyCordovaAssets: true, copyRootApp: false, headers: false, trustHost: true });
|
|
93
|
+
//var sync = ContentSync.sync({ src: null, id: 'myapp', type: 'local', copyRootApp: true });
|
|
94
|
+
var sync = ContentSync.sync({ src: url, id: 'myapp', type: 'merge', copyCordovaAssets: true });
|
|
95
|
+
|
|
96
|
+
var setProgress = this.setProgress;
|
|
97
|
+
|
|
98
|
+
sync.on('progress', function(progress) {
|
|
99
|
+
console.log("Progress event", progress);
|
|
100
|
+
app.setProgress(progress);
|
|
101
|
+
});
|
|
102
|
+
sync.on('complete', function(data) {
|
|
103
|
+
console.log("Complete", data);
|
|
104
|
+
//ContentSync.loadUrl("file://"+data.localPath + "/zipTest-master/www/index.html");
|
|
105
|
+
//document.location = data.localPath + "/zipTest-master/www/index.html";
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
sync.on('error', function(e) {
|
|
109
|
+
console.log("Something went wrong: ", e);
|
|
110
|
+
document.getElementById('status').innerHTML = e;
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
download: function() {
|
|
114
|
+
document.getElementById("downloadExtractBtn").disabled = true;
|
|
115
|
+
var url = "https://github.com/timkim/zipTest/archive/master.zip";
|
|
116
|
+
var extract = this.extract;
|
|
117
|
+
var setProgress = this.setProgress;
|
|
118
|
+
var callback = function(response) {
|
|
119
|
+
console.log(response);
|
|
120
|
+
if(response.progress) {
|
|
121
|
+
app.setProgress(response);
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
if(response.archiveURL) {
|
|
125
|
+
var archiveURL = response.archiveURL;
|
|
126
|
+
document.getElementById("downloadExtractBtn").disabled = false;
|
|
127
|
+
document.getElementById("downloadExtractBtn").innerHTML = "Extract";
|
|
128
|
+
document.getElementById("downloadExtractBtn").onclick = function() {
|
|
129
|
+
app.extract(archiveURL);
|
|
130
|
+
};
|
|
131
|
+
document.getElementById("status").innerHTML = archiveURL;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
ContentSync.download(url, callback);
|
|
135
|
+
},
|
|
136
|
+
extract: function(archiveURL) {
|
|
137
|
+
window.requestFileSystem(PERSISTENT, 1024 * 1024, function(fs) {
|
|
138
|
+
fs.root.getDirectory('zipOutPut', {create: true}, function(fileEntry) {
|
|
139
|
+
var dirUrl = fileEntry.toURL();
|
|
140
|
+
var callback = function(response) {
|
|
141
|
+
console.log(response);
|
|
142
|
+
document.getElementById("downloadExtractBtn").style.display = "none";
|
|
143
|
+
document.getElementById("status").innerHTML = "Extracted";
|
|
144
|
+
}
|
|
145
|
+
console.log(dirUrl, archiveURL);
|
|
146
|
+
Zip.unzip(archiveURL, dirUrl, callback);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
app.initialize();
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/* global cordova:true */
|
|
2
|
+
|
|
3
|
+
/*!
|
|
4
|
+
* Module dependencies.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* cordova.js for node.
|
|
9
|
+
*
|
|
10
|
+
* Think of this as cordova-node, which would be simliar to cordova-android
|
|
11
|
+
* or cordova-browser. The purpose of this module is to enable testing
|
|
12
|
+
* of a plugin's JavaScript interface.
|
|
13
|
+
*
|
|
14
|
+
* When this module is first required, it will insert a global cordova
|
|
15
|
+
* instance, which can hijack cordova-specific commands within the pluin's
|
|
16
|
+
* implementation.
|
|
17
|
+
*
|
|
18
|
+
* Remember to require this module before the plugin that you want to test.
|
|
19
|
+
*
|
|
20
|
+
* Example:
|
|
21
|
+
*
|
|
22
|
+
* var cordova = require('./helper/cordova'),
|
|
23
|
+
* myPlugin = require('../www/myPlugin');
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
module.exports = global.cordova = cordova = {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* cordova.require Mock.
|
|
30
|
+
*
|
|
31
|
+
* Hijacks all cordova.requires. By default, it returns an empty function.
|
|
32
|
+
* You can define your own implementation of each required module before
|
|
33
|
+
* or after it has been required.
|
|
34
|
+
*
|
|
35
|
+
* See `cordova.required` to learn how to add your own module implemtnation.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
require: function(moduleId) {
|
|
39
|
+
// define a default function if it doesn't exist
|
|
40
|
+
if (!cordova.required[moduleId]) {
|
|
41
|
+
cordova.required[moduleId] = function() {};
|
|
42
|
+
}
|
|
43
|
+
// create a new module mapping between the module Id and cordova.required.
|
|
44
|
+
return new ModuleMap(moduleId);
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Cordova module implementations.
|
|
49
|
+
*
|
|
50
|
+
* A key-value hash, where the key is the module such as 'cordova/exec'
|
|
51
|
+
* and the value is the function or object returned.
|
|
52
|
+
*
|
|
53
|
+
* For example:
|
|
54
|
+
*
|
|
55
|
+
* var exec = require('cordova/exec');
|
|
56
|
+
*
|
|
57
|
+
* Will map to:
|
|
58
|
+
*
|
|
59
|
+
* cordova.required['cordova/exec'];
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
required: {
|
|
63
|
+
// populated at runtime
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Module Mapper.
|
|
69
|
+
*
|
|
70
|
+
* Returns a function that when executed will lookup the implementation
|
|
71
|
+
* in cordova.required[id].
|
|
72
|
+
*
|
|
73
|
+
* @param {String} moduleId is the module name/path, such as 'cordova/exec'
|
|
74
|
+
* @return {Function}.
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
function ModuleMap(moduleId) {
|
|
78
|
+
return function() {
|
|
79
|
+
// lookup and execute the module's mock implementation, passing
|
|
80
|
+
// in any parameters that were provided.
|
|
81
|
+
return cordova.required[moduleId].apply(this, arguments);
|
|
82
|
+
};
|
|
83
|
+
}
|