From 7f8f5f3c921ca7752cc3eeb2fba7dc1cfd11e959 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 4 Sep 2017 17:26:43 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E9=82=AE=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/mailer/lost_password.html.erb | 4 ++-- app/views/mailer/register.html.erb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/mailer/lost_password.html.erb b/app/views/mailer/lost_password.html.erb index d7dcf7dbf..48db5bf6a 100644 --- a/app/views/mailer/lost_password.html.erb +++ b/app/views/mailer/lost_password.html.erb @@ -28,7 +28,7 @@
- +

Educoder

@@ -56,7 +56,7 @@

- www.educoder.net + www.educoder.net
diff --git a/app/views/mailer/register.html.erb b/app/views/mailer/register.html.erb index 38d51fb8a..6a4298c5c 100644 --- a/app/views/mailer/register.html.erb +++ b/app/views/mailer/register.html.erb @@ -23,7 +23,7 @@
- +

Educoder

@@ -48,7 +48,7 @@
- www.educoder.net + www.educoder.net
From f3c98cc4612274d164beb3d631fdce4c2f44299c Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 4 Sep 2017 17:34:34 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E6=95=B0=E6=8D=AE=E4=B8=8D=E5=87=86=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_courses.html.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 21e75c387..55e8a19c5 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -169,6 +169,8 @@ <%# end %> <%# end %> + <%# 更新访问数,刷新的时候更新访问次数 %> + <% update_visiti_count @course %> <%= @course.visits %> 次访问 From ef3c4f1d5109546d7f4f39e27a4f019874574a13 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 5 Sep 2017 11:03:49 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E7=AE=80=E5=8C=96=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=92=8C=E8=AF=BE=E5=A0=82=E7=9A=84=E4=B8=93?= =?UTF-8?q?=E4=B8=9A=E5=8F=8A=E8=AF=BE=E7=A8=8B=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 35 +++++-- app/views/shixuns/_form.html.erb | 122 ++++++---------------- app/views/shixuns/_settings_edit.html.erb | 121 +++++---------------- app/views/shixuns/_settings_show.html.erb | 14 +-- public/javascripts/edu/application.js | 38 ++++++- public/javascripts/edu/course.js | 35 ------- public/stylesheets/css/edu-class.css | 2 - public/stylesheets/css/edu-common.css | 2 +- public/stylesheets/css/edu-public.css | 3 + 9 files changed, 128 insertions(+), 244 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index d4dfe0981..5fa93690f 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -463,14 +463,20 @@ class ShixunsController < ApplicationController @shixun = Shixun.new(params[:shixun]) @shixun.user_id = User.current.id @shixun.language = params[:language] - @shixun.major_id = params[:major_id] + #@shixun.major_id = params[:major_id] @shixun.trainee = params[:trainee] @shixun.webssh = params[:webssh].to_i @shixun.identifier = identifier - if params[:course_id] - params[:course_id].each do |course_id| - @shixun.shixun_major_courses << ShixunMajorCourse.new(:major_id => params[:major_id], :course_list_id => course_id) - end + # if params[:course_id] + # params[:course_id].each do |course_id| + # @shixun.shixun_major_courses << ShixunMajorCourse.new(:major_id => params[:major_id], :course_list_id => course_id) + # end + # end + if CourseList.where(:name => params[:course_list].strip).count > 0 + @shixun.shixun_major_courses << ShixunMajorCourse.new(:major_id => -1, :course_list_id => CourseList.where(:name => params[:course_list].strip).first.id) + else + course_list = CourseList.create(:name => params[:course_list].strip, :user_id => User.current.id, :is_admin => 0) + @shixun.shixun_major_courses << ShixunMajorCourse.new(:major_id => -1, :course_list_id => course_list.id) end (params[:shixun][:is_public] == "1" ? @shixun.is_public = true : @shixun.is_public = false) ActiveRecord::Base.transaction do @@ -534,13 +540,20 @@ class ShixunsController < ApplicationController @shixun.language = params[:language] @shixun.trainee = params[:trainee] @shixun.webssh = params[:webssh].to_i - if params[:course_id] - @shixun.shixun_major_courses.destroy_all - params[:course_id].each do |course_id| - @shixun.shixun_major_courses << ShixunMajorCourse.new(:major_id => params[:major_id], :course_list_id => course_id) - end + # if params[:course_id] + # @shixun.shixun_major_courses.destroy_all + # params[:course_id].each do |course_id| + # @shixun.shixun_major_courses << ShixunMajorCourse.new(:major_id => params[:major_id], :course_list_id => course_id) + # end + # end + # @shixun.major_id = params[:major_id] + @shixun.shixun_major_courses.destroy_all + if CourseList.where(:name => params[:course_list].strip).count > 0 + @shixun.shixun_major_courses << ShixunMajorCourse.new(:major_id => -1, :course_list_id => CourseList.where(:name => params[:course_list].strip).first.id) + else + course_list = CourseList.create(:name => params[:course_list].strip, :user_id => User.current.id, :is_admin => 0) + @shixun.shixun_major_courses << ShixunMajorCourse.new(:major_id => -1, :course_list_id => course_list.id) end - @shixun.major_id = params[:major_id] params[:shixun][:is_public] == "on" ? @shixun.is_public = 1 : @shixun.is_public = 0 ActiveRecord::Base.transaction do begin diff --git a/app/views/shixuns/_form.html.erb b/app/views/shixuns/_form.html.erb index ab3557118..fef674277 100644 --- a/app/views/shixuns/_form.html.erb +++ b/app/views/shixuns/_form.html.erb @@ -37,24 +37,23 @@

