1
1
var picker , picker1 , feed , data , ar = true , aspectRatio ;
2
2
var preloadImage = true , preloadCSV = true ;
3
+ var settings = new Store ( "settings" ) ;
3
4
google . setOnLoadCallback ( createPicker ) ;
4
5
google . load ( 'picker' , 1 ) ;
5
6
@@ -27,32 +28,33 @@ $.ajax({url:'https://www.googleapis.com/oauth2/v1/tokeninfo?access_token='+acces
27
28
} ) ;
28
29
29
30
$ . ajax ( { url :'https://www.googleapis.com/oauth2/v1/userinfo?access_token=' + access_info [ "access_token" ] } )
30
- . done ( function ( data ) {
31
- $ . ajax ( { url :'http://badgeitrelay.appspot.com/badgeitupdateuser?userjson=' + encodeURIComponent ( JSON . stringify ( data ) ) , type :'POST' } ) .
32
- done ( function ( ) {
33
- console . log ( "Updated" ) ;
34
- } ) ;
31
+ . done ( function ( data ) {
32
+ $ . ajax ( { url :'http://badgeitrelay.appspot.com/badgeitupdateuser?userjson=' + encodeURIComponent ( JSON . stringify ( data ) ) , type :'POST' } )
33
+ . done ( function ( ) {
34
+ console . log ( "Updated" ) ;
35
35
} ) ;
36
+ } ) ;
37
+
36
38
37
- /*if(localStorage['login']!='true')
38
- {
39
- $('body').css('background-color','whitesmoke');
40
- $('body').html('<p style="font-size:20px; text-align:center; margin-top:100px">Looks like you are not logged in. Redirecting to <a href="./home.html">Home Page</a></p>');
41
- location.href='./home.html';
42
- }*/
43
39
$ ( "#template_gd" ) . hide ( ) ;
44
40
$ ( "#list_gd" ) . hide ( ) ;
45
41
46
42
47
43
var config = {
48
44
'client_id' : '434888942442.apps.googleusercontent.com' ,
49
45
'scope' : 'https://www.googleapis.com/auth/drive' ,
50
- 'immediate' :false
46
+ 'immediate' :false
51
47
} ;
52
48
var isDriveAuth = false ;
53
49
var holder = document . getElementById ( 'holder' ) ;
54
50
55
- localStorage [ "qrcode" ] = "false" ;
51
+ $ ( "#projectName" ) . change ( function ( ) {
52
+ settings . set ( "projectName" , this . value ) ;
53
+ } ) ;
54
+
55
+ //localStorage["qrcode"] = "false";
56
+ settings . set ( "qrcode" , false ) ;
57
+
56
58
if ( typeof window . FileReader === 'undefined' ) {
57
59
console . log ( 'File reader API failed' ) ;
58
60
} else {
@@ -64,12 +66,14 @@ $('#qrcode').click(function() {
64
66
65
67
if ( $ ( this ) . is ( ':checked' ) ) {
66
68
$ ( '#qrCodeSelect' ) . show ( ) ;
67
- localStorage [ "qrcode" ] = "true" ;
69
+ //localStorage["qrcode"] = "true";
70
+ settings . set ( "qrcode" , true ) ;
68
71
$ ( '#qrCodeSelect' ) . find ( 'select' ) . attr ( "required" , "required" ) ;
69
72
}
70
73
else {
71
74
$ ( '#qrCodeSelect' ) . hide ( ) ;
72
- localStorage [ "qrcode" ] = "false" ;
75
+ //localStorage["qrcode"] = "false";
76
+ settings . set ( "qrcode" , false ) ;
73
77
$ ( '#qrCodeSelect' ) . find ( 'select' ) . removeAttr ( "required" ) ;
74
78
}
75
79
} ) ;
@@ -85,7 +89,8 @@ holder.ondrop = function (e) {
85
89
reader = new FileReader ( ) ;
86
90
reader . onload = function ( event ) {
87
91
console . log ( event . target ) ;
88
- localStorage [ "event-template" ] = event . target . result ;
92
+ //localStorage["event-template"] = event.target.result;
93
+ settings . set ( "event-template" , event . target . result ) ;
89
94
90
95
$ ( '#badgepreview' ) . attr ( 'src' , event . target . result ) ;
91
96
@@ -173,7 +178,7 @@ $('#list_gd').on('click',function(e){
173
178
174
179
175
180
176
- $ ( "#form1 " ) . submit ( function ( ) {
181
+ $ ( "#badgeinput " ) . submit ( function ( ) {
177
182
178
183
if ( $ ( '#templateChooser' ) . val ( ) == "" && $ ( '#google_image' ) . val ( ) == "" ) {
179
184
$ ( "#alertmessage" ) . html ( "<strong>Error!</strong> You have not selected template image." ) ;
@@ -235,20 +240,31 @@ $("#form1").submit(function() {
235
240
} ) ;
236
241
if ( selectedCols . length != 0 ) {
237
242
238
- localStorage [ 'selected-cols' ] = selectedCols ;
243
+ //localStorage['selected-cols'] = selectedCols;
244
+ settings . set ( "selected-cols" , selectedCols ) ;
239
245
}
240
246
241
247
242
248
if ( $ ( '#qrcode' ) . is ( ':checked' ) ) {
243
249
$ ( '#qrCodeSelect' ) . find ( ':input:checkbox:checked' ) . each ( function ( ) {
244
250
qrSelectedCols . push ( this . value ) ;
245
251
} ) ;
246
- localStorage [ 'qr-cols' ] = qrSelectedCols ;
252
+ //localStorage['qr-cols'] = qrSelectedCols;
253
+ settings . set ( "qr-cols" , qrSelectedCols ) ;
247
254
}
248
-
249
- _gaq . push ( [ '_trackEvent' , 'Template' , 'Submit' , 'Project' , localStorage [ "projectname" ] ] ) ;
250
- localStorage [ "dimensions" ] = $ ( '#pixelwidth' ) . val ( ) + ',' + $ ( '#pixelheight' ) . val ( ) + ',' + $ ( '#inchwidth' ) . val ( ) + ',' + $ ( '#inchheight' ) . val ( ) + ',' + $ ( '#pixelwidth' ) . val ( ) * $ ( '#dpi' ) . val ( ) / 96 + ',' + $ ( '#pixelheight' ) . val ( ) * $ ( '#dpi' ) . val ( ) / 96 ;
251
-
255
+ settings . set ( "projectName" , $ ( "#projectName" ) . val ( ) ) ;
256
+ //_gaq.push(['_trackEvent', 'Template', 'Submit', 'Project', localStorage["projectName"]]);
257
+ _gaq . push ( [ '_trackEvent' , 'Template' , 'Submit' , 'Project' , settings . get ( "projectName" ) ] ) ;
258
+ dimensions = {
259
+ "pixelwidth" : $ ( '#pixelwidth' ) . val ( ) ,
260
+ "pixelheight" : $ ( '#pixelheight' ) . val ( ) ,
261
+ "inchwidth" : $ ( '#inchwidth' ) . val ( ) ,
262
+ "inchheight" : $ ( '#inchheight' ) . val ( ) ,
263
+ "scalepixelw" : $ ( '#pixelwidth' ) . val ( ) * $ ( '#dpi' ) . val ( ) / 96 ,
264
+ "scalepixelh" : $ ( '#pixelheight' ) . val ( ) * $ ( '#dpi' ) . val ( ) / 96
265
+ }
266
+ //localStorage["dimensions"] = $('#pixelwidth').val()+','+$('#pixelheight').val()+','+$('#inchwidth').val()+','+$('#inchheight').val()+','+$('#pixelwidth').val()*$('#dpi').val()/96+','+$('#pixelheight').val()*$('#dpi').val()/96;
267
+ settings . set ( "dimensions" , dimensions ) ;
252
268
253
269
} ) ;
254
270
@@ -270,6 +286,7 @@ function changeCsv()
270
286
$ ( '#list_fs' ) . show ( ) ;
271
287
$ ( '#list_gd' ) . show ( ) ;
272
288
}
289
+
273
290
function loadPreview ( image )
274
291
{
275
292
$ ( '#badgepreview' ) . attr ( 'src' , image ) ;
@@ -289,13 +306,14 @@ function loadPreview(image)
289
306
$ ( '#holder' ) . css ( 'border' , '0px' ) ;
290
307
$ ( '#holder' ) . css ( 'background-color' , 'white' ) ;
291
308
}
309
+
292
310
function readFileAsDataURL ( file , imageName ) {
293
311
294
312
var reader = new FileReader ( ) ;
295
313
296
314
reader . onload = function ( event ) {
297
- localStorage [ imageName ] =
298
- event . target . result ;
315
+ // localStorage[imageName] = event.target.result;
316
+ settings . set ( "imageName" ) = event . target . result ;
299
317
loadPreview ( event . target . result ) ;
300
318
301
319
} ;
@@ -308,10 +326,12 @@ function getAsText(fileToRead, localName)
308
326
var reader = new FileReader ( ) ;
309
327
reader . readAsText ( fileToRead ) ;
310
328
reader . onload = function ( event ) {
311
- localStorage [ localName ] = event . target . result ;
312
- $ ( '#csvColumnsSelect' ) . empty ( ) ;
329
+ //localStorage[localName] = event.target.result;
330
+ settings . set ( localName , event . target . result ) ;
331
+
332
+ $ ( '#csvColumnsSelect' ) . empty ( ) ;
313
333
createMultipleSelect ( event . target . result , 'csvColumnsSelect' , 'colselect' , 'selected-cols' ) ;
314
- $ ( '#qrCodeSelect' ) . empty ( ) ;
334
+ $ ( '#qrCodeSelect' ) . empty ( ) ;
315
335
createMultipleSelect ( event . target . result , 'qrCodeSelect' , 'qrselect' , 'qr-cols' ) ;
316
336
$ ( '#qrCodeSelect' ) . hide ( ) ;
317
337
} ;
@@ -348,7 +368,7 @@ function clear() {
348
368
$ ( "#badgepreview" ) . val ( "" ) ;
349
369
$ ( '#qrCodeSelect' ) . empty ( ) ;
350
370
$ ( '#csvColumnsSelect' ) . empty ( ) ;
351
- $ ( "#form1 " ) . find ( ':input' ) . each ( function ( ) {
371
+ $ ( "#badgeinput " ) . find ( ':input' ) . each ( function ( ) {
352
372
switch ( this . type ) {
353
373
case 'password' :
354
374
case 'select-multiple' :
@@ -364,36 +384,6 @@ function clear() {
364
384
} ) ;
365
385
} ;
366
386
367
- function move ( ) {
368
-
369
- var selectedCols = new Array ( ) ;
370
- var qrSelectedCols = new Array ( ) ;
371
- $ ( '#csvColumnsSelect' ) . find ( ':input:checkbox:checked' ) . each ( function ( ) {
372
-
373
- selectedCols . push ( this . value ) ;
374
- } ) ;
375
- if ( selectedCols . length != 0 ) {
376
-
377
- localStorage [ 'selected-cols' ] = selectedCols ;
378
- }
379
- else if ( preloadedCSV ) {
380
- localStorage [ 'selected-cols' ] = "1,2" ;
381
- }
382
-
383
- if ( $ ( '#qrcode' ) . is ( ':checked' ) ) {
384
- $ ( '#qrCodeSelect' ) . find ( ':input:checkbox:checked' ) . each ( function ( ) {
385
- qrSelectedCols . push ( this . value ) ;
386
- } ) ;
387
- localStorage [ 'qr-cols' ] = qrSelectedCols ;
388
- }
389
-
390
- _gaq . push ( [ '_trackEvent' , 'Template' , 'Submit' , 'Project' , localStorage [ "projectname" ] ] ) ;
391
- localStorage [ "dimensions" ] = $ ( '#pixelwidth' ) . val ( ) + ',' + $ ( '#pixelheight' ) . val ( ) + ',' + $ ( '#inchwidth' ) . val ( ) + ',' + $ ( '#inchheight' ) . val ( ) ;
392
-
393
-
394
- }
395
-
396
-
397
387
398
388
function createPicker ( ) {
399
389
@@ -451,8 +441,10 @@ function handleDriveImage(response) {
451
441
blobBuilder . append ( oReq . response ) ;
452
442
var blob = blobBuilder . getBlob ( response . mimeType ) ;
453
443
var rdr = new FileReader ( ) ;
454
- rdr . onload = function ( event ) { localStorage [ 'event-template' ] = event . target . result ;
455
- loadPreview ( event . target . result ) ; } ;
444
+ rdr . onload = function ( event ) {
445
+ //localStorage['event-template'] = event.target.result;
446
+ settings . set ( 'event-template' , event . target . result ) ;
447
+ loadPreview ( event . target . result ) ; } ;
456
448
rdr . readAsDataURL ( blob ) ;
457
449
} ;
458
450
@@ -465,7 +457,8 @@ function handleDriveSheet(response) {
465
457
$ . ajax ( { 'url' :'https://badgeitrelay.appspot.com/badgeitrelay?link=' + encodeURIComponent ( url ) , 'crossDomain' :true } ) .
466
458
done ( function ( data ) {
467
459
$ ( '#csvColumnsSelect' ) . html ( "" ) ;
468
- localStorage [ 'event-csv' ] = data ;
460
+ //localStorage['event-csv']=data;
461
+ settings . set ( 'event-csv' , data ) ;
469
462
createMultipleSelect ( data , 'csvColumnsSelect' , 'colselect' , 'selected-cols' ) ;
470
463
createMultipleSelect ( data , 'qrCodeSelect' , 'qrselect' , 'qr-cols' ) ;
471
464
$ ( '#qrCodeSelect' ) . hide ( ) ;
@@ -504,11 +497,13 @@ function setPixelHeight() {
504
497
}
505
498
506
499
function demo ( ) {
507
- localStorage [ "event-template" ] = demoJSON [ "event-template" ]
508
- localStorage [ "dimensions" ] = demoJSON [ "dimensions" ] ;
509
- localStorage [ "event-csv" ] = demoJSON [ "event-csv" ] ;
510
- localStorage [ 'selected-cols' ] = demoJSON [ "selected-cols" ] ;
511
- localStorage [ 'qrcode' ] = demoJSON [ "qrcode" ] ;
512
- localStorage [ 'qr-cols' ] = demoJSON [ "qr-cols" ] ;
513
- $ ( "#form1" ) [ 0 ] . submit ( ) ;
500
+
501
+ //localStorage["event-template"]= demoJSON["event-template"]
502
+ //localStorage["dimensions"]=demoJSON["dimensions"];
503
+ //localStorage["event-csv"]=demoJSON["event-csv"];
504
+ //localStorage['selected-cols'] = demoJSON["selected-cols"];
505
+ //localStorage['qrcode']=demoJSON["qrcode"];
506
+ //localStorage['qr-cols']=demoJSON["qr-cols"];
507
+ settings = new Store ( "settings" , demoJSON ) ;
508
+ $ ( "#badgeinput" ) [ 0 ] . submit ( ) ;
514
509
}
0 commit comments