//for timeline parent library, will be accessable by main library and API library for other people to use.. default inherits orbitDesktopAPI // Harry Bomrah var orbitTimeline = function(dom){ t = this; this.dom = $("#"+dom); this.timelineHtml = $("
"); //this.marker = t.timelineHtml.find("#timline_marker"); this.scale = t.timelineHtml.find("#timeline_scale"); //this.container = t.timelineHtml.find("#t_container"); this.events = new Array; this.monthList = ["","January","February","March","April","May","June","July","August","September","October","November","December"]; this.initialize = function(){ t.dom.html(t.timelineHtml); $("div.scrollbar").hide(); t.constructTimeScale(function(timelineScale){ console.log(timelineScale); $("#timeline_scale").html(timelineScale); var totalyearwidth =timelineScale.find(".year").length * 100; var totalul = 0; for(eve in t.events){ t.makeBubble(t.events[eve]); totalul = $("#scale_wrapper ul").length $(".t_scale").width((totalul*350) + totalyearwidth); } $('.tinycanvas').tinyscrollbar({ axis: 'x'}); }); } this.constructTimeScale = function(callbackFn){ var mon ="",year=""; var scale = $("
"); $.getJSON("desktop_orbit/getevents",{"event":"papers"},function(journals){ $.each(journals,function(x,journal){ $.each(journal.papers,function(i,paper){ var dt = new Date(paper.created_at); var cur_mon = paper.created_at.substr(5,2); var cur_year = dt.getFullYear(); var cdt = paper.created_at.substr(0,7).replace("-",""); var formname = (cur_mon.charAt(0) == "0"?cur_mon.charAt(1) : cur_mon) var bubbleData = {"fulldate" : t.monthList[parseInt(formname)] +", " + dt.getDate() + ", " + cur_year,"title":paper.title,"jtitle":journal.title,"coauthors":paper.coauthors,"abstract":paper.abstract,"timestamp":cdt} t.events.push(bubbleData); if(cur_year != year){ year = cur_year; scale.append($("
"+(year+1)+"
")); } if(cur_mon != mon){ mon = cur_mon; console.log(parseInt(cur_mon)); scale.append($("
"+t.monthList[parseInt(formname)]+"
")) } }); }) scale.append($("
"+year+"
")); if(typeof callbackFn == "function"){ callbackFn.call(this,scale); } }); } this.makeBubble = function(bubbleData){ var totalul = $("#scale_wrapper").find("div[data-content="+bubbleData.timestamp+"] ul").length; var targetul = $("#scale_wrapper div[data-content="+bubbleData.timestamp+"] div.bubble_list ul").eq(totalul-1); if(totalul == 0){ var ul = $(""); $("#scale_wrapper").find("div[data-content="+bubbleData.timestamp+"] div.bubble_list").append(ul); targetul = ul; }else{ var totalli = targetul.find("li").length; if(totalli >= 5){ var ul = $(""); $("#scale_wrapper").find("div[data-content="+bubbleData.timestamp+"] div.bubble_list").append(ul); targetul = ul; } } var bt = (bubbleData.title.length > 70? bubbleData.title.substr(0,70) + "..." : bubbleData.title); var bubble = $("
  • "+bt+" - "+bubbleData.fulldate+"
  • "); bubble.css("margin-left","25px"); targetul.prepend(bubble); bubble.show(); bubble.click(function(){ o.toolPopup({ parent: $(this), html : "

    "+bubbleData.jtitle+"

    Co-Authors:

    "+bubbleData.coauthors+"

    Abstract:

    "+bubbleData.abstract+"
    ", height: "auto", width:"300px" }); })//.mouseout(function(){t.oapi.toolPopup("destroy");}) } }