-
  • - - <%#= select_tag :major_id, options_for_select(shixun_major_option, 0), :id => 'shixun_major', :class => "fl task-form-30 task-height-40"%> - -
    - -
  • + + + + + + + + + + + +
  • -
    - - -
      +
      + +
      @@ -88,93 +87,36 @@ $(function(){ $("#websh").on("click", function(){ $(this).val() == '0' ? $(this).val('1') : $(this).val("0"); - }) + }); // 实训简介自动保存 md_elocalStorage(shixun_editormd, "shixun_in_<%= User.current.id %>", "in"); md_elocalStorage(shixun_propaedeutics, "shixun_pr_<%= User.current.id %>", "pr"); //$("textarea[name='shixun[description]']").md_elocalStorage(); - // 防止刷新页面后适用课程的下拉列表为空 - $("#shixun_major").val("0"); - $(".lesson_content").val(""); - - //多选适用课程 - $("body").click(function(event){ - $(".lesson_checkbox").hide(); - $(".lesson_checkbox").attr("showul","0"); - event.stopPropagation(); + $("#new_course_list").on('input', function(e){ + throttle(search_course_list, window, e); }); - $(".lesson").click(function(event){ - if($("#shixun_major").val() == "0") { - $("#shixun_major_course_notice").html("请先选择适用专业").show(); + $("#new_course_list").on('focus', function (e) { + if ($("#new_course_list").val().trim() != '') { //如果已经有id了。肯定存在,不用去找了。 + return; } else{ - var showul=$(this).find("ul").attr("showul"); - if(showul=="0"){ - $(this).find("ul").show(); - $(this).find("ul").attr("showul","1"); - if($(this).find("ul input").length>5){ - $(this).find("ul").css("overflow-y","scroll"); - } - event.stopPropagation(); - }else{ - $(this).find("ul").hide(); - $(this).find("ul").attr("showul","0"); - event.stopPropagation(); - } + search_course_ajax(''); } }); - $(".lesson_checkbox").on('click', 'label', function(event) { + + $(".course_list_ul").on('click', 'p',function(event) { + $("#new_course_list").val($(this).html()); + $(".course_list_ul").hide(); event.stopPropagation(); }); - $(".lesson_checkbox").on('click', 'input',function(event) { - if ($(this).is(':checked')) { - if ($(".lesson_content").val() == "") { - $(".lesson_content").val($(this).attr("data-val")); - } else { - $(".lesson_content").val($(".lesson_content").val() + "," + $(this).attr("data-val")); - } - $("#shixun_major_course_notice").hide(); - event.stopPropagation(); - } else { - var valueCon = $(".lesson_content").val().split(","); - var list = []; - for (var i = 0; i < valueCon.length; i++) { - if (valueCon[i] != $(this).attr("data-val")) { - list.push(valueCon[i]); - } - } - $(".lesson_content").val(list); - event.stopPropagation(); - } + + $("body").click(function(event){ + $(".course_list_ul").hide(); + event.stopPropagation(); }); }); - $("#shixun_major").on("change", function(){ - if($("#shixun_major").val() != "0"){ - $.ajax({ - url: '/shixuns/shixun_courses', - type: 'get', - data: {major_id:$("#shixun_major").val()}, - success: function(data){ - if (data.result == 1){ - $(".lesson_content").val(""); - $(".lesson_checkbox").html(""); - for(var i=0; i'); - } - $("#shixun_major_notice").hide(); - } - else{ - $(".lesson_content").val(""); - $(".lesson_checkbox").html(""); - } - } - }); - } else{ - $(".lesson_content").val(""); - $(".lesson_checkbox").html(""); - } - }); + /* ------------------------------- 简介md ------------------------------*/ var shixun_editormd = editormd("shixun_introduction", { width : "89.7%", @@ -235,7 +177,7 @@ //提交新建项目 function submit_new_project() { - if(regex_shixun_name() && regex_major() && regex_major_course()) + if(regex_shixun_name() && regex_major_course()) { $("#new_shixun").submit(); } diff --git a/app/views/shixuns/_settings_edit.html.erb b/app/views/shixuns/_settings_edit.html.erb index 741dfd2e8..9124e27c9 100644 --- a/app/views/shixuns/_settings_edit.html.erb +++ b/app/views/shixuns/_settings_edit.html.erb @@ -14,18 +14,17 @@

      -
    • - - <%= select_tag :major_id, options_for_select(shixun_major_option, @shixun.major_id ? @shixun.major_id : 0), :id => 'shixun_major', :class => "fl task-form-30 task-height-40"%> -
      - -
    • + + + + + +
    • -
      - - -
        +
        + @shixun.shixun_major_courses.map(&:course_list_id)).map(&:name).join(",") %>" autocomplete="off" style="border: 1px solid #eee;width: 100%;padding: 5px;" id="new_course_list" class="task-height-40 panel-box-sizing fl" maxlength="100" placeholder="选择实训适用的课程"> +
        @@ -62,7 +61,7 @@