Commit 2d3356eb398eb7425f04e8fd8774648477880c8e

  • avatar
  • arvind
  • Mon Jul 07 18:08:06 IST 2014
Adding changes of swtmaker.js, checks if a given URL is an image or not, loads the respective component of swtr app.
  
6767 return false;
6868 }
6969 /*if(!swtr.access_token) {
70 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 }*/
7272 // setting up params
7373 var where = options.where,
7474 who = options.who || null;
75 url = swtr.swtstoreURL() + swtr.endpoints.get + '?where=' +
76 encodeURIComponent(where) + '&access_token=' + swtr.access_token;
75 url = swtr.swtstoreURL() + swtr.endpoints.get + '?where=' +
76 encodeURIComponent(where) + '&access_token=' + swtr.access_token;
7777 if(who) {
7878 url += '&who=' + who;
7979 }
108108 }
109109
110110 var url = swtr.swtstoreURL() + swtr.endpoints.post +
111 '?access_token=' + swtr.access_token;
111 '?access_token=' + swtr.access_token;
112112
113113 this.sync('create', dummy_collection, {
114114 url: url,
294294 },
295295 setImage: function(event) {
296296 event.preventDefault();
297 this.imgURL = $('#img-url-input').val();
298 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);
299312 return false;
300313 }
301 if(this.$img.attr('src') === this.imgURL) {
302 return;
314 else {
315 window.location.href = '/annotate?where=' + url;
303316 }
304 anno.reset();
305 var self = this;
306 this.$overlay.show();
307 this.helpview.step(7);
308 this.$img.attr('src', this.imgURL);
309 return false;
310317 },
311318 imageLoaded: function(event) {
312319 var self = event.data;
541541 step: function(n) {
542542 var text = '';
543543 switch (n) {
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;
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;
566566 }
567567 $(this.el).html(text);
568568 $(window).scrollTop(0, 0);