Commit cec5dc442e5a0631dbb9530c0856782040f78f54

  • avatar
  • arvind
  • Mon Jul 07 20:07:29 IST 2014
Fix: Removing unwanted key value pair from annotation before adding to
how.
    Fix issues with collection containing sweets not getting updated
    after being posted to store.
    Check if value entered in the input field for url is empty or not.
  • Diff rendering mode:
  • inline
  • side by side

swtr/static/js/app.js

138 if(!(swtr.who)) {138 if(!(swtr.who)) {
139 swtr.who = "Guest";139 swtr.who = "Guest";
140 }140 }
141 swtr.TxtAnnoSwts.add(new TxtAnnoSwt({how: annotation,
141 // Removing the highlights key value pair from annotation object.
142 var tempAnnotation = _.omit(annotation, 'highlights');
143 swtr.TxtAnnoSwts.add(new TxtAnnoSwt({how: tempAnnotation,
142 where: pageURL,144 where: pageURL,
143 who: swtr.who}));145 who: swtr.who}));
144 if($("#show-sweets").attr('disabled')) {146 if($("#show-sweets").attr('disabled')) {
191 this.loadOverlayBar();191 this.loadOverlayBar();
192 },192 },
193 loadOverlayBar: function() {193 loadOverlayBar: function() {
194 var template = "<div id='overlayBar' class='navbar'><a class='navbar-brand'>Swtr - Text Annotation</a>" +
195 "<div class='navbar-inner'><div class='container-fluid'>" +
196 "<button id='sign-in' class='btn btn-default navbar-btn pull-right'>Sign In</button>" +
197 "<button id='show-sweets' disabled='true' class='btn btn-primary navbar-btn'>Sweet</button>" +
198 "<a href='/' class='btn btn-default navbar-btn nav-btn'>Try a different website</a>"
199 "<span id='signinview' class='pull-right'></span>" +
200 "</div></div></div>";
194 var template = "<div id='overlayBar' class='navbar'>"+
195 "<a class='navbar-brand'>Swtr - Text Annotation</a>" +
196 "<div class='navbar-inner'><div class='container-fluid'>" +
197 "<button id='sign-in' class='btn btn-default navbar-btn"+
198 " pull-right'>Sign In</button>" +
199 "<button id='show-sweets' disabled='true' class='btn "+
200 "btn-primary navbar-btn'>Sweet</button>" +
201 "<a href='/' class='btn btn-default navbar-btn nav-btn'>"+
202 "Try a different website</a>"+
203 "<span id='signinview' class='pull-right'></span>" +
204 "</div></div></div>";
201205
202 $(document.body).append(template);206 $(document.body).append(template);
203 },207 },
212 showSweets: function(e) {212 showSweets: function(e) {
213 $("#sweet-list-wrapper").show();213 $("#sweet-list-wrapper").show();
214 swtr.TxtAnnoSwts.each(function(model){214 swtr.TxtAnnoSwts.each(function(model){
215 console.log(model, model.isNew());
215 var templateStr ='<li class="sweet">'+216 var templateStr ='<li class="sweet">'+
216 '<a href="#">@<%= who %></a> <strong>#<%= what %></strong> '+217 '<a href="#">@<%= who %></a> <strong>#<%= what %></strong> '+
217 '<a href="<%= where %>"><%= where.substr(0, 30) + "..." %></a> '+218 '<a href="<%= where %>"><%= where.substr(0, 30) + "..." %></a> '+
236 $("#sweet-list").html('');236 $("#sweet-list").html('');
237 },237 },
238 postSweet: function(e) {238 postSweet: function(e) {
239 swtr.TxtAnnoSwts.post({success: function(data) {
239 swtr.TxtAnnoSwts.post({success: function(collection, data) {
240 swtr.TxtAnnoSwts.set(collection);
241 $("#sweet-list").html('');
240 alert("Your SWeets are posted!!");242 alert("Your SWeets are posted!!");
241 },243 },
242 error: function(data) {244 error: function(data) {

swtr/static/js/swtmaker.js

197 this.collection.post({197 this.collection.post({
198 success: function(collection, response) {198 success: function(collection, response) {
199 console.log(collection, response);199 console.log(collection, response);
200 swtr.sweets.update(collection);
200 swtr.sweets.set(collection);
201 //TODO: move this to a annotation view or something201 //TODO: move this to a annotation view or something
202 anno.removeAll();202 anno.removeAll();
203 _.each(swtr.sweets.models, function(swt) {203 _.each(swtr.sweets.models, function(swt) {
312 return false;312 return false;
313 }313 }
314 else {314 else {
315 if(!url) {
316 return false;
317 }
315 window.location.href = '/annotate?where=' + url;318 window.location.href = '/annotate?where=' + url;
316 }319 }
317 },320 },