src/js/widgets/createAnnotationWidget.js
changeset 944 8a6c9e3d0158
parent 907 27b248a13355
parent 943 a882cc0c936f
child 945 7d9f6fd6f904
equal deleted inserted replaced
907:27b248a13355 944:8a6c9e3d0158
     1 /* Internationalization for this widget */
       
     2 
       
     3 IriSP.i18n.addMessages(
       
     4     {
       
     5         "en": {
       
     6             "submit": "Submit",
       
     7             "add_keywords": "Add keywords",
       
     8             "add_polemic_keywords": "Add polemic keywords",
       
     9             "your_name": "Your name",
       
    10             "type_here": "Type your annotation here.",
       
    11             "wait_while_processed": "Please wait while your request is being processed...",
       
    12             "error_while_contacting": "An error happened while contacting the server. Your annotation has not been saved.",
       
    13             "empty_annotation": "Your annotation is empty. Please write something before submitting.",
       
    14             "annotation_saved": "Thank you, your annotation has been saved.",
       
    15             "share_annotation": "Would you like to share it on social networks ?",
       
    16             "share_on": "Share on",
       
    17             "more_tags": "More tags"
       
    18         },
       
    19         "fr": {
       
    20             "submit": "Envoyer",
       
    21             "add_keywords": "Ajouter des mots-clés",
       
    22             "add_polemic_keywords": "Ajouter des mots-clés polémiques",
       
    23             "your_name": "Votre nom",
       
    24             "type_here": "Rédigez votre annotation ici.",
       
    25             "wait_while_processed": "Veuillez patienter pendant le traitement de votre requête...",
       
    26             "error_while_contacting": "Une erreur s'est produite en contactant le serveur. Votre annotation n'a pas été enregistrée",
       
    27             "empty_annotation": "Votre annotation est vide. Merci de rédiger un texte avant de l'envoyer.",
       
    28             "annotation_saved": "Merci, votre annotation a été enregistrée.",
       
    29             "share_annotation": "Souhaitez-vous la partager sur les réseaux sociaux ?",
       
    30             "share_on": "Partager sur",
       
    31             "more_tags": "Plus de mots-clés"
       
    32         }
       
    33     }
       
    34 );
       
    35 
       
    36 IriSP.createAnnotationWidget = function(Popcorn, config, Serializer) {
       
    37   IriSP.Widget.call(this, Popcorn, config, Serializer);
       
    38   this._hidden = true;
       
    39                          
       
    40   if (!IriSP.null_or_undefined(IriSP.user)) {
       
    41       if (!IriSP.null_or_undefined(IriSP.user.avatar)) {
       
    42         this.user_avatar = IriSP.user.avatar;
       
    43       }
       
    44       if (!IriSP.null_or_undefined(IriSP.user.name)) {
       
    45         this.user_name = IriSP.user.name;
       
    46       }
       
    47   }
       
    48   
       
    49   /* variables to save the current position of the slicer */
       
    50   if (this.cinecast_version) {
       
    51     this.sliceLeft = 0;
       
    52     this.sliceWidth = 0;
       
    53   }
       
    54 };
       
    55 
       
    56 
       
    57 IriSP.createAnnotationWidget.prototype = new IriSP.Widget();
       
    58 
       
    59 IriSP.createAnnotationWidget.prototype.clear = function() {
       
    60     this.selector.find(".Ldt-SaTitle").text("");
       
    61     this.selector.find(".Ldt-SaDescription").text("");
       
    62     this.selector.find(".Ldt-SaKeywordText").text("");
       
    63 };
       
    64 
       
    65 IriSP.createAnnotationWidget.prototype.draw = function() {
       
    66     var _this = this;
       
    67     if (typeof this.remote_tags == "object") {
       
    68         IriSP.jQuery.getJSON((typeof this.remote_tags.alias == "string" ? this.remote_tags.alias : this.remote_tags.url), function(_json) {
       
    69             _this.tags = _json.tags;
       
    70             _this.drawCallback();
       
    71         });
       
    72     } else {
       
    73         this.drawCallback();
       
    74     }
       
    75 }
       
    76 
       
    77 IriSP.createAnnotationWidget.prototype.drawCallback = function() {
       
    78   var _this = this;
       
    79   
       
    80   var annotationMarkup = IriSP.templToHTML(IriSP.createAnnotationWidget_template, 
       
    81                                            this);
       
    82   
       
    83 	this.selector.append(annotationMarkup);
       
    84   
       
    85   if (!this.cinecast_version)
       
    86     this.selector.hide();
       
    87   else {
       
    88     this.showStartScreen();
       
    89   }
       
    90   
       
    91   if (this.random_tags) {
       
    92       this.selector.find(".Ldt-createAnnotation-keywords li").hide();
       
    93       this.showMoreTags();
       
    94       this.selector.find('.Ldt-createAnnotation-moar-keywordz').click(function() {
       
    95           _this.showMoreTags();
       
    96       })
       
    97   }
       
    98   // Add onclick event to both polemic and keywords buttons
       
    99   
       
   100   this.selector.find(".Ldt-createAnnotation-keyword-button, .Ldt-createAnnotation-polemic-button").click(function() {
       
   101       _this.addKeyword(IriSP.jQuery(this).text());
       
   102       return false;
       
   103   });
       
   104   
       
   105   // js_mod is a custom event because there's no simple way to test for a js
       
   106   // change in a textfield.                    
       
   107   this.selector.find(".Ldt-createAnnotation-Description")
       
   108                .bind("propertychange keyup input paste click js_mod", IriSP.wrap(this, this.handleTextChanges));
       
   109                
       
   110   /* the cinecast version of the player is supposed to pause when the user clicks on the button */
       
   111 
       
   112   /* the cinecast version expects the user to comment on a defined segment.
       
   113      As the widget is always shown, we need a way to update it's content as
       
   114      time passes. We do this like we did with the annotationsWidget : we schedule
       
   115      a .code start function which will be called at the right time.
       
   116   */
       
   117   if (this.cinecast_version) {
       
   118     var legal_ids;
       
   119     if (typeof(this._serializer.getChapitrage()) !== "undefined")
       
   120       legal_id = this._serializer.getChapitrage();
       
   121     else 
       
   122       legal_id = this._serializer.getNonTweetIds()[0];
       
   123     
       
   124     var annotations = this._serializer._data.annotations;
       
   125     var i;
       
   126   
       
   127     for (i in annotations) {     
       
   128       var annotation = annotations[i];
       
   129       if (typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined"
       
   130             && legal_id !== annotation.meta["id-ref"]) {
       
   131           continue;
       
   132       }
       
   133       
       
   134       code = {start: annotation.begin / 1000, end: annotation.end / 1000,
       
   135               onStart: function(annotation) { return function() {
       
   136                       if (typeof(annotation.content) !== "undefined")
       
   137                         _this.selector.find(".Ldt-createAnnotation-Title").html(annotation.content.title);
       
   138 
       
   139                       _this._currentAnnotation = annotation;
       
   140                       var beginTime = IriSP.msToTime(annotation.begin);
       
   141                       var endTime = IriSP.msToTime(annotation.end);
       
   142                       var timeTemplate = IriSP.templToHTML("- ({{begin}} - {{ end }})", {begin: beginTime, end: endTime });
       
   143                       _this.selector.find(".Ldt-createAnnotation-TimeFrame").html(timeTemplate);
       
   144               } }(annotation)
       
   145             };
       
   146       
       
   147       this._Popcorn.code(code);
       
   148     }
       
   149   }
       
   150   
       
   151   this.selector.find(".Ldt-createAnnotation-submitButton").click(IriSP.wrap(this, this.handleButtonClick));
       
   152   
       
   153   if (!this.cinecast_version) {
       
   154     this._Popcorn.listen("IriSP.PlayerWidget.AnnotateButton.clicked", 
       
   155                           IriSP.wrap(this, this.handleAnnotateSignal));
       
   156     
       
   157     // handle clicks on the cancel button too.
       
   158     this.selector.find(".Ldt-createAnnotation-Minimize").click(IriSP.wrap(this, 
       
   159       function() {
       
   160         // we've got to simulate the pressing of the button because there's no
       
   161         // other way to minimize the widget and show the widgets that were hidden
       
   162         // same time
       
   163         this._Popcorn.trigger("IriSP.PlayerWidget.AnnotateButton.clicked");
       
   164       }
       
   165     ));
       
   166   }
       
   167 };
       
   168 
       
   169 IriSP.createAnnotationWidget.prototype.showMoreTags = function() {
       
   170     for (var j=0; j < this.random_tags; j++) {
       
   171         var _jq = this.selector.find(".Ldt-createAnnotation-keywords li:hidden");
       
   172         if (_jq.length > 1) {
       
   173             IriSP.jQuery(_jq[Math.floor(_jq.length*Math.random())]).show();
       
   174         } else {
       
   175             _jq.show();
       
   176             break;
       
   177         }     
       
   178     }
       
   179     if (this.selector.find(".Ldt-createAnnotation-keywords li:hidden").length == 0) {
       
   180         this.selector.find('.Ldt-createAnnotation-moar-keywordz').hide();
       
   181     }
       
   182 }
       
   183 
       
   184 /* Handles adding keywords and polemics */
       
   185 IriSP.createAnnotationWidget.prototype.addKeyword = function(_keyword) {
       
   186     var _field = this.selector.find(".Ldt-createAnnotation-Description"),
       
   187         _rx = IriSP.regexpFromText(_keyword),
       
   188         _contents = _field.val();
       
   189     _contents = ( _rx.test(_contents)
       
   190         ? _contents.replace(_rx,"").replace("  "," ").replace(/(^\s+|\s+$)/g,'')
       
   191         : _contents.replace(/(^\s+|\s+$)/g,'') + " " + _keyword
       
   192     );
       
   193     _field.val(_contents.replace(/(^\s+|\s+$)/g,'')).trigger("js_mod");
       
   194 }
       
   195 
       
   196 /** handles clicks on the annotate button. Works only for the non-cinecast version */
       
   197 IriSP.createAnnotationWidget.prototype.handleAnnotateSignal = function() {
       
   198   
       
   199   if (this._hidden == false && this._state == 'startScreen') {
       
   200     this.selector.hide();
       
   201     this._hidden = true;
       
   202     
       
   203     // free the arrow.
       
   204     this._Popcorn.trigger("IriSP.ArrowWidget.releaseArrow");
       
   205     this._Popcorn.trigger("IriSP.SliceWidget.hide");
       
   206     this._Popcorn.trigger("IriSP.AnnotationsWidget.show");
       
   207     
       
   208   } else {
       
   209     this._Popcorn.trigger("IriSP.AnnotationsWidget.hide");
       
   210     this.showStartScreen();    
       
   211     this.selector.show();
       
   212     this._hidden = false;
       
   213     var currentTime = this._Popcorn.currentTime();
       
   214     
       
   215     // block the arrow.
       
   216     this._Popcorn.trigger("IriSP.ArrowWidget.blockArrow");
       
   217     
       
   218     var duration = this.getDuration();
       
   219         
       
   220     var currentChapter = this._serializer.currentChapitre(currentTime);
       
   221 
       
   222     if (IriSP.null_or_undefined(currentChapter)) {      
       
   223       var left = this.selector.width() / 2;
       
   224       var width = this.selector.width() / 10;
       
   225     } else {
       
   226       var left = (currentChapter.begin / duration) * this.selector.width();
       
   227       var width = (currentChapter.end / duration) * this.selector.width() - left;
       
   228     }
       
   229     
       
   230     // slider position and length is kept in percents.
       
   231     this.sliceLeft = (left / this.selector.width()) * 100;
       
   232     this.sliceWidth = (width / this.selector.width()) * 100;
       
   233     
       
   234     this._Popcorn.trigger("IriSP.SliceWidget.position", [left, width]);
       
   235     this._Popcorn.listen("IriSP.SliceWidget.zoneChange", IriSP.wrap(this, this.handleSliderChanges));
       
   236     this._Popcorn.trigger("IriSP.SliceWidget.show");
       
   237     
       
   238     if (!IriSP.null_or_undefined(currentChapter)) {
       
   239       this.selector.find(".Ldt-createAnnotation-Title").html(currentChapter.content.title);
       
   240 
       
   241       this._currentcurrentChapter = currentChapter;
       
   242       var beginTime = IriSP.msToTime(currentChapter.begin);
       
   243       var endTime = IriSP.msToTime(currentChapter.end);
       
   244       var timeTemplate = IriSP.templToHTML("- ({{begin}} - {{ end }})", {begin: beginTime, end: endTime });
       
   245       this.selector.find(".Ldt-createAnnotation-TimeFrame").html(timeTemplate);
       
   246     }
       
   247   }
       
   248 };
       
   249 
       
   250 
       
   251 /** watch for changes in the textfield and change the buttons accordingly */
       
   252 IriSP.createAnnotationWidget.prototype.handleTextChanges = function(event) {
       
   253   var contents = this.selector.find(".Ldt-createAnnotation-Description").val();
       
   254   if (this.cinecast_version) {
       
   255       this._Popcorn.pause();
       
   256   }
       
   257   this.selector.find(".Ldt-createAnnotation-btnblock button").each(function() {
       
   258       var _rx = IriSP.regexpFromText(IriSP.jQuery(this).text());
       
   259       if (_rx.test(contents)) {
       
   260           IriSP.jQuery(this).parent().addClass("Ldt-createAnnotation-active-button");
       
   261       } else {
       
   262           IriSP.jQuery(this).parent().removeClass("Ldt-createAnnotation-active-button");
       
   263       }
       
   264   });
       
   265   
       
   266 };
       
   267 
       
   268 IriSP.createAnnotationWidget.prototype.showStartScreen = function() {
       
   269   this.selector.find(".Ldt-createAnnotation-screen").hide();
       
   270   this.selector.find(".Ldt-createAnnotation-startScreen").show();
       
   271   
       
   272   var jqTextfield = this.selector.find(".Ldt-createAnnotation-Description"); // handle on the textfield. used for the closure
       
   273   
       
   274   /* test if the browser supports the placeholder attribute */
       
   275   if (!IriSP.null_or_undefined(jqTextfield.get(0).placeholder)) {
       
   276     jqTextfield.attr("placeholder", IriSP.i18n.getMessage('type_here')); 
       
   277   } else {
       
   278     jqTextfield.val(IriSP.i18n.getMessage('type_here'));
       
   279     jqTextfield.one("click", IriSP.wrap(this, function() { jqTextfield.val(""); }));    
       
   280   }
       
   281   
       
   282  
       
   283   
       
   284   this._state = "startScreen";
       
   285 };
       
   286 
       
   287 IriSP.createAnnotationWidget.prototype.showWaitScreen = function() {
       
   288   this.selector.find(".Ldt-createAnnotation-screen").hide();
       
   289   this.selector.find(".Ldt-createAnnotation-waitScreen").show();
       
   290   this._state = "waitScreen";
       
   291 };
       
   292 
       
   293 IriSP.createAnnotationWidget.prototype.showErrorScreen = function() {
       
   294   this.selector.find(".Ldt-createAnnotation-screen").hide();
       
   295   this.selector.find(".Ldt-createAnnotation-errorScreen").show();
       
   296   this._state = "errorScreen";
       
   297   var _this = this;
       
   298   window.setTimeout(function() { _this.showStartScreen(); }, 2000);
       
   299 };
       
   300 
       
   301 /** update show the final screen with links to share the created annotation */
       
   302 IriSP.createAnnotationWidget.prototype.showEndScreen = function(annotation) {
       
   303   this.selector.find(".Ldt-createAnnotation-screen").hide();
       
   304   
       
   305   if (this.cinecast_version) {
       
   306     this.selector.find(".Ldt-createAnnotation-Title").parent().show();      
       
   307   }
       
   308 
       
   309   var url = ( (typeof annotation.meta == "object" && typeof annotation.meta.url == "string" && annotation.meta.url.length)
       
   310     ? annotation.meta.url
       
   311     : ( document.location.href + "#id=" + annotation.id ) );
       
   312   var twStatus = IriSP.mkTweetUrl(url);
       
   313   var gpStatus = IriSP.mkGplusUrl(url);
       
   314   var fbStatus = IriSP.mkFbUrl(url);
       
   315   
       
   316   this.selector.find(".Ldt-createAnnotation-endScreen-TweetLink").attr("href", twStatus);
       
   317   this.selector.find(".Ldt-createAnnotation-endScreen-FbLink").attr("href", fbStatus);
       
   318   this.selector.find(".Ldt-createAnnotation-endScreen-GplusLink").attr("href", gpStatus);
       
   319           
       
   320   this.selector.find(".Ldt-createAnnotation-endScreen").show();
       
   321   this._state = "endScreen";
       
   322 };
       
   323 
       
   324 /** handle clicks on "send annotation" button */
       
   325 IriSP.createAnnotationWidget.prototype.handleButtonClick = function(event) {
       
   326   var _this = this;
       
   327   var textfield = this.selector.find(".Ldt-createAnnotation-Description");
       
   328   var contents = textfield.val();
       
   329   
       
   330   if (contents === "") {  
       
   331     if (this.selector.find(".Ldt-createAnnotation-errorMessage").length === 0) {
       
   332       this.selector.find(".Ldt-createAnnotation-Container")
       
   333                    .after(IriSP.templToHTML(IriSP.createAnnotation_errorMessage_template));
       
   334       textfield.css("background-color", "#d93c71");      
       
   335     } else {      
       
   336       this.selector.find(".Ldt-createAnnotation-errorMessage").show();
       
   337     }
       
   338 
       
   339       textfield.one("js_mod propertychange keyup input paste", IriSP.wrap(this, function() {
       
   340                       var contents = textfield.val();
       
   341                       
       
   342                       if (contents !== "") {
       
   343                         this.selector.find(".Ldt-createAnnotation-errorMessage").hide();
       
   344                         textfield.css("background-color", "");
       
   345                       }
       
   346                    }));
       
   347   } else {
       
   348     this.showWaitScreen();
       
   349     
       
   350     this.sendLdtData(contents, function(annotation) {
       
   351                       if (_this.cinecast_version) {
       
   352                           if (_this._Popcorn.media.paused)
       
   353                             _this._Popcorn.play();
       
   354                       }
       
   355 
       
   356                       if (_this._state == "waitScreen") {
       
   357                         _this.showEndScreen(annotation);
       
   358                         if (_this.cinecast_version) {
       
   359                           window.setTimeout(function() { _this.showStartScreen(); }, _this.return_delay);
       
   360                         }
       
   361                       }
       
   362                       // hide the slicer widget
       
   363                       if (!_this.cinecast_version) {                      
       
   364                         _this._Popcorn.trigger("IriSP.SliceWidget.hide");
       
   365                       }           
       
   366                     });
       
   367   }
       
   368 };
       
   369 
       
   370 IriSP.createAnnotationWidget.prototype.handleSliderChanges = function(params) {
       
   371   this.sliceLeft = params[0];
       
   372   this.sliceWidth = params[1];
       
   373 };
       
   374 
       
   375 IriSP.createAnnotationWidget.prototype.sendLdtData = function(contents, callback) {
       
   376   var _this = this;
       
   377   var apiJson = {
       
   378       format : "http://advene.org/ns/cinelab/",
       
   379       annotations : [
       
   380         {}
       
   381         ],
       
   382         meta: {}};
       
   383   var annotation = apiJson.annotations[0];
       
   384   
       
   385   annotation.media = this.currentMedia()["id"];
       
   386   
       
   387   if (this.cinecast_version) {   
       
   388       annotation.begin = Math.round(this._Popcorn.currentTime() * 1000);
       
   389       annotation.end = annotation.begin;      
       
   390   } else {
       
   391     var duration = this.getDuration();    
       
   392     annotation.begin = +((duration * (this.sliceLeft / 100)).toFixed(0));
       
   393     annotation.end = +((duration * ((this.sliceWidth + this.sliceLeft) / 100)).toFixed(0));
       
   394   }
       
   395 
       
   396   // boundary checks
       
   397   annotation.begin = Math.max(0, annotation.begin);
       
   398   annotation.end = Math.min(this.getDuration(), annotation.end);
       
   399   
       
   400   annotation.type = ( this.cinecast_version ? "cinecast:UserAnnotation" : ( this._serializer.getContributions() || "" ));
       
   401   if (typeof(annotation.type) === "undefined")
       
   402     annotation.type = "";
       
   403   
       
   404   annotation.type_title = "Contributions";
       
   405   annotation.content = {};
       
   406   annotation.content.data = contents;
       
   407   if (this.cinecast_version) {
       
   408       var _extract = IriSP.underscore(this._serializer._data.annotations)
       
   409           .filter(function(_a) {
       
   410               return (_a.begin <= annotation.begin && _a.end >= annotation.begin && _a.type == "cinecast:MovieExtract");
       
   411           })
       
   412       if (_extract.length) {
       
   413           annotation.extract = _extract[0].id;
       
   414       }
       
   415   }
       
   416   
       
   417   var meta = apiJson.meta;
       
   418   
       
   419   
       
   420   var _username = this.selector.find(".Ldt-createAnnotation-userName").val();
       
   421   meta.creator = (
       
   422       (_username && _username.length)
       
   423       ? _username
       
   424       : (
       
   425           (!IriSP.null_or_undefined(IriSP.user) && !IriSP.null_or_undefined(IriSP.user.name))
       
   426           ? IriSP.user.name
       
   427           : "Anonymous user"
       
   428       )
       
   429   );
       
   430   
       
   431   meta.created = Date().toString();
       
   432   
       
   433   var _tags = [];
       
   434   IriSP._(this.tags).each(function(_v) {
       
   435       var _rx = IriSP.regexpFromText(_v.meta.description);
       
   436         if (_rx.test(contents)) {
       
   437             _tags.push(_v.id);
       
   438         }
       
   439   });
       
   440 
       
   441   if (typeof this.remote_tags == "object") {
       
   442      _tags = IriSP._(_tags).map(function(_t) {
       
   443          return _this.remote_tags.id + ':' + _t
       
   444      });
       
   445     if (typeof apiJson.imports == "undefined") {
       
   446        apiJson.imports = [];
       
   447     }
       
   448     apiJson.imports.push({
       
   449         "id" : this.remote_tags.id,
       
   450         "url" : this.remote_tags.url
       
   451     })
       
   452   }
       
   453   annotation.tags = IriSP.underscore.uniq(_tags);
       
   454   
       
   455   var jsonString = JSON.stringify(apiJson);
       
   456   var project_id = this._serializer._data.meta.id;
       
   457   
       
   458   //TODO: extract magic url
       
   459   var url = Mustache.to_html(this.api_endpoint_template,
       
   460                               {id: project_id});
       
   461                           
       
   462   IriSP.jQuery.ajax({
       
   463       url: url,
       
   464       type: this.api_method,
       
   465       contentType: 'application/json',
       
   466       data: jsonString,               
       
   467       //dataType: 'json',
       
   468       success: IriSP.wrap(this, function(json, textStatus, XMLHttpRequest) {                   
       
   469                     /* add the annotation to the annotation and tell the world */
       
   470                     var annotation = json.annotations[0];
       
   471                     
       
   472                     if (!this.cinecast_version) {
       
   473                     /* if the media doesn't have a contributions line, we need to add one */
       
   474                         if (typeof(this._serializer.getContributions()) === "undefined") {
       
   475                           /* set up a basic view */
       
   476                           var tmp_view = {"dc:contributor": "perso", "dc:creator": "perso", "dc:title": "Contributions",
       
   477                                           "id": json.annotations[0].type}
       
   478     
       
   479                           
       
   480                             IriSP.get_aliased(this._serializer._data, ["annotation_types", "annotation-types"]).push(tmp_view);
       
   481                         }
       
   482                         
       
   483                         delete annotation.tags;
       
   484                         annotation.content.description = annotation.content.data;
       
   485                         annotation.content.title = "";
       
   486                         delete annotation.content.data;
       
   487                         annotation.id = json.annotations[0].id;
       
   488     
       
   489                         annotation.meta = meta;
       
   490                         annotation.meta["id-ref"] = json.annotations[0]["type"];
       
   491                     } else {
       
   492                         annotation.type = "cinecast:UserAnnotation";
       
   493                     }
       
   494                     // everything is shared so there's no need to propagate the change
       
   495                     var _an_ids = IriSP.underscore(this._serializer._data.annotations).map(function(_a) {
       
   496                         return _a.id.toLowerCase();
       
   497                     });
       
   498                     if (IriSP._(_an_ids).indexOf(annotation.id.toLowerCase()) == -1) {
       
   499                         _this._serializer._data.annotations.push(annotation);
       
   500                     }
       
   501                     
       
   502                     _this._Popcorn.trigger("IriSP.createAnnotationWidget.addedAnnotation", annotation);
       
   503                     this.selector.find(".Ldt-createAnnotation-Description").val("").trigger("js_mod");
       
   504                     callback(annotation);
       
   505       }), 
       
   506       error: 
       
   507               function(jqXHR, textStatus, errorThrown) { 
       
   508                             console.log("an error occured while contacting " 
       
   509                             + url + " and sending " + jsonString + textStatus ); 
       
   510                             _this.showErrorScreen(); } });
       
   511 };