Commit 72c499855cc31bc02274a89a6133a94f1915f68b

Testing out Persona code..
  
77 swtr.sweets = new ImgAnnoSwts();
88 swtr.appView = new AppView();
99 swtr.who = 'Guest';
10
11 $.ajaxSetup({
12 xhrFields: {
13 withCredentials: true
14 },
15 crossDomain: true
16 });
1017 };
1118
1219 /* Model for Image Annotation Sweets */
276276 },
277277 getSignInCredentials: function(event) {
278278 event.preventDefault();
279 if(swtr.who === 'Guest' && !$('#username').length) {
279 navigator.id.request();
280 /*if(swtr.who === 'Guest' && !$('#username').length) {
280281 var template = _.template($('#signin-credentials-template').html());
281282 $('#signin-msg').html(template());
282283 }
285285 var username = $('#username').val();
286286 var password = $('#password').val();
287287 this.signIn(username, password);
288 }
288 }*/
289289 return false;
290290 },
291291 signIn: function(username, password) {
310310 }
311311 }
312312 });
313 },
314 userLoggedIn: function(userData) {
315 swtr.who = userData.username;
316 var text = 'You are signed in as <b>' + swtr.who+ '</b>';
317 $('#signinview').html(text);
318 },
319 userLoggedOut: function() {
320 swtr.who = 'Guest';
321 $('#signinview').html('Logged out');
313322 }
314323 });
315324
362362
363363 //swtr.AppView = AppView;
364364
365 /*navigator.watch({
365 // Persona callbacks
366 navigator.id.watch({
367 //when an user logs in
366368 onlogin: function(assertion) {
369 //verify assertion and login the user
367370 $.ajax({
368371 type: 'POST',
369372 url: swtr.swtstoreURL() + swtr.endpoints.login,
370373 data: {assertion: assertion},
371 success: function() {
374 success: function(data) {
375 console.log('user logged in', data);
376 swtr.appView.userLoggedIn(data);
372377 },
373378 error: function() {
374379 navigator.id.logout();
375380 }
376381 });
377382 },
383 //when an user logs out
378384 onlogout: function() {
379385 $.ajax({
380386 type: 'POST',
387 //data: {email: swtr.who},
381388 url: swtr.swtstoreURL() + swtr.endpoints.logout,
382389 success: function() {
390 console.log('user logged out');
391 //swtr.appView.userLoggedOut();
383392 },
384393 error: function() {
385394 }
386395 });
387396 }
388 });*/
397 });
389398
390399})(swtr);
  
5353 window.swtr = window.swtr || {};
5454 swtr.swtstoreURL = function() { return '{{ conf.swtstoreURL }}'; }
5555 swtr.endpoints = {'get': '/sweets/q', 'post': '/sweets', 'auth':
56 '/authenticate'};
56 '/authenticate', 'login': '/auth/login', 'logout': '/auth/logout'};
5757 window.onload = function() {
5858 swtr.init();
5959 };
6464 <script src="{{ url_for('static', filename='js/lib/backbone-1.0.0.min.js') }}"></script>
6565 <script src="{{ url_for('static', filename='js/lib/annotorious.debug.js') }}"></script>
6666 <!--script src="https://login.persona.org/include.js"></script-->
67 <script src="{{ url_for('static', filename='js/lib/mozilla.persona.include.js') }}"></script>
6768 <script src="{{ url_for('static', filename='js/swtmaker.js') }}"></script>
6869
6970 <script type="text/template" id="sweet-template">