Timeline ajax load fixed… a bit change in structure..

This commit is contained in:
Harry Bomrah 2012-07-03 19:45:47 +08:00
parent bacb1f1e63
commit f20f36383e
7 changed files with 48 additions and 33 deletions

View File

@ -127,12 +127,12 @@ GEM
activemodel (~> 3.1) activemodel (~> 3.1)
mongo (~> 1.3) mongo (~> 1.3)
tzinfo (~> 0.3.22) tzinfo (~> 0.3.22)
mongoid-tree (0.7.0)
mongoid (~> 2.0)
mongoid-encryptor (0.0.5) mongoid-encryptor (0.0.5)
activesupport (~> 3.0) activesupport (~> 3.0)
encrypted_strings (~> 0.3.3) encrypted_strings (~> 0.3.3)
mongoid (~> 2) mongoid (~> 2)
mongoid-tree (0.7.0)
mongoid (~> 2.0)
multi_json (1.1.0) multi_json (1.1.0)
nokogiri (1.5.2) nokogiri (1.5.2)
nokogiri (1.5.2-x86-mingw32) nokogiri (1.5.2-x86-mingw32)
@ -293,8 +293,8 @@ DEPENDENCIES
mini_magick mini_magick
mongo_session_store-rails3 mongo_session_store-rails3
mongoid mongoid
mongoid-tree
mongoid-encryptor mongoid-encryptor
mongoid-tree
nokogiri nokogiri
radius radius
rails (>= 3.1.0, < 3.2.0) rails (>= 3.1.0, < 3.2.0)

View File

