Cyranicus commited on
Commit
752edc4
1 Parent(s): 10f29d6

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +228 -18
index.html CHANGED
@@ -1,19 +1,229 @@
1
- <!DOCTYPE html>
2
  <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <html>
2
+ <head>
3
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
4
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
5
+ <script>
6
+ // edit this with your own apps
7
+ var launchPageConfig = {
8
+ "apps": [{
9
+ "icon": "https://uswest.appetize.io/images/sample-icon.png",
10
+ "iOS": {
11
+ "publicKey": "demo_phq04c56jnvrkg0bn9w5ep4m9r",
12
+ "languages": [{
13
+ "locale": "en_CA",
14
+ "language": "en",
15
+ "name": "English"
16
+ }, {
17
+ "locale": "fr_CA",
18
+ "language": "fr",
19
+ "iosKeyboard": "fr_CA@sw=QWERTY-Accents",
20
+ "name": "French"
21
+ }],
22
+ "devices": [{
23
+ "name": "Phone",
24
+ "type": "iphone8"
25
+ }, {
26
+ "name": "Tablet",
27
+ "type": "ipadair2"
28
+ }]
29
+ },
30
+ "Android": {
31
+ "publicKey": "demo_r0m5r98axtdhftx1hmmhq1c0m8",
32
+ "languages": [{
33
+ "language": "en_CA",
34
+ "name": "English"
35
+ }, {
36
+ "language": "fr_CA",
37
+ "name": "French"
38
+ }],
39
+ "devices": [{
40
+ "name": "Phone",
41
+ "type": "nexus5"
42
+ }, {
43
+ "name": "Tablet",
44
+ "type": "nexus9"
45
+ }]
46
+ }
47
+ }],
48
+ "options": {
49
+ "hidePasswords": true
50
+ }
51
+ };
52
+
53
+ $( document ).ready(function() {
54
+ // list apps
55
+ var appElements = [];
56
+ for (var i = 0; i < launchPageConfig.apps.length; i++) {
57
+ appElements.push("<a onclick='selectApp(" + i + ");'><img src='" + launchPageConfig.apps[i].icon + "' class='launch-icon'/></a>");
58
+ }
59
+ $('#apps').empty();
60
+ $('#apps').append(appElements);
61
+ selectApp(0);
62
+ });
63
+ // select app, update platforms, devices, languages
64
+ var selectedApp = 0;
65
+ function selectApp(index) {
66
+ if (!sessionActive || confirm('This will restart your session. Do you want to continue?')) {
67
+ sessionActive = false;
68
+ selectedApp = index;
69
+ $('#apps .selected').removeClass('selected');
70
+ $($('#apps img')[selectedApp]).addClass('selected');
71
+ // create platform buttons
72
+ var platformElements = [];
73
+ if (launchPageConfig.apps[index].iOS)
74
+ platformElements.push("<a onclick=\"selectPlatform('iOS');\"><button type=\"button\" class=\"btn btn-info\">iOS</button></a>");
75
+ if (launchPageConfig.apps[index].Android)
76
+ platformElements.push("<a onclick=\"selectPlatform('Android');\"><button type=\"button\" class=\"btn btn-info\">Android</button></a>");
77
+ $('#platforms').empty();
78
+ $('#platforms').append(platformElements);
79
+ // select default platform
80
+ if (launchPageConfig.apps[index].iOS)
81
+ selectPlatform('iOS');
82
+ else if (launchPageConfig.apps[index].Android)
83
+ selectPlatform('Android');
84
+ }
85
+ }
86
+ var selectedPlatform;
87
+ function selectPlatform(platform) {
88
+ if (!sessionActive || confirm('This will restart your session. Do you want to continue?')) {
89
+ sessionActive = false;
90
+ $('#savescreenshot').hide();
91
+ $('#endsession').hide();
92
+ selectedPlatform = platform;
93
+ $('#platforms .selected').removeClass('selected');
94
+ $('#platforms .btn:contains("'+selectedPlatform+'")').addClass('selected');
95
+ var deviceElements = [];
96
+ if (launchPageConfig.apps[selectedApp][platform].devices && launchPageConfig.apps[selectedApp][selectedPlatform].devices.length > 0) {
97
+ for (var i = 0; i < launchPageConfig.apps[selectedApp][platform].devices.length; i++) {
98
+ var element = $(document.createElement('a'));
99
+ element.attr("onclick", "selectDevice(launchPageConfig.apps[selectedApp][selectedPlatform].devices["+i+"])");
100
+ element.append("<button type=\"button\" class=\"btn btn-info\">"+launchPageConfig.apps[selectedApp][selectedPlatform].devices[i].name+"</button>");
101
+ deviceElements.push(element);
102
+ }
103
+ $('#devices').empty();
104
+ $('#devices').append(deviceElements);
105
+ selectDevice(launchPageConfig.apps[selectedApp][selectedPlatform].devices[0]);
106
+ }
107
+ var languageElements = [];
108
+ if (launchPageConfig.apps[selectedApp][selectedPlatform].languages && launchPageConfig.apps[selectedApp][selectedPlatform].languages.length > 0) {
109
+ for (var i = 0; i < launchPageConfig.apps[selectedApp][selectedPlatform].languages.length; i++) {
110
+ var element = $(document.createElement('a'));
111
+ element.attr("onclick", "selectLanguage(launchPageConfig.apps[selectedApp][selectedPlatform].languages["+i+"])");
112
+ element.append("<button type=\"button\" class=\"btn btn-info\">"+launchPageConfig.apps[selectedApp][selectedPlatform].languages[i].name+"</button>");
113
+
114
+ languageElements.push(element);
115
+ }
116
+ $('#languages').empty();
117
+ $('#languages').append(languageElements);
118
+ selectLanguage(launchPageConfig.apps[selectedApp][selectedPlatform].languages[0]);
119
+ }
120
+ }
121
+ }
122
+ var selectedDevice;
123
+ function selectDevice(device) {
124
+ if (!sessionActive || confirm('This will restart your session. Do you want to continue?')) {
125
+ sessionActive = false;
126
+ $('#savescreenshot').hide();
127
+ $('#endsession').hide();
128
+ selectedDevice = device;
129
+ $('#devices .selected').removeClass('selected');
130
+ $('#devices .btn:contains("'+selectedDevice.name+'")').addClass('selected');
131
+ updateIframeSrcUrl();
132
+ }
133
+ }
134
+ var selectedLanguage = {};
135
+ function selectLanguage(language) {
136
+ if (!sessionActive || confirm('This will restart your session. Do you want to continue?')) {
137
+ sessionActive = false;
138
+ $('#savescreenshot').hide();
139
+ $('#endsession').hide();
140
+ selectedLanguage = language;
141
+ $('#languages .selected').removeClass('selected');
142
+ $('#languages .btn:contains("'+selectedLanguage.name+'")').addClass('selected');
143
+ updateIframeSrcUrl();
144
+ }
145
+ }
146
+ function updateIframeSrcUrl() {
147
+ var url = 'https://appetize.io/embed/' + launchPageConfig.apps[selectedApp][selectedPlatform].publicKey + '?deviceColor=white&centered=true&toast=top&xdocMsg=true&device=' + selectedDevice.type + '&language=' + selectedLanguage.language + '&locale=' + selectedLanguage.locale + '&iosKeyboard=' + selectedLanguage.iosKeyboard + '&hidePasswords=' + launchPageConfig.options.hidePasswords + '&orientation=auto';
148
+ $('#app_iframe').attr('src', url);
149
+ iframe = document.querySelector('iframe');
150
+ }
151
+ $(document).on('input', '#slider', function() {
152
+ setScale( $(this).val()*100 );
153
+ });
154
+ // Sending messages to iframe from parent window
155
+ var iframe = document.querySelector('iframe');
156
+ function rotateLeft() {
157
+ iframe.contentWindow.postMessage('rotateLeft', '*');
158
+ }
159
+ function rotateRight() {
160
+ iframe.contentWindow.postMessage('rotateRight', '*');
161
+ }
162
+ function setScale(number) {
163
+ iframe.contentWindow.postMessage({
164
+ type: 'setScale',
165
+ value: number
166
+ }, '*');
167
+ }
168
+ function saveScreenshot() {
169
+ iframe.contentWindow.postMessage('saveScreenshot', '*');
170
+ }
171
+ function endSession() {
172
+ if (!sessionActive || confirm('This will restart your session. Do you want to continue?')) {
173
+ iframe.contentWindow.postMessage('endSession', '*');
174
+ }
175
+ }
176
+ // Receiving cross-document messages from iframe in parent window
177
+ var sessionActive;
178
+ var messageEventHandler = function(event) {
179
+ if (event.data == 'appLaunch') {
180
+ sessionActive = true;
181
+ $('#savescreenshot').show();
182
+ $('#endsession').show();
183
+ } else if (event.data == 'sessionEnded') {
184
+ sessionActive = false;
185
+ $('#savescreenshot').hide();
186
+ $('#endsession').hide();
187
+ }
188
+ };
189
+ window.addEventListener('message', messageEventHandler, false);
190
+ </script>
191
+ <style>
192
+ body {
193
+ padding: 20px;
194
+ }
195
+ a {
196
+ cursor: pointer;
197
+ }
198
+ .launch-icon {
199
+ width: 50px;
200
+ border-radius: 5px;
201
+ }
202
+ button{
203
+ margin-bottom: 10px;
204
+ }
205
+ .toggles .btn:not(.selected),
206
+ .toggles img:not(.selected) {
207
+ opacity: .4;
208
+ }
209
+ </style>
210
+ </head>
211
+ <body>
212
+ <h5>
213
+ Platform
214
+ </h5>
215
+ <div id="platforms" class="toggles"><a onclick="selectPlatform(&#39;iOS&#39;);"><button type="button" class="btn btn-info selected">iOS</button></a><a onclick="selectPlatform(&#39;Android&#39;);"><button type="button" class="btn btn-info">Android</button></a></div>
216
+ <br>
217
+ <h5>
218
+ Device
219
+ </h5>
220
+ <div id="devices" class="toggles"><a onclick="selectDevice(launchPageConfig.apps[selectedApp][selectedPlatform].devices[0])"><button type="button" class="btn btn-info selected">Phone</button></a><a onclick="selectDevice(launchPageConfig.apps[selectedApp][selectedPlatform].devices[1])"><button type="button" class="btn btn-info">Tablet</button></a></div>
221
+ <h5>
222
+ Rotate
223
+ </h5>
224
+ <div id="rotate" class="toggles"><a onclick="rotateLeft();"><button type="button" class="btn btn-info selected">Rotate</button></a></div>
225
+
226
+ <div class="col-md-9">
227
+ <iframe id="app_iframe" width="1500px" height="700px" frameborder="0" scrolling="no" style="max-width: 100%;"></iframe>
228
+ </div>
229
+ </body></html>