diff --git a/app/assets/javascripts/admins/shixun_feedback_messages/index.js b/app/assets/javascripts/admins/shixun_feedback_messages/index.js new file mode 100644 index 000000000..c0b32ba32 --- /dev/null +++ b/app/assets/javascripts/admins/shixun_feedback_messages/index.js @@ -0,0 +1,22 @@ +$(document).on('turbolinks:load', function(){ + if ($('body.admins-shixun-feedback-messages-index-page').length > 0) { + + var baseOptions = { + autoclose: true, + language: 'zh-CN', + format: 'yyyy-mm-dd 00:00:00', + startDate: '2017-04-01' + } + + var defineDateRangeSelect = function(element){ + var options = $.extend({inputs: $(element).find('.start-date, .end-date')}, baseOptions); + $(element).datepicker(options); + + $(element).find('.start-date').datepicker().on('changeDate', function(e){ + $(element).find('.end-date').datepicker('setStartDate', e.date); + }) + }; + + defineDateRangeSelect('.grow-date-input-daterange'); + } +}) \ No newline at end of file diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 2d1b39590..f03cbdef8 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -60,7 +60,7 @@ class AccountsController < ApplicationController ua = UserAgent.find_by_ip(ip) ua.update_column(:agent_type, UserAgent::USER_REGISTER) if ua successful_authentication(@user) - session[:user_id] = @user.id + # session[:user_id] = @user.id normal_status("注册成功") end rescue Exception => e @@ -94,7 +94,7 @@ class AccountsController < ApplicationController successful_authentication(@user) login_control.clear # 重置每日密码错误次数 - session[:user_id] = @user.id + # session[:user_id] = @user.id end # 忘记密码 @@ -127,7 +127,7 @@ class AccountsController < ApplicationController end end - def successful_authentication(user) + def successful_authentication(user) uid_logger("Successful authentication start: '#{user.login}' from #{request.remote_ip} at #{Time.now.utc}") # Valid user self.logged_user = user @@ -136,6 +136,7 @@ class AccountsController < ApplicationController set_autologin_cookie(user) UserAction.create(:action_id => user.try(:id), :action_type => "Login", :user_id => user.try(:id), :ip => request.remote_ip) user.update_column(:last_login_on, Time.now) + session[:"#{default_yun_session}"] = user.id # 注册完成后有一天的试用申请(先去掉) # UserDayCertification.create(user_id: user.id, status: 1) end @@ -158,7 +159,6 @@ class AccountsController < ApplicationController def logout UserAction.create(action_id: User.current.id, action_type: "Logout", user_id: User.current.id, :ip => request.remote_ip) - session[:user_id] = nil logout_user render :json => {status: 1, message: "退出成功!"} end diff --git a/app/controllers/admins/courses_controller.rb b/app/controllers/admins/courses_controller.rb new file mode 100644 index 000000000..e69de29bb diff --git a/app/controllers/admins/laboratory_subjects_controller.rb b/app/controllers/admins/laboratory_subjects_controller.rb index 866a20a76..c09697c7e 100644 --- a/app/controllers/admins/laboratory_subjects_controller.rb +++ b/app/controllers/admins/laboratory_subjects_controller.rb @@ -17,9 +17,15 @@ class Admins::LaboratorySubjectsController < Admins::BaseController def destroy return render_js_error('不能删除自建课程', type: :notify) if current_laboratory_subject.ownership? - current_laboratory_subject.destroy! - - render_delete_success + ActiveRecord::Base.transaction do + current_subject = current_laboratory_subject.subject + current_subject.shixuns.each do |shixun| + shixun.destroy! + end + current_subject.destroy! + + render_delete_success + end end diff --git a/app/controllers/admins/schools_controller.rb b/app/controllers/admins/schools_controller.rb index 8c4f1d59e..7e1626d98 100644 --- a/app/controllers/admins/schools_controller.rb +++ b/app/controllers/admins/schools_controller.rb @@ -5,7 +5,7 @@ class Admins::SchoolsController < Admins::BaseController schools = Admins::SchoolQuery.call(params) - @schools = paginate schools + @schools = paginate schools.includes(:user_extensions) school_ids = @schools.map(&:id) @department_count = Department.where(school_id: school_ids).group(:school_id).count diff --git a/app/controllers/admins/shixun_feedback_messages_controller.rb b/app/controllers/admins/shixun_feedback_messages_controller.rb new file mode 100644 index 000000000..09aa465bd --- /dev/null +++ b/app/controllers/admins/shixun_feedback_messages_controller.rb @@ -0,0 +1,22 @@ +class Admins::ShixunFeedbackMessagesController < Admins::BaseController + + def index + @params_page = params[:page] || 1 + if params[:keyword].present? + discusses = Discuss.joins("LEFT JOIN shixuns ON discusses.dis_id = shixuns.id AND dis_type = 'Shixun'") + .where("shixuns.name like ?", "%#{params[:keyword]}%") + else + discusses = Discuss.where(:dis_type => 'Shixun').includes(:user, :dis) + end + + if params[:begin_date].present? + discusses = discusses.where("discusses.created_at > ?", params[:begin_date]) + end + + if params[:end_date].present? + discusses = discusses.where("discusses.created_at < ?", params[:end_date]) + end + + @discusses = paginate discusses.order("created_at desc") + end +end \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c6aca5ae5..3ec8ad0f7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -299,9 +299,11 @@ class ApplicationController < ActionController::Base # and starts a session if needed def find_current_user uid_logger("user setup start: session[:user_id] is #{session[:user_id]}") - if session[:user_id] + uid_logger("0000000000000user setup start: default_yun_session is #{default_yun_session}, session[:current_user_id] is #{session[:"#{default_yun_session}"]}") + current_domain_session = session[:"#{default_yun_session}"] + if current_domain_session # existing session - (User.active.find(session[:user_id]) rescue nil) + (User.active.find(current_domain_session) rescue nil) elsif autologin_user = try_to_autologin autologin_user elsif params[:format] == 'atom' && params[:key] && request.get? && accept_rss_auth? @@ -313,10 +315,10 @@ class ApplicationController < ActionController::Base def try_to_autologin if cookies[autologin_cookie_name] # auto-login feature starts a new session - user = User.try_to_autologin(cookies[autologin_cookie_name]) - if user - start_user_session(user) - end + user = nil + Rails.logger.info("111111111111111111#{default_yun_session}, session is #{session[:"#{default_yun_session}"]} ") + user = User.try_to_autologin(cookies[autologin_cookie_name]) if session[:"#{default_yun_session}"] + start_user_session(user) if user user end end @@ -402,25 +404,6 @@ class ApplicationController < ActionController::Base end end - # 处理返回非0就报错的请求 - def interface_post(uri, params, status, message) - begin - uid_logger_dubug("--uri_exec: params is #{params}, url is #{uri}") - uri = URI.parse(URI.encode(uri.strip)) - res = Net::HTTP.post_form(uri, params).body - uid_logger_dubug("--uri_exec: .....res is #{res}") - res = JSON.parse(res) - if (res && res['code'] != 0) - tip_exception(status, message) - else - res - end - rescue Exception => e - uid_logger("--uri_exec: exception #{e.message}") - raise Educoder::TipException.new("实训平台繁忙(繁忙等级:84)") - end - end - # json格式请求 def interface_json_post(uri, params, status, message) begin diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index da6e99418..0c9c49621 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -125,7 +125,7 @@ class AttachmentsController < ApplicationController end digest = md5_file(temp_file) - digest = "#{digest}_#{Time.now.to_i}" + digest = "#{digest}_#{(Time.now.to_f * 1000).to_i}" local_file_path = File.join(save_path, digest) + ext save_temp_file(temp_file, local_file_path) diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index c21a493e0..0b5140743 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -308,6 +308,7 @@ class ChallengesController < ApplicationController end def challenge_params + tip_exception("评测时间不能超过300秒") if params[:challenge][:exec_time].to_i > 300 params.require(:challenge).permit(:subject, :task_pass, :difficulty, :score, :st, :modify_time, :test_set_average, :path, :exec_path, :show_type, :original_picture_path, :test_set_score, :expect_picture_path, :picture_path, :web_route, :answer, :exec_time) diff --git a/app/controllers/concerns/laboratory_helper.rb b/app/controllers/concerns/laboratory_helper.rb index 870a1d90e..e03273d68 100644 --- a/app/controllers/concerns/laboratory_helper.rb +++ b/app/controllers/concerns/laboratory_helper.rb @@ -6,6 +6,7 @@ module LaboratoryHelper helper_method :current_laboratory helper_method :default_setting + helper_method :default_yun_session end def current_laboratory @@ -23,4 +24,9 @@ module LaboratoryHelper def setup_laboratory Laboratory.current = current_laboratory end + + def default_yun_session + laboratory ||= (Laboratory.find_by_subdomain(request.subdomain) || Laboratory.find(1)) + @_default_yun_session = "#{laboratory.try(:identifier).split('.').first}_user_id" + end end \ No newline at end of file diff --git a/app/controllers/concerns/login_helper.rb b/app/controllers/concerns/login_helper.rb index b3ec6da63..ede7ff071 100644 --- a/app/controllers/concerns/login_helper.rb +++ b/app/controllers/concerns/login_helper.rb @@ -29,7 +29,7 @@ module LoginHelper Rails.logger.info("id: #{user&.id} Successful authentication start: '#{user.login}' from #{request.remote_ip} at #{Time.now.utc}") # Valid user self.logged_user = user - + session[:"#{default_yun_session}"] = user.id # generate a key and set cookie if autologin set_autologin_cookie(user) @@ -47,12 +47,16 @@ module LoginHelper User.current.delete_session_token(session[:tk]) self.logged_user = nil end - session[:user_id] = nil + # 云上实验室退出清理当前session + laboratory ||= (Laboratory.find_by_subdomain(request.subdomain) || Laboratory.find(1)) + default_yun_session = "#{laboratory.try(:identifier).split('.').first}_user_id" + # end + session[:"#{default_yun_session}"] = nil end # Sets the logged in user def logged_user=(user) - reset_session + # reset_session if user && user.is_a?(User) User.current = user start_user_session(user) @@ -73,7 +77,8 @@ module LoginHelper # # session[:"#{request.subdomain}_user_id"] = user.id # # end - session[:user_id] = user.id + # session[:user_id] = user.id + session[:"#{default_yun_session}"] = user.id session[:ctime] = Time.now.utc.to_i session[:atime] = Time.now.utc.to_i end diff --git a/app/controllers/hack_user_lastest_codes_controller.rb b/app/controllers/hack_user_lastest_codes_controller.rb index 9602673e5..37102a166 100644 --- a/app/controllers/hack_user_lastest_codes_controller.rb +++ b/app/controllers/hack_user_lastest_codes_controller.rb @@ -1,9 +1,9 @@ class HackUserLastestCodesController < ApplicationController before_action :require_login, except: [:listen_result] before_action :find_my_hack, only: [:show, :code_debug, :code_submit, :update_code, - :listen_result, :result, :submit_records] + :listen_result, :result, :submit_records, :restore_initial_code] before_action :update_user_hack_status, only: [:code_debug, :code_submit] - before_action :require_auth_identity, only: [:update_code] + before_action :require_auth_identity, only: [:update_code, :restore_initial_code] before_action :require_manager_identity, only: [:update_code] def show @@ -12,6 +12,13 @@ class HackUserLastestCodesController < ApplicationController def update_code @my_hack.update_attribute(:code, params[:code]) + render_ok + end + + # 回复初始代码 + def restore_initial_code + @my_hack.update_attribute(:code, @hack.code) + render_ok end # 调试代码 @@ -35,7 +42,7 @@ class HackUserLastestCodesController < ApplicationController # 提交结果显示 def result if @my_hack.submit_status == 1 - render json: {status:0, message: "正在评测中"} + render json: {status: 1, message: "正在评测中"} else @mode = params[:mode] @result = @@ -105,7 +112,7 @@ class HackUserLastestCodesController < ApplicationController else [{input: params[:input]}] end - testCases = Base64.urlsafe_encode64(test_sets.to_json) + testCases = Base64.encode64(test_sets.to_json) #codeFileContent = Base64.urlsafe_encode64(@my_hack.code) debug_params = {execMode: exec_mode, tpiID: @my_hack.identifier, @@ -121,6 +128,7 @@ class HackUserLastestCodesController < ApplicationController # 正则错误行数 def regular_match_error_line content, language + content = Base64.decode64(content).force_encoding("utf-8") case language when 'Java' content.scan(/.java.\d+/).map{|s| s.match(/\d+/)[0].to_i}.min diff --git a/app/controllers/hacks_controller.rb b/app/controllers/hacks_controller.rb index aee4ba338..993cba4e6 100644 --- a/app/controllers/hacks_controller.rb +++ b/app/controllers/hacks_controller.rb @@ -1,8 +1,9 @@ class HacksController < ApplicationController before_action :require_login, except: [:index] + before_action :find_hack, only: [:edit, :update, :publish, :start, :update_set, :delete_set] before_action :require_teacher_identity, only: [:create, :update_set] before_action :require_auth_identity, only: [:update, :edit, :publish, :update_set, :delete_set] - before_action :find_hack, only: [:edit, :update, :publish, :start, :update_set, :delete_set] + # 开启编程,如果第一次开启,创建一条记录,如果已经开启过的话,直接返回标识即可 def start @@ -19,7 +20,7 @@ class HacksController < ApplicationController @hack.hack_user_lastest_codes.create!(user_code) user_identifier end - render_ok(data: {identifier: identifier}) + render_ok(identifier: identifier) end # 首页 @@ -46,6 +47,8 @@ class HacksController < ApplicationController hack.identifier = generate_identifier Hack, 8 hack.save! # 创建测试集与代码 + logger.info("hack_sets_params:#{hack_sets_params}") + logger.info("hack_code_params:#{hack_code_params}") hack.hack_sets.create!(hack_sets_params) hack.hack_codes.create!(hack_code_params) end diff --git a/app/controllers/helps_controller.rb b/app/controllers/helps_controller.rb index 9aefb5129..8d58663f6 100644 --- a/app/controllers/helps_controller.rb +++ b/app/controllers/helps_controller.rb @@ -25,7 +25,16 @@ class HelpsController < ApplicationController end def feedback - content = "