@ -18,7 +18,7 @@ var orbitTimeline = function(dom){
$("div.scrollbar").hide(); $("div.scrollbar").hide();
t.constructTimeScale(function(timelineScale){ t.constructTimeScale(function(timelineScale){
$("#timeline_scale").html(timelineScale); $("#timeline_scale").html(timelineScale);
var totalyearwidth =timelineScale.find(".year").length * 100; var totalyearwidth =timelineScale.find(".year").length * 200;
var totalul = 0; var totalul = 0;
$(".t_scale").css({"min-width":$(".tinycanvas .viewport").width()+200 + "px"}) $(".t_scale").css({"min-width":$(".tinycanvas .viewport").width()+200 + "px"})
for(eve in t.events){ for(eve in t.events){
@ -51,8 +51,9 @@ var orbitTimeline = function(dom){
this.constructTimeScale = function(callbackFn){ this.constructTimeScale = function(callbackFn){
var mon ="",year="",formname; var mon ="",year="",formname;
var scale = $("<div id='scale_wrapper'></div>"); var scale = $("<div id='scale_wrapper'></div>");
$.getJSON("desktop_orbit/getevents",{"event":"papers","from":t.fromdate},function(papers){ $.getJSON("desktop_orbit/eventajaxload",{"event":"papers","from":t.fromdate},function(papersArray){
$.each(papers,function(i,paper){ $.each(papersArray,function(i,pa){
$.each(pa.papers,function(i,paper){
var dt = new Date(paper.created_at); var dt = new Date(paper.created_at);
var cur_mon = paper.created_at.substr(5,2); var cur_mon = paper.created_at.substr(5,2);
var cur_year = dt.getFullYear(); var cur_year = dt.getFullYear();
@ -70,6 +71,7 @@ var orbitTimeline = function(dom){
yr.append($("<div class='scale_region month' data-content='"+cdt+"'><div class='month_heading'>"+t.monthList[parseInt(formname)]+"</div><div class='bubble_list'></div></div>")) yr.append($("<div class='scale_region month' data-content='"+cdt+"'><div class='month_heading'>"+t.monthList[parseInt(formname)]+"</div><div class='bubble_list'></div></div>"))
} }
}); });
});
scale.append($("<div class='scale_region year'>"+year+"</div><div data-content='"+(year-1)+"'></div>")); scale.append($("<div class='scale_region year'>"+year+"</div><div data-content='"+(year-1)+"'></div>"));
t.fromdate = [year,formname-1]; t.fromdate = [year,formname-1];
if(typeof callbackFn == "function"){ if(typeof callbackFn == "function"){
@ -137,9 +139,9 @@ var orbitTimeline = function(dom){
}); });
}); });
if(papersArray.length != 0){ if(papersArray.length != 0){
if(scale.find("div[data-content="+(year-1)+"]").length == 0)
scale.append($("<div class='scale_region year'>"+year+"</div><div data-content='"+(year-1)+"'></div>")); scale.append($("<div class='scale_region year'>"+year+"</div><div data-content='"+(year-1)+"'></div>"));
t.ajaxload = true; t.ajaxload = true;
console.log(year);
t.fromdate = [year,formname-1]; t.fromdate = [year,formname-1];
} }
if(typeof callbackFn == "function"){ if(typeof callbackFn == "function"){

View File

@ -16,14 +16,16 @@ class DesktopOrbitController< ApplicationController
end end
def eventajaxload def eventajaxload
@limit = 15
@fromdate = params["from"] @fromdate = params["from"]
@fromdate[0] = Integer(@fromdate[0]) @fromdate[0] = Integer(@fromdate[0])
@fromdate[1] = Integer(@fromdate[1]) @fromdate[1] = Integer(@fromdate[1])
@totalpapers = 0 @totalpapers = 0
@lastpaper = current_user.papers.all.desc(:created_at).last @lastpaper = current_user.papers.all.desc(:created_at).last
@date = Date.new(Integer(@lastpaper.created_at.strftime("%Y")),Integer(@lastpaper.created_at.strftime("%m")))
@data = Array.new @data = Array.new
while @totalpapers < 15 while @totalpapers < @limit
if @lastpaper.created_at > Date.new(@fromdate[0],@fromdate[1]) if Date.new(@date.year,@date.month-1) > Date.new(@fromdate[0],@fromdate[1])
break break
end end
if(@fromdate[1] == 12) if(@fromdate[1] == 12)

View File

@ -12,7 +12,7 @@ class DesktopPublicationsController< ApplicationController
end end
def create_journal def create_journal
Journal.create(user_id: current_user.id, title: "Google") Journal.create(user_id: current_user.id, title: "Ice Cream Sandwich")
b = Array.new b = Array.new
b << {"success"=>"true"} b << {"success"=>"true"}
render :json=>b.to_json render :json=>b.to_json
@ -35,4 +35,15 @@ class DesktopPublicationsController< ApplicationController
b << {"success"=>"true"} b << {"success"=>"true"}
render :json=>b.to_json render :json=>b.to_json
end end
def update_journal
@journal = Journal.find("4ff2d6ebbd98eb02b9000017")
@papers = @journal.papers
@papers.each do |paper|
paper.update_attributes(:user_id => current_user.id)
end
b = Array.new
b << {"success"=>"true"}
render :json=>b.to_json
end
end end

View File

@ -11,7 +11,7 @@ class Journal
before_create :initialize_paper before_create :initialize_paper
def initialize_paper def initialize_paper
for i in 0..5 for i in 0..11
self.papers.build self.papers.build
end end
end end

View File

@ -7,9 +7,8 @@ class Paper
field :abstract, default: "The concept of microstructure engineering has gained increasingly attention with the goal to quantitatively link the operational parameters of an industrial process to the properties of its product. The key component of this concept is to accurately model the microstructure evolution along the processing path. Modelling of recrystallization in Cuinterconnects will be presented as an example of a conventional process model. Further, the potential of developing next generation process models will be discussed by using models across different length and time scale. The multi-scale modelling approach will be illustrated with a case study for phase transformation in Fe-Mn alloys." field :abstract, default: "The concept of microstructure engineering has gained increasingly attention with the goal to quantitatively link the operational parameters of an industrial process to the properties of its product. The key component of this concept is to accurately model the microstructure evolution along the processing path. Modelling of recrystallization in Cuinterconnects will be presented as an example of a conventional process model. Further, the potential of developing next generation process models will be discussed by using models across different length and time scale. The multi-scale modelling approach will be illustrated with a case study for phase transformation in Fe-Mn alloys."
field :level, default: "SCI" field :level, default: "SCI"
field :coauthors, default: "Allen, Shelly, Eric, Manson, Chris, Clara, Anna, Albee, Vincent, Devin, Chunchi, Ika, Jaoshua, Ray, Matt, Lin, Spen" field :coauthors, default: "Allen, Shelly, Eric, Manson, Chris, Clara, Anna, Albee, Vincent, Devin, Chunchi, Ika, Jaoshua, Ray, Matt, Lin, Spen"
field :created_at, type: Date, default: ->{12.months.ago} field :created_at, type: Date
belongs_to :journal
belongs_to :user

View File

@ -199,8 +199,9 @@ Orbit::Application.routes.draw do
match '/desktop_orbit/orbit' => 'desktop_orbit#orbit' match '/desktop_orbit/orbit' => 'desktop_orbit#orbit'
match '/desktop_orbit/eventajaxload'=> 'desktop_orbit#eventajaxload' match '/desktop_orbit/eventajaxload'=> 'desktop_orbit#eventajaxload'
match '/desktop_orbit/getevents' => 'desktop_orbit#getevents' match '/desktop_orbit/getevents' => 'desktop_orbit#getevents'
#match '/desktop_orbit/getevents' => 'desktop_publications#create_journal' #match '/desktop_orbit/eventajaxload' => 'desktop_publications#create_journal'
#match '/desktop_orbit/getevents' => 'desktop_publications#delete_journal' #match '/desktop_orbit/eventajaxload' => 'desktop_publications#delete_journal'
# match '/desktop_orbit/eventajaxload' => 'desktop_publications#update_journal'
match '/desktop/temp_func/'=>'desktop#temp_func' match '/desktop/temp_func/'=>'desktop#temp_func'