src/js/widgets/polemicWidget.js
branchpopcorn-port
changeset 265 e0d32948bf62
parent 246 533716922da5
child 357 6edf399cfa26
equal deleted inserted replaced
264:9fb001b19dd2 265:e0d32948bf62
   137         if(typeof(view.annotation_types) !== "undefined" && view.annotation_types.length > 1) {
   137         if(typeof(view.annotation_types) !== "undefined" && view.annotation_types.length > 1) {
   138           tweet_annot_type = view.annotation_types[1];
   138           tweet_annot_type = view.annotation_types[1];
   139         }
   139         }
   140       
   140       
   141       for(var i = 0; i < json.annotations.length; i++) {
   141       for(var i = 0; i < json.annotations.length; i++) {
   142         var item = json.annotations[i];              
   142         var item = json.annotations[i];        
   143         var MyTime  = Math.floor(item.begin/duration*lineSize);
   143         var MyTime  = Math.floor(item.begin/duration*lineSize);
   144         var Myframe = Math.floor(MyTime/lineSize*frameLength);
   144         var Myframe = Math.floor(MyTime/lineSize*frameLength);
   145 
   145 
   146         if (typeof(item.meta) !== "undefined" 
   146         if (typeof(item.meta) !== "undefined" 
   147           && typeof(item.meta["id-ref"]) !== "undefined"
   147           && typeof(item.meta["id-ref"]) !== "undefined"
   150           var MyTJson = JSON.parse(item.meta['dc:source']['content']);
   150           var MyTJson = JSON.parse(item.meta['dc:source']['content']);
   151           
   151           
   152             if (item.content['polemics'] != undefined 
   152             if (item.content['polemics'] != undefined 
   153             && item.content['polemics'][0] != null) {
   153             && item.content['polemics'][0] != null) {
   154             
   154             
   155             
   155               // a tweet can have many polemics at the same time.
   156               for(var j=0; j<item.content['polemics'].length; j++){
   156               for(var j=0; j<item.content['polemics'].length; j++){
   157                   
   157                   
   158                   this.tweets[numberOfTweet] = {
   158                   this.tweets[numberOfTweet] = {
   159                         id:i,
   159                         id:i,
   160                         qualification:colorTranslation(item.content['polemics'][j]),
   160                         qualification:colorTranslation(item.content['polemics'][j]),
   162                         yframe:Myframe,
   162                         yframe:Myframe,
   163                         title:item.content['title'],
   163                         title:item.content['title'],
   164                         timeframe:item.begin,
   164                         timeframe:item.begin,
   165                         userId: MyTJson.id,
   165                         userId: MyTJson.id,
   166                         userScreenName: MyTJson.screen_name,
   166                         userScreenName: MyTJson.screen_name,
   167                         tsource:MyTJson
   167                         tsource:MyTJson,
       
   168                         cinecast_id: item.id
   168                         };
   169                         };
   169                   numberOfTweet+=1;
   170                   numberOfTweet+=1;
   170                   
   171                   
   171               }
   172               }
   172           }
   173           }
   178                   yframe:Myframe,
   179                   yframe:Myframe,
   179                   title:item.content['title'],
   180                   title:item.content['title'],
   180                   timeframe:item.begin,
   181                   timeframe:item.begin,
   181                   userId: MyTJson.id,
   182                   userId: MyTJson.id,
   182                   userScreenName: MyTJson.screen_name,
   183                   userScreenName: MyTJson.screen_name,
   183                   tsource:MyTJson
   184                   tsource:MyTJson,
   184                   
   185                   cinecast_id: item.id
   185             };
   186             };
   186             numberOfTweet+=1;
   187             numberOfTweet+=1;
   187           }
   188           }
   188           
   189           
   189         } 
   190         } 
   264                   
   265                   
   265                   if (this.yMax > y) {
   266                   if (this.yMax > y) {
   266                     this.yMax = y;
   267                     this.yMax = y;
   267                   }
   268                   }
   268                   
   269                   
   269                   var e = this.paper.rect(x, y, frameSize - margin, TweetHeight /* height */).attr({stroke:"#00","stroke-width":0.1,  fill: colors[j]});  
   270                   var e = this.paper.rect(x, y, frameSize - margin, TweetHeight /* height */)
       
   271                                     .attr({stroke:"#00","stroke-width":0.1,  fill: colors[j]});  
   270                   this.svgElements.push(e);
   272                   this.svgElements.push(e);
   271                   
   273                   
   272                   addEheight += TweetHeight;
   274                   addEheight += TweetHeight;
   273                   
   275                   
   274                   e.time= frames[i].mytweetsID[k].timeframe;
   276                   e.time = frames[i].mytweetsID[k].timeframe;
   275                   e.title= frames[i].mytweetsID[k].title;
   277                   e.title = frames[i].mytweetsID[k].title;
   276                   
   278                   e.id = frames[i].mytweetsID[k].cinecast_id;
       
   279 
   277                   e.mouseover(function(element) { return function (event) {
   280                   e.mouseover(function(element) { return function (event) {
   278                         // event.clientX and event.clientY are to raphael what event.pageX and pageY are to jquery.                        
   281                         // event.clientX and event.clientY are to raphael what event.pageX and pageY are to jquery.                        
   279                         self.TooltipWidget.show.call(self.TooltipWidget, element.title, element.attr("fill"), event.clientX - 106, event.clientY - 160);
   282                         self.TooltipWidget.show.call(self.TooltipWidget, element.title, element.attr("fill"), event.clientX - 106, event.clientY - 160);
   280                         element.displayed = true;
   283                         element.displayed = true;
   281                   }}(e)).mouseout(function(element) { return function () {                          
   284                   }}(e)).mouseout(function(element) { return function () {                          
   282                           self.TooltipWidget.hide.call(self.TooltipWidget);
   285                           self.TooltipWidget.hide.call(self.TooltipWidget);
   283                   }}(e)).mousedown(function () {
   286                   }}(e)).mousedown(function () {
   284                     self._Popcorn.currentTime(this.time/1000);
   287                     self._Popcorn.currentTime(this.time/1000);
       
   288                     self._Popcorn.trigger("IriSP.PolemicTweet.click", this.id); 
   285                   });
   289                   });
   286                   
   290                   
   287                   IriSP.jQuery(e.node).attr('id', 't' + k + '');
   291                   IriSP.jQuery(e.node).attr('id', 't' + k + '');
   288                   IriSP.jQuery(e.node).attr('title', frames[i].mytweetsID[k].title);
   292                   IriSP.jQuery(e.node).attr('title', frames[i].mytweetsID[k].title);
   289                   IriSP.jQuery(e.node).attr('begin',  frames[i].mytweetsID[k].timeframe);                  
   293                   IriSP.jQuery(e.node).attr('begin',  frames[i].mytweetsID[k].timeframe);