[#{params[:question_kind]}]

问题页面网址:#{params[:url]}

#{params[:description]}" + if params[:url].blank? + content = "

[#{params[:question_kind]}]

#{params[:description]}" + if params[:attachment_ids] + params[:attachment_ids].each do |attachment_id| + content += "![](/api/attachments/#{attachment_id})↵" + end + end + else + content = "

[#{params[:question_kind]}]

问题页面网址:#{params[:url]}

#{params[:description]}" + end ActiveRecord::Base.transaction do attr = { sender_id: User.current.id, receiver_id: 1, content: content, send_time: Time.now } diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 65a1d345a..e31c77499 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -30,10 +30,10 @@ class HomeController < ApplicationController @main_shixuns = Shixun.where(homepage_show: true).includes(:tag_repertoires, :challenges).limit(8) @main_subjects = Subject.where(homepage_show: true).includes(:shixuns, :repertoire).limit(8) - if current_laboratory.main_site? - @tea_users = User.where(homepage_teacher: 1).includes(:user_extension).limit(10).order("experience desc") - @stu_users = User.where(is_test: 0).includes(:user_extension).where(user_extensions: {identity: 1}).limit(10).order("experience desc") - end + # if current_laboratory.main_site? + # @tea_users = User.where(homepage_teacher: 1).includes(:user_extension).limit(10).order("experience desc") + # @stu_users = User.where(is_test: 0).includes(:user_extension).where(user_extensions: {identity: 1}).limit(10).order("experience desc") + # end end def search diff --git a/app/controllers/oauth/base_controller.rb b/app/controllers/oauth/base_controller.rb index e4068fbda..11ac69d71 100644 --- a/app/controllers/oauth/base_controller.rb +++ b/app/controllers/oauth/base_controller.rb @@ -2,6 +2,7 @@ class Oauth::BaseController < ActionController::Base include RenderHelper include LoginHelper include ControllerRescueHandler + include LaboratoryHelper skip_before_action :verify_authenticity_token @@ -12,7 +13,8 @@ class Oauth::BaseController < ActionController::Base private def session_user_id - session[:user_id] + # session[:user_id] + session[:"#{default_yun_session}"] end def current_user @@ -23,4 +25,9 @@ class Oauth::BaseController < ActionController::Base Rails.logger.info("[OAuth2] omniauth.auth -> #{request.env['omniauth.auth'].inspect}") request.env['omniauth.auth'] end + + def default_yun_session + @_default_yun_session = "#{request.subdomain.split('.').first}_user_id" + # @_default_yun_session = "#{current_laboratory.try(:identifier).split('.').first}_user_id" + end end \ No newline at end of file diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 5a3fda7a4..068a0dafd 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -198,14 +198,14 @@ class PollsController < ApplicationController def common_header ActiveRecord::Base.transaction do begin + @poll_status = @poll.get_poll_status(current_user) if @user_course_identity > Course::ASSISTANT_PROFESSOR @is_teacher_or = 0 - @user_poll_answer = @poll.check_user_votes_status(current_user) + @user_poll_answer = @poll.check_user_votes_status(current_user, @poll_status) else @is_teacher_or = 1 @user_poll_answer = 3 #教师页面 end - @poll_status = @poll.get_poll_status(current_user) poll_id_array = [@poll.id] @poll_publish_count = get_user_permission_course(poll_id_array,2).count #是否存在已发布的 @poll_unpublish_count = get_user_permission_course(poll_id_array,1).count #是否存在未发布的 diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index e7555f927..12cac2933 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -10,7 +10,7 @@ class ShixunsController < ApplicationController before_action :find_shixun, except: [:index, :new, :create, :menus, :get_recommend_shixuns, :propaedeutics, :departments, :apply_shixun_mirror, - :get_mirror_script, :download_file, :shixun_list] + :get_mirror_script, :download_file, :shixun_list, :batch_send_to_course] before_action :shixun_access_allowed, except: [:index, :new, :create, :menus, :get_recommend_shixuns, :propaedeutics, :departments, :apply_shixun_mirror, @@ -515,7 +515,7 @@ class ShixunsController < ApplicationController end # 添加第二仓库 if params[:is_secret_repository] - add_secret_repository + add_secret_repository if @shixun.shixun_secret_repository.blank? else # 如果有仓库,就要删 if @shixun.shixun_secret_repository&.repo_name @@ -990,6 +990,16 @@ class ShixunsController < ApplicationController CreateStudentWorkJob.perform_later(homework.id) end + # 批量发送 + def batch_send_to_course + @course = Course.find_by!(id: params[:course_id]) + shixuns = Shixun.where(id: params[:shixun_ids]).unhidden + shixuns.each do |shixun| + homework = HomeworksService.new.create_homework shixun, @course, nil, current_user + CreateStudentWorkJob.perform_later(homework.id) + end + end + # 二维码扫描下载 def download_file file_path = params[:file_name] diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index d38293a8f..096a0fe52 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -2,7 +2,7 @@ class SubjectsController < ApplicationController before_action :require_login, :check_auth, except: [:index, :show, :right_banner] # before_action :check_auth, except: [:index] before_action :check_account, except: [:index, :show, :right_banner] - before_action :find_subject, except: [:index, :create, :new, :append_to_stage] + before_action :find_subject, except: [:index, :create, :new, :append_to_stage, :add_shixun_to_stage] before_action :allowed, only: [:update, :edit, :destroy, :publish, :cancel_publish, :cancel_has_publish, :search_members, :add_subject_members, :statistics, :shixun_report, :school_report, :up_member_position, :down_member_position, :update_team_title] @@ -10,6 +10,7 @@ class SubjectsController < ApplicationController include ApplicationHelper include SubjectsHelper + include GitCommon def index @tech_system = current_laboratory.subject_repertoires @@ -212,6 +213,28 @@ class SubjectsController < ApplicationController @shixuns = Shixun.where(id: params[:shixun_id]).order("id desc") end + # 添加实训项目 + def add_shixun_to_stage + identifier = generate_identifier Shixun, 8 + ActiveRecord::Base.transaction do + @shixun = Shixun.create!(name: params[:name], user_id: current_user.id, identifier: identifier) + # 添加合作者 + @shixun.shixun_members.create!(user_id: current_user.id, role: 1) + # 创建长字段 + ShixunInfo.create!(shixun_id: @shixun.id, description: "请在此处添加实训描述") + # 创建版本库 + repo_path = repo_namespace(current_user.login, identifier) + GitService.add_repository(repo_path: repo_path) + # todo: 为什么保存的时候要去除后面的.git呢?? + @shixun.update_column(:repo_name, repo_path.split(".")[0]) + mirror_id = MirrorRepository.find_by(type_name: 'Python3.6')&.id + if mirror_id + ShixunMirrorRepository.create!(:shixun_id => @shixun.id, :mirror_repository_id => mirror_id) + @shixun.shixun_service_configs.create!(:shixun_id => @shixun.id, :mirror_repository_id => mirror_id) + end + end + end + def choose_course course_ids = Course.find_by_sql("SELECT c.id FROM courses c, course_members m WHERE m.course_id = c.id AND m.role in (1,2,3) diff --git a/app/controllers/tidings_controller.rb b/app/controllers/tidings_controller.rb index 9324b2755..5acffcb16 100644 --- a/app/controllers/tidings_controller.rb +++ b/app/controllers/tidings_controller.rb @@ -6,6 +6,7 @@ class TidingsController < ApplicationController def index tidings = current_user.tidings + @onclick_time = current_user.click_time tiding_types = case params[:type] @@ -18,11 +19,13 @@ class TidingsController < ApplicationController end tidings = tidings.where(tiding_type: tiding_types) if tiding_types.present? + tidings = tidings.where(container_type: 'JoinCourse') if params[:type] == 'course_apply' + @course_apply_count = tidings.where("created_at > '#{@onclick_time}'").where(container_type: 'JoinCourse').count + tidings = tidings.where(container_type: 'ProjectPackage') if params[:type] == 'project_package' @count = tidings.count @tidings = paginate(tidings.order(created_at: :desc), per_page: 10) - @onclick_time = current_user.click_time end private diff --git a/app/controllers/weapps/code_sessions_controller.rb b/app/controllers/weapps/code_sessions_controller.rb index 887e97eed..2dbd08e82 100644 --- a/app/controllers/weapps/code_sessions_controller.rb +++ b/app/controllers/weapps/code_sessions_controller.rb @@ -15,6 +15,8 @@ class Weapps::CodeSessionsController < Weapps::BaseController logged = true else # 根据 code没拿到 unionid + Rails.logger.info("[Weapp] session_key: #{result['session_key']}") + Rails.logger.info("[Weapp] code: #{params[:code]}") user_info = Wechat::Weapp.decrypt(result['session_key'], params[:encrypted_data], params[:iv]) # 老用户,已绑定 diff --git a/app/controllers/weapps/courses_controller.rb b/app/controllers/weapps/courses_controller.rb index f35b0591a..c2335998e 100644 --- a/app/controllers/weapps/courses_controller.rb +++ b/app/controllers/weapps/courses_controller.rb @@ -35,6 +35,9 @@ class Weapps::CoursesController < Weapps::BaseController # 教师列表 def teachers @course = current_course + @page = (params[:page] || 1).to_i + @limit = (params[:limit] || 20).to_i + search = params[:search].present? ? params[:search].strip : "" if @course.try(:id) != 1309 || current_user.admin? || current_user.try(:id) == 15582 @teacher_list = @course.course_members.joins(:user).where("course_members.role in (1, 2, 3)") else @@ -42,17 +45,26 @@ class Weapps::CoursesController < Weapps::BaseController and course_members.role = 2))") end + if search.present? + @teacher_list = @teacher_list.joins(:user).where("LOWER(CONCAT(users.lastname, users.firstname)) like ?", "%#{search}%") + end + @teacher_list_size = @teacher_list.size @applications_size = CourseMessage.unhandled_join_course_requests_by_course(@course).size - @teacher_list = @teacher_list.preload(user: [user_extension: :school]) + @teacher_list = @teacher_list.includes(user: [user_extension: :school]) + # 中英文混合排序(忽略大小写) + @teacher_list = @teacher_list.sort {|x, y| Pinyin.t(x.user&.real_name, splitter: '').upcase <=> Pinyin.t(y.user&.real_name, splitter: '').upcase} + @teacher_list = @teacher_list[(@page-1)*@limit ... @page*@limit] end # 批量删除教师或助教 def delete_course_teachers begin @course = current_course + @page = (params[:page] || 1).to_i + @limit = (params[:limit] || 20).to_i course_members = @course.course_members.where(id: params[:course_member_ids], role: %i[PROFESSOR ASSISTANT_PROFESSOR]) user_ids = course_members.pluck(:user_id) course_members.destroy_all @@ -67,10 +79,18 @@ class Weapps::CoursesController < Weapps::BaseController def students @course = current_course + @page = (params[:page] || 1).to_i + @limit = (params[:limit] || 20).to_i + search = params[:search].present? ? params[:search].strip : nil course_group_id = params[:course_group_id].present? ? params[:course_group_id].to_i : nil @students = CourseMember.students(@course) + if search.present? + @students = @students.joins(user: :user_extension).where("LOWER(CONCAT(users.lastname, users.firstname)) like ? or + user_extensions.student_id like ?", "%#{search}%", "%#{search}%") + end + if course_group_id.present? course_group = CourseGroup.find(course_group_id) if course_group_id != 0 @students = @students.where(course_group_id: course_group&.id.to_i) @@ -78,6 +98,9 @@ class Weapps::CoursesController < Weapps::BaseController @students_count = @students.size @students = @students.includes(user: :user_extension) + # 中英文混合排序(忽略大小写) + @students = @students.sort {|x, y| Pinyin.t(x.user&.real_name, splitter: '').upcase <=> Pinyin.t(y.user&.real_name, splitter: '').upcase} + @students = @students[(@page-1)*@limit ... @page*@limit] end # 批量修改角色 diff --git a/app/controllers/weapps/registers_controller.rb b/app/controllers/weapps/registers_controller.rb index 0cbab7fd4..de48ebd54 100644 --- a/app/controllers/weapps/registers_controller.rb +++ b/app/controllers/weapps/registers_controller.rb @@ -48,9 +48,10 @@ class Weapps::RegistersController < Weapps::BaseController ) end successful_authentication(@user) - session[:user_id] = @user.id + # session[:user_id] = @user.id + session[:"#{default_yun_session}"] = @user.id - render_ok + # render_ok(user_id: @user.id) end private diff --git a/app/helpers/polls_helper.rb b/app/helpers/polls_helper.rb index 866d28254..7ae4470e2 100644 --- a/app/helpers/polls_helper.rb +++ b/app/helpers/polls_helper.rb @@ -77,7 +77,7 @@ module PollsHelper ex_pb_time = poll.get_poll_times(user.id,false) poll_publish_time = ex_pb_time[:publish_time] poll_end_time = ex_pb_time[:end_time] - current_status = poll.check_user_votes_status(user) + current_status = poll.check_user_votes_status(user, poll_status) lock_icon = 0 #不显示锁图标 else poll_users_list = poll.get_poll_exercise_users diff --git a/app/helpers/weapps/courses_helper.rb b/app/helpers/weapps/courses_helper.rb index 94769fc2e..32de8f253 100644 --- a/app/helpers/weapps/courses_helper.rb +++ b/app/helpers/weapps/courses_helper.rb @@ -20,10 +20,10 @@ module Weapps::CoursesHelper end end end - data = data.sort do |a, b| - [a[:letter]] <=> [b[:letter]] - end - data.push(data.shift) if data.select{|a|a[:letter]=='#'}.first.present? # '#'排在最后 + # data = data.sort do |a, b| + # [a[:letter]] <=> [b[:letter]] + # end + # data.push(data.shift) if data.select{|a|a[:letter]=='#'}.first.present? # '#'排在最后 return data end @@ -47,10 +47,10 @@ module Weapps::CoursesHelper end end end - data = data.sort do |a, b| - [a[:letter]] <=> [b[:letter]] - end - data.push(data.shift) if data.select{|a|a[:letter]=='#'}.first.present? # '#'排在最后 + # data = data.sort do |a, b| + # [a[:letter]] <=> [b[:letter]] + # end + # data.push(data.shift) if data.select{|a|a[:letter]=='#'}.first.present? # '#'排在最后 return data end diff --git a/app/libs/wechat/weapp.rb b/app/libs/wechat/weapp.rb index 9684206cd..ca356b28d 100644 --- a/app/libs/wechat/weapp.rb +++ b/app/libs/wechat/weapp.rb @@ -31,7 +31,9 @@ class Wechat::Weapp cipher.padding = 0 cipher.key = session_key cipher.iv = iv + Rails.logger.info("[Weapp] encrypted_data: #{encrypted_data}") data = cipher.update(encrypted_data) << cipher.final + Rails.logger.info("[Weapp] data: #{data}") result = JSON.parse(data[0...-data.last.ord]) raise Wechat::Error.new(-1, '解密错误') if result.dig('watermark', 'appid') != appid diff --git a/app/models/hack.rb b/app/models/hack.rb index 814debef5..80724d3d4 100644 --- a/app/models/hack.rb +++ b/app/models/hack.rb @@ -26,9 +26,11 @@ class Hack < ApplicationRecord def code if hack_codes.count == 1 - tran_base64_decode64(hack_codes.first.code) + #tran_base64_decode64(hack_codes.first.code) + hack_codes.first.code else - tran_base64_decode64(hack_codes.pluck(:code)) + #tran_base64_decode64(hack_codes.pluck(:code)) + hack_codes.pluck(:code) end end diff --git a/app/models/hack_set.rb b/app/models/hack_set.rb index 669fa10b1..5dab862b5 100644 --- a/app/models/hack_set.rb +++ b/app/models/hack_set.rb @@ -1,6 +1,6 @@ class HackSet < ApplicationRecord validates :input, presence: { message: "测试集输入不能为空" } - validates :output, uniqueness: { message: "测试集输出不能为空" } + validates :output, presence: { message: "测试集输出不能为空" } # 编程题测试集 belongs_to :hack end diff --git a/app/models/poll.rb b/app/models/poll.rb index 9cb860f61..5c1a9a64c 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -128,7 +128,7 @@ class Poll < ApplicationRecord en_time = end_time else poll_group_setting = poll_group_settings - user_group = course.course_members.where(user_id: user_id).select(:course_group_id) + user_group = course.students.where(user_id: user_id).select(:course_group_id) if user_group.exists? user_group_id = user_group.first&.course_group_id user_p_group_setting = poll_group_setting.where(course_group_id: user_group_id).select(:publish_time,:end_time) @@ -146,12 +146,22 @@ class Poll < ApplicationRecord end #判断当前用户的答题状态 - def check_user_votes_status(user) + def check_user_votes_status(user, poll_status) poll_answer_user = poll_users.where(user_id: user.id).select(:start_at,:end_at,:commit_status) user_status = 2 if poll_answer_user.exists? && (poll_answer_user.first&.start_at.present? || poll_answer_user.first&.end_at.present?) #学生有过答题的,或者立即截止,但学生未做试卷的 user_status = poll_answer_user.first.commit_status end + # 问卷已截止时学生的答题状态需要考虑问卷的状态 + if poll_status > 2 + # 问卷如果还是继续答题状态则自动提交 + if user_status == 0 + poll_end_time = get_poll_times(user.id,false)[:end_time] + poll_answer_user.first.update_attributes!(:commit_status => 1, :end_at => poll_end_time) + user_status = 1 + end + user_status = user_status == 1 ? 1 : 4 + end user_status end diff --git a/app/models/shixun_tag_repertoire.rb b/app/models/shixun_tag_repertoire.rb index 6cb311f7a..afd956350 100644 --- a/app/models/shixun_tag_repertoire.rb +++ b/app/models/shixun_tag_repertoire.rb @@ -3,5 +3,5 @@ class ShixunTagRepertoire < ApplicationRecord belongs_to :tag_repertoire has_many :memos, :through => :memo_tag_repertoires - has_many :memo_tag_repertoires, :dependent => :destroy + # has_many :memo_tag_repertoires, :dependent => :destroy end diff --git a/app/models/user.rb b/app/models/user.rb index ec0640700..27c9e03ae 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -329,7 +329,7 @@ class User < ApplicationRecord # 实训路径:合作者、admin def manager_of_subject?(subject) - subject.subject_members.exists?(user_id: id, role: [1,2]) || admin? + subject.subject_members.exists?(user_id: id, role: [1,2]) || admin? || business? end # 实训管理员:实训合作者、admin diff --git a/app/queries/admins/school_query.rb b/app/queries/admins/school_query.rb index 7361588c4..888cded97 100644 --- a/app/queries/admins/school_query.rb +++ b/app/queries/admins/school_query.rb @@ -13,11 +13,10 @@ class Admins::SchoolQuery < ApplicationQuery schools = School.all keyword = strip_param(:keyword) - schools = schools.where('schools.name LIKE ?', "%#{keyword}%") if keyword - - schools = schools.joins(:user_extensions).group(:id) - schools = schools.select('schools.*, COUNT(*) AS users_count') - + Rails.logger.info("###########{keyword}") + if keyword + schools = schools.where('schools.name LIKE ?', "%#{keyword}%") + end custom_sort schools, params[:sort_by], params[:sort_direction] end end \ No newline at end of file diff --git a/app/views/admins/competition_prize_users/index.xlsx.axlsx b/app/views/admins/competition_prize_users/index.xlsx.axlsx index 63e23a214..0284484dc 100644 --- a/app/views/admins/competition_prize_users/index.xlsx.axlsx +++ b/app/views/admins/competition_prize_users/index.xlsx.axlsx @@ -3,7 +3,7 @@ wb = xlsx_package.workbook wb.styles do |s| blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 25,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center} wb.add_worksheet(name: "#{@competition.name}证书审批列表") do |sheet| - sheet.add_row %w(序号 排名 奖项 战队ID 战队名称 姓名 职业 学号 学校名称 学院名称 地区 实名认证 职业认证 手机号码 队长 签领/开户行及银行卡号 审批时间 审批人), :height => 25,:style => blue_cell + sheet.add_row %w(序号 排名 奖项 战队ID 战队名称 姓名 性别 职业 学号 学校名称 学院名称 地区 实名认证 职业认证 手机号码 队长 身份证号 签领/开户行及银行卡号 审批时间 审批人), :height => 25,:style => blue_cell @all_prize_users.each_with_index do |prize_user, index| user = prize_user.user @@ -14,15 +14,17 @@ wb.styles do |s| prize_user.competition_team_id, prize_user.competition_team.name, user.real_name, + user.gender == 1 ? "女" : "男", user.identity, - user.student_id, + user.student_id.present? ? (user.student_id.to_s + "\t") : "--", user.school_name, user.department_name, user.location, user.auth_status, user.pro_status, - user.phone, + user.phone.present? ? (user.phone.to_s + "\t") : "--", prize_user.leader? ? "是" : "-", + user.ID_number.present? ? (user.ID_number.to_s + "\t") : "--", [prize_user.extra&.[]('bank'), prize_user.extra&.[]('second_bank'), prize_user.extra&.[]('card_no')].compact.join('/'), prize_user.approved_at&.strftime('%Y-%m-%d %H:%M'), prize_user.approver&.real_name diff --git a/app/views/admins/schools/shared/_list.html.erb b/app/views/admins/schools/shared/_list.html.erb index b1453f1a1..ec7475028 100644 --- a/app/views/admins/schools/shared/_list.html.erb +++ b/app/views/admins/schools/shared/_list.html.erb @@ -31,7 +31,7 @@ <%= school.province %> <%= school.city %> <%= school.address %> - <%= school.users_count %> + <%= school.user_extensions.count %> <%= @department_count.fetch(school.id, 0) %> <%= school.created_at&.strftime('%Y-%m-%d %H:%M') %> diff --git a/app/views/admins/shared/_sidebar.html.erb b/app/views/admins/shared/_sidebar.html.erb index f78b52ac7..7b1f5db7a 100644 --- a/app/views/admins/shared/_sidebar.html.erb +++ b/app/views/admins/shared/_sidebar.html.erb @@ -65,6 +65,12 @@ <% end %> +
  • + <%= sidebar_item_group('#comments-submenu', '消息', icon: 'comments') do %> +
  • <%= sidebar_item(admins_shixun_feedback_messages_path, '实训反馈', icon: 'comment', controller: 'admins-shixun_feedback_messages') %>
  • + <% end %> + +
  • <%= sidebar_item_group('#major-identification-submenu', '工程认证', icon: 'anchor') do %>
  • <%= sidebar_item(admins_major_informations_path, '本科专业目录', icon: 'outdent', controller: 'admins-major_informations') %>
  • diff --git a/app/views/admins/shixun_feedback_messages/index.html.erb b/app/views/admins/shixun_feedback_messages/index.html.erb new file mode 100644 index 000000000..210d3bfb6 --- /dev/null +++ b/app/views/admins/shixun_feedback_messages/index.html.erb @@ -0,0 +1,23 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('实训反馈', admins_shixun_feedback_messages_path) %> +<% end %> + +
    + <%= form_tag(admins_shixun_feedback_messages_path, method: :get, class: 'form-inline search-form', remote: true) do %> + <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-md-4 ml-3', placeholder: '输入实训名称关键字进行搜索') %> +
    +
    +
    + <%= text_field_tag :begin_date, params[:begin_date], class: 'form-control start-date mx-0', placeholder: '开始时间' %> +
    + <%= text_field_tag :end_date, params[:end_date], class: 'form-control end-date mx-0', placeholder: '结束时间' %> +
    +
    +
    + <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + <% end %> +
    + +
    + <%= render(partial: 'admins/shixun_feedback_messages/shared/list', locals: {discusses: @discusses}) %> +
    \ No newline at end of file diff --git a/app/views/admins/shixun_feedback_messages/index.js.erb b/app/views/admins/shixun_feedback_messages/index.js.erb new file mode 100644 index 000000000..6eab9be54 --- /dev/null +++ b/app/views/admins/shixun_feedback_messages/index.js.erb @@ -0,0 +1,2 @@ +$(".shixun_feedback_messages-list-container") + .html("<%= j render partial: "admins/shixun_feedback_messages/shared/list", locals: {discusses: @discusses} %>") \ No newline at end of file diff --git a/app/views/admins/shixun_feedback_messages/shared/_list.html.erb b/app/views/admins/shixun_feedback_messages/shared/_list.html.erb new file mode 100644 index 000000000..af81f9e58 --- /dev/null +++ b/app/views/admins/shixun_feedback_messages/shared/_list.html.erb @@ -0,0 +1,29 @@ + + + + + + + + + + + + <% if discusses.present? %> + <% discusses.each_with_index do |discuss, index| %> + + + <% identifier = Game.find_by(challenge_id: discuss.challenge_id, user_id: discuss.user_id)&.identifier %> + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
    序号实训名称评论内容评论者评论时间
    <%= (@params_page.to_i - 1) * 20 + index + 1 %><%= link_to discuss.dis.name, "/tasks/#{identifier}", target: '_blank'%><%= content_safe discuss.content %><%= discuss.user.show_real_name %><%= format_time discuss.created_at %>
    + +<%= render partial: 'admins/shared/paginate', locals: { objects: discusses } %> \ No newline at end of file diff --git a/app/views/hack_user_lastest_codes/record_detail.json.jbuilder b/app/views/hack_user_lastest_codes/record_detail.json.jbuilder index 247dced91..c3a111ab7 100644 --- a/app/views/hack_user_lastest_codes/record_detail.json.jbuilder +++ b/app/views/hack_user_lastest_codes/record_detail.json.jbuilder @@ -1,2 +1,3 @@ json.(@hack_user, :id, :status, :error_line, :error_msg, :expected_output, - :input, :output, :execute_time, :execute_memory) \ No newline at end of file + :input, :output, :execute_time, :execute_memory) +json.language @hack_user.hack.language \ No newline at end of file diff --git a/app/views/hack_user_lastest_codes/restore_initial_code.json.jbuilder b/app/views/hack_user_lastest_codes/restore_initial_code.json.jbuilder new file mode 100644 index 000000000..3b272f298 --- /dev/null +++ b/app/views/hack_user_lastest_codes/restore_initial_code.json.jbuilder @@ -0,0 +1 @@ +json.code @hack.code \ No newline at end of file diff --git a/app/views/hack_user_lastest_codes/result.json.jbuilder b/app/views/hack_user_lastest_codes/result.json.jbuilder index 31164d4f7..2561d4ecd 100644 --- a/app/views/hack_user_lastest_codes/result.json.jbuilder +++ b/app/views/hack_user_lastest_codes/result.json.jbuilder @@ -1,7 +1,12 @@ -json.(@result, :id, :status, :error_line, :error_msg, - :input, :output, :execute_time, :execute_memory) +json.status 0 +json.message "评测成功" +json.data do + json.(@result, :id, :status, :error_line, :error_msg, + :input, :output, :execute_time, :execute_memory) # 提交模式多了一个预计输出 -if @mode == "submit" - json.expected_output @result.expected_output + if @mode == "submit" + json.expected_output @result.expected_output + end end + diff --git a/app/views/hack_user_lastest_codes/submit_records.json.jbuilder b/app/views/hack_user_lastest_codes/submit_records.json.jbuilder index 9aa505160..a5905b16d 100644 --- a/app/views/hack_user_lastest_codes/submit_records.json.jbuilder +++ b/app/views/hack_user_lastest_codes/submit_records.json.jbuilder @@ -1,3 +1,4 @@ json.array! @my_hack.hack_user_codes do |hack_user| json.(hack_user, :id, :created_at, :status, :execute_time, :execute_memory) + json.language hack_user.hack.language end \ No newline at end of file diff --git a/app/views/hacks/edit.json.jbuilder b/app/views/hacks/edit.json.jbuilder index 95124666f..24d51385b 100644 --- a/app/views/hacks/edit.json.jbuilder +++ b/app/views/hacks/edit.json.jbuilder @@ -1,5 +1,5 @@ # 编程内容 -json.(@hack, :name, :description, :language, :code) +json.(@hack, :name, :description, :language, :difficult, :category, :time_limit, :open_or_not) # 代码 json.language @hack.language diff --git a/app/views/home/index.json.jbuilder b/app/views/home/index.json.jbuilder index 8edbcb339..de219052f 100644 --- a/app/views/home/index.json.jbuilder +++ b/app/views/home/index.json.jbuilder @@ -10,12 +10,12 @@ json.subjects do json.partial! 'subjects/subject', locals: {subjects: @subjects} end -if current_laboratory.main_site? - json.teachers do - json.partial! 'users/user_small', users: @tea_users - end - - json.students do - json.partial! 'users/user_small', users: @stu_users - end -end +# if current_laboratory.main_site? +# json.teachers do +# json.partial! 'users/user_small', users: @tea_users +# end +# +# json.students do +# json.partial! 'users/user_small', users: @stu_users +# end +# end diff --git a/app/views/shixuns/batch_send_to_course.json.jbuilder b/app/views/shixuns/batch_send_to_course.json.jbuilder new file mode 100644 index 000000000..bd9002842 --- /dev/null +++ b/app/views/shixuns/batch_send_to_course.json.jbuilder @@ -0,0 +1,4 @@ +json.status 1 +json.message "发送成功" +json.course_id @course.id +json.first_category_url module_url(@course.none_hidden_course_modules.first, @course) \ No newline at end of file diff --git a/app/views/subjects/add_shixun_to_stage.json.jbuilder b/app/views/subjects/add_shixun_to_stage.json.jbuilder new file mode 100644 index 000000000..45b584231 --- /dev/null +++ b/app/views/subjects/add_shixun_to_stage.json.jbuilder @@ -0,0 +1,3 @@ +json.shixun_identifier @shixun.identifier +json.shixun_name @shixun.name +json.shixun_id @shixun.id \ No newline at end of file diff --git a/app/views/tidings/index.json.jbuilder b/app/views/tidings/index.json.jbuilder index 69f932f8f..26c31d98b 100644 --- a/app/views/tidings/index.json.jbuilder +++ b/app/views/tidings/index.json.jbuilder @@ -1,2 +1,3 @@ json.count @count json.tidings @tidings, partial: 'tidings/tiding', as: :tiding +json.course_apply_count @course_apply_count diff --git a/app/views/weapps/registers/create.json.jbuilder b/app/views/weapps/registers/create.json.jbuilder new file mode 100644 index 000000000..0cfb5e30f --- /dev/null +++ b/app/views/weapps/registers/create.json.jbuilder @@ -0,0 +1,4 @@ +json.status 0 +json.user do + json.partial! 'weapps/shared/user', locals: { user: @user } +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 86bac4533..aa4aad8ec 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -42,7 +42,6 @@ Rails.application.routes.draw do member do post :publish get :start - get :result post :update_set delete :delete_set end @@ -57,8 +56,16 @@ Rails.application.routes.draw do get :code_debug get :code_submit match :listen_result, :via => [:get, :post] + get :result + get :submit_records + post :restore_initial_code + end + + collection do + get :record_detail end + end @@ -217,6 +224,7 @@ Rails.application.routes.draw do post :apply_shixun_mirror get :download_file get :shixun_lists + post :batch_send_to_course end member do @@ -325,6 +333,7 @@ Rails.application.routes.draw do get 'create_subject' get 'new_subject' post 'append_to_stage' + post :add_shixun_to_stage get 'search' end end @@ -1039,6 +1048,7 @@ Rails.application.routes.draw do end resources :shixuns, only: [:index,:destroy] resources :shixun_settings, only: [:index,:update] + resources :shixun_feedback_messages, only: [:index] resources :department_applies,only: [:index,:destroy] do collection do post :merge diff --git a/public/editormd/plugins/code-block-dialog/code-block-dialog.js b/public/editormd/plugins/code-block-dialog/code-block-dialog.js index 0e89e37f4..09078f146 100644 --- a/public/editormd/plugins/code-block-dialog/code-block-dialog.js +++ b/public/editormd/plugins/code-block-dialog/code-block-dialog.js @@ -1,237 +1,238 @@ -/*! - * Code block dialog plugin for Editor.md - * - * @file code-block-dialog.js - * @author pandao - * @version 1.2.0 - * @updateTime 2015-03-07 - * {@link https://github.com/pandao/editor.md} - * @license MIT - */ - -(function() { - - var factory = function (exports) { - var cmEditor; - var pluginName = "code-block-dialog"; - - // for CodeBlock dialog select - var codeLanguages = exports.codeLanguages = { - asp : ["ASP", "vbscript"], - actionscript : ["ActionScript(3.0)/Flash/Flex", "clike"], - bash : ["Bash/Bat", "shell"], - css : ["CSS", "css"], - c : ["C", "clike"], - cpp : ["C++", "clike"], - csharp : ["C#", "clike"], - coffeescript : ["CoffeeScript", "coffeescript"], - d : ["D", "d"], - dart : ["Dart", "dart"], - delphi : ["Delphi/Pascal", "pascal"], - erlang : ["Erlang", "erlang"], - go : ["Golang", "go"], - groovy : ["Groovy", "groovy"], - html : ["HTML", "text/html"], - java : ["Java", "clike"], - json : ["JSON", "text/json"], - javascript : ["Javascript", "javascript"], - lua : ["Lua", "lua"], - less : ["LESS", "css"], - markdown : ["Markdown", "gfm"], - "objective-c" : ["Objective-C", "clike"], - php : ["PHP", "php"], - perl : ["Perl", "perl"], - python : ["Python", "python"], - r : ["R", "r"], - rst : ["reStructedText", "rst"], - ruby : ["Ruby", "ruby"], - sql : ["SQL", "sql"], - sass : ["SASS/SCSS", "sass"], - shell : ["Shell", "shell"], - scala : ["Scala", "clike"], - swift : ["Swift", "clike"], - vb : ["VB/VBScript", "vb"], - xml : ["XML", "text/xml"], - yaml : ["YAML", "yaml"] - }; - - exports.fn.codeBlockDialog = function() { - - var _this = this; - var cm = this.cm; - var lang = this.lang; - var editor = this.editor; - var settings = this.settings; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - var classPrefix = this.classPrefix; - var dialogName = classPrefix + pluginName, dialog; - var dialogLang = lang.dialog.codeBlock; - - cm.focus(); - - if (editor.find("." + dialogName).length > 0) - { - dialog = editor.find("." + dialogName); - dialog.find("option:first").attr("selected", "selected"); - dialog.find("textarea").val(selection); - - this.dialogShowMask(dialog); - this.dialogLockScreen(); - dialog.show(); - } - else - { - var dialogHTML = "
    " + - dialogLang.selectLabel + "" + - "
    " + - ""; - - dialog = this.createDialog({ - name : dialogName, - title : dialogLang.title, - width : 780, - height : 565, - mask : settings.dialogShowMask, - drag : settings.dialogDraggable, - content : dialogHTML, - lockScreen : settings.dialogLockScreen, - maskStyle : { - opacity : settings.dialogMaskOpacity, - backgroundColor : settings.dialogMaskBgColor - }, - buttons : { - enter : [lang.buttons.enter, function() { - var codeTexts = this.find("textarea").val(); - var langName = this.find("select").val(); - - if (langName === "") - { - alert(lang.dialog.codeBlock.unselectedLanguageAlert); - return false; - } - - if (codeTexts === "") - { - alert(lang.dialog.codeBlock.codeEmptyAlert); - return false; - } - - langName = (langName === "other") ? "" : langName; - - cm.replaceSelection(["```" + langName, codeTexts, "```"].join("\n")); - - if (langName === "") { - cm.setCursor(cursor.line, cursor.ch + 3); - } - - this.hide().lockScreen(false).hideMask(); - - return false; - }], - cancel : [lang.buttons.cancel, function() { - this.hide().lockScreen(false).hideMask(); - - return false; - }] - } - }); - } - - var langSelect = dialog.find("select"); - - if (langSelect.find("option").length === 1) - { - for (var key in codeLanguages) - { - var codeLang = codeLanguages[key]; - langSelect.append(""); - } - - langSelect.append(""); - } - - var mode = langSelect.find("option:selected").attr("mode"); - - var cmConfig = { - mode : (mode) ? mode : "text/html", - theme : settings.theme, - tabSize : 4, - autofocus : true, - autoCloseTags : true, - indentUnit : 4, - lineNumbers : true, - lineWrapping : true, - extraKeys : {"Ctrl-Q": function(cm){ cm.foldCode(cm.getCursor()); }}, - foldGutter : true, - gutters : ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], - matchBrackets : true, - indentWithTabs : true, - styleActiveLine : true, - styleSelectedText : true, - autoCloseBrackets : true, - showTrailingSpace : true, - highlightSelectionMatches : true - }; - - var textarea = dialog.find("textarea"); - var cmObj = dialog.find(".CodeMirror"); - - if (dialog.find(".CodeMirror").length < 1) - { - cmEditor = exports.$CodeMirror.fromTextArea(textarea[0], cmConfig); - cmObj = dialog.find(".CodeMirror"); - - cmObj.css({ - "float" : "none", - margin : "8px 0", - border : "1px solid #ddd", - fontSize : settings.fontSize, - width : "100%", - height : "390px" - }); - - cmEditor.on("change", function(cm) { - textarea.val(cm.getValue()); - }); - } - else - { - - cmEditor.setValue(cm.getSelection()); - } - - langSelect.change(function(){ - var _mode = $(this).find("option:selected").attr("mode"); - cmEditor.setOption("mode", _mode); - }); - }; - - }; - - // CommonJS/Node.js - if (typeof require === "function" && typeof exports === "object" && typeof module === "object") - { - module.exports = factory; - } - else if (typeof define === "function") // AMD/CMD/Sea.js - { - if (define.amd) { // for Require.js - - define(["editormd"], function(editormd) { - factory(editormd); - }); - - } else { // for Sea.js - define(function(require) { - var editormd = require("./../../editormd"); - factory(editormd); - }); - } - } - else - { - factory(window.editormd); - } - -})(); +/*! + * Code block dialog plugin for Editor.md + * + * @file code-block-dialog.js + * @author pandao + * @version 1.2.0 + * @updateTime 2015-03-07 + * {@link https://github.com/pandao/editor.md} + * @license MIT + */ + +(function() { + + var factory = function (exports) { + var cmEditor; + var pluginName = "code-block-dialog"; + + // for CodeBlock dialog select + var codeLanguages = exports.codeLanguages = { + asp : ["ASP", "vbscript"], + actionscript : ["ActionScript(3.0)/Flash/Flex", "clike"], + bash : ["Bash/Bat", "shell"], + css : ["CSS", "css"], + c : ["C", "clike"], + cpp : ["C++", "clike"], + csharp : ["C#", "clike"], + coffeescript : ["CoffeeScript", "coffeescript"], + d : ["D", "d"], + dart : ["Dart", "dart"], + delphi : ["Delphi/Pascal", "pascal"], + erlang : ["Erlang", "erlang"], + go : ["Golang", "go"], + groovy : ["Groovy", "groovy"], + html : ["HTML", "text/html"], + java : ["Java", "clike"], + json : ["JSON", "text/json"], + javascript : ["Javascript", "javascript"], + lua : ["Lua", "lua"], + less : ["LESS", "css"], + markdown : ["Markdown", "gfm"], + "objective-c" : ["Objective-C", "clike"], + php : ["PHP", "php"], + perl : ["Perl", "perl"], + python : ["Python", "python"], + r : ["R", "r"], + rst : ["reStructedText", "rst"], + ruby : ["Ruby", "ruby"], + sql : ["SQL", "sql"], + sass : ["SASS/SCSS", "sass"], + shell : ["Shell", "shell"], + scala : ["Scala", "clike"], + swift : ["Swift", "clike"], + vb : ["VB/VBScript", "vb"], + xml : ["XML", "text/xml"], + yaml : ["YAML", "yaml"] + }; + + exports.fn.codeBlockDialog = function() { + + var _this = this; + var cm = this.cm; + var lang = this.lang; + var editor = this.editor; + var settings = this.settings; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + var classPrefix = this.classPrefix; + var dialogName = classPrefix + pluginName, dialog; + var dialogLang = lang.dialog.codeBlock; + + cm.focus(); + + if (editor.find("." + dialogName).length > 0) + { + dialog = editor.find("." + dialogName); + dialog.find("option:first").attr("selected", "selected"); + dialog.find("textarea").val(selection); + + this.dialogShowMask(dialog); + this.dialogLockScreen(); + dialog.show(); + } + else + { + var dialogHTML = "
    " + + dialogLang.selectLabel + "" + + "
    " + + ""; + + dialog = this.createDialog({ + name : dialogName, + title : dialogLang.title, + width : 780, + height : 565, + mask : settings.dialogShowMask, + drag : settings.dialogDraggable, + content : dialogHTML, + lockScreen : settings.dialogLockScreen, + maskStyle : { + opacity : settings.dialogMaskOpacity, + backgroundColor : settings.dialogMaskBgColor + }, + buttons : { + enter : [lang.buttons.enter, function() { + var codeTexts = this.find("textarea").val(); + var langName = this.find("select").val(); + + if (langName === "") + { + alert(lang.dialog.codeBlock.unselectedLanguageAlert); + return false; + } + + if (codeTexts === "") + { + alert(lang.dialog.codeBlock.codeEmptyAlert); + return false; + } + + langName = (langName === "other") ? "" : langName; + + cm.replaceSelection(["```" + langName, codeTexts, "```"].join("\n")); + + if (langName === "") { + cm.setCursor(cursor.line, cursor.ch + 3); + } + + this.hide().lockScreen(false).hideMask(); + + cm.focus && cm.focus(); + return false; + }], + cancel : [lang.buttons.cancel, function() { + this.hide().lockScreen(false).hideMask(); + cm.focus && cm.focus(); + return false; + }] + } + }); + } + + var langSelect = dialog.find("select"); + + if (langSelect.find("option").length === 1) + { + for (var key in codeLanguages) + { + var codeLang = codeLanguages[key]; + langSelect.append(""); + } + + langSelect.append(""); + } + + var mode = langSelect.find("option:selected").attr("mode"); + + var cmConfig = { + mode : (mode) ? mode : "text/html", + theme : settings.theme, + tabSize : 4, + autofocus : true, + autoCloseTags : true, + indentUnit : 4, + lineNumbers : true, + lineWrapping : true, + extraKeys : {"Ctrl-Q": function(cm){ cm.foldCode(cm.getCursor()); }}, + foldGutter : true, + gutters : ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], + matchBrackets : true, + indentWithTabs : true, + styleActiveLine : true, + styleSelectedText : true, + autoCloseBrackets : true, + showTrailingSpace : true, + highlightSelectionMatches : true + }; + + var textarea = dialog.find("textarea"); + var cmObj = dialog.find(".CodeMirror"); + + if (dialog.find(".CodeMirror").length < 1) + { + cmEditor = exports.$CodeMirror.fromTextArea(textarea[0], cmConfig); + cmObj = dialog.find(".CodeMirror"); + + cmObj.css({ + "float" : "none", + margin : "8px 0", + border : "1px solid #ddd", + fontSize : settings.fontSize, + width : "100%", + height : "390px" + }); + + cmEditor.on("change", function(cm) { + textarea.val(cm.getValue()); + }); + } + else + { + + cmEditor.setValue(cm.getSelection()); + } + + langSelect.change(function(){ + var _mode = $(this).find("option:selected").attr("mode"); + cmEditor.setOption("mode", _mode); + }); + }; + + }; + + // CommonJS/Node.js + if (typeof require === "function" && typeof exports === "object" && typeof module === "object") + { + module.exports = factory; + } + else if (typeof define === "function") // AMD/CMD/Sea.js + { + if (define.amd) { // for Require.js + + define(["editormd"], function(editormd) { + factory(editormd); + }); + + } else { // for Sea.js + define(function(require) { + var editormd = require("./../../editormd"); + factory(editormd); + }); + } + } + else + { + factory(window.editormd); + } + +})(); diff --git a/public/editormd/plugins/emoji-dialog/emoji-dialog.js b/public/editormd/plugins/emoji-dialog/emoji-dialog.js index c85bcbb74..e1d4b9c4f 100644 --- a/public/editormd/plugins/emoji-dialog/emoji-dialog.js +++ b/public/editormd/plugins/emoji-dialog/emoji-dialog.js @@ -1,327 +1,329 @@ -/*! - * Emoji dialog plugin for Editor.md - * - * @file emoji-dialog.js - * @author pandao - * @version 1.2.0 - * @updateTime 2015-03-08 - * {@link https://github.com/pandao/editor.md} - * @license MIT - */ - -(function() { - - var factory = function (exports) { - - var $ = jQuery; - var pluginName = "emoji-dialog"; - var emojiTabIndex = 0; - var emojiData = []; - var selecteds = []; - - var logoPrefix = "editormd-logo"; - var logos = [ - logoPrefix, - logoPrefix + "-1x", - logoPrefix + "-2x", - logoPrefix + "-3x", - logoPrefix + "-4x", - logoPrefix + "-5x", - logoPrefix + "-6x", - logoPrefix + "-7x", - logoPrefix + "-8x" - ]; - - var langs = { - "zh-cn" : { - toolbar : { - emoji : "Emoji 表情" - }, - dialog : { - emoji : { - title : "Emoji 表情" - } - } - }, - "zh-tw" : { - toolbar : { - emoji : "Emoji 表情" - }, - dialog : { - emoji : { - title : "Emoji 表情" - } - } - }, - "en" : { - toolbar : { - emoji : "Emoji" - }, - dialog : { - emoji : { - title : "Emoji" - } - } - } - }; - - exports.fn.emojiDialog = function() { - var _this = this; - var cm = this.cm; - var settings = _this.settings; - - if (!settings.emoji) - { - alert("settings.emoji == false"); - return ; - } - - var path = settings.pluginPath + pluginName + "/"; - var editor = this.editor; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - var classPrefix = this.classPrefix; - - $.extend(true, this.lang, langs[this.lang.name]); - this.setToolbar(); - - var lang = this.lang; - var dialogName = classPrefix + pluginName, dialog; - var dialogLang = lang.dialog.emoji; - - var dialogContent = [ - "
    ", - "
    ", - "
    ", - ].join("\n"); - - cm.focus(); - - if (editor.find("." + dialogName).length > 0) - { - dialog = editor.find("." + dialogName); - - selecteds = []; - dialog.find("a").removeClass("selected"); - - this.dialogShowMask(dialog); - this.dialogLockScreen(); - dialog.show(); - } - else - { - dialog = this.createDialog({ - name : dialogName, - title : dialogLang.title, - width : 800, - height : 475, - mask : settings.dialogShowMask, - drag : settings.dialogDraggable, - content : dialogContent, - lockScreen : settings.dialogLockScreen, - maskStyle : { - opacity : settings.dialogMaskOpacity, - backgroundColor : settings.dialogMaskBgColor - }, - buttons : { - enter : [lang.buttons.enter, function() { - cm.replaceSelection(selecteds.join(" ")); - this.hide().lockScreen(false).hideMask(); - - return false; - }], - cancel : [lang.buttons.cancel, function() { - this.hide().lockScreen(false).hideMask(); - - return false; - }] - } - }); - } - - var category = ["Github emoji", "Twemoji", "Font awesome", "Editor.md logo"]; - var tab = dialog.find("." + classPrefix + "tab"); - - if (tab.html() === "") - { - var head = ""; - - tab.append(head); - - var container = "
    "; - - for (var x = 0; x < 4; x++) - { - var display = (x === 0) ? "" : "display:none;"; - container += "
    "; - } - - container += "
    "; - - tab.append(container); - } - - var tabBoxs = tab.find("." + classPrefix + "tab-box"); - var emojiCategories = ["github-emoji", "twemoji", "font-awesome", logoPrefix]; - - var drawTable = function() { - var cname = emojiCategories[emojiTabIndex]; - var $data = emojiData[cname]; - var $tab = tabBoxs.eq(emojiTabIndex); - - if ($tab.html() !== "") { - //console.log("break =>", cname); - return ; - } - - var pagination = function(data, type) { - var rowNumber = (type === "editormd-logo") ? "5" : 20; - var pageTotal = Math.ceil(data.length / rowNumber); - var table = "
    "; - - for (var i = 0; i < pageTotal; i++) - { - var row = "
    "; - - for (var x = 0; x < rowNumber; x++) - { - var emoji = $.trim(data[(i * rowNumber) + x]); - - if (typeof emoji !== "undefined" && emoji !== "") - { - var img = "", icon = ""; - - if (type === "github-emoji") - { - var src = (emoji === "+1") ? "plus1" : emoji; - src = (src === "black_large_square") ? "black_square" : src; - src = (src === "moon") ? "waxing_gibbous_moon" : src; - - src = exports.emoji.path + src + exports.emoji.ext; - img = "\":""; - row += "" + img + ""; - } - else if (type === "twemoji") - { - var twemojiSrc = exports.twemoji.path + emoji + exports.twemoji.ext; - img = "\"twemoji-""; - row += "" + img + ""; - } - else if (type === "font-awesome") - { - icon = ""; - row += "" + icon + ""; - } - else if (type === "editormd-logo") - { - icon = ""; - row += "" + icon + ""; - } - } - else - { - row += ""; - } - } - - row += "
    "; - - table += row; - } - - table += "
    "; - - return table; - }; - - if (emojiTabIndex === 0) - { - for (var i = 0, len = $data.length; i < len; i++) - { - var h4Style = (i === 0) ? " style=\"margin: 0 0 10px;\"" : " style=\"margin: 10px 0;\""; - $tab.append("" + $data[i].category + ""); - $tab.append(pagination($data[i].list, cname)); - } - } - else - { - $tab.append(pagination($data, cname)); - } - - $tab.find("." + classPrefix + "emoji-btn").bind(exports.mouseOrTouch("click", "touchend"), function() { - $(this).toggleClass("selected"); - - if ($(this).hasClass("selected")) - { - selecteds.push($(this).attr("value")); - } - }); - }; - - if (emojiData.length < 1) - { - if (typeof dialog.loading === "function") { - dialog.loading(true); - } - - $.getJSON(path + "emoji.json?temp=" + Math.random(), function(json) { - - if (typeof dialog.loading === "function") { - dialog.loading(false); - } - - emojiData = json; - emojiData[logoPrefix] = logos; - drawTable(); - }); - } - else - { - drawTable(); - } - - tab.find("li").bind(exports.mouseOrTouch("click", "touchend"), function() { - var $this = $(this); - emojiTabIndex = $this.index(); - - $this.addClass("active").siblings().removeClass("active"); - tabBoxs.eq(emojiTabIndex).show().siblings().hide(); - drawTable(); - }); - }; - - }; - - // CommonJS/Node.js - if (typeof require === "function" && typeof exports === "object" && typeof module === "object") - { - module.exports = factory; - } - else if (typeof define === "function") // AMD/CMD/Sea.js - { - if (define.amd) { // for Require.js - - define(["editormd"], function(editormd) { - factory(editormd); - }); - - } else { // for Sea.js - define(function(require) { - var editormd = require("./../../editormd"); - factory(editormd); - }); - } - } - else - { - factory(window.editormd); - } - -})(); +/*! + * Emoji dialog plugin for Editor.md + * + * @file emoji-dialog.js + * @author pandao + * @version 1.2.0 + * @updateTime 2015-03-08 + * {@link https://github.com/pandao/editor.md} + * @license MIT + */ + +(function() { + + var factory = function (exports) { + + var $ = jQuery; + var pluginName = "emoji-dialog"; + var emojiTabIndex = 0; + var emojiData = []; + var selecteds = []; + + var logoPrefix = "editormd-logo"; + var logos = [ + logoPrefix, + logoPrefix + "-1x", + logoPrefix + "-2x", + logoPrefix + "-3x", + logoPrefix + "-4x", + logoPrefix + "-5x", + logoPrefix + "-6x", + logoPrefix + "-7x", + logoPrefix + "-8x" + ]; + + var langs = { + "zh-cn" : { + toolbar : { + emoji : "Emoji 表情" + }, + dialog : { + emoji : { + title : "Emoji 表情" + } + } + }, + "zh-tw" : { + toolbar : { + emoji : "Emoji 表情" + }, + dialog : { + emoji : { + title : "Emoji 表情" + } + } + }, + "en" : { + toolbar : { + emoji : "Emoji" + }, + dialog : { + emoji : { + title : "Emoji" + } + } + } + }; + + exports.fn.emojiDialog = function() { + var _this = this; + var cm = this.cm; + var settings = _this.settings; + + if (!settings.emoji) + { + alert("settings.emoji == false"); + return ; + } + + var path = settings.pluginPath + pluginName + "/"; + var editor = this.editor; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + var classPrefix = this.classPrefix; + + $.extend(true, this.lang, langs[this.lang.name]); + this.setToolbar(); + + var lang = this.lang; + var dialogName = classPrefix + pluginName, dialog; + var dialogLang = lang.dialog.emoji; + + var dialogContent = [ + "
    ", + "
    ", + "
    ", + ].join("\n"); + + cm.focus(); + + if (editor.find("." + dialogName).length > 0) + { + dialog = editor.find("." + dialogName); + + selecteds = []; + dialog.find("a").removeClass("selected"); + + this.dialogShowMask(dialog); + this.dialogLockScreen(); + dialog.show(); + } + else + { + dialog = this.createDialog({ + name : dialogName, + title : dialogLang.title, + width : 800, + height : 475, + mask : settings.dialogShowMask, + drag : settings.dialogDraggable, + content : dialogContent, + lockScreen : settings.dialogLockScreen, + maskStyle : { + opacity : settings.dialogMaskOpacity, + backgroundColor : settings.dialogMaskBgColor + }, + buttons : { + enter : [lang.buttons.enter, function() { + cm.replaceSelection(selecteds.join(" ")); + this.hide().lockScreen(false).hideMask(); + cm.focus && cm.focus(); + + return false; + }], + cancel : [lang.buttons.cancel, function() { + this.hide().lockScreen(false).hideMask(); + cm.focus && cm.focus(); + + return false; + }] + } + }); + } + + var category = ["Github emoji", "Twemoji", "Font awesome", "Editor.md logo"]; + var tab = dialog.find("." + classPrefix + "tab"); + + if (tab.html() === "") + { + var head = ""; + + tab.append(head); + + var container = "
    "; + + for (var x = 0; x < 4; x++) + { + var display = (x === 0) ? "" : "display:none;"; + container += "
    "; + } + + container += "
    "; + + tab.append(container); + } + + var tabBoxs = tab.find("." + classPrefix + "tab-box"); + var emojiCategories = ["github-emoji", "twemoji", "font-awesome", logoPrefix]; + + var drawTable = function() { + var cname = emojiCategories[emojiTabIndex]; + var $data = emojiData[cname]; + var $tab = tabBoxs.eq(emojiTabIndex); + + if ($tab.html() !== "") { + //console.log("break =>", cname); + return ; + } + + var pagination = function(data, type) { + var rowNumber = (type === "editormd-logo") ? "5" : 20; + var pageTotal = Math.ceil(data.length / rowNumber); + var table = "
    "; + + for (var i = 0; i < pageTotal; i++) + { + var row = "
    "; + + for (var x = 0; x < rowNumber; x++) + { + var emoji = $.trim(data[(i * rowNumber) + x]); + + if (typeof emoji !== "undefined" && emoji !== "") + { + var img = "", icon = ""; + + if (type === "github-emoji") + { + var src = (emoji === "+1") ? "plus1" : emoji; + src = (src === "black_large_square") ? "black_square" : src; + src = (src === "moon") ? "waxing_gibbous_moon" : src; + + src = exports.emoji.path + src + exports.emoji.ext; + img = "\":""; + row += "" + img + ""; + } + else if (type === "twemoji") + { + var twemojiSrc = exports.twemoji.path + emoji + exports.twemoji.ext; + img = "\"twemoji-""; + row += "" + img + ""; + } + else if (type === "font-awesome") + { + icon = ""; + row += "" + icon + ""; + } + else if (type === "editormd-logo") + { + icon = ""; + row += "" + icon + ""; + } + } + else + { + row += ""; + } + } + + row += "
    "; + + table += row; + } + + table += "
    "; + + return table; + }; + + if (emojiTabIndex === 0) + { + for (var i = 0, len = $data.length; i < len; i++) + { + var h4Style = (i === 0) ? " style=\"margin: 0 0 10px;\"" : " style=\"margin: 10px 0;\""; + $tab.append("" + $data[i].category + ""); + $tab.append(pagination($data[i].list, cname)); + } + } + else + { + $tab.append(pagination($data, cname)); + } + + $tab.find("." + classPrefix + "emoji-btn").bind(exports.mouseOrTouch("click", "touchend"), function() { + $(this).toggleClass("selected"); + + if ($(this).hasClass("selected")) + { + selecteds.push($(this).attr("value")); + } + }); + }; + + if (emojiData.length < 1) + { + if (typeof dialog.loading === "function") { + dialog.loading(true); + } + + $.getJSON(path + "emoji.json?temp=" + Math.random(), function(json) { + + if (typeof dialog.loading === "function") { + dialog.loading(false); + } + + emojiData = json; + emojiData[logoPrefix] = logos; + drawTable(); + }); + } + else + { + drawTable(); + } + + tab.find("li").bind(exports.mouseOrTouch("click", "touchend"), function() { + var $this = $(this); + emojiTabIndex = $this.index(); + + $this.addClass("active").siblings().removeClass("active"); + tabBoxs.eq(emojiTabIndex).show().siblings().hide(); + drawTable(); + }); + }; + + }; + + // CommonJS/Node.js + if (typeof require === "function" && typeof exports === "object" && typeof module === "object") + { + module.exports = factory; + } + else if (typeof define === "function") // AMD/CMD/Sea.js + { + if (define.amd) { // for Require.js + + define(["editormd"], function(editormd) { + factory(editormd); + }); + + } else { // for Sea.js + define(function(require) { + var editormd = require("./../../editormd"); + factory(editormd); + }); + } + } + else + { + factory(window.editormd); + } + +})(); diff --git a/public/editormd/plugins/goto-line-dialog/goto-line-dialog.js b/public/editormd/plugins/goto-line-dialog/goto-line-dialog.js index 4992026ae..f569ad7b3 100644 --- a/public/editormd/plugins/goto-line-dialog/goto-line-dialog.js +++ b/public/editormd/plugins/goto-line-dialog/goto-line-dialog.js @@ -1,157 +1,159 @@ -/*! - * Goto line dialog plugin for Editor.md - * - * @file goto-line-dialog.js - * @author pandao - * @version 1.2.1 - * @updateTime 2015-06-09 - * {@link https://github.com/pandao/editor.md} - * @license MIT - */ - -(function() { - - var factory = function (exports) { - - var $ = jQuery; - var pluginName = "goto-line-dialog"; - - var langs = { - "zh-cn" : { - toolbar : { - "goto-line" : "跳转到行" - }, - dialog : { - "goto-line" : { - title : "跳转到行", - label : "请输入行号", - error : "错误:" - } - } - }, - "zh-tw" : { - toolbar : { - "goto-line" : "跳轉到行" - }, - dialog : { - "goto-line" : { - title : "跳轉到行", - label : "請輸入行號", - error : "錯誤:" - } - } - }, - "en" : { - toolbar : { - "goto-line" : "Goto line" - }, - dialog : { - "goto-line" : { - title : "Goto line", - label : "Enter a line number, range ", - error : "Error: " - } - } - } - }; - - exports.fn.gotoLineDialog = function() { - var _this = this; - var cm = this.cm; - var editor = this.editor; - var settings = this.settings; - var path = settings.pluginPath + pluginName +"/"; - var classPrefix = this.classPrefix; - var dialogName = classPrefix + pluginName, dialog; - - $.extend(true, this.lang, langs[this.lang.name]); - this.setToolbar(); - - var lang = this.lang; - var dialogLang = lang.dialog["goto-line"]; - var lineCount = cm.lineCount(); - - dialogLang.error += dialogLang.label + " 1-" + lineCount; - - if (editor.find("." + dialogName).length < 1) - { - var dialogContent = [ - "
    ", - "

    " + dialogLang.label + " 1-" + lineCount +"   

    ", - "
    " - ].join("\n"); - - dialog = this.createDialog({ - name : dialogName, - title : dialogLang.title, - width : 400, - height : 180, - mask : settings.dialogShowMask, - drag : settings.dialogDraggable, - content : dialogContent, - lockScreen : settings.dialogLockScreen, - maskStyle : { - opacity : settings.dialogMaskOpacity, - backgroundColor : settings.dialogMaskBgColor - }, - buttons : { - enter : [lang.buttons.enter, function() { - var line = parseInt(this.find("[data-line-number]").val()); - - if (line < 1 || line > lineCount) { - alert(dialogLang.error); - - return false; - } - - _this.gotoLine(line); - - this.hide().lockScreen(false).hideMask(); - - return false; - }], - - cancel : [lang.buttons.cancel, function() { - this.hide().lockScreen(false).hideMask(); - - return false; - }] - } - }); - } - - dialog = editor.find("." + dialogName); - - this.dialogShowMask(dialog); - this.dialogLockScreen(); - dialog.show(); - }; - - }; - - // CommonJS/Node.js - if (typeof require === "function" && typeof exports === "object" && typeof module === "object") - { - module.exports = factory; - } - else if (typeof define === "function") // AMD/CMD/Sea.js - { - if (define.amd) { // for Require.js - - define(["editormd"], function(editormd) { - factory(editormd); - }); - - } else { // for Sea.js - define(function(require) { - var editormd = require("./../../editormd"); - factory(editormd); - }); - } - } - else - { - factory(window.editormd); - } - -})(); +/*! + * Goto line dialog plugin for Editor.md + * + * @file goto-line-dialog.js + * @author pandao + * @version 1.2.1 + * @updateTime 2015-06-09 + * {@link https://github.com/pandao/editor.md} + * @license MIT + */ + +(function() { + + var factory = function (exports) { + + var $ = jQuery; + var pluginName = "goto-line-dialog"; + + var langs = { + "zh-cn" : { + toolbar : { + "goto-line" : "跳转到行" + }, + dialog : { + "goto-line" : { + title : "跳转到行", + label : "请输入行号", + error : "错误:" + } + } + }, + "zh-tw" : { + toolbar : { + "goto-line" : "跳轉到行" + }, + dialog : { + "goto-line" : { + title : "跳轉到行", + label : "請輸入行號", + error : "錯誤:" + } + } + }, + "en" : { + toolbar : { + "goto-line" : "Goto line" + }, + dialog : { + "goto-line" : { + title : "Goto line", + label : "Enter a line number, range ", + error : "Error: " + } + } + } + }; + + exports.fn.gotoLineDialog = function() { + var _this = this; + var cm = this.cm; + var editor = this.editor; + var settings = this.settings; + var path = settings.pluginPath + pluginName +"/"; + var classPrefix = this.classPrefix; + var dialogName = classPrefix + pluginName, dialog; + + $.extend(true, this.lang, langs[this.lang.name]); + this.setToolbar(); + + var lang = this.lang; + var dialogLang = lang.dialog["goto-line"]; + var lineCount = cm.lineCount(); + + dialogLang.error += dialogLang.label + " 1-" + lineCount; + + if (editor.find("." + dialogName).length < 1) + { + var dialogContent = [ + "
    ", + "

    " + dialogLang.label + " 1-" + lineCount +"   

    ", + "
    " + ].join("\n"); + + dialog = this.createDialog({ + name : dialogName, + title : dialogLang.title, + width : 400, + height : 180, + mask : settings.dialogShowMask, + drag : settings.dialogDraggable, + content : dialogContent, + lockScreen : settings.dialogLockScreen, + maskStyle : { + opacity : settings.dialogMaskOpacity, + backgroundColor : settings.dialogMaskBgColor + }, + buttons : { + enter : [lang.buttons.enter, function() { + var line = parseInt(this.find("[data-line-number]").val()); + + if (line < 1 || line > lineCount) { + alert(dialogLang.error); + + return false; + } + + _this.gotoLine(line); + + this.hide().lockScreen(false).hideMask(); + cm.focus && cm.focus(); + + return false; + }], + + cancel : [lang.buttons.cancel, function() { + this.hide().lockScreen(false).hideMask(); + cm.focus && cm.focus(); + + return false; + }] + } + }); + } + + dialog = editor.find("." + dialogName); + + this.dialogShowMask(dialog); + this.dialogLockScreen(); + dialog.show(); + }; + + }; + + // CommonJS/Node.js + if (typeof require === "function" && typeof exports === "object" && typeof module === "object") + { + module.exports = factory; + } + else if (typeof define === "function") // AMD/CMD/Sea.js + { + if (define.amd) { // for Require.js + + define(["editormd"], function(editormd) { + factory(editormd); + }); + + } else { // for Sea.js + define(function(require) { + var editormd = require("./../../editormd"); + factory(editormd); + }); + } + } + else + { + factory(window.editormd); + } + +})(); diff --git a/public/editormd/plugins/help-dialog/help-dialog.js b/public/editormd/plugins/help-dialog/help-dialog.js index 4e2b279bd..2cb8cb9a1 100644 --- a/public/editormd/plugins/help-dialog/help-dialog.js +++ b/public/editormd/plugins/help-dialog/help-dialog.js @@ -1,102 +1,104 @@ -/*! - * Help dialog plugin for Editor.md - * - * @file help-dialog.js - * @author pandao - * @version 1.2.0 - * @updateTime 2015-03-08 - * {@link https://github.com/pandao/editor.md} - * @license MIT - */ - -(function() { - - var factory = function (exports) { - - var $ = jQuery; - var pluginName = "help-dialog"; - - exports.fn.helpDialog = function() { - var _this = this; - var lang = this.lang; - var editor = this.editor; - var settings = this.settings; - var path = settings.pluginPath + pluginName + "/"; - var classPrefix = this.classPrefix; - var dialogName = classPrefix + pluginName, dialog; - var dialogLang = lang.dialog.help; - - if (editor.find("." + dialogName).length < 1) - { - var dialogContent = "
    "; - - dialog = this.createDialog({ - name : dialogName, - title : dialogLang.title, - width : 840, - height : 540, - mask : settings.dialogShowMask, - drag : settings.dialogDraggable, - content : dialogContent, - lockScreen : settings.dialogLockScreen, - maskStyle : { - opacity : settings.dialogMaskOpacity, - backgroundColor : settings.dialogMaskBgColor - }, - buttons : { - close : [lang.buttons.close, function() { - this.hide().lockScreen(false).hideMask(); - - return false; - }] - } - }); - } - - dialog = editor.find("." + dialogName); - - this.dialogShowMask(dialog); - this.dialogLockScreen(); - dialog.show(); - - var helpContent = dialog.find(".markdown-body"); - - if (helpContent.html() === "") - { - $.get(path + "help.md", function(text) { - var md = exports.$marked(text); - helpContent.html(md); - - helpContent.find("a").attr("target", "_blank"); - }); - } - }; - - }; - - // CommonJS/Node.js - if (typeof require === "function" && typeof exports === "object" && typeof module === "object") - { - module.exports = factory; - } - else if (typeof define === "function") // AMD/CMD/Sea.js - { - if (define.amd) { // for Require.js - - define(["editormd"], function(editormd) { - factory(editormd); - }); - - } else { // for Sea.js - define(function(require) { - var editormd = require("./../../editormd"); - factory(editormd); - }); - } - } - else - { - factory(window.editormd); - } - -})(); +/*! + * Help dialog plugin for Editor.md + * + * @file help-dialog.js + * @author pandao + * @version 1.2.0 + * @updateTime 2015-03-08 + * {@link https://github.com/pandao/editor.md} + * @license MIT + */ + +(function() { + + var factory = function (exports) { + + var $ = jQuery; + var pluginName = "help-dialog"; + + exports.fn.helpDialog = function() { + var _this = this; + var lang = this.lang; + var cm = this.cm; + var editor = this.editor; + var settings = this.settings; + var path = settings.pluginPath + pluginName + "/"; + var classPrefix = this.classPrefix; + var dialogName = classPrefix + pluginName, dialog; + var dialogLang = lang.dialog.help; + + if (editor.find("." + dialogName).length < 1) + { + var dialogContent = "
    "; + + dialog = this.createDialog({ + name : dialogName, + title : dialogLang.title, + width : 840, + height : 540, + mask : settings.dialogShowMask, + drag : settings.dialogDraggable, + content : dialogContent, + lockScreen : settings.dialogLockScreen, + maskStyle : { + opacity : settings.dialogMaskOpacity, + backgroundColor : settings.dialogMaskBgColor + }, + buttons : { + close : [lang.buttons.close, function() { + this.hide().lockScreen(false).hideMask(); + cm.focus && cm.focus(); + + return false; + }] + } + }); + } + + dialog = editor.find("." + dialogName); + + this.dialogShowMask(dialog); + this.dialogLockScreen(); + dialog.show(); + + var helpContent = dialog.find(".markdown-body"); + + if (helpContent.html() === "") + { + $.get(path + "help.md", function(text) { + var md = exports.$marked(text); + helpContent.html(md); + + helpContent.find("a").attr("target", "_blank"); + }); + } + }; + + }; + + // CommonJS/Node.js + if (typeof require === "function" && typeof exports === "object" && typeof module === "object") + { + module.exports = factory; + } + else if (typeof define === "function") // AMD/CMD/Sea.js + { + if (define.amd) { // for Require.js + + define(["editormd"], function(editormd) { + factory(editormd); + }); + + } else { // for Sea.js + define(function(require) { + var editormd = require("./../../editormd"); + factory(editormd); + }); + } + } + else + { + factory(window.editormd); + } + +})(); diff --git a/public/editormd/plugins/html-entities-dialog/html-entities-dialog.js b/public/editormd/plugins/html-entities-dialog/html-entities-dialog.js index cc9835b56..e3dc91e20 100644 --- a/public/editormd/plugins/html-entities-dialog/html-entities-dialog.js +++ b/public/editormd/plugins/html-entities-dialog/html-entities-dialog.js @@ -1,173 +1,173 @@ -/*! - * HTML entities dialog plugin for Editor.md - * - * @file html-entities-dialog.js - * @author pandao - * @version 1.2.0 - * @updateTime 2015-03-08 - * {@link https://github.com/pandao/editor.md} - * @license MIT - */ - -(function() { - - var factory = function (exports) { - - var $ = jQuery; - var pluginName = "html-entities-dialog"; - var selecteds = []; - var entitiesData = []; - - exports.fn.htmlEntitiesDialog = function() { - var _this = this; - var cm = this.cm; - var lang = _this.lang; - var settings = _this.settings; - var path = settings.pluginPath + pluginName + "/"; - var editor = this.editor; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - var classPrefix = _this.classPrefix; - - var dialogName = classPrefix + "dialog-" + pluginName, dialog; - var dialogLang = lang.dialog.htmlEntities; - - var dialogContent = [ - '
    ', - '
    ', - '
    ', - '
    ', - ].join("\r\n"); - - cm.focus(); - - if (editor.find("." + dialogName).length > 0) - { - dialog = editor.find("." + dialogName); - - selecteds = []; - dialog.find("a").removeClass("selected"); - - this.dialogShowMask(dialog); - this.dialogLockScreen(); - dialog.show(); - } - else - { - dialog = this.createDialog({ - name : dialogName, - title : dialogLang.title, - width : 800, - height : 475, - mask : settings.dialogShowMask, - drag : settings.dialogDraggable, - content : dialogContent, - lockScreen : settings.dialogLockScreen, - maskStyle : { - opacity : settings.dialogMaskOpacity, - backgroundColor : settings.dialogMaskBgColor - }, - buttons : { - enter : [lang.buttons.enter, function() { - cm.replaceSelection(selecteds.join(" ")); - this.hide().lockScreen(false).hideMask(); - - return false; - }], - cancel : [lang.buttons.cancel, function() { - this.hide().lockScreen(false).hideMask(); - - return false; - }] - } - }); - } - - var table = dialog.find("." + classPrefix + "grid-table"); - - var drawTable = function() { - - if (entitiesData.length < 1) return ; - - var rowNumber = 20; - var pageTotal = Math.ceil(entitiesData.length / rowNumber); - - table.html(""); - - for (var i = 0; i < pageTotal; i++) - { - var row = "
    "; - - for (var x = 0; x < rowNumber; x++) - { - var entity = entitiesData[(i * rowNumber) + x]; - - if (typeof entity !== "undefined") - { - var name = entity.name.replace("&", "&"); - - row += "" + name + ""; - } - } - - row += "
    "; - - table.append(row); - } - - dialog.find("." + classPrefix + "html-entity-btn").bind(exports.mouseOrTouch("click", "touchend"), function() { - $(this).toggleClass("selected"); - - if ($(this).hasClass("selected")) - { - selecteds.push($(this).attr("value")); - } - }); - }; - - if (entitiesData.length < 1) - { - if (typeof (dialog.loading) == "function") dialog.loading(true); - - $.getJSON(path + pluginName.replace("-dialog", "") + ".json", function(json) { - - if (typeof (dialog.loading) == "function") dialog.loading(false); - - entitiesData = json; - drawTable(); - }); - } - else - { - drawTable(); - } - }; - - }; - - // CommonJS/Node.js - if (typeof require === "function" && typeof exports === "object" && typeof module === "object") - { - module.exports = factory; - } - else if (typeof define === "function") // AMD/CMD/Sea.js - { - if (define.amd) { // for Require.js - - define(["editormd"], function(editormd) { - factory(editormd); - }); - - } else { // for Sea.js - define(function(require) { - var editormd = require("./../../editormd"); - factory(editormd); - }); - } - } - else - { - factory(window.editormd); - } - -})(); +/*! + * HTML entities dialog plugin for Editor.md + * + * @file html-entities-dialog.js + * @author pandao + * @version 1.2.0 + * @updateTime 2015-03-08 + * {@link https://github.com/pandao/editor.md} + * @license MIT + */ + +(function() { + + var factory = function (exports) { + + var $ = jQuery; + var pluginName = "html-entities-dialog"; + var selecteds = []; + var entitiesData = []; + + exports.fn.htmlEntitiesDialog = function() { + var _this = this; + var cm = this.cm; + var lang = _this.lang; + var settings = _this.settings; + var path = settings.pluginPath + pluginName + "/"; + var editor = this.editor; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + var classPrefix = _this.classPrefix; + + var dialogName = classPrefix + "dialog-" + pluginName, dialog; + var dialogLang = lang.dialog.htmlEntities; + + var dialogContent = [ + '
    ', + '
    ', + '
    ', + '
    ', + ].join("\r\n"); + + cm.focus(); + + if (editor.find("." + dialogName).length > 0) + { + dialog = editor.find("." + dialogName); + + selecteds = []; + dialog.find("a").removeClass("selected"); + + this.dialogShowMask(dialog); + this.dialogLockScreen(); + dialog.show(); + } + else + { + dialog = this.createDialog({ + name : dialogName, + title : dialogLang.title, + width : 800, + height : 475, + mask : settings.dialogShowMask, + drag : settings.dialogDraggable, + content : dialogContent, + lockScreen : settings.dialogLockScreen, + maskStyle : { + opacity : settings.dialogMaskOpacity, + backgroundColor : settings.dialogMaskBgColor + }, + buttons : { + enter : [lang.buttons.enter, function() { + cm.replaceSelection(selecteds.join(" ")); + this.hide().lockScreen(false).hideMask(); + cm.focus && cm.focus(); + return false; + }], + cancel : [lang.buttons.cancel, function() { + this.hide().lockScreen(false).hideMask(); + cm.focus && cm.focus(); + return false; + }] + } + }); + } + + var table = dialog.find("." + classPrefix + "grid-table"); + + var drawTable = function() { + + if (entitiesData.length < 1) return ; + + var rowNumber = 20; + var pageTotal = Math.ceil(entitiesData.length / rowNumber); + + table.html(""); + + for (var i = 0; i < pageTotal; i++) + { + var row = "
    "; + + for (var x = 0; x < rowNumber; x++) + { + var entity = entitiesData[(i * rowNumber) + x]; + + if (typeof entity !== "undefined") + { + var name = entity.name.replace("&", "&"); + + row += "" + name + ""; + } + } + + row += "
    "; + + table.append(row); + } + + dialog.find("." + classPrefix + "html-entity-btn").bind(exports.mouseOrTouch("click", "touchend"), function() { + $(this).toggleClass("selected"); + + if ($(this).hasClass("selected")) + { + selecteds.push($(this).attr("value")); + } + }); + }; + + if (entitiesData.length < 1) + { + if (typeof (dialog.loading) == "function") dialog.loading(true); + + $.getJSON(path + pluginName.replace("-dialog", "") + ".json", function(json) { + + if (typeof (dialog.loading) == "function") dialog.loading(false); + + entitiesData = json; + drawTable(); + }); + } + else + { + drawTable(); + } + }; + + }; + + // CommonJS/Node.js + if (typeof require === "function" && typeof exports === "object" && typeof module === "object") + { + module.exports = factory; + } + else if (typeof define === "function") // AMD/CMD/Sea.js + { + if (define.amd) { // for Require.js + + define(["editormd"], function(editormd) { + factory(editormd); + }); + + } else { // for Sea.js + define(function(require) { + var editormd = require("./../../editormd"); + factory(editormd); + }); + } + } + else + { + factory(window.editormd); + } + +})(); diff --git a/public/editormd/plugins/link-dialog/link-dialog.js b/public/editormd/plugins/link-dialog/link-dialog.js index c0c0c581a..e121a8462 100644 --- a/public/editormd/plugins/link-dialog/link-dialog.js +++ b/public/editormd/plugins/link-dialog/link-dialog.js @@ -1,133 +1,134 @@ -/*! - * Link dialog plugin for Editor.md - * - * @file link-dialog.js - * @author pandao - * @version 1.2.1 - * @updateTime 2015-06-09 - * {@link https://github.com/pandao/editor.md} - * @license MIT - */ - -(function() { - - var factory = function (exports) { - - var pluginName = "link-dialog"; - - exports.fn.linkDialog = function() { - - var _this = this; - var cm = this.cm; - var editor = this.editor; - var settings = this.settings; - var selection = cm.getSelection(); - var lang = this.lang; - var linkLang = lang.dialog.link; - var classPrefix = this.classPrefix; - var dialogName = classPrefix + pluginName, dialog; - - cm.focus(); - - if (editor.find("." + dialogName).length > 0) - { - dialog = editor.find("." + dialogName); - dialog.find("[data-url]").val("http://"); - dialog.find("[data-title]").val(selection); - - this.dialogShowMask(dialog); - this.dialogLockScreen(); - dialog.show(); - } - else - { - var dialogHTML = "
    " + - "" + - "" + - "
    " + - "" + - "" + - "
    " + - "
    "; - - dialog = this.createDialog({ - title : linkLang.title, - width : 380, - height : 211, - content : dialogHTML, - mask : settings.dialogShowMask, - drag : settings.dialogDraggable, - lockScreen : settings.dialogLockScreen, - maskStyle : { - opacity : settings.dialogMaskOpacity, - backgroundColor : settings.dialogMaskBgColor - }, - buttons : { - enter : [lang.buttons.enter, function() { - var url = this.find("[data-url]").val(); - var title = this.find("[data-title]").val(); - - if (url === "http://" || url === "") - { - alert(linkLang.urlEmpty); - return false; - } - - /*if (title === "") - { - alert(linkLang.titleEmpty); - return false; - }*/ - - var str = "[" + title + "](" + url + " \"" + title + "\")"; - - if (title == "") - { - str = "[" + url + "](" + url + ")"; - } - - cm.replaceSelection(str); - - this.hide().lockScreen(false).hideMask(); - - return false; - }], - - cancel : [lang.buttons.cancel, function() { - this.hide().lockScreen(false).hideMask(); - - return false; - }] - } - }); - } - }; - - }; - - // CommonJS/Node.js - if (typeof require === "function" && typeof exports === "object" && typeof module === "object") - { - module.exports = factory; - } - else if (typeof define === "function") // AMD/CMD/Sea.js - { - if (define.amd) { // for Require.js - - define(["editormd"], function(editormd) { - factory(editormd); - }); - - } else { // for Sea.js - define(function(require) { - var editormd = require("./../../editormd"); - factory(editormd); - }); - } - } - else - { - factory(window.editormd); - } - -})(); +/*! + * Link dialog plugin for Editor.md + * + * @file link-dialog.js + * @author pandao + * @version 1.2.1 + * @updateTime 2015-06-09 + * {@link https://github.com/pandao/editor.md} + * @license MIT + */ + +(function() { + + var factory = function (exports) { + + var pluginName = "link-dialog"; + + exports.fn.linkDialog = function() { + + var _this = this; + var cm = this.cm; + var editor = this.editor; + var settings = this.settings; + var selection = cm.getSelection(); + var lang = this.lang; + var linkLang = lang.dialog.link; + var classPrefix = this.classPrefix; + var dialogName = classPrefix + pluginName, dialog; + + cm.focus(); + + if (editor.find("." + dialogName).length > 0) + { + dialog = editor.find("." + dialogName); + dialog.find("[data-url]").val("http://"); + dialog.find("[data-title]").val(selection); + + this.dialogShowMask(dialog); + this.dialogLockScreen(); + dialog.show(); + } + else + { + var dialogHTML = "
    " + + "" + + "" + + "
    " + + "" + + "" + + "
    " + + "
    "; + + dialog = this.createDialog({ + title : linkLang.title, + width : 380, + height : 211, + content : dialogHTML, + mask : settings.dialogShowMask, + drag : settings.dialogDraggable, + lockScreen : settings.dialogLockScreen, + maskStyle : { + opacity : settings.dialogMaskOpacity, + backgroundColor : settings.dialogMaskBgColor + }, + buttons : { + enter : [lang.buttons.enter, function() { + var url = this.find("[data-url]").val(); + var title = this.find("[data-title]").val(); + + if (url === "http://" || url === "") + { + alert(linkLang.urlEmpty); + return false; + } + + /*if (title === "") + { + alert(linkLang.titleEmpty); + return false; + }*/ + + var str = "[" + title + "](" + url + " \"" + title + "\")"; + + if (title == "") + { + str = "[" + url + "](" + url + ")"; + } + + cm.replaceSelection(str); + + this.hide().lockScreen(false).hideMask(); + cm.focus && cm.focus(); + + return false; + }], + + cancel : [lang.buttons.cancel, function() { + this.hide().lockScreen(false).hideMask(); + cm.focus && cm.focus(); + return false; + }] + } + }); + } + }; + + }; + + // CommonJS/Node.js + if (typeof require === "function" && typeof exports === "object" && typeof module === "object") + { + module.exports = factory; + } + else if (typeof define === "function") // AMD/CMD/Sea.js + { + if (define.amd) { // for Require.js + + define(["editormd"], function(editormd) { + factory(editormd); + }); + + } else { // for Sea.js + define(function(require) { + var editormd = require("./../../editormd"); + factory(editormd); + }); + } + } + else + { + factory(window.editormd); + } + +})(); diff --git a/public/editormd/plugins/preformatted-text-dialog/preformatted-text-dialog.js b/public/editormd/plugins/preformatted-text-dialog/preformatted-text-dialog.js index e19bbd54a..733e644b8 100644 --- a/public/editormd/plugins/preformatted-text-dialog/preformatted-text-dialog.js +++ b/public/editormd/plugins/preformatted-text-dialog/preformatted-text-dialog.js @@ -1,172 +1,174 @@ -/*! - * Preformatted text dialog plugin for Editor.md - * - * @file preformatted-text-dialog.js - * @author pandao - * @version 1.2.0 - * @updateTime 2015-03-07 - * {@link https://github.com/pandao/editor.md} - * @license MIT - */ - -(function() { - - var factory = function (exports) { - var cmEditor; - var pluginName = "preformatted-text-dialog"; - - exports.fn.preformattedTextDialog = function() { - - var _this = this; - var cm = this.cm; - var lang = this.lang; - var editor = this.editor; - var settings = this.settings; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - var classPrefix = this.classPrefix; - var dialogLang = lang.dialog.preformattedText; - var dialogName = classPrefix + pluginName, dialog; - - cm.focus(); - - if (editor.find("." + dialogName).length > 0) - { - dialog = editor.find("." + dialogName); - dialog.find("textarea").val(selection); - - this.dialogShowMask(dialog); - this.dialogLockScreen(); - dialog.show(); - } - else - { - var dialogContent = ""; - - dialog = this.createDialog({ - name : dialogName, - title : dialogLang.title, - width : 780, - height : 540, - mask : settings.dialogShowMask, - drag : settings.dialogDraggable, - content : dialogContent, - lockScreen : settings.dialogLockScreen, - maskStyle : { - opacity : settings.dialogMaskOpacity, - backgroundColor : settings.dialogMaskBgColor - }, - buttons : { - enter : [lang.buttons.enter, function() { - var codeTexts = this.find("textarea").val(); - - if (codeTexts === "") - { - alert(dialogLang.emptyAlert); - return false; - } - - codeTexts = codeTexts.split("\n"); - - for (var i in codeTexts) - { - codeTexts[i] = " " + codeTexts[i]; - } - - codeTexts = codeTexts.join("\n"); - - if (cursor.ch !== 0) { - codeTexts = "\r\n\r\n" + codeTexts; - } - - cm.replaceSelection(codeTexts); - - this.hide().lockScreen(false).hideMask(); - - return false; - }], - cancel : [lang.buttons.cancel, function() { - this.hide().lockScreen(false).hideMask(); - - return false; - }] - } - }); - } - - var cmConfig = { - mode : "text/html", - theme : settings.theme, - tabSize : 4, - autofocus : true, - autoCloseTags : true, - indentUnit : 4, - lineNumbers : true, - lineWrapping : true, - extraKeys : {"Ctrl-Q": function(cm){ cm.foldCode(cm.getCursor()); }}, - foldGutter : true, - gutters : ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], - matchBrackets : true, - indentWithTabs : true, - styleActiveLine : true, - styleSelectedText : true, - autoCloseBrackets : true, - showTrailingSpace : true, - highlightSelectionMatches : true - }; - - var textarea = dialog.find("textarea"); - var cmObj = dialog.find(".CodeMirror"); - - if (dialog.find(".CodeMirror").length < 1) - { - cmEditor = exports.$CodeMirror.fromTextArea(textarea[0], cmConfig); - cmObj = dialog.find(".CodeMirror"); - - cmObj.css({ - "float" : "none", - margin : "0 0 5px", - border : "1px solid #ddd", - fontSize : settings.fontSize, - width : "100%", - height : "410px" - }); - - cmEditor.on("change", function(cm) { - textarea.val(cm.getValue()); - }); - } - else - { - cmEditor.setValue(cm.getSelection()); - } - }; - - }; - - // CommonJS/Node.js - if (typeof require === "function" && typeof exports === "object" && typeof module === "object") - { - module.exports = factory; - } - else if (typeof define === "function") // AMD/CMD/Sea.js - { - if (define.amd) { // for Require.js - - define(["editormd"], function(editormd) { - factory(editormd); - }); - - } else { // for Sea.js - define(function(require) { - var editormd = require("./../../editormd"); - factory(editormd); - }); - } - } - else - { - factory(window.editormd); - } - -})(); +/*! + * Preformatted text dialog plugin for Editor.md + * + * @file preformatted-text-dialog.js + * @author pandao + * @version 1.2.0 + * @updateTime 2015-03-07 + * {@link https://github.com/pandao/editor.md} + * @license MIT + */ + +(function() { + + var factory = function (exports) { + var cmEditor; + var pluginName = "preformatted-text-dialog"; + + exports.fn.preformattedTextDialog = function() { + + var _this = this; + var cm = this.cm; + var lang = this.lang; + var editor = this.editor; + var settings = this.settings; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + var classPrefix = this.classPrefix; + var dialogLang = lang.dialog.preformattedText; + var dialogName = classPrefix + pluginName, dialog; + + cm.focus(); + + if (editor.find("." + dialogName).length > 0) + { + dialog = editor.find("." + dialogName); + dialog.find("textarea").val(selection); + + this.dialogShowMask(dialog); + this.dialogLockScreen(); + dialog.show(); + } + else + { + var dialogContent = ""; + + dialog = this.createDialog({ + name : dialogName, + title : dialogLang.title, + width : 780, + height : 540, + mask : settings.dialogShowMask, + drag : settings.dialogDraggable, + content : dialogContent, + lockScreen : settings.dialogLockScreen, + maskStyle : { + opacity : settings.dialogMaskOpacity, + backgroundColor : settings.dialogMaskBgColor + }, + buttons : { + enter : [lang.buttons.enter, function() { + var codeTexts = this.find("textarea").val(); + + if (codeTexts === "") + { + alert(dialogLang.emptyAlert); + return false; + } + + codeTexts = codeTexts.split("\n"); + + for (var i in codeTexts) + { + codeTexts[i] = " " + codeTexts[i]; + } + + codeTexts = codeTexts.join("\n"); + + if (cursor.ch !== 0) { + codeTexts = "\r\n\r\n" + codeTexts; + } + + cm.replaceSelection(codeTexts); + + this.hide().lockScreen(false).hideMask(); + cm.focus && cm.focus(); + + return false; + }], + cancel : [lang.buttons.cancel, function() { + this.hide().lockScreen(false).hideMask(); + cm.focus && cm.focus(); + + return false; + }] + } + }); + } + + var cmConfig = { + mode : "text/html", + theme : settings.theme, + tabSize : 4, + autofocus : true, + autoCloseTags : true, + indentUnit : 4, + lineNumbers : true, + lineWrapping : true, + extraKeys : {"Ctrl-Q": function(cm){ cm.foldCode(cm.getCursor()); }}, + foldGutter : true, + gutters : ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], + matchBrackets : true, + indentWithTabs : true, + styleActiveLine : true, + styleSelectedText : true, + autoCloseBrackets : true, + showTrailingSpace : true, + highlightSelectionMatches : true + }; + + var textarea = dialog.find("textarea"); + var cmObj = dialog.find(".CodeMirror"); + + if (dialog.find(".CodeMirror").length < 1) + { + cmEditor = exports.$CodeMirror.fromTextArea(textarea[0], cmConfig); + cmObj = dialog.find(".CodeMirror"); + + cmObj.css({ + "float" : "none", + margin : "0 0 5px", + border : "1px solid #ddd", + fontSize : settings.fontSize, + width : "100%", + height : "410px" + }); + + cmEditor.on("change", function(cm) { + textarea.val(cm.getValue()); + }); + } + else + { + cmEditor.setValue(cm.getSelection()); + } + }; + + }; + + // CommonJS/Node.js + if (typeof require === "function" && typeof exports === "object" && typeof module === "object") + { + module.exports = factory; + } + else if (typeof define === "function") // AMD/CMD/Sea.js + { + if (define.amd) { // for Require.js + + define(["editormd"], function(editormd) { + factory(editormd); + }); + + } else { // for Sea.js + define(function(require) { + var editormd = require("./../../editormd"); + factory(editormd); + }); + } + } + else + { + factory(window.editormd); + } + +})(); diff --git a/public/editormd/plugins/reference-link-dialog/reference-link-dialog.js b/public/editormd/plugins/reference-link-dialog/reference-link-dialog.js index fea88f294..e6ca126e0 100644 --- a/public/editormd/plugins/reference-link-dialog/reference-link-dialog.js +++ b/public/editormd/plugins/reference-link-dialog/reference-link-dialog.js @@ -1,153 +1,155 @@ -/*! - * Reference link dialog plugin for Editor.md - * - * @file reference-link-dialog.js - * @author pandao - * @version 1.2.1 - * @updateTime 2015-06-09 - * {@link https://github.com/pandao/editor.md} - * @license MIT - */ - -(function() { - - var factory = function (exports) { - - var pluginName = "reference-link-dialog"; - var ReLinkId = 1; - - exports.fn.referenceLinkDialog = function() { - - var _this = this; - var cm = this.cm; - var lang = this.lang; - var editor = this.editor; - var settings = this.settings; - var cursor = cm.getCursor(); - var selection = cm.getSelection(); - var dialogLang = lang.dialog.referenceLink; - var classPrefix = this.classPrefix; - var dialogName = classPrefix + pluginName, dialog; - - cm.focus(); - - if (editor.find("." + dialogName).length < 1) - { - var dialogHTML = "
    " + - "" + - "" + - "
    " + - "" + - "" + - "
    " + - "" + - "" + - "
    " + - "" + - "" + - "
    " + - "
    "; - - dialog = this.createDialog({ - name : dialogName, - title : dialogLang.title, - width : 380, - height : 296, - content : dialogHTML, - mask : settings.dialogShowMask, - drag : settings.dialogDraggable, - lockScreen : settings.dialogLockScreen, - maskStyle : { - opacity : settings.dialogMaskOpacity, - backgroundColor : settings.dialogMaskBgColor - }, - buttons : { - enter : [lang.buttons.enter, function() { - var name = this.find("[data-name]").val(); - var url = this.find("[data-url]").val(); - var rid = this.find("[data-url-id]").val(); - var title = this.find("[data-title]").val(); - - if (name === "") - { - alert(dialogLang.nameEmpty); - return false; - } - - if (rid === "") - { - alert(dialogLang.idEmpty); - return false; - } - - if (url === "http://" || url === "") - { - alert(dialogLang.urlEmpty); - return false; - } - - //cm.replaceSelection("[" + title + "][" + name + "]\n[" + name + "]: " + url + ""); - cm.replaceSelection("[" + name + "][" + rid + "]"); - - if (selection === "") { - cm.setCursor(cursor.line, cursor.ch + 1); - } - - title = (title === "") ? "" : " \"" + title + "\""; - - cm.setValue(cm.getValue() + "\n[" + rid + "]: " + url + title + ""); - - this.hide().lockScreen(false).hideMask(); - - return false; - }], - cancel : [lang.buttons.cancel, function() { - this.hide().lockScreen(false).hideMask(); - - return false; - }] - } - }); - } - - dialog = editor.find("." + dialogName); - dialog.find("[data-name]").val("[" + ReLinkId + "]"); - dialog.find("[data-url-id]").val(""); - dialog.find("[data-url]").val("http://"); - dialog.find("[data-title]").val(selection); - - this.dialogShowMask(dialog); - this.dialogLockScreen(); - dialog.show(); - - ReLinkId++; - }; - - }; - - // CommonJS/Node.js - if (typeof require === "function" && typeof exports === "object" && typeof module === "object") - { - module.exports = factory; - } - else if (typeof define === "function") // AMD/CMD/Sea.js - { - if (define.amd) { // for Require.js - - define(["editormd"], function(editormd) { - factory(editormd); - }); - - } else { // for Sea.js - define(function(require) { - var editormd = require("./../../editormd"); - factory(editormd); - }); - } - } - else - { - factory(window.editormd); - } - -})(); +/*! + * Reference link dialog plugin for Editor.md + * + * @file reference-link-dialog.js + * @author pandao + * @version 1.2.1 + * @updateTime 2015-06-09 + * {@link https://github.com/pandao/editor.md} + * @license MIT + */ + +(function() { + + var factory = function (exports) { + + var pluginName = "reference-link-dialog"; + var ReLinkId = 1; + + exports.fn.referenceLinkDialog = function() { + + var _this = this; + var cm = this.cm; + var lang = this.lang; + var editor = this.editor; + var settings = this.settings; + var cursor = cm.getCursor(); + var selection = cm.getSelection(); + var dialogLang = lang.dialog.referenceLink; + var classPrefix = this.classPrefix; + var dialogName = classPrefix + pluginName, dialog; + + cm.focus(); + + if (editor.find("." + dialogName).length < 1) + { + var dialogHTML = "
    " + + "" + + "" + + "
    " + + "" + + "" + + "
    " + + "" + + "" + + "
    " + + "" + + "" + + "
    " + + "
    "; + + dialog = this.createDialog({ + name : dialogName, + title : dialogLang.title, + width : 380, + height : 296, + content : dialogHTML, + mask : settings.dialogShowMask, + drag : settings.dialogDraggable, + lockScreen : settings.dialogLockScreen, + maskStyle : { + opacity : settings.dialogMaskOpacity, + backgroundColor : settings.dialogMaskBgColor + }, + buttons : { + enter : [lang.buttons.enter, function() { + var name = this.find("[data-name]").val(); + var url = this.find("[data-url]").val(); + var rid = this.find("[data-url-id]").val(); + var title = this.find("[data-title]").val(); + + if (name === "") + { + alert(dialogLang.nameEmpty); + return false; + } + + if (rid === "") + { + alert(dialogLang.idEmpty); + return false; + } + + if (url === "http://" || url === "") + { + alert(dialogLang.urlEmpty); + return false; + } + + //cm.replaceSelection("[" + title + "][" + name + "]\n[" + name + "]: " + url + ""); + cm.replaceSelection("[" + name + "][" + rid + "]"); + + if (selection === "") { + cm.setCursor(cursor.line, cursor.ch + 1); + } + + title = (title === "") ? "" : " \"" + title + "\""; + + cm.setValue(cm.getValue() + "\n[" + rid + "]: " + url + title + ""); + + this.hide().lockScreen(false).hideMask(); + cm.focus && cm.focus(); + + return false; + }], + cancel : [lang.buttons.cancel, function() { + this.hide().lockScreen(false).hideMask(); + cm.focus && cm.focus(); + + return false; + }] + } + }); + } + + dialog = editor.find("." + dialogName); + dialog.find("[data-name]").val("[" + ReLinkId + "]"); + dialog.find("[data-url-id]").val(""); + dialog.find("[data-url]").val("http://"); + dialog.find("[data-title]").val(selection); + + this.dialogShowMask(dialog); + this.dialogLockScreen(); + dialog.show(); + + ReLinkId++; + }; + + }; + + // CommonJS/Node.js + if (typeof require === "function" && typeof exports === "object" && typeof module === "object") + { + module.exports = factory; + } + else if (typeof define === "function") // AMD/CMD/Sea.js + { + if (define.amd) { // for Require.js + + define(["editormd"], function(editormd) { + factory(editormd); + }); + + } else { // for Sea.js + define(function(require) { + var editormd = require("./../../editormd"); + factory(editormd); + }); + } + } + else + { + factory(window.editormd); + } + +})(); diff --git a/public/editormd/plugins/table-dialog/table-dialog.js b/public/editormd/plugins/table-dialog/table-dialog.js index 366083f25..cac8c2460 100644 --- a/public/editormd/plugins/table-dialog/table-dialog.js +++ b/public/editormd/plugins/table-dialog/table-dialog.js @@ -1,218 +1,220 @@ -/*! - * Table dialog plugin for Editor.md - * - * @file table-dialog.js - * @author pandao - * @version 1.2.1 - * @updateTime 2015-06-09 - * {@link https://github.com/pandao/editor.md} - * @license MIT - */ - -(function() { - - var factory = function (exports) { - - var $ = jQuery; - var pluginName = "table-dialog"; - - var langs = { - "zh-cn" : { - toolbar : { - table : "表格" - }, - dialog : { - table : { - title : "添加表格", - cellsLabel : "单元格数", - alignLabel : "对齐方式", - rows : "行数", - cols : "列数", - aligns : ["默认", "左对齐", "居中对齐", "右对齐"] - } - } - }, - "zh-tw" : { - toolbar : { - table : "添加表格" - }, - dialog : { - table : { - title : "添加表格", - cellsLabel : "單元格數", - alignLabel : "對齊方式", - rows : "行數", - cols : "列數", - aligns : ["默認", "左對齊", "居中對齊", "右對齊"] - } - } - }, - "en" : { - toolbar : { - table : "Tables" - }, - dialog : { - table : { - title : "Tables", - cellsLabel : "Cells", - alignLabel : "Align", - rows : "Rows", - cols : "Cols", - aligns : ["Default", "Left align", "Center align", "Right align"] - } - } - } - }; - - exports.fn.tableDialog = function() { - var _this = this; - var cm = this.cm; - var editor = this.editor; - var settings = this.settings; - var path = settings.path + "../plugins/" + pluginName +"/"; - var classPrefix = this.classPrefix; - var dialogName = classPrefix + pluginName, dialog; - - $.extend(true, this.lang, langs[this.lang.name]); - this.setToolbar(); - - var lang = this.lang; - var dialogLang = lang.dialog.table; - - var dialogContent = [ - "
    ", - "", - dialogLang.rows + "   ", - dialogLang.cols + "
    ", - "", - "
    ", - "
    " - ].join("\n"); - - if (editor.find("." + dialogName).length > 0) - { - dialog = editor.find("." + dialogName); - - this.dialogShowMask(dialog); - this.dialogLockScreen(); - dialog.show(); - } - else - { - dialog = this.createDialog({ - name : dialogName, - title : dialogLang.title, - width : 360, - height : 244, - mask : settings.dialogShowMask, - drag : settings.dialogDraggable, - content : dialogContent, - lockScreen : settings.dialogLockScreen, - maskStyle : { - opacity : settings.dialogMaskOpacity, - backgroundColor : settings.dialogMaskBgColor - }, - buttons : { - enter : [lang.buttons.enter, function() { - var rows = parseInt(this.find("[data-rows]").val()); - var cols = parseInt(this.find("[data-cols]").val()); - var align = this.find("[name=\"table-align\"]:checked").val(); - var table = ""; - var hrLine = "------------"; - - var alignSign = { - _default : hrLine, - left : ":" + hrLine, - center : ":" + hrLine + ":", - right : hrLine + ":" - }; - - if ( rows > 1 && cols > 0) - { - for (var r = 0, len = rows; r < len; r++) - { - var row = []; - var head = []; - - for (var c = 0, len2 = cols; c < len2; c++) - { - if (r === 1) { - head.push(alignSign[align]); - } - - row.push(" "); - } - - if (r === 1) { - table += "| " + head.join(" | ") + " |" + "\n"; - } - - table += "| " + row.join( (cols === 1) ? "" : " | " ) + " |" + "\n"; - } - } - - cm.replaceSelection(table); - - this.hide().lockScreen(false).hideMask(); - - return false; - }], - - cancel : [lang.buttons.cancel, function() { - this.hide().lockScreen(false).hideMask(); - - return false; - }] - } - }); - } - - var faBtns = dialog.find(".fa-btns"); - - if (faBtns.html() === "") - { - var icons = ["align-justify", "align-left", "align-center", "align-right"]; - var _lang = dialogLang.aligns; - var values = ["_default", "left", "center", "right"]; - - for (var i = 0, len = icons.length; i < len; i++) - { - var checked = (i === 0) ? " checked=\"checked\"" : ""; - var btn = ""; - - faBtns.append(btn); - } - } - }; - - }; - - // CommonJS/Node.js - if (typeof require === "function" && typeof exports === "object" && typeof module === "object") - { - module.exports = factory; - } - else if (typeof define === "function") // AMD/CMD/Sea.js - { - if (define.amd) { // for Require.js - - define(["editormd"], function(editormd) { - factory(editormd); - }); - - } else { // for Sea.js - define(function(require) { - var editormd = require("./../../editormd"); - factory(editormd); - }); - } - } - else - { - factory(window.editormd); - } - -})(); +/*! + * Table dialog plugin for Editor.md + * + * @file table-dialog.js + * @author pandao + * @version 1.2.1 + * @updateTime 2015-06-09 + * {@link https://github.com/pandao/editor.md} + * @license MIT + */ + +(function() { + + var factory = function (exports) { + + var $ = jQuery; + var pluginName = "table-dialog"; + + var langs = { + "zh-cn" : { + toolbar : { + table : "表格" + }, + dialog : { + table : { + title : "添加表格", + cellsLabel : "单元格数", + alignLabel : "对齐方式", + rows : "行数", + cols : "列数", + aligns : ["默认", "左对齐", "居中对齐", "右对齐"] + } + } + }, + "zh-tw" : { + toolbar : { + table : "添加表格" + }, + dialog : { + table : { + title : "添加表格", + cellsLabel : "單元格數", + alignLabel : "對齊方式", + rows : "行數", + cols : "列數", + aligns : ["默認", "左對齊", "居中對齊", "右對齊"] + } + } + }, + "en" : { + toolbar : { + table : "Tables" + }, + dialog : { + table : { + title : "Tables", + cellsLabel : "Cells", + alignLabel : "Align", + rows : "Rows", + cols : "Cols", + aligns : ["Default", "Left align", "Center align", "Right align"] + } + } + } + }; + + exports.fn.tableDialog = function() { + var _this = this; + var cm = this.cm; + var editor = this.editor; + var settings = this.settings; + var path = settings.path + "../plugins/" + pluginName +"/"; + var classPrefix = this.classPrefix; + var dialogName = classPrefix + pluginName, dialog; + + $.extend(true, this.lang, langs[this.lang.name]); + this.setToolbar(); + + var lang = this.lang; + var dialogLang = lang.dialog.table; + + var dialogContent = [ + "
    ", + "", + dialogLang.rows + "   ", + dialogLang.cols + "
    ", + "", + "
    ", + "
    " + ].join("\n"); + + if (editor.find("." + dialogName).length > 0) + { + dialog = editor.find("." + dialogName); + + this.dialogShowMask(dialog); + this.dialogLockScreen(); + dialog.show(); + } + else + { + dialog = this.createDialog({ + name : dialogName, + title : dialogLang.title, + width : 360, + height : 244, + mask : settings.dialogShowMask, + drag : settings.dialogDraggable, + content : dialogContent, + lockScreen : settings.dialogLockScreen, + maskStyle : { + opacity : settings.dialogMaskOpacity, + backgroundColor : settings.dialogMaskBgColor + }, + buttons : { + enter : [lang.buttons.enter, function() { + var rows = parseInt(this.find("[data-rows]").val()); + var cols = parseInt(this.find("[data-cols]").val()); + var align = this.find("[name=\"table-align\"]:checked").val(); + var table = ""; + var hrLine = "------------"; + + var alignSign = { + _default : hrLine, + left : ":" + hrLine, + center : ":" + hrLine + ":", + right : hrLine + ":" + }; + + if ( rows > 1 && cols > 0) + { + for (var r = 0, len = rows; r < len; r++) + { + var row = []; + var head = []; + + for (var c = 0, len2 = cols; c < len2; c++) + { + if (r === 1) { + head.push(alignSign[align]); + } + + row.push(" "); + } + + if (r === 1) { + table += "| " + head.join(" | ") + " |" + "\n"; + } + + table += "| " + row.join( (cols === 1) ? "" : " | " ) + " |" + "\n"; + } + } + + cm.replaceSelection(table); + + this.hide().lockScreen(false).hideMask(); + cm.focus && cm.focus(); + + return false; + }], + + cancel : [lang.buttons.cancel, function() { + this.hide().lockScreen(false).hideMask(); + cm.focus && cm.focus(); + + return false; + }] + } + }); + } + + var faBtns = dialog.find(".fa-btns"); + + if (faBtns.html() === "") + { + var icons = ["align-justify", "align-left", "align-center", "align-right"]; + var _lang = dialogLang.aligns; + var values = ["_default", "left", "center", "right"]; + + for (var i = 0, len = icons.length; i < len; i++) + { + var checked = (i === 0) ? " checked=\"checked\"" : ""; + var btn = ""; + + faBtns.append(btn); + } + } + }; + + }; + + // CommonJS/Node.js + if (typeof require === "function" && typeof exports === "object" && typeof module === "object") + { + module.exports = factory; + } + else if (typeof define === "function") // AMD/CMD/Sea.js + { + if (define.amd) { // for Require.js + + define(["editormd"], function(editormd) { + factory(editormd); + }); + + } else { // for Sea.js + define(function(require) { + var editormd = require("./../../editormd"); + factory(editormd); + }); + } + } + else + { + factory(window.editormd); + } + +})(); diff --git a/public/images/educoder/xcx/IDCard.png b/public/images/educoder/xcx/IDCard.png new file mode 100644 index 000000000..d64e02a14 Binary files /dev/null and b/public/images/educoder/xcx/IDCard.png differ diff --git a/public/images/educoder/xcx/camera.png b/public/images/educoder/xcx/camera.png new file mode 100644 index 000000000..0c9faedbf Binary files /dev/null and b/public/images/educoder/xcx/camera.png differ diff --git a/public/images/educoder/xcx/myinfobanner.png b/public/images/educoder/xcx/myinfobanner.png new file mode 100644 index 000000000..10046e361 Binary files /dev/null and b/public/images/educoder/xcx/myinfobanner.png differ diff --git a/public/react/public/css/edu-all.css b/public/react/public/css/edu-all.css index f51e0e630..5988709eb 100644 --- a/public/react/public/css/edu-all.css +++ b/public/react/public/css/edu-all.css @@ -80,6 +80,27 @@ em.vertical-line{display: inline-block;width: 2px;background: #999;height: 10px} .inner-footernav li{float: left;height: 50px;width: 80px;text-align: center} .inner-footernav li a{width: 100%;text-align: center;line-height: 50px;color: #888} .inner-footer_con{ width: 1200px; margin: 0 auto;} +.inner-footernavysl{ display: flex;flex-direction:initial;} +.inner-footernavysl li a { + height: 40px; + line-height: 40px; + color:#878786; + font-size: 19px; +} + +.inner-footernavysl li Link { + height: 40px; + line-height: 40px; + color:#878786; +} + +.intermediatecenter{ + width:100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} .footer_con-p{ color: #888; margin-top:10px;} /*banner图*/ .banner{width:100%;height:345px;position: relative;overflow: hidden;border-radius: 10px;} diff --git a/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js b/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js index a06cbbfa7..7cef67aad 100644 --- a/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js +++ b/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js @@ -27,7 +27,6 @@ const Search = Input.Search; const RadioGroup = Radio.Group; const CheckboxGroup = Checkbox.Group; const {Option} = Select; - //学生老师页面 class Studentshavecompletedthelist extends Component { // http://localhost:3007/courses/1309/exercises/722/exercises/student_exercise_list?debug=s @@ -317,6 +316,26 @@ class Studentshavecompletedthelist extends Component { : + record.commit_method===5? + +
    最终调整成绩:{record.efficiencyscore}分
    + }> + 90 ? { + color: '#DD1717', + textAlign: "center" + } : parseInt(record.efficiencyscore) <= 90 ? { + color: '#FF6800', + textAlign: "center" + } : parseInt(record.efficiencyscore) <= 60 ? { + color: '#747A7F', + textAlign: "center", + } : { + color: '#747A7F', + textAlign: "center" + }}>{record.efficiencyscore} +
    + : 90 ? { color: '#DD1717', textAlign: "center" @@ -587,6 +606,30 @@ class Studentshavecompletedthelist extends Component { }}>-- : + record.commit_method===5? + +
    最终调整成绩:{record.efficiencyscore}分
    + }> + 90 ? { + color: '#DD1717', + textAlign: "center", + width:"199px" + } : parseInt(record.efficiencyscore) <= 90 ? { + color: '#FF6800', + textAlign: "center", + width:"199px" + } : parseInt(record.efficiencyscore) <= 60 ? { + color: '#747A7F', + textAlign: "center", + width:"199px" + } : { + color: '#747A7F', + textAlign: "center", + width:"199px" + }}>{record.efficiencyscore} +
    + : 90 ? { color: '#DD1717', textAlign: "center", @@ -845,6 +888,26 @@ class Studentshavecompletedthelist extends Component { }}>-- : + record.commit_method===5? + +
    最终调整成绩:{record.efficiencyscore}分
    + }> + 90 ? { + color: '#DD1717', + textAlign: "center", + } : parseInt(record.efficiencyscore) <= 90 ? { + color: '#FF6800', + textAlign: "center", + } : parseInt(record.efficiencyscore) <= 60 ? { + color: '#747A7F', + textAlign: "center", + } : { + color: '#747A7F', + textAlign: "center", + }}>{record.efficiencyscore} +
    + : 90 ? { color: '#DD1717', textAlign: "center", @@ -1048,6 +1111,26 @@ class Studentshavecompletedthelist extends Component { textAlign: "center",}}>-- : + record.commit_method===5? + +
    最终调整成绩:{record.efficiencyscore}分
    + }> + 90 ? { + color: '#DD1717', + textAlign: "center", + } : parseInt(record.efficiencyscore) <= 90 ? { + color: '#FF6800', + textAlign: "center", + } : parseInt(record.efficiencyscore) <= 60 ? { + color: '#747A7F', + textAlign: "center", + } : { + color: '#747A7F', + textAlign: "center", + }}>{record.efficiencyscore} +
    + : 90 ? { color: '#DD1717', textAlign: "center", @@ -1246,6 +1329,26 @@ class Studentshavecompletedthelist extends Component { textAlign: "center",}}>-- : + record.commit_method===5? + +
    最终调整成绩:{record.efficiencyscore}分
    + }> + 90 ? { + color: '#DD1717', + textAlign: "center", + } : parseInt(record.efficiencyscore) <= 90 ? { + color: '#FF6800', + textAlign: "center", + } : parseInt(record.efficiencyscore) <= 60 ? { + color: '#747A7F', + textAlign: "center", + } : { + color: '#747A7F', + textAlign: "center", + }}>{record.efficiencyscore} +
    + : 90 ? { color: '#DD1717', textAlign: "center", @@ -1401,7 +1504,9 @@ class Studentshavecompletedthelist extends Component { // //console.log("试卷学生未截止"); this.Generatenewdatas(response.data.exercise_users); if (response.data.exercise_types.subjective === 0) { + if (this.state.noclassroom === undefined || this.state.noclassroom === "" || this.state.noclassroom === null) { + console.log("4"); var arr =[]; for(var i=0;i { // 教师列表 - parseInt(tab[0])==0 ? this.setcourse_groupysls(value)} current_status = {this.state.current_status} Commonheadofthetestpaper={this.state.Commonheadofthetestpaper}>:"" + parseInt(tab[0])==0 ? this.setcourse_groupysls(value)} current_status = {this.state.current_status} Commonheadofthetestpaper={this.state.Commonheadofthetestpaper} yslstustate={[`${polls_status[Commonheadofthetestpaper && Commonheadofthetestpaper.exercise_status]}`]}>:"" } {/*统计结果*/} diff --git a/public/react/src/modules/home/shixunsHome.js b/public/react/src/modules/home/shixunsHome.js index 68e37deb6..6439338eb 100644 --- a/public/react/src/modules/home/shixunsHome.js +++ b/public/react/src/modules/home/shixunsHome.js @@ -314,7 +314,7 @@ class ShixunsHome extends Component { } {/*精选实训 改为 开发社区*/} - {shixuntype===true||homedatalist===undefined?"":homedatalist.shixuns.length===0?"":
    + {shixuntype===true||homedatalist===undefined?"":homedatalist.shixuns.length===0?"":

    实训项目

    DEVELOPMENT COMMUNITY

    @@ -411,160 +411,160 @@ class ShixunsHome extends Component { {/*导师排行榜*/} - { homedatalist !== undefined && homedatalist.teachers !== undefined && ( - this.props.user&&this.props.user.main_site===true?
    -
    -
    -

    导师排行榜

    -

    MENTOR RANKING

    -
    - -
    -
      - { - homedatalist===undefined?"":homedatalist.teachers.map((item,key)=>{ - - if(key===1){ - return( -
    • - - - -

      {item.username}

      -
      -
    • - ) - } - })} - { - homedatalist===undefined?"":homedatalist.teachers.map((item,key)=>{ - if(key===0){ - return( -
    • - - - -

      {item.username}

      -
      -
    • - ) - } - })} - { - homedatalist===undefined?"":homedatalist.teachers.map((item,key)=>{ - if(key===2){ - return( -
    • - - - -

      {item.username}

      -
      -
    • - ) - } - })} -
    -
    -
      - { - homedatalist===undefined?"":homedatalist.teachers.map((item,key)=>{ - if(key>2) { - return ( -
    • - - -

      {item.username}

      -
      -
    • - ) - } - })} - - -
    -
    - - -
    -
    :"" - )} + {/* { homedatalist !== undefined && homedatalist.teachers !== undefined && (*/} + {/* this.props.user&&this.props.user.main_site===true?
    */} + {/*
    */} + {/*
    */} + {/*

    导师排行榜

    */} + {/*

    MENTOR RANKING

    */} + {/*
    */} + + {/*
    */} + {/*
      */} + {/* {*/} + {/* homedatalist===undefined?"":homedatalist.teachers.map((item,key)=>{*/} + + {/* if(key===1){*/} + {/* return(*/} + {/*
    • */} + {/* */} + {/* */} + {/* */} + {/*

      {item.username}

      */} + {/*
      */} + {/*
    • */} + {/* )*/} + {/* }*/} + {/* })}*/} + {/* {*/} + {/* homedatalist===undefined?"":homedatalist.teachers.map((item,key)=>{*/} + {/* if(key===0){*/} + {/* return(*/} + {/*
    • */} + {/* */} + {/* */} + {/* */} + {/*

      {item.username}

      */} + {/*
      */} + {/*
    • */} + {/* )*/} + {/* }*/} + {/* })}*/} + {/* {*/} + {/* homedatalist===undefined?"":homedatalist.teachers.map((item,key)=>{*/} + {/* if(key===2){*/} + {/* return(*/} + {/*
    • */} + {/* */} + {/* */} + {/* */} + {/*

      {item.username}

      */} + {/*
      */} + {/*
    • */} + {/* )*/} + {/* }*/} + {/* })}*/} + {/*
    */} + {/*
    */} + {/*
      */} + {/* {*/} + {/* homedatalist===undefined?"":homedatalist.teachers.map((item,key)=>{*/} + {/* if(key>2) {*/} + {/* return (*/} + {/*
    • */} + {/* */} + {/* */} + {/*

      {item.username}

      */} + {/*
      */} + {/*
    • */} + {/* )*/} + {/* }*/} + {/* })}*/} + + + {/*
    */} + {/*
    */} + + + {/*
    */} + {/*
    :""*/} + {/* )}*/} {/*程序员排行榜*/} - { homedatalist !== undefined && homedatalist.students !== undefined && ( - this.props.user&&this.props.user.main_site===true?
    -
    -
    -

    程序员排行榜

    -

    PROGRAMMER RANKING

    -
    -
    -
      - { - homedatalist===undefined?"":homedatalist.students.map((item,key)=>{ - if(key===1){ - return( -
    • - - - -

      {item.username}

      -
      -
    • - ) - } - })} - { - homedatalist===undefined?"":homedatalist.students.map((item,key)=>{ - if(key===0){ - return( -
    • - - - -

      {item.username}

      -
      -
    • - ) - } - })} - { - homedatalist===undefined?"":homedatalist.students.map((item,key)=>{ - if(key===2){ - return( -
    • - - - -

      {item.username}

      -
      -
    • - ) - } - })} -
    -
    -
      - { - homedatalist===undefined?"":homedatalist.students.map((item,key)=>{ - if(key>2) { - return ( -
    • - - -

      {item.username}

      -
      -
    • - ) - } - })} - - -
    -
    -
    -
    :"" - )} + {/*{ homedatalist !== undefined && homedatalist.students !== undefined && (*/} + {/* this.props.user&&this.props.user.main_site===true?
    */} + {/*
    */} + {/*
    */} + {/*

    程序员排行榜

    */} + {/*

    PROGRAMMER RANKING

    */} + {/*
    */} + {/*
    */} + {/*
      */} + {/* {*/} + {/* homedatalist===undefined?"":homedatalist.students.map((item,key)=>{*/} + {/* if(key===1){*/} + {/* return(*/} + {/*
    • */} + {/* */} + {/* */} + {/* */} + {/*

      {item.username}

      */} + {/*
      */} + {/*
    • */} + {/* )*/} + {/* }*/} + {/* })}*/} + {/* {*/} + {/* homedatalist===undefined?"":homedatalist.students.map((item,key)=>{*/} + {/* if(key===0){*/} + {/* return(*/} + {/*
    • */} + {/* */} + {/* */} + {/* */} + {/*

      {item.username}

      */} + {/*
      */} + {/*
    • */} + {/* )*/} + {/* }*/} + {/* })}*/} + {/* {*/} + {/* homedatalist===undefined?"":homedatalist.students.map((item,key)=>{*/} + {/* if(key===2){*/} + {/* return(*/} + {/*
    • */} + {/* */} + {/* */} + {/* */} + {/*

      {item.username}

      */} + {/*
      */} + {/*
    • */} + {/* )*/} + {/* }*/} + {/* })}*/} + {/*
    */} + {/*
    */} + {/*
      */} + {/* {*/} + {/* homedatalist===undefined?"":homedatalist.students.map((item,key)=>{*/} + {/* if(key>2) {*/} + {/* return (*/} + {/*
    • */} + {/* */} + {/* */} + {/*

      {item.username}

      */} + {/*
      */} + {/*
    • */} + {/* )*/} + {/* }*/} + {/* })}*/} + + + {/*
    */} + {/*
    */} + {/*
    */} + {/*
    :""*/} + {/*)}*/}
    diff --git a/public/react/src/modules/paths/PathDetail/Addshixuns.js b/public/react/src/modules/paths/PathDetail/Addshixuns.js new file mode 100644 index 000000000..48951b5e1 --- /dev/null +++ b/public/react/src/modules/paths/PathDetail/Addshixuns.js @@ -0,0 +1,102 @@ +import React, { Component } from 'react'; +import {getImageUrl} from 'educoder'; +import {Modal,Input} from 'antd'; +class Addshixuns extends Component { + constructor(props) { + super(props); + this.state = { + shixunname:undefined, + shixunzero:false + } + } + + handleChange=(e)=>{ + this.setState({ + shixunname:e.target.value, + }) + + if(e.target.value.length>0){ + this.setState({ + shixunzero:false + }) + } + } + + + modalCancel=()=>{ + this.setState({ + shixunname:undefined, + }) + this.props.modalCancel() + } + + //判断是否为空 + getshixunname( str ){ + if ( str == "" ) return true; + var regu = "^[ ]+$"; + var re = new RegExp(regu); + return re.test(str); + } + + modalSave=()=>{ + let {shixunname}=this.state; + if(this.getshixunname(shixunname)===true){ + this.setState({ + shixunzero:true + }) + return + } + if(shixunname===undefined||shixunname.length===0){ + this.setState({ + shixunzero:true + }) + return + } + this.props.Setaddshixuns(shixunname); + this.props.modalCancel(); + } + + render() { + + return( + + {this.props.Addshixunstype===true?:""} + +
    +

    + 实训名称: + + +

    + {this.state.shixunzero===true?

    请输入实训名称

    :""} +
    + 取消 + 确定 +
    + +
    + +
    + ) + } +} + +export default Addshixuns; diff --git a/public/react/src/modules/paths/PathDetail/DetailCards.js b/public/react/src/modules/paths/PathDetail/DetailCards.js index 6bc972a03..fdcbb0297 100644 --- a/public/react/src/modules/paths/PathDetail/DetailCards.js +++ b/public/react/src/modules/paths/PathDetail/DetailCards.js @@ -420,7 +420,35 @@ class DetailCards extends Component{ { idsum===key&&pathCardsedittype===true?'': - this.props.detailInfoList===undefined?"":this.props.detailInfoList.allow_statistics===true? + this.props.detailInfoList===undefined?"": + this.props.current_user&&this.props.current_user.admin===true||this.props.current_user&&this.props.current_user.business===true? + + + { editbuttomtype===true?'': + this.pathCardsedit(key, item.stage_id)}> + + + } + + { + pathCardsList.length=== key+1?"":this.operations(item.down_path)}> + + + + + } + + + {key===0?"": + this.operations(item.up_path)}> + + + + } + + : + this.props.detailInfoList.allow_statistics===true? { editbuttomtype===true?'': @@ -453,7 +481,14 @@ class DetailCards extends Component{ { idsum === key && pathCardsedittype === true ? - this.props.detailInfoList===undefined?"":this.props.detailInfoList.allow_statistics===true? + this.props.detailInfoList===undefined?"": + this.props.current_user&&this.props.current_user.admin===true||this.props.current_user&&this.props.current_user.business===true? + this.delectpathCardsedit(item.stage_id)}> + + + + : + this.props.detailInfoList.allow_statistics===true? this.delectpathCardsedit(item.stage_id)}> @@ -471,8 +506,36 @@ class DetailCards extends Component{
    - { - item.shixuns_list && item.shixuns_list.map((line,index)=>{ + {this.props.current_user&&this.props.current_user.admin===true||this.props.current_user&&this.props.current_user.business===true? + item.shixuns_list && item.shixuns_list.map((line,index)=>{ + return( +
    this.showparagraph(key,index)} onMouseLeave={this.hideparagraph}> + +
  • + + + { + line.complete_status === 1 ? + : + } + + + {key+1}-{index+1}  {line.shixun_name} + + +
  • + + +
  • + { + showparagraphkey===key&&showparagraphindex===index?
    + 查看详情 +
    :"" + } +
  • + +
    ) + }):item.shixuns_list && item.shixuns_list.map((line,index)=>{ return(
    this.showparagraph(key,index)} onMouseLeave={this.hideparagraph}> diff --git a/public/react/src/modules/paths/PathDetail/DetailCardsEditAndAdd.js b/public/react/src/modules/paths/PathDetail/DetailCardsEditAndAdd.js index 159c40475..c054ac0db 100644 --- a/public/react/src/modules/paths/PathDetail/DetailCardsEditAndAdd.js +++ b/public/react/src/modules/paths/PathDetail/DetailCardsEditAndAdd.js @@ -3,6 +3,7 @@ import {getImageUrl} from 'educoder'; import {Modal,Input,Checkbox,Tooltip,Spin,notification} from "antd"; import { DragDropContext , Draggable, Droppable} from 'react-beautiful-dnd'; import Modals from '../../modals/Modals'; +import Addshixuns from './Addshixuns'; import '../ShixunPaths.css'; import axios from 'axios'; import NewShixunModel from '../../courses/coursesPublic/NewShixunModel'; @@ -52,7 +53,8 @@ class DetailCardsEditAndAdd extends Component{ Modalsbottomval:"", ChooseShixunListshixun_list:undefined, stage_nametype:false, - descriptiontype:false + descriptiontype:false, + Addshixunstype:false } this.onDragEnd = this.onDragEnd.bind(this); } @@ -113,9 +115,12 @@ class DetailCardsEditAndAdd extends Component{ for(var z=0; z{ + this.setState({ + Addshixunstype:true, + }) + } + + Getaddshixuns=(value)=>{ + let { + shixuns_listeditlist, + shixuns_listedit, + } = this.state + let newshixuns_listedit=shixuns_listedit; + let list=shixuns_listeditlist + let url='/paths/add_shixun_to_stage.json'; + axios.post(url,{ + name:value + }).then((response) => { + if(response){ + if(response.data){ + newshixuns_listedit.push(response.data); + list.push(response.data.shixun_id); + this.setState({ + shixuns_listedit:newshixuns_listedit, + shixuns_listeditlist:list, + patheditarry:[], + selectShixun:false, + page:1, + }) + } + } + }).catch((error) => { + console.log(error) + }); + } + render(){ let {selectShixun, @@ -340,6 +381,22 @@ class DetailCardsEditAndAdd extends Component{ > + {this.state.Addshixunstype===true?this.Getaddshixuns(value)} + {...this.props} + {...this.state} + />:""} + + { editPanel &&
    @@ -371,13 +428,21 @@ class DetailCardsEditAndAdd extends Component{
    描述不能超多最大限制300个字符
    -

    - +

    + this.Addshixuns()} className="fl defalutGreyBorder color-grey-6 ml37"> - 选用实训项目 - 选择下面实训后,可以通过拖拽进行排序调整 + 新建实训项目

    +

    + this.AddShixunBox()} className="fl defalutGreyBorder color-grey-6 ml37"> + + 选用实训项目 + +

    +

    + 下面实训可以通过拖拽进行排序调整 +

    {selectShixun===true? { this.props.idsum===this.props.keys&&this.props.pathCardsedittype===true?
    @@ -381,13 +428,22 @@ class DetailCardsEditAndEdit extends Component{ >
    描述不能超多最大限制300个字符
    -

    - - 选用实训项目 + +

    + + 新建实训项目 - 选择下面实训后,可以通过拖拽进行排序调整

    +

    + + 选用实训项目 + + +

    +

    + 下面实训可以通过拖拽进行排序调整 +

    {selectShixun===true? + {/*newContainers*/}
    {this.props.user&&this.props.user.main_site===true?
    diff --git a/public/react/src/modules/tpm/NewHeader.js b/public/react/src/modules/tpm/NewHeader.js index cf59a1dc3..ff2f067e4 100644 --- a/public/react/src/modules/tpm/NewHeader.js +++ b/public/react/src/modules/tpm/NewHeader.js @@ -1290,10 +1290,12 @@ submittojoinclass=(value)=>{
    diff --git a/public/react/src/modules/tpm/challengesnew/TPManswer2.js b/public/react/src/modules/tpm/challengesnew/TPManswer2.js index 6cbfcd081..ba38776cd 100644 --- a/public/react/src/modules/tpm/challengesnew/TPManswer2.js +++ b/public/react/src/modules/tpm/challengesnew/TPManswer2.js @@ -177,7 +177,8 @@ export default class TPManswer extends Component { this.props.showSnackbar(response.data.message); } if (response.data.status == 1) { - $("html").animate({ scrollTop: 0 }) + window.location.href=`/shixuns/${id}/challenges`; + // $("html").animate({ scrollTop: 0 }) } } diff --git a/public/react/src/modules/tpm/challengesnew/TPMchallengesnew.js b/public/react/src/modules/tpm/challengesnew/TPMchallengesnew.js index 9da0b79f5..f6bac13a5 100644 --- a/public/react/src/modules/tpm/challengesnew/TPMchallengesnew.js +++ b/public/react/src/modules/tpm/challengesnew/TPMchallengesnew.js @@ -240,8 +240,8 @@ export default class TPMchallengesnew extends Component { }).then((response) => { if (response.data.status === 1) { // $("html").animate({ scrollTop: 0 }) - - window.location.href=`/shixuns/${id}/challenges/${response.data.challenge_id}/editcheckpoint`; + //window.location.href=`/shixuns/${id}/challenges/${response.data.challenge_id}/editcheckpoint?tab=2`; + window.location.href=`/shixuns/${id}/challenges/${response.data.challenge_id}/tab=2`; // this.setState({ // setopen: true, // CreatePracticesendtype:false, @@ -363,6 +363,7 @@ export default class TPMchallengesnew extends Component { }).then((response) => { this.props.showSnackbar(response.data.messages); if (response.data.status === 1) { + window.location.href=`/shixuns/${id}/challenges/${checkpointId}/tab=2`; this.setState({ setopen: true, editPracticesendtype:false, diff --git a/public/react/src/modules/tpm/challengesnew/TPMevaluation.js b/public/react/src/modules/tpm/challengesnew/TPMevaluation.js index f29e9311e..c4e28a883 100644 --- a/public/react/src/modules/tpm/challengesnew/TPMevaluation.js +++ b/public/react/src/modules/tpm/challengesnew/TPMevaluation.js @@ -673,6 +673,7 @@ export default class TPMevaluation extends Component { } ).then((response) => { this.props.showSnackbar(response.data.messages); + window.location.href=`/shixuns/${id}/challenges/${response.data.challenge_id}/tab=3`; // if(response.data.status===1){ // window.location.href = "/shixuns/" + id + "/challenges/"+response.data.challenge_id+"/tab=3" // } diff --git a/public/react/src/modules/tpm/shixunchild/Challenges/Challenges.js b/public/react/src/modules/tpm/shixunchild/Challenges/Challenges.js index 1470d45db..b6d70af87 100644 --- a/public/react/src/modules/tpm/shixunchild/Challenges/Challenges.js +++ b/public/react/src/modules/tpm/shixunchild/Challenges/Challenges.js @@ -380,31 +380,31 @@ class Challenges extends Component {

    全部任务 - {this.props.identity < 5 && ChallengesDataList&&ChallengesDataList.shixun_status=== 0 ? - - - - 实践任务 - - - : "" - } - {this.props.identity < 5 && ChallengesDataList&&ChallengesDataList.shixun_status=== 0 ? - - - - 选择题任务 - - : "" - } + {/*{this.props.identity < 5 && ChallengesDataList&&ChallengesDataList.shixun_status=== 0 ?*/} + {/**/} + {/**/} + {/**/} + {/*实践任务*/} + {/**/} + + {/* : ""*/} + {/*}*/} + {/*{this.props.identity < 5 && ChallengesDataList&&ChallengesDataList.shixun_status=== 0 ?*/} + {/**/} + {/**/} + {/**/} + {/*选择题任务*/} + {/**/} + {/* : ""*/} + {/*}*/}

    diff --git a/public/react/src/modules/user/modal/RealNameCertificationModal.js b/public/react/src/modules/user/modal/RealNameCertificationModal.js index 2d37c4449..bb641af20 100644 --- a/public/react/src/modules/user/modal/RealNameCertificationModal.js +++ b/public/react/src/modules/user/modal/RealNameCertificationModal.js @@ -490,6 +490,13 @@ class RealNameCertificationModal extends Component{ action: this.props.current_user ? `${getUploadActionUrl()}` : '', className: 'idPic-uploader', onChange: this.handleChange2, + beforeUpload: (file) => { + const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/jpg' || file.type === 'image/bmp'; + if (!isJpgOrPng) { + this.props.showNotification('请上传正确文件格式'); + } + return isJpgOrPng; + }, }; // form合并了 @@ -739,7 +746,9 @@ class RealNameCertificationModal extends Component{ avatar - + {imageUrl2 ? // avatar diff --git a/public/react/src/search/SearchPage.js b/public/react/src/search/SearchPage.js index c2afca884..1bf1d83d4 100644 --- a/public/react/src/search/SearchPage.js +++ b/public/react/src/search/SearchPage.js @@ -81,10 +81,11 @@ class SearchPage extends Component{ setdatafuns =(value)=>{ this.setState({ - keywords:value + keywords:value, + page:1 }) this.props.history.replace(`/search?value=${value}`) - this.getdata(this.state.page,this.state.type,value); + this.getdata(1,this.state.type,value); } paginationonChanges = (pageNumber) => { this.setState({ diff --git a/public/stylesheets/educoder/edu-all.css b/public/stylesheets/educoder/edu-all.css index 3ed8a36c3..6fcbd3b5c 100644 --- a/public/stylesheets/educoder/edu-all.css +++ b/public/stylesheets/educoder/edu-all.css @@ -84,6 +84,27 @@ em.vertical-line{display: inline-block;width: 2px;background: #999;height: 10px} .inner-footernav li{float: left;height: 50px;width: 80px;text-align: center} .inner-footernav li a{width: 100%;text-align: center;line-height: 50px;color: #888} .inner-footer_con{ width: 1200px; margin: 0 auto;} +.inner-footernavysl{ display: flex;flex-direction:initial;} +.inner-footernavysl li a { + height: 40px; + line-height: 40px; + color:#878786; + font-size: 19px; +} + +.inner-footernavysl li Link { + height: 40px; + line-height: 40px; + color:#878786; +} + +.intermediatecenter{ + width:100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} .footer_con-p{ color: #888; margin-top:10px;} /*banner图*/ .banner{width:100%;height:345px;position: relative;overflow: hidden;border-radius: 10px;} @@ -3773,4 +3794,4 @@ a.singlepublishtwo{ .fontweightbold{ font-weight: bold !important; -} \ No newline at end of file +}