Commit 2d3356eb398eb7425f04e8fd8774648477880c8e
Adding changes of swtmaker.js, checks if a given URL is an image or not, loads the respective component of swtr app.
| | | | 67 | return false; | 67 | return false; |
---|
68 | } | 68 | } |
---|
69 | /*if(!swtr.access_token) { | 69 | /*if(!swtr.access_token) { |
---|
70 | throw new Error('Access Token required to get query that API'); | | throw new Error('Access Token required to get query that API'); |
---|
71 | }*/ | | }*/ |
---|
| | 70 | throw new Error('Access Token required to get query that API'); | | | 71 | }*/ |
---|
72 | // setting up params | 72 | // setting up params |
---|
73 | var where = options.where, | 73 | var where = options.where, |
---|
74 | who = options.who || null; | 74 | who = options.who || null; |
---|
75 | url = swtr.swtstoreURL() + swtr.endpoints.get + '?where=' + | | url = swtr.swtstoreURL() + swtr.endpoints.get + '?where=' + |
---|
76 | encodeURIComponent(where) + '&access_token=' + swtr.access_token; | | encodeURIComponent(where) + '&access_token=' + swtr.access_token; |
---|
| | 75 | url = swtr.swtstoreURL() + swtr.endpoints.get + '?where=' + | | | 76 | encodeURIComponent(where) + '&access_token=' + swtr.access_token; |
---|
77 | if(who) { | 77 | if(who) { |
---|
78 | url += '&who=' + who; | 78 | url += '&who=' + who; |
---|
79 | } | 79 | } |
---|
… | | … | |
---|
108 | } | 108 | } |
---|
109 | | 109 | |
---|
110 | var url = swtr.swtstoreURL() + swtr.endpoints.post + | 110 | var url = swtr.swtstoreURL() + swtr.endpoints.post + |
---|
111 | '?access_token=' + swtr.access_token; | | '?access_token=' + swtr.access_token; |
---|
| | 111 | '?access_token=' + swtr.access_token; | 112 | | 112 | |
---|
113 | this.sync('create', dummy_collection, { | 113 | this.sync('create', dummy_collection, { |
---|
114 | url: url, | 114 | url: url, |
---|
… | | … | |
---|
294 | }, | 294 | }, |
---|
295 | setImage: function(event) { | 295 | setImage: function(event) { |
---|
296 | event.preventDefault(); | 296 | event.preventDefault(); |
---|
297 | this.imgURL = $('#img-url-input').val(); | | this.imgURL = $('#img-url-input').val(); |
---|
298 | if(!this.imgURL) { | | if(!this.imgURL) { |
---|
| | 297 | var url = $('#img-url-input').val(); | | | 298 | if(url.contains('.jpg') || url.contains('.png') || |
---|
| | 299 | url.contains('.gif') || url.contains('.jpeg')) { |
---|
| | 300 | this.imgURL = $('#img-url-input').val(); |
---|
| | 301 | if(!this.imgURL) { |
---|
| | 302 | return false; |
---|
| | 303 | } |
---|
| | 304 | if(this.$img.attr('src') === this.imgURL) { |
---|
| | 305 | return; |
---|
| | 306 | } |
---|
| | 307 | anno.reset(); |
---|
| | 308 | var self = this; |
---|
| | 309 | this.$overlay.show(); |
---|
| | 310 | this.helpview.step(7); |
---|
| | 311 | this.$img.attr('src', this.imgURL); |
---|
299 | return false; | 312 | return false; |
---|
300 | } | 313 | } |
---|
301 | if(this.$img.attr('src') === this.imgURL) { | | if(this.$img.attr('src') === this.imgURL) { |
---|
302 | return; | | return; |
---|
| | 314 | else { | | | 315 | window.location.href = '/annotate?where=' + url; |
---|
303 | } | 316 | } |
---|
304 | anno.reset(); | | anno.reset(); |
---|
305 | var self = this; | | var self = this; |
---|
306 | this.$overlay.show(); | | this.$overlay.show(); |
---|
307 | this.helpview.step(7); | | this.helpview.step(7); |
---|
308 | this.$img.attr('src', this.imgURL); | | this.$img.attr('src', this.imgURL); |
---|
309 | return false; | | return false; |
---|
310 | }, | 317 | }, |
---|
311 | imageLoaded: function(event) { | 318 | imageLoaded: function(event) { |
---|
312 | var self = event.data; | 319 | var self = event.data; |
---|
… | | … | |
---|
541 | step: function(n) { | 541 | step: function(n) { |
---|
542 | var text = ''; | 542 | var text = ''; |
---|
543 | switch (n) { | 543 | switch (n) { |
---|
544 | case 0 : text = 'Getting annotations..'; | | case 0 : text = 'Getting annotations..'; |
---|
545 | break; | | break; |
---|
546 | case 1: text = 'Enter the URL of an image below, and start annotating!'; | | case 1: text = 'Enter the URL of an image below, and start annotating!'; |
---|
547 | break; | | break; |
---|
548 | case 2: text = 'Annotate the image, or see other annotations'; | | case 2: text = 'Annotate the image, or see other annotations'; |
---|
549 | break; | | break; |
---|
550 | case 3: text = 'Now you can sweet this annotation, or add more annotations'; | | case 3: text = 'Now you can sweet this annotation, or add more annotations'; |
---|
551 | break; | | break; |
---|
552 | case 4: text = 'Click Sweet button to publish these annotations to the Sweet Store'; | | case 4: text = 'Click Sweet button to publish these annotations to the Sweet Store'; |
---|
553 | break; | | break; |
---|
554 | case 5: text = 'Publishing your sweets'; | | case 5: text = 'Publishing your sweets'; |
---|
555 | break; | | break; |
---|
556 | case 6: text = 'Sweets successfully posted'; | | case 6: text = 'Sweets successfully posted'; |
---|
557 | break; | | break; |
---|
558 | case 7: text = 'Fetching your image..'; | | case 7: text = 'Fetching your image..'; |
---|
559 | break; | | break; |
---|
560 | case 8: text = 'Oops! Seems like the image URL is wrong! Or we couldn\'t fetch the image.'; | | case 8: text = 'Oops! Seems like the image URL is wrong! Or we couldn\'t fetch the image.'; |
---|
561 | break; | | break; |
---|
562 | case 9: text = 'You have to be <i>signed in</i> to sweet store to post sweets'; | | case 9: text = 'You have to be <i>signed in</i> to sweet store to post sweets'; |
---|
563 | break; | | break; |
---|
564 | case 10: text = 'Oops! Something went wrong. We couldn\'t publish the sweets. Try again.' | | case 10: text = 'Oops! Something went wrong. We couldn\'t publish the sweets. Try again.' |
---|
565 | break; | | break; |
---|
| | 544 | case 0 : text = 'Getting annotations..'; | | | 545 | break; |
---|
| | 546 | case 1: text = 'Enter the URL of an image below, and start annotating!'; |
---|
| | 547 | break; |
---|
| | 548 | case 2: text = 'Annotate the image, or see other annotations'; |
---|
| | 549 | break; |
---|
| | 550 | case 3: text = 'Now you can sweet this annotation, or add more annotations'; |
---|
| | 551 | break; |
---|
| | 552 | case 4: text = 'Click Sweet button to publish these annotations to the Sweet Store'; |
---|
| | 553 | break; |
---|
| | 554 | case 5: text = 'Publishing your sweets'; |
---|
| | 555 | break; |
---|
| | 556 | case 6: text = 'Sweets successfully posted'; |
---|
| | 557 | break; |
---|
| | 558 | case 7: text = 'Fetching your image..'; |
---|
| | 559 | break; |
---|
| | 560 | case 8: text = 'Oops! Seems like the image URL is wrong! Or we couldn\'t fetch the image.'; |
---|
| | 561 | break; |
---|
| | 562 | case 9: text = 'You have to be <i>signed in</i> to sweet store to post sweets'; |
---|
| | 563 | break; |
---|
| | 564 | case 10: text = 'Oops! Something went wrong. We couldn\'t publish the sweets. Try again.' |
---|
| | 565 | break; |
---|
566 | } | 566 | } |
---|
567 | $(this.el).html(text); | 567 | $(this.el).html(text); |
---|
568 | $(window).scrollTop(0, 0); | 568 | $(window).scrollTop(0, 0); |
---|