diff --git a/app/assets/javascripts/desktop/orbitdesktop.js b/app/assets/javascripts/desktop/orbitdesktop.js index 0d6ed59fd..f45b8796f 100755 --- a/app/assets/javascripts/desktop/orbitdesktop.js +++ b/app/assets/javascripts/desktop/orbitdesktop.js @@ -226,7 +226,8 @@ var orbitDesktop = function(dom){ this.bindDesktopEvents = function(){ //this function will bind the global handlers to thd desktop, for example doc $(".docklist a").click(function(){ - o.menu_item($(this)); + if( !$( this ).hasClass( 'disable' ) ) + o.menu_item($(this)); return false; }); @@ -274,10 +275,11 @@ var orbitDesktop = function(dom){ }); $("body").on("click","*[ajax-remote]",function(){ - var $e = $(this); - var t = $e.attr("ajax-remote"); - var classes_to_toggle = $e.attr("toggle-onclick"); - var exe = $e.attr("callback-method"); // (typeof $e.attr("callback-method") == "function"? $e.attr("callback-method") : ""); + var $e = $(this), + t = $e.attr("ajax-remote"), + classes_to_toggle = $e.attr("toggle-onclick"), + responsetype = $e.attr('response-type') ? $e.attr('response-type') : "html", + exe = $e.attr("callback-method"); // (typeof $e.attr("callback-method") == "function"? $e.attr("callback-method") : ""); if(classes_to_toggle){ $e.toggleClass(classes_to_toggle); } @@ -289,9 +291,9 @@ var orbitDesktop = function(dom){ } var ca = $e.attr("content-holder"); var a = function(){ - $.ajax({ type : t, + dataType : responsetype, url : $e.attr("href"), success : function(data){ if(typeof data == "string"){ @@ -302,6 +304,7 @@ var orbitDesktop = function(dom){ // $("div[container=true]").html(data); } } + if(exe) window.o[o.data_method][exe](data,$e); if(t == "delete"){ diff --git a/app/controllers/admin/import_data_controller.rb b/app/controllers/admin/import_data_controller.rb index a66ab342a..7a754a03d 100644 --- a/app/controllers/admin/import_data_controller.rb +++ b/app/controllers/admin/import_data_controller.rb @@ -322,6 +322,12 @@ class Admin::ImportDataController < OrbitBackendController puts "No conference by Teacher" end end + respond_to do |format| + + format.html + format.json { render json: {"success"=>true}.to_json} + + end end @@ -331,64 +337,80 @@ class Admin::ImportDataController < OrbitBackendController @user = User.find("#{params[:user_id]}") # teachers.each do |hash| - if @user.sid.present? - ntu_seq = @user.sid - paper_xml = Nokogiri::XML( \ - #open("http://versatile.management.ntu.edu.tw/publication1/journal/#{ntuseq}.xml")) - open("http://ann.cc.ntu.edu.tw/Achv/xmlPaper.asp?Seq=#{ntu_seq}&type=J")) - @journal_papers = paper_xml.xpath("//Paper").map do |paper_node| - { - author: (paper_node>"Authors").text, - year: (paper_node>"PublishYear").text, - title: (paper_node>"PaperTitle").text, - journal: (paper_node>"PublishOn").text, - volume:(paper_node>"Volume").text, - volumeno:(paper_node>"VolumeNo").text, - beginpage:(paper_node>"BeginPage").text, - endpage:(paper_node>"EndPage").text, - subgroup:(paper_node>"subgroup").text, - remarks: (paper_node>"Remarks").text, - cate: ((paper_node>"subgroup")>"Group").text - } - end - if @journal_papers.present? - @journal_papers.each do |b| - @journal_paper = WritingJournal.new - I18n.locale = :zh_tw - @journal_paper.authors = b[:author] - if b[:title].blank? - @journal_paper.paper_title = "No Title Present" - else - @journal_paper.paper_title = b[:title] - end - @journal_paper.journal_title = b[:journal] - @journal_paper.note = b[:remarks] - I18n.locale = :en - @journal_paper.authors = b[:author] - if b[:title].blank? - @journal_paper.paper_title = "No Title Present" - else - @journal_paper.paper_title = b[:title] - end - @journal_paper.journal_title = b[:journal] - @journal_paper.note = b[:remarks] - @journal_paper.year = b[:year] - @journal_paper.vol_no = b[:volumeno] - @journal_paper.form_to_start = b[:beginpage] - @journal_paper.form_to_end = b[:endpage] - if !b[:cate].blank? - @level_type = JournalLevelType.where(:key => b[:cate]) - if @level_type.present? - @journal_paper.journal_level_type_ids = ["#{@level_type.first.id}"] - end - end + if @user.sid.present? + ntu_seq = @user.sid + paper_xml = Nokogiri::XML( \ + #open("http://versatile.management.ntu.edu.tw/publication1/journal/#{ntuseq}.xml")) + open("http://ann.cc.ntu.edu.tw/Achv/xmlPaper.asp?Seq=#{ntu_seq}&type=J")) + @journal_papers = paper_xml.xpath("//Paper").map do |paper_node| + { + author: (paper_node>"Authors").text, + year: (paper_node>"PublishYear").text, + title: (paper_node>"PaperTitle").text, + journal: (paper_node>"PublishOn").text, + volume:(paper_node>"Volume").text, + volumeno:(paper_node>"VolumeNo").text, + beginpage:(paper_node>"BeginPage").text, + endpage:(paper_node>"EndPage").text, + subgroup:(paper_node>"subgroup").text, + remarks: (paper_node>"Remarks").text, + cate: ((paper_node>"subgroup")>"Group").text + } + end + if @journal_papers.present? + @journal_papers.each do |b| + @journal_paper = WritingJournal.new + I18n.locale = :zh_tw + @journal_paper.authors = b[:author] - @journal_paper.create_user_id = @user.id - @journal_paper.save! - end - else - puts "No journal paper by Teacher" + if b[:title].blank? + @journal_paper.paper_title = "No Title Present" + else + @journal_paper.paper_title = b[:title] + end + + @journal_paper.journal_title = b[:journal] + @journal_paper.note = b[:remarks] + I18n.locale = :en + @journal_paper.authors = b[:author] + + if b[:title].blank? + @journal_paper.paper_title = "No Title Present" + else + @journal_paper.paper_title = b[:title] + end + + @journal_paper.journal_title = b[:journal] + @journal_paper.note = b[:remarks] + @journal_paper.year = b[:year] + @journal_paper.vol_no = b[:volumeno] + @journal_paper.form_to_start = b[:beginpage] + @journal_paper.form_to_end = b[:endpage] + + if !b[:cate].blank? + @level_type = JournalLevelType.where(:key => b[:cate]) + if @level_type.present? + @journal_paper.journal_level_type_ids = ["#{@level_type.first.id}"] + end + end + + @journal_paper.create_user_id = @user.id + @journal_paper.save! + respond_to do |format| + + format.html + format.json { render json: {"success"=>true}.to_json} + + end + end end + + end + respond_to do |format| + + format.html + format.json { render json: {"success"=>true}.to_json} + end end @@ -431,10 +453,14 @@ def sync_book_data @book.create_user_id = @user.id @book.save end - else - puts "No books by Teacher" - end + end end + respond_to do |format| + + format.html + format.json { render json: {"success"=>true}.to_json} + + end end diff --git a/app/views/desktop/index.html.erb b/app/views/desktop/index.html.erb index 9796ade73..cd3b6fcdb 100644 --- a/app/views/desktop/index.html.erb +++ b/app/views/desktop/index.html.erb @@ -32,32 +32,32 @@