diff -r a14343a9e897 -r 427632a324d5 src/js/widgets/polemicWidget.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/js/widgets/polemicWidget.js Fri Oct 28 17:28:15 2011 +0200 @@ -0,0 +1,594 @@ +/* + * + * Copyright 2010 Institut de recherche et d'innovation + * contributor(s) : Samuel Huron + * + * contact@iri.centrepompidou.fr + * http://www.iri.centrepompidou.fr + * + * This software is a computer program whose purpose is to show and add annotations on a video . + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-C license and that you accept its terms. +*/ +// CHART TIMELINE / VERSION PROTOTYPE :: + +IriSP.PolemicWidget = function(Popcorn, config, Serializer) { + IriSP.Widget.call(this, Popcorn, config, Serializer); + + this.RAWTweets; + this.userPol = new Array(); + this.userNoPol = new Array(); + this.userst = new Array(); + this.numberOfTweet = 0; + this.Users; + this.TweetPolemic; + this.yMax = this.height; + this.PaperSlider; + this.heightOfChart; + this.tweets = new Array(); + + // Make and define the Raphael area + this.paper = Raphael(document.getElementById(this._id), config.width, config.height); + +}; + +IriSP.PolemicWidget.prototype = new IriSP.Widget(); + +IriSP.PolemicWidget.prototype.draw = function() { + + // variable + // yMax + var yCoef = 2; // coef for height of 1 tweet + var frameSize = 5; // frame size + var margin = 1; // marge between frame + var lineSize = this.width; // timeline pixel width + var nbrframes = lineSize/frameSize; // frame numbers + var numberOfTweet = 0; // number of tweet overide later + var duration = config.duration; // timescale width + var frameLenght = lineSize/frameSize; // frame timescale + var timeline; + var colors = new Array("","#1D973D","#C5A62D","#CE0A15","#036AAE","#585858"); + + // array + //var tweets = new Array(); + var element = new Array(); + var cluster = new Array(); + var frames = new Array(frameLenght); + var slices = new Array(); + + + // Classes ======================================================================= + var Frames = function(){ + + var Myclusters; + var x; + var y; + var width; + var height; + }; + Frames = function(json){ + // make my clusters + // ou Frame vide + }; + Frames.prototype.draw = function(){ + }; + Frames.prototype.zoom = function(){ + }; + Frames.prototype.inside = function(){ + }; + var Clusters = function(){ + var Object; + var yDist; + var x; + var y; + var width; + var height; + }; + Clusters = function(json){ + // make my object + }; + var Tweet = function(){ + }; + // Classes ======================================================================= + + // trace function + var traceNum = 0; + function trace(msg,value){ + traceNum += 1; + __IriSP.jQuery("
"+traceNum+" - "+msg+" : "+value+"
").appendTo("#output"); + } + + // Refactoring (parametere) ************************************************************ + // color translastion + var qTweet_0 =0; + var qTweet_Q =0; + var qTweet_REF=0; + var qTweet_OK =0; + var qTweet_KO =0; + function colorTranslation(value){ + if(value == "Q"){ + qTweet_Q+=1; + return 2; + }else if(value =="REF"){ + qTweet_REF+=1; + return 4; + }else if(value =="OK"){ + qTweet_OK+=1; + return 1; + }else if(value =="KO"){ + qTweet_KO+=1; + return 3; + }else if(value ==""){ + qTweet_0+=1; + return 5; + } + } + + + // Refactoring (parametere) ************************************************************ + // load tweets send in parameters + __IriSP.jQuery.ajax({ + dataType: "jsonp", + url:config.metadata, + success : function(json){ + trace("load",""); + // get current view (the first ???) + view = json.views[0]; + + // the tweets are by definition of the second annotation type + tweet_annot_type = null; + if(typeof(view.annotation_types) !== "undefined" && view.annotation_types.length > 1) { + tweet_annot_type = view.annotation_types[1]; + } + RAWTweets = json.annotations; + + __IriSP.jQuery.each(json.annotations, function(i,item) { + + var MyTime = Math.floor(item.begin/duration*lineSize); + var Myframe = Math.floor(MyTime/lineSize*frameLenght); + + if (typeof(item.meta) !== "undefined" + && typeof(item.meta["id-ref"]) !== "undefined" + && item.meta["id-ref"] === tweet_annot_type) { + + var MyTJson = JSON.parse(item.meta['dc:source']['content']); + + if (item.content['polemics'] != undefined + && item.content['polemics'][0] != null) { + + + //console.log(item.meta['dc:source']['content']); + + for(var j=0; j0){Report();} + + } + }); + + function pourcent(value,max){ + var myPourcentage = Math.round(value/max*1000)/10; + return myPourcentage; + + } + function round2Dec(value){ + var myValueRounded = Math.round(value*100)/100; + return myValueRounded + } + + + function searchKeyValueArray(mykey,myvalue,myarray){ + for(var i=0; i0){ + for(var i=0; i1){ + console.log("t: "+tweetClient[i].total+" / sp :"+tweetClient[i].numberSp+" : "+tweetClient[i].client); + } + } + console.log(JSON.stringify(tweetClient)); + } + function conversationalCount(tweet){ + if(tweet.tsource.entities.user_mentions.length>2){ + if (tweet.qualification!=5){ + tweetConversationelSP+=1; + } + var myTc = { + polemique:tweet.qualification, + user_mentions:tweet.tsource.entities.user_mentions, + tsource:tweet + } + tweetConversationel.push(myTc); + } + } + function conversationalReport(){ + console.log("_______________________________"); + console.log("tweets conversationel : "+tweetConversationel.length); + console.log("tweets conversationel sp : "+pourcent(tweetConversationelSP,tweetConversationel.length)); + console.log("tweets conversationel nsp: "+pourcent(tweetConversationel.length-tweetConversationelSP,tweetConversationel.length)); + } + function tweetsStats(){ + for(var i=0; imax){max=moy;} + } + + var tweetDrawed = new Array(); + var TweetHeight = 5; + + // DRAW TWEETS ============================================ + for(var i=0; i