-
Notifications
You must be signed in to change notification settings - Fork 32
/
qr.js
280 lines (267 loc) · 10.1 KB
/
qr.js
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
// Function for appName =ing the aesthetically pleasing stylization of an app name
// The case is the id of the app in the HTML, the appName = is what the user
// will see.
function appMeta(appID){
switch(appID){
case 'andless':
appName = 'andLess';
qrLink = "market://details?id=net.avs234";
break;
case 'andstatus':
appName = 'AndStatus';
qrLink = "market://details?id=org.andstatus.app";
break;
case 'antennapod':
appName = 'AntennaPod';
qrLink = "market://details?id=de.danoeh.antennapod";
break;
case 'anysoftkeyboard':
appName = 'AnySoftKeyboard';
qrLink = "market://details?id=com.menny.android.anysoftkeyboard";
break;
case 'barcodescanner':
appName = 'Barcode Scanner';
qrLink = "market://details?id=com.google.zxing.client.android";
break;
case 'cgeo':
appName = 'c:geo';
qrLink = "market://details?id=cgeo.geocaching";
break;
case 'chatsecure':
appName = 'ChatSecure';
qrLink = "market://details?id=info.guardianproject.otr.app.im";
break;
case 'csipsimple':
appName = 'CSipSimple';
qrLink = "market://details?id=com.csipsimple";
break;
case 'coolreader':
appName = 'CoolReader';
qrLink = "market://details?id=org.coolreader";
break;
case 'fbreader':
appName = 'FBReader';
qrLink = "market://details?id=org.geometerplus.zlibrary.ui.android";
break;
case 'feedex':
appName = 'FeedEx';
qrLink = "market://details?id=net.fred.feedex";
break;
case 'fileexplorer':
appName = 'File Explorer';
qrLink = "market://details?id=net.appositedesigns.fileexplorer";
break;
case 'firefox':
appName = 'Firefox';
qrLink = "market://details?id=org.mozilla.firefox";
break;
case 'flappycow':
appName = 'FlappyCow';
qrLink = "market://details?id=com.quchen.flappycow";
break;
case 'ghostcommander':
appName = 'Ghost Commander';
qrLink = "market://details?id=com.ghostsq.commander";
break;
case 'hackerskeyboard':
appName = 'Hacker\'s Keyboard';
qrLink = "market://details?id=org.pocketworkstation.pckeyboard";
break;
case 'impeller':
appName = 'Impeller';
qrLink = "market://details?id=eu.e43.impeller";
break;
case 'k9':
appName = 'K-9 Mail';
qrLink = "market://details?id=com.fsck.k9";
break;
case 'linphone':
appName = 'Linphone Video';
qrLink = "market://details?id=org.linphone";
break;
case 'mosf':
appName = 'Minimal Open Source Flashlight';
qrLink = "market://details?id=de.repat.mosf";
break;
case 'mupdf':
appName = 'MuPDF';
qrLink = "market://details?id=com.artifex.mupdfdemo";
break;
case 'musicplayer':
appName = 'Music Player';
qrLink = "market://details?id=com.android.music";
break;
case 'navit':
appName = 'Navit';
qrLink = "market://details?id=org.navitproject.navit";
break;
case 'notecipher':
appName = 'NoteCipher';
qrLink = "market://details?id=info.guardianproject.notepadbot";
break;
case 'oifilemanager':
appName = 'OI File Manager';
qrLink = "market://details?id=org.openintents.filemanager";
break;
case 'oiflashlight':
appName = 'OI Flashlight';
qrLink = "market://details?id=org.openintents.flashlight";
break;
case 'oinotepad':
appName = 'OI Notepad';
qrLink = "market://details?id=org.openintents.notepad";
break;
case 'opendocumentreader':
appName = 'OpenDocument Reader';
qrLink = "market://details?id=at.tomtasche.reader";
break;
case 'openmanager':
appName = 'Open Manager';
qrLink = "market://details?id=com.nexes.manager";
break;
case 'osmand':
appName = 'OsmAnd';
qrLink = "market://details?id=net.osmand.plus";
break;
case 'owncloud':
appName = 'ownCloud';
qrLink = "market://details?id=com.owncloud.android";
break;
case 'owncloudnewsreader':
appName = 'ownCloud News Reader';
qrLink = "market://details?id=de.luhmer.owncloudnewsreader";
break;
case 'prey':
appName = 'Prey';
qrLink = "market://details?id=com.prey";
break;
case 'redphone':
appName = 'RedPhone';
qrLink = "market://details?id=org.thoughtcrime.redphone";
break;
case 'redreader':
appName = 'RedReader';
qrLink = "market://details?id=org.quantumbadger.redreader";
break;
case 'sipdroid':
appName = 'Sipdroid';
qrLink = "market://details?id=org.sipdroid.sipua";
break;
case 'surespot':
appName = 'surespot';
qrLink = "market://details?id=com.twofours.surespot";
break;
case 'telegram':
appName = 'Telegram';
qrLink = "market://details?id=org.telegram.messenger";
break;
case 'textsecure':
appName = 'TextSecure';
qrLink = "market://details?id=org.thoughtcrime.securesms";
break;
case 'tinfoil':
appName = 'Tinfoil';
qrLink = "market://details?id=com.danvelazco.fbwrapper";
break;
case 'tint':
appName = 'Tint';
qrLink = "market://details?id=org.tint";
break;
case 'tomdroid':
appName = 'Tomdroid';
qrLink = "market://details?id=org.tomdroid";
break;
case 'ttrssreader':
appName = 'TTRSS-Reader';
qrLink = "market://details?id=org.ttrssreader";
break;
case 'tweetlanes':
appName = 'Tweet Lanes';
qrLink = "market://details?id=com.tweetlanes.android";
break;
case 'twidere':
appName = 'Twidere';
qrLink = "market://details?id=org.mariotaku.twidere";
break;
case 'vanillamusic':
appName = 'Vanilla Music';
qrLink = "market://details?id=ch.blinkenlights.android.vanilla";
break;
case 'vlc':
appName = 'VLC';
qrLink = "market://details?id=org.videolan.vlc";
break;
case 'vlcplayer':
appName = 'VLC';
qrLink = "market://details?id=org.videolan.vlc";
break;
case 'vudroid':
appName = 'VuDroid';
qrLink = "market://details?id=org.vudroid";
break;
case 'xabber':
appName = 'Xabber';
qrLink = "market://details?id=com.xabber.androiddev";
break;
case 'zirco':
appName = 'Zirco Browser';
qrLink = "market://details?id=org.zirco";
break;
default:
appName = appID;
qrLink = appID;
break;
}
}
// Variables
var qrFade = '#qrFade'; // The big, faded background behind the white one.
var qrBackground = '#qrBackground'; // The white background behind the QR code/text.
var qrText = '#qrText'; // The text with the app name and description.
var qrCode = '#qrCode'; // The actual QR code.
// Displays a faded background along with a popup of a QR code when the
// user clicks an image of the 'qr' class.
$(document).ready(function(){
$('.qr').click(function(){
// This sets variables according to which app QR was clicked.
appMeta( $(this).attr('id') );
// This weirdy indented mess is the block of HTML added to index.html
// when clicking the QR link. The backslashes(\) are JS, not HTML, and
// they allow us to escape newlines and thus make the indentions.
// I like it, Vim's syntax hilighting does not.
$('body').prepend('<div id="qrFade">\
</div>\
<div class="emph-Block" id="qrBackground">\
<div id="qrText">\
<h2>'+appName+'</h2>\
<a href="'+qrLink+'">\
<h4>'+qrLink+'</h4>\
</a>\
<hr>\
<h4>Scan using a barcode scanner.</h4>\
</div>\
<a href="'+qrLink+'">\
<div id="qrCode"></div>\
</a>\
<script type="text/javascript">\
new QRCode(document.getElementById("qrCode"), qrLink);\
</script>\
</div>');
// This sets the margin and centers the popup.
marginTop = $(qrBackground).height()/2;
marginRight = $(qrBackground).width()/2;
$(qrBackground).css({'margin-top': -marginTop, 'margin-right': -marginRight});
//This fades the whole thing in, making it look quite nice.
$(qrFade).fadeIn('slow');
$(qrBackground).fadeIn('slow');
$(qrText).fadeIn('slow');
$(qrCode).fadeIn('slow');
});
});
// Removes the QR popup and fade when clicking outside the white, i.e., on qrFade.
$(document).on('click', '#qrFade', function(){
$(qrFade).remove();
$(qrBackground).remove();
$(qrText).remove();
$(qrCode).remove();
});
// Maybe add resize reposition for .$(qrCode).