| @@ -0,0 +1,3 @@ | |||||
| # Place all the behaviors and hooks related to the matching controller here. | |||||
| # All this logic will automatically be available in application.js. | |||||
| # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ | |||||
| @@ -0,0 +1,3 @@ | |||||
| # Place all the behaviors and hooks related to the matching controller here. | |||||
| # All this logic will automatically be available in application.js. | |||||
| # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ | |||||
| @@ -0,0 +1,3 @@ | |||||
| # Place all the behaviors and hooks related to the matching controller here. | |||||
| # All this logic will automatically be available in application.js. | |||||
| # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ | |||||
| @@ -0,0 +1,3 @@ | |||||
| # Place all the behaviors and hooks related to the matching controller here. | |||||
| # All this logic will automatically be available in application.js. | |||||
| # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ | |||||
| @@ -0,0 +1,3 @@ | |||||
| # Place all the behaviors and hooks related to the matching controller here. | |||||
| # All this logic will automatically be available in application.js. | |||||
| # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ | |||||
| @@ -0,0 +1,3 @@ | |||||
| # Place all the behaviors and hooks related to the matching controller here. | |||||
| # All this logic will automatically be available in application.js. | |||||
| # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ | |||||
| @@ -0,0 +1,3 @@ | |||||
| // Place all the styles related to the challenges controller here. | |||||
| // They will automatically be included in application.css. | |||||
| // You can use Sass (SCSS) here: http://sass-lang.com/ | |||||
| @@ -0,0 +1,3 @@ | |||||
| // Place all the styles related to the codes controller here. | |||||
| // They will automatically be included in application.css. | |||||
| // You can use Sass (SCSS) here: http://sass-lang.com/ | |||||
| @@ -0,0 +1,3 @@ | |||||
| // Place all the styles related to the games controller here. | |||||
| // They will automatically be included in application.css. | |||||
| // You can use Sass (SCSS) here: http://sass-lang.com/ | |||||
| @@ -0,0 +1,3 @@ | |||||
| // Place all the styles related to the mark_down controller here. | |||||
| // They will automatically be included in application.css. | |||||
| // You can use Sass (SCSS) here: http://sass-lang.com/ | |||||
| @@ -0,0 +1,3 @@ | |||||
| // Place all the styles related to the myshixuns controller here. | |||||
| // They will automatically be included in application.css. | |||||
| // You can use Sass (SCSS) here: http://sass-lang.com/ | |||||
| @@ -0,0 +1,3 @@ | |||||
| // Place all the styles related to the shixuns controller here. | |||||
| // They will automatically be included in application.css. | |||||
| // You can use Sass (SCSS) here: http://sass-lang.com/ | |||||
| @@ -1,3 +1,4 @@ | |||||
| #coding=utf-8 | |||||
| # Redmine - project management software | # Redmine - project management software | ||||
| # Copyright (C) 2006-2013 Jean-Philippe Lang | # Copyright (C) 2006-2013 Jean-Philippe Lang | ||||
| # | # | ||||
| @@ -42,7 +43,34 @@ class AccountController < ApplicationController | |||||
| redirect_to user_path(User.current) | redirect_to user_path(User.current) | ||||
| end | end | ||||
| else | else | ||||
| render :layout => 'login' | |||||
| render :layout => 'login_bigdata' | |||||
| end | |||||
| else | |||||
| authenticate_user | |||||
| end | |||||
| end | |||||
| def user_join | |||||
| if params[:type] == "activated" | |||||
| @message = l(:notice_account_activated) | |||||
| elsif params[:type] == "expired" | |||||
| @message = l(:notice_account_expired) | |||||
| end | |||||
| if request.get? | |||||
| @login = params[:login] || true | |||||
| if User.current.logged? | |||||
| # 判断用户基本资料是否完善,不完善讲强制完善基本资料,完善进入主页 | |||||
| user = UserExtensions.where(:user_id => User.current.id).first | |||||
| if user.gender.nil? || user.school_id.nil? || User.current.lastname.nil? | |||||
| redirect_to my_account_path(:tip => 1) | |||||
| elsif user.identity == 3 && user.school_id.nil? | |||||
| redirect_to my_account_path(:tip => 1) | |||||
| else | |||||
| redirect_to user_path(User.current) | |||||
| end | |||||
| else | |||||
| render :layout => 'login_bigdata' | |||||
| end | end | ||||
| else | else | ||||
| authenticate_user | authenticate_user | ||||
| @@ -121,7 +149,7 @@ class AccountController < ApplicationController | |||||
| return | return | ||||
| end | end | ||||
| end | end | ||||
| render :layout => 'static_base' | |||||
| render :layout => 'login_bigdata' | |||||
| end | end | ||||
| end | end | ||||
| @@ -145,12 +173,17 @@ class AccountController < ApplicationController | |||||
| end | end | ||||
| else | else | ||||
| us = UsersService.new | us = UsersService.new | ||||
| @user = us.register user_params.merge(:should_confirmation_password => true) | |||||
| @user = us.register user_params.merge(:should_confirmation_password => false) | |||||
| case Setting.self_registration | case Setting.self_registration | ||||
| when '1' | when '1' | ||||
| #register_by_email_activation(@user) | #register_by_email_activation(@user) | ||||
| unless @user.new_record? | unless @user.new_record? | ||||
| redirect_to account_email_valid_path(:mail => @user.mail, :user_id => @user.id) | |||||
| if params[:user][:mail] | |||||
| redirect_to account_email_valid_path(:mail => @user.mail, :user_id => @user.id) | |||||
| else | |||||
| self.logged_user = @user | |||||
| redirect_to my_account_url(:tip=>1) | |||||
| end | |||||
| # flash[:notice] = l(:notice_account_register_done) | # flash[:notice] = l(:notice_account_register_done) | ||||
| # render action: 'email_valid', locals: {:mail => @user.mail} | # render action: 'email_valid', locals: {:mail => @user.mail} | ||||
| end | end | ||||
| @@ -240,6 +273,13 @@ class AccountController < ApplicationController | |||||
| req[:message] = faker.errors[:login] | req[:message] = faker.errors[:login] | ||||
| end | end | ||||
| if valid_attr.eql?('phone') | |||||
| faker.phone = valid_value | |||||
| faker.valid? | |||||
| req[:valid] = faker.errors[:phone].blank? | |||||
| req[:message] = "" | |||||
| end | |||||
| if valid_attr.eql?('mail') | if valid_attr.eql?('mail') | ||||
| faker.mail = valid_value | faker.mail = valid_value | ||||
| faker.valid? | faker.valid? | ||||
| @@ -251,6 +291,141 @@ class AccountController < ApplicationController | |||||
| render :json => req | render :json => req | ||||
| end | end | ||||
| # 手机号或邮箱是否已注册 | |||||
| def valid_register_user | |||||
| req = Hash.new(false) | |||||
| req[:message] = '' | |||||
| valid_attr = params[:valid] | |||||
| valid_value = params[:value] | |||||
| if valid_attr.eql?('phone') | |||||
| user = User.where(:phone => valid_value).first | |||||
| req[:valid] = !user.nil? | |||||
| req[:message] = user.nil? ? "该手机号未注册" : "" | |||||
| elsif valid_attr.eql?('mail') | |||||
| user = User.where(:mail => valid_value).first | |||||
| req[:valid] = !user.nil? | |||||
| req[:message] = user.nil? ? "该邮箱未注册" : "" | |||||
| end | |||||
| render :json => req | |||||
| end | |||||
| # 验证码是否有效 | |||||
| def valid_verification_code | |||||
| req = Hash.new(false) | |||||
| req[:valid] = false | |||||
| type = params[:type].to_i | |||||
| if type == 1 || type == 2 || params[:phone] =~ /^1\d{10}$/ | |||||
| code = VerificationCode.where(:phone => params[:phone], :code => params[:code], :code_type => (params[:type].to_i != 1 && params[:type].to_i != 2) ? 2 : params[:type].to_i ).last | |||||
| else | |||||
| code = VerificationCode.where(:email => params[:phone], :code => params[:code], :code_type => 3).last | |||||
| end | |||||
| req[:valid] = !code.nil? && (Time.now.to_i - code.created_at.to_i) <= 10*60 | |||||
| render :json => req | |||||
| end | |||||
| # 发送验证码:type 1:注册手机验证码 2:找回密码手机验证码 3:找回密码邮箱验证码 | |||||
| def get_verification_code | |||||
| code = %W(0 1 2 3 4 5 6 7 8 9) | |||||
| type = params[:type].to_i | |||||
| req = Hash.new(false) | |||||
| req[:status] = 0 | |||||
| if type == 1 | |||||
| if User.where(:phone => params[:value]).count > 0 | |||||
| req[:status] = 2 | |||||
| else | |||||
| begin | |||||
| verification_code = code.sample(6).join | |||||
| status = Trustie::Sms.send(mobile: params[:value], code: verification_code) | |||||
| if status | |||||
| VerificationCode.create(:phone => params[:value], :status => 1, :code_type => 1, :code => verification_code) | |||||
| end | |||||
| rescue => e | |||||
| Rails.logger.error "发送验证码出错: #{e}" | |||||
| end | |||||
| req[:status] = 1 | |||||
| end | |||||
| else | |||||
| if params[:value] =~ /^[a-zA-Z0-9]+([._\\]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/ | |||||
| if User.where(:mail => params[:value]).count == 0 | |||||
| req[:status] = 2 | |||||
| else | |||||
| begin | |||||
| verification_code = code.sample(6).join | |||||
| user = User.where(:mail => params[:value]).first | |||||
| token = Token.new(:user => user, :action => "recovery") | |||||
| if token.save | |||||
| Mailer.run.lost_password(token, verification_code) | |||||
| VerificationCode.create(:email => params[:value], :status => 1, :code_type => 3, :code => verification_code) | |||||
| end | |||||
| rescue => e | |||||
| Rails.logger.error "发送验证码出错: #{e}" | |||||
| end | |||||
| req[:status] = 3 | |||||
| req[:link] = params[:value].split("@")[1] | |||||
| end | |||||
| elsif params[:value] =~ /^1\d{10}$/ | |||||
| if User.where(:phone => params[:value]).count == 0 | |||||
| req[:status] = 2 | |||||
| else | |||||
| begin | |||||
| verification_code = code.sample(6).join | |||||
| status = Trustie::Sms.send(mobile: params[:value], code: verification_code) | |||||
| if status | |||||
| VerificationCode.create(:phone => params[:value], :status => 1, :code_type => 2, :code => verification_code) | |||||
| end | |||||
| rescue => e | |||||
| Rails.logger.error "发送验证码出错: #{e}" | |||||
| end | |||||
| req[:status] = 1 | |||||
| end | |||||
| else | |||||
| req[:status] = 2 | |||||
| end | |||||
| end | |||||
| render :json => req | |||||
| end | |||||
| def wechat_bind | |||||
| respond_to do |format| | |||||
| format.html { render :layout => "login_bigdata"} | |||||
| end | |||||
| end | |||||
| def reset_psd | |||||
| if request.get? | |||||
| @user = User.where("phone = '#{params[:value]}' or mail = '#{params[:value]}'").first | |||||
| if @user | |||||
| respond_to do |format| | |||||
| format.html { render :layout => "login_bigdata"} | |||||
| end | |||||
| else | |||||
| redirect_to signin_path | |||||
| return | |||||
| end | |||||
| else | |||||
| @user = User.find params[:user] | |||||
| if @user | |||||
| @user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation] | |||||
| if @user.save | |||||
| Token.where(:user_id => @user, :action => "recovery").destroy_all | |||||
| respond_to do |format| | |||||
| format.js | |||||
| end | |||||
| else | |||||
| redirect_to signin_path | |||||
| return | |||||
| end | |||||
| else | |||||
| redirect_to signin_path | |||||
| return | |||||
| end | |||||
| end | |||||
| end | |||||
| def email_valid | def email_valid | ||||
| begin | begin | ||||
| @mail_type = params[:mail].split("@")[1] | @mail_type = params[:mail].split("@")[1] | ||||
| @@ -259,7 +434,7 @@ class AccountController < ApplicationController | |||||
| return render_404 | return render_404 | ||||
| end | end | ||||
| respond_to do |format| | respond_to do |format| | ||||
| format.html { render :layout => "base_mail"} | |||||
| format.html { render :layout => "login_bigdata"} | |||||
| format.js | format.js | ||||
| end | end | ||||
| end | end | ||||
| @@ -282,14 +457,15 @@ class AccountController < ApplicationController | |||||
| def change_email | def change_email | ||||
| user = User.find params[:user_id].to_i | user = User.find params[:user_id].to_i | ||||
| user.update_attributes(:mail => params[:value]) | user.update_attributes(:mail => params[:value]) | ||||
| result = {:email => user.mail} | |||||
| token = Token.create(:user => user, :action => "register") | |||||
| Mailer.run.register(token) | |||||
| result = {:email => user.mail, :email_link => user.mail.split("@")[1]} | |||||
| render :json => result | render :json => result | ||||
| end | end | ||||
| def email_activation | def email_activation | ||||
| end | end | ||||
| private | private | ||||
| @@ -429,7 +605,7 @@ class AccountController < ApplicationController | |||||
| logger.warn "Failed login for '#{params[:username]}' from #{request.remote_ip} at #{Time.now.utc}" | logger.warn "Failed login for '#{params[:username]}' from #{request.remote_ip} at #{Time.now.utc}" | ||||
| # flash[:error] = l(:notice_account_invalid_creditentials_new) | # flash[:error] = l(:notice_account_invalid_creditentials_new) | ||||
| # render signin_path(:login=>true) | # render signin_path(:login=>true) | ||||
| render :action => 'email_activation' | |||||
| render :action => 'email_activation',:layout => 'login_bigdata' | |||||
| end | end | ||||
| # Register a user for email activation. | # Register a user for email activation. | ||||
| @@ -432,6 +432,8 @@ class ApplicationController < ActionController::Base | |||||
| def find_project_by_project_id | def find_project_by_project_id | ||||
| if params[:project_id] | if params[:project_id] | ||||
| @project = Project.find(params[:project_id]) | @project = Project.find(params[:project_id]) | ||||
| elsif params[:shixun_id] | |||||
| @shixun = Shixun.find(params[:shixun_id]) | |||||
| elsif params[:course_id] | elsif params[:course_id] | ||||
| @course = Course.find(params[:course_id]) | @course = Course.find(params[:course_id]) | ||||
| elsif params[:org_subfield_id] | elsif params[:org_subfield_id] | ||||
| @@ -0,0 +1,209 @@ | |||||
| # encoding: utf-8 | |||||
| class ChallengesController < ApplicationController | |||||
| layout "base_shixun" | |||||
| before_filter :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build] | |||||
| before_filter :find_challenge, :only => [:show, :edit, :update, :challenge_build, :index_up, :index_down, :destroy] | |||||
| before_filter :build_challege_from_params, :only => [:new, :create] | |||||
| before_filter :tpi_manager_allowed, :only => [:challenge_build, :destroy, :show, :edit, :new, :create] | |||||
| before_filter :query_challeges, :only => [:show, :edit, :update] | |||||
| before_filter :find_shixun_language, :only => [:show, :new, :edit] | |||||
| include ApplicationHelper | |||||
| def new | |||||
| # 顶部导航 | |||||
| @project_menu_type = 11 | |||||
| respond_to do |format| | |||||
| format.html { render :action => 'new', :layout => 'base_shixun' } | |||||
| end | |||||
| end | |||||
| def create | |||||
| challenge_count = @shixun.challenges.count | |||||
| @challenge = Challenge.new(params[:challenge]) | |||||
| @challenge.position = challenge_count + 1 | |||||
| @challenge.shixun = @shixun | |||||
| @challenge.user = User.current | |||||
| if @challenge.save | |||||
| if params[:sample][:input].length > 0 | |||||
| params[:sample][:input].each_with_index do |value, index| | |||||
| unless (value == params[:sample][:output][index] && value.blank?) | |||||
| ChallengeSample.create(:challenge_id => @challenge.id, :input => value, :output => params[:sample][:output][index]) | |||||
| end | |||||
| end | |||||
| end | |||||
| if params[:program][:output].length > 0 | |||||
| params[:program][:output].each do |output| | |||||
| TestSet.create(:challenge_id => @challenge.id, :input => nil, :output => output) | |||||
| end | |||||
| end | |||||
| unless params[:knowledge].blank? | |||||
| params[:knowledge][:input].each do |input| | |||||
| ChallengeTag.create(:name => input, :challenge_id => @challenge.id) | |||||
| end | |||||
| end | |||||
| respond_to do |format| | |||||
| format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun), notice: '创建成功!'} | |||||
| end | |||||
| else | |||||
| respond_to do |format| | |||||
| format.html { render :action => 'new' } | |||||
| end | |||||
| end | |||||
| end | |||||
| def index | |||||
| # 顶部导航 | |||||
| @challenges = @shixun.challenges.order("position desc") | |||||
| respond_to do |format| | |||||
| format.js | |||||
| format.html | |||||
| end | |||||
| rescue ActiveRecord::RecordNotFound | |||||
| render_404 | |||||
| end | |||||
| def show | |||||
| respond_to do |format| | |||||
| format.html | |||||
| format.js | |||||
| end | |||||
| end | |||||
| def edit | |||||
| end | |||||
| def destroy | |||||
| @challenge.destroy | |||||
| respond_to do |format| | |||||
| format.html{redirect_to shixun_challenges_path(@shixun)} | |||||
| end | |||||
| end | |||||
| def update | |||||
| respond_to do |format| | |||||
| if @challenge.update_attributes(params[:challenge]) | |||||
| ActiveRecord::Base.transaction do | |||||
| @challenge_samples.delete_all unless @challenge_samples.blank? | |||||
| @test_sets.delete_all unless @test_sets.blank? | |||||
| @challenge_tags.delete_all unless @challenge_tags.blank? | |||||
| if params[:sample][:input].length > 0 | |||||
| params[:sample][:input].each_with_index do |value, index| | |||||
| unless (value == params[:sample][:output][index] && value.blank?) | |||||
| ChallengeSample.create(:challenge_id => @challenge.id, :input => value, :output => params[:sample][:output][index]) | |||||
| end | |||||
| end | |||||
| end | |||||
| if params[:program][:output].length > 0 | |||||
| params[:program][:output].each do |output| | |||||
| TestSet.create(:challenge_id => @challenge.id, :input => nil, :output => output) | |||||
| end | |||||
| end | |||||
| unless params[:knowledge].blank? | |||||
| params[:knowledge][:input].each do |input| | |||||
| ChallengeTag.create(:name => input, :challenge_id => @challenge.id) | |||||
| end | |||||
| end | |||||
| end | |||||
| format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun), notice: '更新成功!'} | |||||
| format.json { head :no_content } | |||||
| else | |||||
| format.html { render action: "edit" } | |||||
| format.json { render json: @challenge.errors } | |||||
| end | |||||
| end | |||||
| end | |||||
| def index_down | |||||
| next_challenge = @challenge.next_challenge | |||||
| position = @challenge.position | |||||
| @challenge.update_attribute(:position, (position + 1)) | |||||
| next_challenge.update_attribute(:position, next_challenge.position - 1) | |||||
| @challenges = @shixun.challenges | |||||
| end | |||||
| def index_up | |||||
| position = @challenge.position | |||||
| last_challenge = @challenge.last_challenge | |||||
| @challenge.update_attribute(:position, (position - 1)) | |||||
| last_challenge.update_attribute(:position, last_challenge.position + 1) | |||||
| @challenges = @shixun.challenges | |||||
| end | |||||
| # build job 只负责发送请求 | |||||
| def challenge_build | |||||
| gitUrl = git_repository_url(@shixun, "Shixun") | |||||
| gitUrl = Base64.encode64(gitUrl) | |||||
| taskId = params[:id] | |||||
| jobName = @shixun.forked_form | |||||
| step = @challenge.position | |||||
| jenkins_shixuns = Redmine::Configuration['jenkins_shixuns'] | |||||
| if @challenge.status == 0 | |||||
| params = {:jobName => "#{jobName}", :taskId => "#{taskId}", :step => "#{step}", :gitUrl => "#{gitUrl}"} | |||||
| uri = URI("#{jenkins_shixuns}/jenkins-exec/api/buildJob") | |||||
| res = uri_exec uri, params | |||||
| # @challenge.update_attribute(:status, 1) | |||||
| end | |||||
| respond_to do |format| | |||||
| format.js | |||||
| end | |||||
| end | |||||
| private | |||||
| def count_input input, output | |||||
| if input.length == 0 && output.length == 0 | |||||
| result = 0 | |||||
| else | |||||
| if input.length > output.length | |||||
| end | |||||
| end | |||||
| end | |||||
| def tpi_manager_allowed | |||||
| unless (User.current.manager_of_shixun?(@shixun) || User.current.admin?) | |||||
| render_403 | |||||
| end | |||||
| end | |||||
| def build_challege_from_params | |||||
| if params[:id].blank? | |||||
| @challenge = Challenge.new | |||||
| @challenge.shixun = @shixun | |||||
| else | |||||
| @challenge = @shixun.challenges.find(params[:id]) | |||||
| end | |||||
| @challenge.shixun = @shixun | |||||
| @challenge.user ||= User.current | |||||
| end | |||||
| def query_challeges | |||||
| @challenge_samples = @challenge.challenge_samples | |||||
| @test_sets = @challenge.test_sets | |||||
| @challenge_tags = @challenge.challenge_tags | |||||
| end | |||||
| def find_challenge | |||||
| @challenge = Challenge.find(params[:id]) | |||||
| @shixun = @challenge.shixun | |||||
| rescue ActiveRecord::RecordNotFound | |||||
| render_404 | |||||
| end | |||||
| # Find project of id params[:id] | |||||
| def find_shixun | |||||
| shixun_id = params[:shixun_id] || (params[:challenge] && params[:challenge][:shixun_id]) | |||||
| @shixun = Shixun.find(shixun_id) | |||||
| rescue ActiveRecord::RecordNotFound | |||||
| render_404 | |||||
| end | |||||
| def find_shixun_language | |||||
| language = @shixun.language | |||||
| @language = language_switch language | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,2 @@ | |||||
| class CodesController < ApplicationController | |||||
| end | |||||
| @@ -0,0 +1,255 @@ | |||||
| #coding=utf-8 | |||||
| class GamesController < ApplicationController | |||||
| layout "base_myshixun" | |||||
| skip_before_filter :verify_authenticity_token, :only => [:file_update] | |||||
| before_filter :find_myshixun, :only => [:index] | |||||
| before_filter :find_game, :only => [:show, :game_build, :entry,:next_step, :outputs_show, :file_edit, :file_update, :game_status, :change_status] | |||||
| before_filter :find_repository, :only => [:show, :entry, :file_edit, :file_update] | |||||
| before_filter :allowd_manager | |||||
| before_filter :allowd_view, :only => [:show] | |||||
| before_filter :find__shixun_language, :only => [:show, :entry] | |||||
| include ApplicationHelper | |||||
| def index | |||||
| @games = @myshixun.games.includes(:challenge) | |||||
| @games_count = @games.count | |||||
| respond_to do |format| | |||||
| format.html | |||||
| format.js | |||||
| end | |||||
| end | |||||
| # mushixun的版本库必须创建时就创建 | |||||
| # 首次进入版本库自动打开文件 | |||||
| # path:"" && path: @game.path | |||||
| def show | |||||
| @game_challenge = @game.challenge | |||||
| logger.info("test ................#{@game_challenge.id}") | |||||
| game_path = (@game_challenge.path.blank? ? @path : @game_challenge.path.strip) | |||||
| logger.info("test game_path ................#{game_path}") | |||||
| @rev = @rev.nil? ? "master" : @rev | |||||
| @git_url = git_repository_url(@myshixun, "Myshixun") | |||||
| @type = params[:type] | |||||
| logger.info("##########************languae is #{@language}") | |||||
| logger.info("out is666************#{@path} ") | |||||
| # 默认打开文件 | |||||
| if @path == "" && !game_path.nil? && !@repository.cat(game_path, @rev).blank? && @type != "root" | |||||
| @path = game_path | |||||
| @file_open = true | |||||
| logger.info("666666666666************languae ") | |||||
| logger.info("path is666************#{@path} ") | |||||
| @content = @repository.cat(@path, @rev) | |||||
| logger.info("666666666666************languae is #{@content}") | |||||
| else | |||||
| logger.info("77777************languae ") | |||||
| @entries = @repository.entries(@path, @rev) | |||||
| logger.info("7777************#{@entries} ") | |||||
| end | |||||
| logger.info("88888************#{@entries} ") | |||||
| @latest_output = @game.latest_output.try(:out_put).to_s | |||||
| outputs = @game.outputs | |||||
| (@myshixun.games.count == @game_challenge.position && @game.status ==2) ? @had_done = 1 : @had_done = 0 | |||||
| if outputs.count == 0 | |||||
| @results = [] | |||||
| else | |||||
| @results = outputs.map{|result| [result.code, result.id]} | |||||
| end | |||||
| logger.info("##################languae is #{@language}") | |||||
| logger.info("##################latest_output is #{@latest_output}") | |||||
| logger.info("##################had_done is #{@had_done}") | |||||
| logger.info("##################status is #{@game.status}") | |||||
| logger.info("##################result is #{@results}") | |||||
| respond_to do |format| | |||||
| format.html | |||||
| format.js | |||||
| end | |||||
| rescue Exception => e | |||||
| flash[:error] = e.message | |||||
| end | |||||
| # 代码预览 | |||||
| def entry | |||||
| entry_and_raw(false) | |||||
| @content = @repository.cat(@path, @rev) | |||||
| end | |||||
| def file_edit | |||||
| # entry_and_raw(false) | |||||
| # @content = @repository.cat(@path, @rev).strip | |||||
| # # respond_to do |format| | |||||
| # # format.js | |||||
| # end | |||||
| end | |||||
| def file_update | |||||
| @g = Gitlab.client | |||||
| content = params[:content].strip | |||||
| @g.edit_file(@myshixun.gpid, :content => params[:content], :file_path => @path, :branch_name => @rev, :commit_message => "shixun exec") | |||||
| respond_to do |format| | |||||
| format.js{redirect_to entry_myshixun_game_path(@game, :myshixun_id => @myshixun, :path => @path)} | |||||
| end | |||||
| rescue Exception => e | |||||
| puts e.message | |||||
| end | |||||
| # json调用,显示左边的隐藏具体详情@game 字段 msg | |||||
| # 刷新右边的输出结果 @game out_put | |||||
| def outputs_show | |||||
| @output = Output.find(params[:game_output_id]) | |||||
| respond_to do |format| | |||||
| format.js | |||||
| end | |||||
| end | |||||
| # status 0: 未提交测评或者提交测评失败后报错;1:中间状态还没返回值;2:返回值并成功 | |||||
| def game_build | |||||
| game_challenge = @game.challenge | |||||
| gitUrl = git_repository_url(@myshixun, "Myshixun") | |||||
| gitUrl = Base64.encode64(gitUrl) | |||||
| taskId = params[:id] | |||||
| jobName = "myshixun_#{@myshixun.id}" | |||||
| ActiveRecord::Base.transaction do | |||||
| @game.update_attributes!(:status => 1) | |||||
| testCode = {} | |||||
| test_sets = game_challenge.test_sets | |||||
| unless test_sets.blank? | |||||
| test_sets.each_with_index do |test_set, index| | |||||
| testCode.store("testCode_#{index}",test_set.try(:output)) | |||||
| end | |||||
| end | |||||
| testCode = testCode.to_json | |||||
| jenkins_shixuns = Redmine::Configuration['jenkins_shixuns'] | |||||
| step = game_challenge.try(:position) | |||||
| params = {:jobName => "#{jobName}", :taskId => "#{taskId}", :step => "#{step}", :gitUrl => "#{gitUrl}", :testCode => "#{testCode}"} | |||||
| uri = URI("#{jenkins_shixuns}/jenkins-exec/api/buildJob") | |||||
| res = uri_exec uri, params | |||||
| if (res && res['code'] != 0) | |||||
| raise("Build job failed") | |||||
| end | |||||
| render :json => {data:"success"} | |||||
| end | |||||
| rescue | |||||
| raise ActiveRecord::Rollback | |||||
| redirect_to myshixun_game_path(@game, :myshixun_id => @myshixun) | |||||
| end | |||||
| def game_status | |||||
| outputs = @game.outputs | |||||
| game_challenge = @game.challenge | |||||
| if outputs.count == 0 | |||||
| outputs = "" | |||||
| else | |||||
| outputs = outputs.map{|result| [result.code, result.id]} | |||||
| end | |||||
| (@myshixun.games.count == game_challenge.position && @game.status ==2) ? had_done = 1 : had_done = 0 | |||||
| # 下一关自动开启 | |||||
| if had_done != 1 && @game.status == 2 | |||||
| @game.next_game.update_attribute(:status, 0) | |||||
| end | |||||
| latest_output = @game.latest_output.try(:out_put) | |||||
| render :json => {status: @game.status, output: latest_output, results: outputs, had_done: had_done} | |||||
| end | |||||
| def change_status | |||||
| @game.update_attribute(:status, 0) | |||||
| outputs = @game.outputs | |||||
| if outputs.count == 0 | |||||
| outputs = "" | |||||
| else | |||||
| outputs = outputs.map{|result| [result.code, result.id]} | |||||
| end | |||||
| render :json => {status: @game.status, output: "服务器网络异常", results: outputs, had_done: 0} | |||||
| end | |||||
| # 自动推送下一个任务 | |||||
| def next_step | |||||
| render_403 if @game.status != 2 | |||||
| next_game = @game.next_game | |||||
| next_game.update_attribute(:status, 0) if next_game.status == 3 | |||||
| respond_to do |format| | |||||
| format.js{redirect_to myshixun_game_path(next_game, :myshixun_id => @myshixun.id)} | |||||
| end | |||||
| end | |||||
| private | |||||
| def entry_and_raw(is_raw) | |||||
| @entry = @repository.entry(@path, @rev) | |||||
| (show_error_not_found; return) unless @entry | |||||
| # If the entry is a dir, show the browser | |||||
| (show; return) if @entry.is_dir? | |||||
| @content = @repository.cat(@path, @rev) | |||||
| (show_error_not_found; return) unless @content | |||||
| if is_raw || (@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) || !is_entry_text_data?(@content, @path) | |||||
| # Force the download | |||||
| send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) } | |||||
| send_type = Redmine::MimeType.of(@path) | |||||
| send_opt[:type] = send_type.to_s if send_type | |||||
| send_opt[:disposition] = (Redmine::MimeType.is_type?('image', @path) && !is_raw ? 'inline' : 'attachment') | |||||
| send_data @content, send_opt | |||||
| else | |||||
| # Prevent empty lines when displaying a file with Windows style eol | |||||
| # TODO: UTF-16 | |||||
| # Is this needs? AttachmentsController reads file simply. | |||||
| @content.gsub!("\r\n", "\n") | |||||
| @changeset = @repository.find_changeset_by_name(@rev) | |||||
| end | |||||
| end | |||||
| def is_entry_text_data?(ent, path) | |||||
| # UTF-16 contains "\x00". | |||||
| # It is very strict that file contains less than 30% of ascii symbols | |||||
| # in non Western Europe. | |||||
| return true if Redmine::MimeType.is_type?('text', path) | |||||
| # Ruby 1.8.6 has a bug of integer divisions. | |||||
| # http://apidock.com/ruby/v1_8_6_287/String/is_binary_data%3F | |||||
| return false if ent.is_binary_data? | |||||
| true | |||||
| end | |||||
| def find_repository | |||||
| @repository = @myshixun.repository | |||||
| render_404 if @myshixun.gpid.nil? | |||||
| @path = params[:path].is_a?(Array) ? params[:path].join('/') : params[:path].to_s | |||||
| @g = Gitlab.client | |||||
| @g_project = @g.project(@myshixun.gpid) | |||||
| @g_default_branch = @g_project.default_branch | |||||
| # gitlab端获取默认分支 | |||||
| @rev = params[:rev].blank? ? @g_default_branch : params[:rev].to_s.strip | |||||
| rescue ActiveRecord::RecordNotFound | |||||
| render_404 | |||||
| end | |||||
| def allowd_manager | |||||
| render_403 unless (User.current.manager_of_myshixun?(@myshixun) || User.current.admin? || User.current.id == @myshixun.shixun.try(:user_id)) | |||||
| end | |||||
| # 判断成员是否允许查看 | |||||
| def allowd_view | |||||
| render_403 if @game.status == 3 | |||||
| end | |||||
| def find__shixun_language | |||||
| language = @myshixun.shixun.try(:language) | |||||
| @language = language_switch(language) | |||||
| end | |||||
| # Find myshixun of id params[:id] | |||||
| def find_myshixun | |||||
| myshixun_id = params[:myshixun_id] || (params[:game] && params[:game][:myshixun_id]) | |||||
| @myshixun = Myshixun.find(myshixun_id) | |||||
| rescue ActiveRecord::RecordNotFound | |||||
| render_404 | |||||
| end | |||||
| def find_game | |||||
| @game = Game.find(params[:id]) | |||||
| @myshixun = @game.myshixun | |||||
| rescue ActiveRecord::RecordNotFound | |||||
| render_404 | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,14 @@ | |||||
| class MarkDownController < ApplicationController | |||||
| layout "base_md" | |||||
| def new | |||||
| end | |||||
| def create | |||||
| end | |||||
| def show | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,48 @@ | |||||
| class MyshixunsController < ApplicationController | |||||
| layout 'base_myshixun' | |||||
| skip_before_filter :verify_authenticity_token, :only => [:training_task_status] | |||||
| before_filter :require_login, :except => [:training_task_status] | |||||
| before_filter :find_myshixun, :only => [:show] | |||||
| # taskId 即返回的game id | |||||
| # params [:stauts] 0 表示成功,其它则失败 | |||||
| # msg 错误信息 | |||||
| # output 为测试用户编译输出结果 | |||||
| # myshixun:status 1为完成实训 | |||||
| def training_task_status | |||||
| status = params[:status].to_i | |||||
| task_id = params[:taskId] | |||||
| outPut = Base64.decode64(params[:outPut]) unless params[:outPut].blank? | |||||
| message = Base64.decode64(params[:msg]) unless params[:msg].blank? | |||||
| game = Game.find(task_id) | |||||
| challenge = game.challenge | |||||
| if status == 0 | |||||
| myshixun = game.myshixun | |||||
| games_count = myshixun.games.count | |||||
| if challenge.position == games_count | |||||
| myshixun.update_attribute(:status, 1) | |||||
| end | |||||
| game_outputs = Output.create(:code => status, :msg => message, :game_id => task_id, :out_put => outPut) | |||||
| game.update_attribute(:status, 2) | |||||
| game.update_attribute(:final_score, challenge.score) | |||||
| else | |||||
| game_outputs = Output.create(:code => status, :msg => message, :game_id => task_id, :out_put => outPut) | |||||
| game.update_attribute(:status, 0) | |||||
| end | |||||
| render :json => {:data => "success"} | |||||
| end | |||||
| def show | |||||
| respond_to do |format| | |||||
| format.html{redirect_to myshixun_game_path(@myshixun.current_task, :myshixun_id => @myshixun)} | |||||
| end | |||||
| end | |||||
| private | |||||
| # Find myshixun of id params[:id] | |||||
| def find_myshixun | |||||
| @myshixun = Myshixun.find(params[:id]) | |||||
| rescue ActiveRecord::RecordNotFound | |||||
| render_404 | |||||
| end | |||||
| end | |||||
| @@ -35,13 +35,18 @@ class RepositoriesController < ApplicationController | |||||
| before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo, :stats, :quality_analysis] | before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo, :stats, :quality_analysis] | ||||
| before_filter :find_repository, :only => [:edit, :update, :destroy, :committers] | before_filter :find_repository, :only => [:edit, :update, :destroy, :committers] | ||||
| before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked, :export_rep_static, :training_project_extend] | |||||
| before_filter :find_project_repository, :except => [:commits, :shixun_show, :new, :create, :newcreate, :edit, :update, :destroy, :committers, | |||||
| :newrepo, :to_gitlab, :forked, :export_rep_static, :training_project_extend, :shixun_entry] | |||||
| # 实训项目新增 | |||||
| before_filter :find_project_and_repository, :only => [:commits, :shixun_show, :shixun_entry] | |||||
| # 连接gitlab | # 连接gitlab | ||||
| # before_filter :connect_gitlab, :only => [:quality_analysis, :commit_diff] | # before_filter :connect_gitlab, :only => [:quality_analysis, :commit_diff] | ||||
| before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue] | before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue] | ||||
| # before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :project_archive, :quality_analysis, :commit_diff] | # before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :project_archive, :quality_analysis, :commit_diff] | ||||
| before_filter :authorize_visible , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :project_archive, :quality_analysis, :commit_diff] | |||||
| before_filter :authorize_visible , :except => [:shixun_show, :newrepo,:newcreate,:fork, :to_gitlab, :forked, :project_archive, :quality_analysis, :commit_diff] | |||||
| # 版本库新增权限 | # 版本库新增权限 | ||||
| # before_filter :show_rep, :only => [:show, :stats, :revisions, :revision, :diff, :commit_diff ] | # before_filter :show_rep, :only => [:show, :stats, :revisions, :revision, :diff, :commit_diff ] | ||||
| accept_rss_auth :revisions | accept_rss_auth :revisions | ||||
| @@ -346,37 +351,67 @@ update | |||||
| } | } | ||||
| def create | def create | ||||
| # 判断版本库创建者是否有同名版本库,避免版本库路径一致问题 | |||||
| unless is_sigle_identifier?(@project.user_id, params[:repository].first[1]) | |||||
| flash[:notice] = l(:project_gitlab_create_double_message) | |||||
| redirect_to settings_project_url(@project, :tab => 'repositories') | |||||
| else | |||||
| attrs = pickup_extra_info | |||||
| @repository = Repository.factory('Git') | |||||
| @repository.safe_attributes = params[:repository] | |||||
| if attrs[:attrs_extra].keys.any? | |||||
| @repository.merge_extra_info(attrs[:attrs_extra]) | |||||
| end | |||||
| @repository.project = @project | |||||
| # 实训项目 | |||||
| if @shixun | |||||
| # REDO:报错信息处理 | |||||
| @repository = Repository.new | |||||
| @repository.shixun = @shixun | |||||
| @repository.type = 'Repository::Gitlab' | @repository.type = 'Repository::Gitlab' | ||||
| @repository.identifier = @repository.identifier.downcase | |||||
| @repository.identifier = params[:repository][:identifier].downcase | |||||
| @repository.url = @repository.identifier | @repository.url = @repository.identifier | ||||
| @repository.project_id = -1 | |||||
| ActiveRecord::Base.transaction do | ActiveRecord::Base.transaction do | ||||
| begin | |||||
| if request.post? && @repository.save | if request.post? && @repository.save | ||||
| s = Trustie::Gitlab::Sync.new | |||||
| s.create_project(@project, @repository) | |||||
| raise "sync failed" if @project.gpid.blank? | |||||
| redirect_to(:controller => 'repositories', :action => 'show', :id => @project, :repository_id => gitlab_repository(@project).try(:identifier)) | |||||
| begin | |||||
| s = Trustie::Gitlab::Sync.new | |||||
| gproject = s.create_shixun(@shixun, @repository) | |||||
| raise "sync failed" if @shixun.gpid.blank? | |||||
| redirect_to(:controller => 'repositories', :action => 'shixun_show', :id => @shixun, :repository_id => shixun_repository(@shixun).try(:identifier)) | |||||
| rescue Exception => e | |||||
| @shixun.update_attribute(:gpid, nil) | |||||
| if @repository.id | |||||
| @repository.destroy | |||||
| end | |||||
| end | |||||
| else | else | ||||
| redirect_to settings_project_url(@project, :tab => 'repositories',:repository_error_message=>@repository.errors.full_messages) | |||||
| respond_to do |format| | |||||
| format.js{flash[:notice] = l(:notice_failed_create)} | |||||
| end | |||||
| end | |||||
| end | |||||
| elsif @project | |||||
| # 判断版本库创建者是否有同名版本库,避免版本库路径一致问题 | |||||
| unless is_sigle_identifier?(@project.user_id, params[:repository].first[1]) | |||||
| flash[:notice] = l(:project_gitlab_create_double_message) | |||||
| redirect_to settings_project_url(@project, :tab => 'repositories') | |||||
| else | |||||
| attrs = pickup_extra_info | |||||
| @repository = Repository.factory('Git') | |||||
| @repository.safe_attributes = params[:repository] | |||||
| if attrs[:attrs_extra].keys.any? | |||||
| @repository.merge_extra_info(attrs[:attrs_extra]) | |||||
| end | |||||
| @repository.project = @project | |||||
| @repository.type = 'Repository::Gitlab' | |||||
| @repository.identifier = @repository.identifier.downcase | |||||
| @repository.url = @repository.identifier | |||||
| ActiveRecord::Base.transaction do | |||||
| begin | |||||
| if request.post? && @repository.save | |||||
| s = Trustie::Gitlab::Sync.new | |||||
| s.create_project(@project, @repository) | |||||
| raise "sync failed" if @project.gpid.blank? | |||||
| redirect_to(:controller => 'repositories', :action => 'show', :id => @project, :repository_id => gitlab_repository(@project).try(:identifier)) | |||||
| else | |||||
| redirect_to settings_project_url(@project, :tab => 'repositories',:repository_error_message=>@repository.errors.full_messages) | |||||
| end | |||||
| rescue Gitlab::Error::Forbidden => e | |||||
| @message = l(:label_pull_request_forbidden) | |||||
| rescue Gitlab::Error::NotFound => e | |||||
| @message = l(:label_pull_request_notfound) | |||||
| rescue Exception => e | |||||
| puts e | |||||
| end | end | ||||
| rescue Gitlab::Error::Forbidden => e | |||||
| @message = l(:label_pull_request_forbidden) | |||||
| rescue Gitlab::Error::NotFound => e | |||||
| @message = l(:label_pull_request_notfound) | |||||
| rescue Exception => e | |||||
| puts e | |||||
| end | end | ||||
| end | end | ||||
| end | end | ||||
| @@ -486,6 +521,40 @@ update | |||||
| redirect_to :controller => 'repositories', :action => 'show', :id => @project.id, to: 'gitlab' | redirect_to :controller => 'repositories', :action => 'show', :id => @project.id, to: 'gitlab' | ||||
| end | end | ||||
| def shixun_show | |||||
| # 顶部导航 | |||||
| @project_menu_type = 5 | |||||
| @entries = @repository.entries(@path, @rev) | |||||
| if request.xhr? | |||||
| @entries ? render(:partial => 'dir_list_content') : render(:nothing => true) | |||||
| else | |||||
| @changesets_latest_coimmit = @g.rep_last_changes(@shixun.gpid, :rev => @rev, :path => @path) | |||||
| # @g.rep_last_changes(@project.gpid, :rev => @rev, :path => @path) | |||||
| # 总的提交数 | |||||
| @changesets_all_count = @g.user_static(@shixun.gpid, :rev => @rev).count | |||||
| # 获取默认分支 | |||||
| @g_default_branch = @g_project.default_branch.nil? ? "master" : @g_project.default_branch | |||||
| @creator = @shixun.owner.to_s | |||||
| gitlab_address = Redmine::Configuration['gitlab_address'] | |||||
| gitlab_token = Gitlab.private_token | |||||
| # token值加密解密 | |||||
| token = aes_encrypt("priEn3UwXfJs3Pmy", gitlab_token) | |||||
| # token值解密 | |||||
| # gitlab_token = aes_dicrypt("priEn3UwXfJs3Pmy", token) | |||||
| @zip_path = Gitlab.endpoint.to_s + "/projects/" + @shixun.gpid.to_s + "/repository/archive?&private_token=" + token | |||||
| @creator = @shixun.owner.to_s | |||||
| gitlab_address = Redmine::Configuration['gitlab_address'] | |||||
| @repos_url = gitlab_address.to_s+"/" + @creator + "/" + @repository.identifier+"."+"git" | |||||
| # 提交总数同步更新 | |||||
| @shixun.update_attribute(:changeset_num, @changesets_all_count) | |||||
| render :layout => 'base_shixun' | |||||
| end | |||||
| end | |||||
| # 权限: | # 权限: | ||||
| # 如果项目隐藏了版本库,则非项目成员及项目报告人员不能够访问版本库 | # 如果项目隐藏了版本库,则非项目成员及项目报告人员不能够访问版本库 | ||||
| # 如果没有隐藏版本库,只要项目公开,其它成员都可以看到版本库 | # 如果没有隐藏版本库,只要项目公开,其它成员都可以看到版本库 | ||||
| @@ -545,6 +614,20 @@ update | |||||
| end | end | ||||
| def commits | |||||
| # 顶部导航 | |||||
| @project_menu_type = 5 | |||||
| @entry = @repository.entry(@path, @rev) | |||||
| (show_error_not_found; return) unless @entry | |||||
| limit = 10 | |||||
| # 每次页面的换回值从1开始,但是gitlab的页面查询是从0开始,所以先改变page的类型减一在改回来 | |||||
| @commits = @g.commits(@shixun.gpid, page:(params[:page].to_i - 1).to_s, ref_name:@rev) | |||||
| @commits_count = params[:commit_count].nil? ? @g.user_static(@shixun.gpid, :rev => @rev).count : params[:commit_count].to_i | |||||
| @commits_pages = Paginator.new @commits_count, limit, params[:page] | |||||
| render :layout => 'base_shixun' | |||||
| end | |||||
| # 注:由于考虑到性能所以commits api每次返回20条记录 | # 注:由于考虑到性能所以commits api每次返回20条记录 | ||||
| def changes | def changes | ||||
| # 顶部导航 | # 顶部导航 | ||||
| @@ -600,6 +683,21 @@ update | |||||
| end | end | ||||
| end | end | ||||
| def shixun_entry | |||||
| # 顶部导航 | |||||
| @project_menu_type = 5 | |||||
| entry_and_raw(false) | |||||
| @content = @repository.cat(@path, @rev) | |||||
| # @changesets_latest_coimmit = @g.commit(@project.gpid, @entry.try(:lastrev)) | |||||
| @changesets_latest_coimmit = @g.rep_last_changes(@shixun.gpid, :rev => @rev, :path => @path) | |||||
| # 总的提交数 | |||||
| @changesets_all_count = @g.user_static(@shixun.gpid, :rev => @rev).count | |||||
| if is_entry_text_data?(@content, @path) | |||||
| render :layout => 'base_shixun' | |||||
| end | |||||
| end | |||||
| def entry_and_raw(is_raw) | def entry_and_raw(is_raw) | ||||
| @entry = @repository.entry(@path, @rev) | @entry = @repository.entry(@path, @rev) | ||||
| (show_error_not_found; return) unless @entry | (show_error_not_found; return) unless @entry | ||||
| @@ -699,6 +797,21 @@ update | |||||
| render :layout => 'base_projects' | render :layout => 'base_projects' | ||||
| end | end | ||||
| # 实训项目 | |||||
| # 每次提交对应的文件差异 | |||||
| def commit | |||||
| # 顶部导航 | |||||
| @project_menu_type = 5 | |||||
| @commit_diff = @g.commit_diff(@project.gpid, params[:changeset]) | |||||
| diff = ActiveSupport::JSON.decode(@commit_diff.to_json).first | |||||
| diff = OpenStruct.new(diff) | |||||
| @diff_file = Trustie::Gitlab::Diff::File.new(diff) | |||||
| @commit_details = @g.commit(@project.gpid, params[:changeset]) | |||||
| render :layout => 'base_projects' | |||||
| end | |||||
| def diff | def diff | ||||
| if params[:format] == 'diff' | if params[:format] == 'diff' | ||||
| @diff = @repository.diff(@path, @rev, @rev_to) | @diff = @repository.diff(@path, @rev, @rev_to) | ||||
| @@ -786,6 +899,29 @@ update | |||||
| end | end | ||||
| end | end | ||||
| def find_project_and_repository | |||||
| @shixun = Shixun.find(params[:id]) | |||||
| @repository = @shixun.repository | |||||
| render_404 if @shixun.gpid.nil? | |||||
| @path = params[:path].is_a?(Array) ? params[:path].join('/') : params[:path].to_s | |||||
| @g = Gitlab.client | |||||
| @g_project = @g.project(@shixun.gpid) | |||||
| @branchs = @g.branches(@shixun.gpid) | |||||
| @g_default_branch = @g_project.default_branch | |||||
| # gitlab端获取默认分支 | |||||
| @rev = params[:rev].blank? ? @g_default_branch : params[:rev].to_s.strip | |||||
| @rev_to = params[:rev_to] | |||||
| unless @rev.to_s.match(REV_PARAM_RE) && @rev_to.to_s.match(REV_PARAM_RE) | |||||
| if @branchs.blank? | |||||
| raise InvalidRevisionParam | |||||
| end | |||||
| end | |||||
| rescue ActiveRecord::RecordNotFound | |||||
| render_404 | |||||
| rescue InvalidRevisionParam | |||||
| show_error_not_found | |||||
| end | |||||
| def authorize_visible | def authorize_visible | ||||
| allowed = authorize_allowed(params[:controller], params[:action], global = false) | allowed = authorize_allowed(params[:controller], params[:action], global = false) | ||||
| if allowed || User.current.admin? || (@project.hidden_repo && User.current.member_of?(@project) && !role_of_members_in_project(@project.id, User.current.id) == "Reporter") | if allowed || User.current.admin? || (@project.hidden_repo && User.current.member_of?(@project) && !role_of_members_in_project(@project.id, User.current.id) == "Reporter") | ||||
| @@ -0,0 +1,225 @@ | |||||
| # encoding: utf-8 | |||||
| # REDO: 创建版本库权限控制 | |||||
| class ShixunsController < ApplicationController | |||||
| layout 'base_shixun' | |||||
| before_filter :require_login | |||||
| before_filter :find_shixun, :except => [ :index, :new, :create] | |||||
| before_filter :shixun_view_allow, :only => [:show] | |||||
| before_filter :require_manager, :only => [ :settings, :add_script] | |||||
| include ApplicationHelper | |||||
| def shixun_monitor | |||||
| monitor_filter | |||||
| if @had_exec | |||||
| @tpm = Myshixun.where(:user_id => User.current, :shixun_id => @shixun).first | |||||
| end | |||||
| respond_to do |format| | |||||
| format.js | |||||
| end | |||||
| end | |||||
| # copy_shixun:复制一个新的实训模块包括版本库 | |||||
| # copy_myshixun自动创建系列game,game中只包含状态等信息,公共信息从Challeges中读取 | |||||
| # | |||||
| def shixun_exec | |||||
| if has_exec_cur_shixun(@shixun) || User.current.id == @shixun.user_id | |||||
| render_403 | |||||
| end | |||||
| repository = @shixun.repository | |||||
| ActiveRecord::Base.transaction do | |||||
| begin | |||||
| @g = Gitlab.client | |||||
| if User.current.gid.nil? | |||||
| s = Trustie::Gitlab::Sync.new | |||||
| s.sync_user(User.current) | |||||
| end | |||||
| gshixun = @g.fork(@shixun.gpid, User.current.gid) | |||||
| if !gshixun.id.nil? | |||||
| myshixun = copy_myshixun(@shixun, gshixun) | |||||
| challenges = @shixun.challenges | |||||
| # 之所以增加user_id是为了方便统计查询性能 | |||||
| challenges.each_with_index do |challenge, index| | |||||
| status = (index == 0 ? 0 : 3) | |||||
| Game.create!(:challenge_id => challenge.id, :myshixun_id => myshixun.id, :status => status, :user_id => myshixun.user_id) | |||||
| end | |||||
| else | |||||
| raise("网络异常,请稍后重试") | |||||
| end | |||||
| respond_to do |format| | |||||
| format.html{myshixun_game_url(myshixun.current_task, :myshixun_id => myshixun)} | |||||
| end | |||||
| rescue Exception => e | |||||
| flash[:error] = l(:notice_shixun_failed_exec)+ " : " + e.message | |||||
| @g.delete_project(gshixun.id) if !gshixun.id.nil? | |||||
| raise ActiveRecord::Rollback | |||||
| end | |||||
| end | |||||
| end | |||||
| def new | |||||
| @shixun = Shixun.new | |||||
| respond_to do |format| | |||||
| format.html{render :layout => 'new_base'} | |||||
| format.json | |||||
| end | |||||
| end | |||||
| def create | |||||
| @shixun = Shixun.new(params[:shixun]) | |||||
| @shixun.user_id = User.current.id | |||||
| @shixun.language = params[:language] | |||||
| (params[:shixun][:is_public] == "1" ? @shixun.is_public = true : @shixun.is_public = false) | |||||
| respond_to do |format| | |||||
| if @shixun.save | |||||
| m = ShixunMember.new(:user_id => User.current.id, :role => 1) | |||||
| @shixun.shixun_members << m | |||||
| format.html { redirect_to @shixun, notice: l(:notice_successful_create) } | |||||
| format.js | |||||
| else | |||||
| format.html { render action: "new" } | |||||
| format.js | |||||
| end | |||||
| end | |||||
| end | |||||
| def show | |||||
| respond_to do |format| | |||||
| format.html{redirect_to shixun_challenges_path(@shixun)} | |||||
| end | |||||
| end | |||||
| def edit | |||||
| end | |||||
| def update | |||||
| @shixun.attributes = params[:shixun] | |||||
| @shixun.language = params[:language] | |||||
| params[:shixun][:is_public] == "on" ? @shixun.is_public = 1 : @shixun.is_public = 0 | |||||
| @shixun.save | |||||
| respond_to do |format| | |||||
| format.html{redirect_to settings_shixun_url(@shixun)} | |||||
| end | |||||
| end | |||||
| def destroy | |||||
| end | |||||
| def settings | |||||
| @repository = Repository.where(:shixun_id => @shixun, :type => "Repository::Gitlab").first | |||||
| unless @repository.nil? | |||||
| gitlab_address = Redmine::Configuration['gitlab_address'] | |||||
| creator = @shixun.owner.try(:login) | |||||
| @repos_url = gitlab_address+"/" + creator + "/" + @repository.identifier+"."+"git" | |||||
| end | |||||
| end | |||||
| # 添加实训脚本 | |||||
| def add_script | |||||
| if @shixun.update_attribute(:script, params[:shixun_script]) | |||||
| @notice = "脚本添加成功" | |||||
| else | |||||
| @notice = "脚本添加失败" | |||||
| end | |||||
| end | |||||
| # 创建实训job | |||||
| def shixun_job_create | |||||
| if @shixun.challenges.count == 0 | |||||
| @notice = "实训开启失败:请先发布实训任务" | |||||
| return | |||||
| elsif Repository.where(:shixun_id => @shixun.id, :type => "Repository::Gitlab").count == 0 | |||||
| @notice = "实训开启失败:请先创建版本库" | |||||
| return | |||||
| end | |||||
| @shixun.update_attribute(:status, 1) | |||||
| end | |||||
| # 更新实训job | |||||
| def shixun_job_update | |||||
| # jobName = "#{@shixun.id}" | |||||
| # pipeLine = "#{Base64.encode64(@shixun.script)}" | |||||
| # uri = URI("http://123.59.135.74:9999/jenkins-exec/api/updateJob") | |||||
| # params = {jobName: jobName, pipeLine: pipeLine} | |||||
| # res = uri_exec uri, params | |||||
| training_shixun_notice res | |||||
| if res['code'] == 0 | |||||
| @shixun.update_attribute(:status, 1) | |||||
| end | |||||
| end | |||||
| # Find shixun of id params[:id] | |||||
| def find_shixun | |||||
| @shixun = Shixun.find(params[:id]) | |||||
| rescue ActiveRecord::RecordNotFound | |||||
| render_404 | |||||
| end | |||||
| def monitor_filter | |||||
| if User.current.id == @shixun.user_id | |||||
| @notice = l(:label_shixun_mine) | |||||
| else | |||||
| if has_exec_cur_shixun(@shixun) | |||||
| @notice = l(:label_shixun_had_forked) | |||||
| @had_exec = true | |||||
| else | |||||
| @notice = l(:label_shixun_exec) | |||||
| @had_exec = false | |||||
| end | |||||
| end | |||||
| end | |||||
| private | |||||
| # REDO: 新增类型copy的时候 | |||||
| # 复制项目 | |||||
| # gshixun --> gitlab project | |||||
| def copy_myshixun shixun, gshixun | |||||
| myshixun = Myshixun.new | |||||
| myshixun.attributes = shixun.attributes.dup.except("id","user_id","visits","gpid","status") | |||||
| myshixun.shixun_id = shixun.id | |||||
| myshixun.user_id = User.current.id | |||||
| myshixun.gpid = gshixun.id | |||||
| jenkins_shixuns = Redmine::Configuration['jenkins_shixuns'] | |||||
| if myshixun.save! | |||||
| MyshixunMember.create!(:myshixun_id => myshixun.id, :user_id => User.current.id, :role => 1) | |||||
| uri = URI("#{jenkins_shixuns}/jenkins-exec/api/createJob") | |||||
| pipeLine = "#{Base64.encode64(shixun.script)}" | |||||
| params = {jobName: "myshixun_#{myshixun.id}", pipeLine: pipeLine} | |||||
| res = uri_exec uri, params | |||||
| rep = Repository.new(:myshixun_id => myshixun.id, :identifier => gshixun.name,:project_id => -1, :shixun_id => -2) | |||||
| rep.type = "Repository::Gitlab" | |||||
| rep.save! | |||||
| if (res && res['code'] != 0) | |||||
| raise("Job 创建失败") | |||||
| end | |||||
| return myshixun | |||||
| end | |||||
| end | |||||
| def training_shixun_notice res | |||||
| if res['code'] == 0 | |||||
| @notice = "实训开启成功" | |||||
| else | |||||
| @notice = res['msg'].nil? ? "实训开启失败" : res['msg'] | |||||
| end | |||||
| end | |||||
| # 权限控制 | |||||
| def shixun_view_allow | |||||
| if @shixun.is_public? | |||||
| true | |||||
| else | |||||
| User.current.member_of?(@shixun) ? true : false | |||||
| end | |||||
| end | |||||
| # 实训管理员或者超级管理员 | |||||
| def require_manager | |||||
| render_403 unless User.current.manager_of_shixun?(@shixun) | |||||
| end | |||||
| end | |||||
| @@ -42,7 +42,8 @@ class UsersController < ApplicationController | |||||
| :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,:user_contestlist, :user_manage_issues, :user_receive_issues, | :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,:user_contestlist, :user_manage_issues, :user_receive_issues, | ||||
| :user_courses4show,:user_projects4show,:user_contests4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction, | :user_courses4show,:user_projects4show,:user_contests4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction, | ||||
| :user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course,:user_courselist,:user_projectlist,:sort_syllabus_list, | :user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course,:user_courselist,:user_projectlist,:sort_syllabus_list, | ||||
| :sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks, :cancel_or_collect,:expand_courses,:homepage, :user_issues, :course_community, :project_community, :contest_community] | |||||
| :sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks, :cancel_or_collect,:expand_courses,:homepage, :user_issues, :course_community, :project_community, :contest_community, | |||||
| :user_shixuns] | |||||
| before_filter :auth_user_extension, only: :show | before_filter :auth_user_extension, only: :show | ||||
| before_filter :show_system_message, :only => [:show] | before_filter :show_system_message, :only => [:show] | ||||
| #before_filter :rest_user_score, only: :show | #before_filter :rest_user_score, only: :show | ||||
| @@ -651,6 +652,14 @@ class UsersController < ApplicationController | |||||
| end | end | ||||
| end | end | ||||
| # 我发布的实训 | |||||
| def user_shixuns | |||||
| @shixuns = Shixun.where(:user_id => User.current) | |||||
| respond_to do |format| | |||||
| format.html{render :layout=>'base_users_new'} | |||||
| end | |||||
| end | |||||
| #处理加入课程成为教辅教师的请求 | #处理加入课程成为教辅教师的请求 | ||||
| #status 1 同意 2 拒绝 | #status 1 同意 2 拒绝 | ||||
| def dealwith_apply_request | def dealwith_apply_request | ||||
| @@ -26,70 +26,8 @@ class WelcomeController < ApplicationController | |||||
| before_filter :entry_select, :only => [:index] | before_filter :entry_select, :only => [:index] | ||||
| def index | def index | ||||
| # 企业版定制: params[:project]为传过来的参数 | |||||
| redirect_to signin_path | |||||
| return | |||||
| unless params[:organization].nil? | |||||
| @organization = Organization.find params[:organization] | |||||
| # @organization_projects = Project.joins(:project_status).joins("LEFT JOIN project_scores ON projects.id = project_scores.project_id").where("projects.organization_id = ?", @organization.id).order("score DESC").limit(10).all | |||||
| @organization_projects = @organization.projects.visible.joins("LEFT JOIN project_scores ON projects.id = project_scores.project_id").order("project_scores.score DESC").limit(10).all | |||||
| @part_projects = @organization_projects.count < 9 ? find_miracle_project( 9 - @organization_projects.count, 3,"score desc") : [] | |||||
| # @cur_projects = Project.find(params[:organization]) | |||||
| # @organization = @cur_projects.enterprise_name | |||||
| # @organization_projects = (current_user.admin? || User.current.member_of?(@cur_projects)) ? Project.where("enterprise_name =? ", @organization) : Project.all_public.where("enterprise_name =? ", @organization) | |||||
| # @e_count = @organization_projects.count | |||||
| # @part_projects = [] | |||||
| # # 取十个 | |||||
| # @organization_projects.each do |obj| | |||||
| # break if(@organization_projects[10] == obj) | |||||
| # @part_projects << Project.visible.find_by_id("#{obj.id}") unless obj.id.nil? | |||||
| # end | |||||
| # # 不够十个的用最火项目替代 | |||||
| # @e_count < 9 ? @part_projects = find_miracle_project( 9 - @e_count, 3,"score desc") : @part_projects | |||||
| # # 配置文件首页定制 | |||||
| @enterprise_page = FirstPage.find_by_page_type('enterprise') | |||||
| if @enterprise_page.nil? | |||||
| @enterprise_page = FirstPage.new | |||||
| @enterprise_page.page_type = 'enterprise' | |||||
| end | |||||
| # 主页配置部分结束 | |||||
| end | |||||
| # end 企业版定制结束 | |||||
| if @first_page.nil? || @first_page.sort_type.nil? | |||||
| @projects = find_miracle_project(10, 3,"score desc") | |||||
| else | |||||
| case @first_page.sort_type | |||||
| when 0 | |||||
| @my_projects = find_my_projects | |||||
| @other_projects = @my_projects.count < 9 ? find_miracle_project( 9 - @my_projects.count, 3,"score desc") : [] | |||||
| @projects = find_miracle_project(10, 3,"created_on desc") | |||||
| #@projects = @projects_all.order("created_on desc") | |||||
| when 1 | |||||
| @my_projects = find_my_projects | |||||
| @other_projects = @my_projects.count < 9 ? find_miracle_project( 9 - @my_projects.count, 3,"score desc") : [] | |||||
| @projects = find_miracle_project(10, 3,"score desc") | |||||
| #@projects = @projects_all.order("grade desc") | |||||
| when 2 | |||||
| @my_projects = find_my_projects | |||||
| @other_projects = @my_projects.count < 9 ? find_miracle_project( 9 - @my_projects.count, 3,"score desc") : [] | |||||
| @projects = find_miracle_project(10, 3,"watchers_count desc") | |||||
| #@projects = @projects_all.order("watchers_count desc") | |||||
| #gcm | |||||
| #when '3' | |||||
| #@projects=desc_sort_course_by_avtivity(@project_activity_count_array,@project_all_array) | |||||
| # @projects=handle_project @projects_all,@project_activity_count | |||||
| # @s_type = 3 | |||||
| # @projects = @projects[@project_pages.offset, @project_pages.per_page] | |||||
| else | |||||
| @projects = @projects_all.order("score desc") | |||||
| end | |||||
| end | |||||
| rescue Exception => e | |||||
| render_404 | |||||
| @welcome = true | |||||
| render :layout => 'login_bigdata' | |||||
| end | end | ||||
| def robots | def robots | ||||
| @@ -33,9 +33,157 @@ module ApplicationHelper | |||||
| extend Forwardable | extend Forwardable | ||||
| def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter | def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter | ||||
| # codeMirror语言转换 | |||||
| def language_switch language | |||||
| case language | |||||
| when "Java" | |||||
| "text/x-java" | |||||
| when "C" | |||||
| "text/x-csrc" | |||||
| when "C++" | |||||
| "text/x-c++src" | |||||
| when "Python" | |||||
| "text/x-python" | |||||
| when "Ruby" | |||||
| "text/x-ruby" | |||||
| end | |||||
| end | |||||
| # 定义实训相关方法 | |||||
| # myshixun 最高分 | |||||
| def top_score shixun, position | |||||
| Game.find_by_sql("SELECT max(final_score) as top_score FROM `games` g, `challenges` c where g.challenge_id = c.id and c.position=#{position} and g.myshixun_id in (SELECT id FROM `myshixuns` ms where ms.shixun_id=#{shixun.id})").first.try(:top_score) | |||||
| end | |||||
| # 实训平均分 | |||||
| def shixun_avg_score shixun, position | |||||
| Game.find_by_sql("SELECT avg(g.final_score) as avg_score FROM `games` g, `challenges` c where g.challenge_id=c.id and c.position=#{position} and g.myshixun_id in (SELECT id FROM `myshixuns` ms where ms.shixun_id=#{shixun.id})").first.try(:avg_score) | |||||
| end | |||||
| # 正在进行中任务 | |||||
| def shixun_running shixun, position | |||||
| Shixun.find_by_sql("SELECT count(*) as count FROM `myshixuns` ms, `games` g, `challenges` c where g.myshixun_id = ms.id and ms.shixun_id =#{shixun.id} and g.challenge_id=c.id and c.position=#{position} and g.status in ('0','1');").first.try(:count) | |||||
| end | |||||
| # 已完成任务 | |||||
| def shixun_done shixun, position | |||||
| Shixun.find_by_sql("SELECT count(*) as count FROM `myshixuns` ms, `games` g, `challenges` c where g.myshixun_id = ms.id and ms.shixun_id =#{shixun.id} and g.challenge_id=c.id and c.position=#{position} and g.status=2;").first.try(:count) | |||||
| end | |||||
| # 测评次数 | |||||
| def shixun_exec_total_count shixun, position | |||||
| Game.find_by_sql("SELECT * FROM `outputs` op, `games` g, `myshixuns` m where op.game_id = g.id and g.stage='#{position}' and m.parent_id = '#{shixun.id}';") | |||||
| end | |||||
| # 平均耗时 | |||||
| def shixun_avg | |||||
| end | |||||
| # 平均耗时 | |||||
| def game_avg_day created_at, updated_at | |||||
| time = (updated_at - created_at).to_i | |||||
| day = time / 86400 | |||||
| end | |||||
| # 平均耗时 | |||||
| def game_avg_hour created_at, updated_at | |||||
| time = (updated_at - created_at).to_i | |||||
| hour = time % (24*60*60) / (60*60) | |||||
| end | |||||
| # 平均耗时 | |||||
| def game_avg_min created_at, updated_at | |||||
| time = (updated_at - created_at).to_i | |||||
| min = time % (24*60*60) % (60*60) / 60 | |||||
| end | |||||
| # 耗时:天、小时、分 | |||||
| # 小于1分钟则不显示 | |||||
| def game_spend_time start_time, end_time | |||||
| time = (end_time - start_time).to_i | |||||
| day = time / 86400 | |||||
| hour = time % (24*60*60) / (60*60) | |||||
| min = time % (24*60*60) % (60*60) / 60 | |||||
| if day < 1 | |||||
| if hour < 1 | |||||
| if time < 1 | |||||
| time = time == 0 ? "--" : "小于1分钟" | |||||
| else | |||||
| time = "#{min} 分钟" | |||||
| end | |||||
| else | |||||
| time = "#{hour}小时 : #{min}分" | |||||
| end | |||||
| else | |||||
| time = "#{day}天 : #{hour}小时 : #{min}分" | |||||
| end | |||||
| return time | |||||
| end | |||||
| def avg_spend_time shixun_id, position | |||||
| Game.find_by_sql("SELECT avg(g.updated_at - g.created_at) as avg_time FROM `games` g, `challenges` c where c.id=g.challenge_id and g.status =2 and c.position = #{position} and g.myshixun_id in (SELECT id FROM `myshixuns` where shixun_id= #{shixun_id});").first.try(:avg_time).to_i | |||||
| end | |||||
| # 已闯关 | |||||
| def had_pass shixun_id, position | |||||
| Game.find_by_sql("SELECT count(*) as count FROM `games` g, `challenges` c where c.id=g.challenge_id and g.status =2 and c.position =#{position} and g.myshixun_id in (SELECT id FROM `myshixuns` where shixun_id=#{shixun_id});").first.try(:count) | |||||
| end | |||||
| # 单个game测评次数 | |||||
| def avg_my_pass game | |||||
| Output.where(:game_id => game).count | |||||
| end | |||||
| def shixun_final_score myshixun | |||||
| Game.find_by_sql("SELECT sum(final_score) as final_score FROM `games` where myshixun_id='#{myshixun.id}';").first.try(:final_score) | |||||
| end | |||||
| # def user_blogs_path(resource,parameters={}) | # def user_blogs_path(resource,parameters={}) | ||||
| # super | # super | ||||
| # end | # end | ||||
| # 复制一个任务 | |||||
| def publish_games challenge, myshixun_id, index | |||||
| game = Game.new | |||||
| game.attributes = challenge.attributes.dup.except("id","shixun_id","user_id","visits") | |||||
| game.myshixun_id = myshixun_id | |||||
| game.user_id = User.current.id | |||||
| game.stage = challenge.position | |||||
| index == 0 ? game.status = 0 : game.status = 3 | |||||
| challenge_samples = challenge.challenge_samples | |||||
| test_sets = challenge.test_sets | |||||
| if game.save | |||||
| unless challenge_samples.blank? | |||||
| challenge_samples.each do |cs| | |||||
| ChallengeSample.create(:game_id => game.id, :input => cs.input, :output => cs.output, :challenge_id => -1) | |||||
| end | |||||
| end | |||||
| unless test_sets.blank? | |||||
| test_sets.each do |ts| | |||||
| TestSet.create(:game_id => game.id, :input => ts.input, :output => ts.output, :challenge_id => -1) | |||||
| end | |||||
| end | |||||
| end | |||||
| end | |||||
| def git_repository_url project, type | |||||
| if type == "Shixun" | |||||
| rep_identify = Repository.where(:shixun_id => project.id, :type => "Repository::Gitlab").first.try(:identifier) | |||||
| elsif type == "Myshixun" | |||||
| rep_identify = Repository.where(:myshixun_id => project.id, :type => "Repository::Gitlab").first.try(:identifier) | |||||
| else | |||||
| rep_identify = Repository.where(:project_id => project.id, :type => "Repository::Gitlab").first.try(:identifier) | |||||
| end | |||||
| gitlab_address = Redmine::Configuration['gitlab_address'] | |||||
| gitUrl = gitlab_address.to_s+"/"+project.owner.to_s+"/"+ rep_identify + "."+"git" | |||||
| end | |||||
| def uri_exec uri, params | |||||
| res = Net::HTTP.post_form(uri, params).body | |||||
| res = JSON.parse(res) | |||||
| end | |||||
| # 公共分页 | # 公共分页 | ||||
| def paginator_list objs, objs_count, limit, is_remote | def paginator_list objs, objs_count, limit, is_remote | ||||
| @@ -121,6 +269,16 @@ module ApplicationHelper | |||||
| end | end | ||||
| end | end | ||||
| # 判断当前用户是否已经实训过当前项目 | |||||
| # project: current_project | |||||
| def has_exec_cur_shixun shixun | |||||
| Myshixun.where(:user_id => User.current.id, :shixun_id => shixun.id).count > 0 ? true : false | |||||
| end | |||||
| def allow_shixun_exec shixun | |||||
| (User.current.logged? && User.current.id != shixun.user_id && shixun.status == 1) | |||||
| end | |||||
| # 通过系统外部邮箱查找用户,如果用户不存在则用邮箱替换 | # 通过系统外部邮箱查找用户,如果用户不存在则用邮箱替换 | ||||
| def get_user_by_mail mail | def get_user_by_mail mail | ||||
| user = User.find_by_mail(mail) | user = User.find_by_mail(mail) | ||||
| @@ -1125,6 +1283,11 @@ module ApplicationHelper | |||||
| rep = Repository.where("project_id =? and type =?", project.id,"Repository::Gitlab" ).first | rep = Repository.where("project_id =? and type =?", project.id,"Repository::Gitlab" ).first | ||||
| end | end | ||||
| # 获取单一gitlab项目 | |||||
| def shixun_repository(shixun) | |||||
| rep = Repository.where(:shixun_id => shixun, :type => "Repository::Gitlab" ).first | |||||
| end | |||||
| # 判断当前用户是否为项目管理员 | # 判断当前用户是否为项目管理员 | ||||
| def is_project_manager?(user_id, project_id) | def is_project_manager?(user_id, project_id) | ||||
| @result = false | @result = false | ||||
| @@ -1384,13 +1547,15 @@ module ApplicationHelper | |||||
| if args.empty? | if args.empty? | ||||
| title = @html_title || [] | title = @html_title || [] | ||||
| if @project | if @project | ||||
| title << @project.name | |||||
| title << (@project.name.nil? ? "让创新更美好" : @project.name) | |||||
| elsif @welcome | |||||
| title << "高校教育大数据服务平台" | |||||
| elsif @course | elsif @course | ||||
| title << @course.name | |||||
| title << (@course.name.nil? ? "让创新更美好" : @course.name) | |||||
| elsif @contest | elsif @contest | ||||
| title << @contest.name | |||||
| title << (@contest.name.nil? ? "让创新更美好" : @contest.name) | |||||
| elsif @organization | elsif @organization | ||||
| title << @organization.name | |||||
| title << (@organization.name.nil? ? "让创新更美好" : @organization.name) | |||||
| elsif @forum || params[:controller] == "forums" | elsif @forum || params[:controller] == "forums" | ||||
| title << "问吧" | title << "问吧" | ||||
| elsif @user | elsif @user | ||||
| @@ -1416,11 +1581,11 @@ module ApplicationHelper | |||||
| else | else | ||||
| title << (User.current.id == 2 ? "未登录" : User.current.try(:realname)) | title << (User.current.id == 2 ? "未登录" : User.current.try(:realname)) | ||||
| end | end | ||||
| if first_page.nil? || first_page.web_title.nil? | |||||
| title << Setting.app_title unless Setting.app_title == title.last | |||||
| else | |||||
| title << first_page.web_title unless first_page.web_title == title.last | |||||
| end | |||||
| # if first_page.nil? || first_page.web_title.nil? | |||||
| # title << Setting.app_title unless Setting.app_title == title.last | |||||
| # else | |||||
| # title << first_page.web_title unless first_page.web_title == title.last | |||||
| # end | |||||
| title.select {|t| !t.blank? }.join(' - ') | title.select {|t| !t.blank? }.join(' - ') | ||||
| else | else | ||||
| @html_title ||= [] | @html_title ||= [] | ||||
| @@ -0,0 +1,2 @@ | |||||
| module ChallengesHelper | |||||
| end | |||||
| @@ -0,0 +1,2 @@ | |||||
| module CodesHelper | |||||
| end | |||||
| @@ -0,0 +1,2 @@ | |||||
| module GamesHelper | |||||
| end | |||||
| @@ -0,0 +1,2 @@ | |||||
| module MarkDownHelper | |||||
| end | |||||
| @@ -0,0 +1,14 @@ | |||||
| module MyshixunsHelper | |||||
| def myshixun_score myshixun | |||||
| end | |||||
| def time_ranking myshixun | |||||
| end | |||||
| def score_ranking myshixun | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,17 @@ | |||||
| module ShixunsHelper | |||||
| #显示项目配置菜单 | |||||
| def show_project_memu user | |||||
| if user.allowed_to?(:edit_project, @shixun) | |||||
| result = "edit_project" | |||||
| elsif user.allowed_to?(:manage_members, @shixun) | |||||
| result = "training_task" | |||||
| elsif user.allowed_to?(:manage_versions, @shixun) | |||||
| result = "manage_versions" | |||||
| elsif user.allowed_to?(:manage_repository, @shixun) | |||||
| result = "manage_repository" | |||||
| end | |||||
| result | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,27 @@ | |||||
| class Challenge < ActiveRecord::Base | |||||
| default_scope :order => 'position' | |||||
| belongs_to :shixun,:touch=> true | |||||
| belongs_to :user | |||||
| has_many :challenge_samples, :dependent => :destroy | |||||
| has_many :test_sets, :dependent => :destroy | |||||
| has_many :challenge_tags, :dependent => :destroy | |||||
| has_many :games, :dependent => :destroy | |||||
| validates_presence_of :subject | |||||
| validates_presence_of :score | |||||
| validates_presence_of :task_pass | |||||
| validates_length_of :subject, :maximum => 255 | |||||
| def next_challenge | |||||
| challenge_count = Challenge.where(:shixun_id => self.shixun_id).count | |||||
| render_404 if self.position ==challenge_count | |||||
| Challenge.where(:position => (self.position + 1), :shixun_id => self.shixun).first | |||||
| end | |||||
| def last_challenge | |||||
| render_404 if self.position < 2 | |||||
| position = self.position - 1 | |||||
| Challenge.where(:position => position, :shixun_id => self.shixun).first | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,4 @@ | |||||
| class ChallengeSample < ActiveRecord::Base | |||||
| attr_accessible :challenge_id, :input, :output, :game_id | |||||
| belongs_to :challenge | |||||
| end | |||||
| @@ -0,0 +1,4 @@ | |||||
| class ChallengeTag < ActiveRecord::Base | |||||
| attr_accessible :challenge_id, :name | |||||
| belongs_to :challenge | |||||
| end | |||||
| @@ -0,0 +1,26 @@ | |||||
| class Game < ActiveRecord::Base | |||||
| # stauts 0: can exe 1:doing 2:successed 3:locked | |||||
| default_scope :order => 'created_at desc' | |||||
| attr_accessible :myshixun_id, :user_id, :status, :final_score, :challenge_id | |||||
| belongs_to :myshixun,:touch=> true | |||||
| belongs_to :user | |||||
| belongs_to :challenge | |||||
| has_many :outputs, :dependent => :destroy | |||||
| has_many :test_sets, :dependent => :destroy | |||||
| has_many :challenge_samples, :dependent => :destroy | |||||
| def next_game | |||||
| challenge = self.challenge | |||||
| next_challenge_id = challenge.next_challenge | |||||
| game = Game.where(:myshixun_id => self.myshixun_id, :challenge_id => next_challenge_id).first | |||||
| render_404 if game.nil? | |||||
| return game | |||||
| end | |||||
| # 获取game最新的一条输出结果 | |||||
| def latest_output | |||||
| outputs = Output.where(:game_id => self.id).order("created_at desc") | |||||
| output = outputs.blank? ? nil : outputs.first | |||||
| return output | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,3 @@ | |||||
| class GameOutputs < ActiveRecord::Base | |||||
| attr_accessible :code, :msg, :out_put, :game_id | |||||
| end | |||||
| @@ -837,10 +837,11 @@ class Mailer < ActionMailer::Base | |||||
| :subject => l(:mail_subject_register, Setting.app_title) | :subject => l(:mail_subject_register, Setting.app_title) | ||||
| end | end | ||||
| def lost_password(token) | |||||
| def lost_password(token, code="111111") | |||||
| set_language_if_valid(token.user.language) | set_language_if_valid(token.user.language) | ||||
| @login = token.user.try(:login) | |||||
| @token = token | @token = token | ||||
| @url = url_for(:controller => 'account', :action => 'lost_password', :token => token.value) | |||||
| @code = code | |||||
| mail :to => token.user.mail, | mail :to => token.user.mail, | ||||
| :subject => l(:mail_subject_lost_password, Setting.app_title) | :subject => l(:mail_subject_lost_password, Setting.app_title) | ||||
| end | end | ||||
| @@ -0,0 +1,3 @@ | |||||
| class MarkDown < ActiveRecord::Base | |||||
| attr_accessible :description | |||||
| end | |||||
| @@ -0,0 +1,33 @@ | |||||
| class Myshixun < ActiveRecord::Base | |||||
| attr_accessible :description, :name, :parent_id, :user_id, :gpid, :forked_from, :visits, :is_public | |||||
| has_many :users, :through => :myshixun_members | |||||
| has_many :myshixun_members | |||||
| has_one :repository | |||||
| has_many :games, :dependent => :destroy, :order => "games.id ASC" | |||||
| belongs_to :shixun | |||||
| # 当前任务:一个实训中只可能一个未完成任务(status 0或1只会存在一条记录) | |||||
| # status:0 可以测评的,正在测评的 | |||||
| # 如果都完成,则当前任务为最后一个任务 | |||||
| def current_task | |||||
| games = self.games | |||||
| current_game = games.select{|game| game.status==1 || game.status==0}.first | |||||
| if current_game.blank? | |||||
| passed_games = games.select{|game| game.status==2} | |||||
| current_game = passed_games.last | |||||
| end | |||||
| return current_game | |||||
| end | |||||
| def parent | |||||
| Shixun.find(self.parent_id) | |||||
| rescue ActiveRecord::RecordNotFound | |||||
| render_404 | |||||
| end | |||||
| def owner | |||||
| User.find(self.user_id) | |||||
| rescue ActiveRecord::RecordNotFound | |||||
| render_404 | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,5 @@ | |||||
| class MyshixunMember < ActiveRecord::Base | |||||
| attr_accessible :myshixun_id, :role, :user_id | |||||
| belongs_to :myshixun | |||||
| belongs_to :user | |||||
| end | |||||
| @@ -0,0 +1,4 @@ | |||||
| class Output < ActiveRecord::Base | |||||
| # attr_accessible :title, :body | |||||
| default_scope :order => 'created_at desc' | |||||
| end | |||||
| @@ -25,6 +25,8 @@ class Repository < ActiveRecord::Base | |||||
| IDENTIFIER_MAX_LENGTH = 254 | IDENTIFIER_MAX_LENGTH = 254 | ||||
| belongs_to :project | belongs_to :project | ||||
| belongs_to :shixun | |||||
| belongs_to :myshixun | |||||
| has_many :changesets, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC" | has_many :changesets, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC" | ||||
| has_many :filechanges, :class_name => 'Change', :through => :changesets | has_many :filechanges, :class_name => 'Change', :through => :changesets | ||||
| @@ -106,8 +108,7 @@ class Repository < ActiveRecord::Base | |||||
| def scm | def scm | ||||
| unless @scm | unless @scm | ||||
| @scm = self.scm_adapter.new(url, root_url, | |||||
| login, password, path_encoding, project_id) | |||||
| @scm = self.scm_adapter.new(url, root_url, login, password, path_encoding, project_id, shixun_id, myshixun_id) | |||||
| if root_url.blank? && @scm.root_url.present? | if root_url.blank? && @scm.root_url.present? | ||||
| update_attribute(:root_url, @scm.root_url) | update_attribute(:root_url, @scm.root_url) | ||||
| end | end | ||||
| @@ -59,6 +59,8 @@ class Role < ActiveRecord::Base | |||||
| has_many :org_members,:through => :org_member_roles | has_many :org_members,:through => :org_member_roles | ||||
| has_many :contest_member_roles, :dependent => :destroy | has_many :contest_member_roles, :dependent => :destroy | ||||
| has_many :contest_members, :through => :contest_member_roles | has_many :contest_members, :through => :contest_member_roles | ||||
| has_many :shixun_members, :through => :shixun_member_roles | |||||
| has_many :shixun_member_roles, :dependent => :destroy | |||||
| acts_as_list | acts_as_list | ||||
| serialize :permissions, ::Role::PermissionsAttributeCoder | serialize :permissions, ::Role::PermissionsAttributeCoder | ||||
| @@ -0,0 +1,16 @@ | |||||
| # status 控制实训的状态,0:未开启;1: 已开启(TPM) | |||||
| class Shixun < ActiveRecord::Base | |||||
| attr_accessible :description, :is_public, :name, :changeset_num, :status, :user_id, :gpid, :language | |||||
| has_many :users, :through => :shixun_members | |||||
| has_many :shixun_members | |||||
| has_one :repository | |||||
| has_many :challenges, :dependent => :destroy, :order => "challenges.id ASC" | |||||
| has_many :myshixuns | |||||
| def owner | |||||
| User.find(self.user_id) | |||||
| rescue ActiveRecord::RecordNotFound | |||||
| render_404 | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,6 @@ | |||||
| class ShixunMember < ActiveRecord::Base | |||||
| attr_accessible :shixun_id, :user_id, :role | |||||
| belongs_to :shixun | |||||
| belongs_to :user | |||||
| has_many :roles ,:through => :shixun_member_roles, :foreign_key => 'role_id' | |||||
| end | |||||
| @@ -0,0 +1,3 @@ | |||||
| class ShixunTags < ActiveRecord::Base | |||||
| # attr_accessible :title, :body | |||||
| end | |||||
| @@ -0,0 +1,4 @@ | |||||
| class TestSet < ActiveRecord::Base | |||||
| attr_accessible :challenge_id, :input, :output, :game_id | |||||
| belongs_to :challenge | |||||
| end | |||||
| @@ -124,6 +124,9 @@ class User < Principal | |||||
| has_many :contestant_work_scores | has_many :contestant_work_scores | ||||
| has_many :contestant_work_projects | has_many :contestant_work_projects | ||||
| has_many :shixun_members, :dependent => :destroy | |||||
| has_many :challenges, :dependent => :destroy | |||||
| has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)}, | has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)}, | ||||
| :after_remove => Proc.new {|user, group| group.user_removed(user)} | :after_remove => Proc.new {|user, group| group.user_removed(user)} | ||||
| has_many :changesets, :dependent => :nullify | has_many :changesets, :dependent => :nullify | ||||
| @@ -244,7 +247,8 @@ class User < Principal | |||||
| LOGIN_LENGTH_LIMIT = 30 | LOGIN_LENGTH_LIMIT = 30 | ||||
| MAIL_LENGTH_LIMIT = 60 | MAIL_LENGTH_LIMIT = 60 | ||||
| validates_presence_of :login, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) } | |||||
| #validates_presence_of :login, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) } | |||||
| validates_presence_of :login, :if => Proc.new { |user| !user.is_a?(AnonymousUser) } | |||||
| validates_uniqueness_of :login, :if => Proc.new { |user| user.login_changed? && user.login.present? }, :case_sensitive => false | validates_uniqueness_of :login, :if => Proc.new { |user| user.login_changed? && user.login.present? }, :case_sensitive => false | ||||
| validates_uniqueness_of :mail, :if => Proc.new { |user| user.mail_changed? && user.mail.present? }, :case_sensitive => false | validates_uniqueness_of :mail, :if => Proc.new { |user| user.mail_changed? && user.mail.present? }, :case_sensitive => false | ||||
| # Login must contain letters, numbers, underscores only | # Login must contain letters, numbers, underscores only | ||||
| @@ -534,6 +538,7 @@ class User < Principal | |||||
| end | end | ||||
| VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i | VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i | ||||
| VALID_PHONE_REGEX = /^1\d{10}$/ | |||||
| # VALID_EMAIL_REGEX = /^[0-9a-zA-Z_-]+@[0-9a-zA-Z_-]+(\.[0-9a-zA-Z_-]+)+$/ | # VALID_EMAIL_REGEX = /^[0-9a-zA-Z_-]+@[0-9a-zA-Z_-]+(\.[0-9a-zA-Z_-]+)+$/ | ||||
| # Returns the user that matches provided login and password, or nil | # Returns the user that matches provided login and password, or nil | ||||
| #登录,返回用户名与密码匹配的用户 | #登录,返回用户名与密码匹配的用户 | ||||
| @@ -545,6 +550,8 @@ class User < Principal | |||||
| return nil if login.empty? || password.empty? | return nil if login.empty? || password.empty? | ||||
| if (login =~ VALID_EMAIL_REGEX) | if (login =~ VALID_EMAIL_REGEX) | ||||
| user = find_by_mail(login) | user = find_by_mail(login) | ||||
| elsif (login =~ VALID_PHONE_REGEX) | |||||
| user = find_by_phone(login) | |||||
| else | else | ||||
| user = find_by_login(login) | user = find_by_login(login) | ||||
| end | end | ||||
| @@ -778,6 +785,10 @@ class User < Principal | |||||
| where("LOWER(mail) = ?", mail.to_s.downcase).first | where("LOWER(mail) = ?", mail.to_s.downcase).first | ||||
| end | end | ||||
| def self.find_by_phone(phone) | |||||
| where("phone = ?", phone).first | |||||
| end | |||||
| # Returns true if the default admin account can no longer be used | # Returns true if the default admin account can no longer be used | ||||
| def self.default_admin_account_changed? | def self.default_admin_account_changed? | ||||
| !User.active.find_by_login("admin").try(:check_password?, "admin") | !User.active.find_by_login("admin").try(:check_password?, "admin") | ||||
| @@ -891,6 +902,18 @@ class User < Principal | |||||
| projects.to_a.include?(project) | projects.to_a.include?(project) | ||||
| end | end | ||||
| # 超级管理员或者role为1 | |||||
| def manager_of_shixun?(shixun) | |||||
| member = ShixunMember.where(:user_id => self.id, :shixun_id => shixun.id, :role => 1) | |||||
| (!member.blank? || User.current.admin?) ? true : false | |||||
| end | |||||
| # 超级管理员或者role为1 | |||||
| def manager_of_myshixun?(myshixun) | |||||
| member = MyshixunMember.where(:user_id => self.id, :myshixun_id => myshixun.id, :role => 1) | |||||
| (!member.blank? || User.current.admin?) ? true : false | |||||
| end | |||||
| def member_of_course?(course) | def member_of_course?(course) | ||||
| courses.to_a.include?(course) | courses.to_a.include?(course) | ||||
| end | end | ||||
| @@ -0,0 +1,5 @@ | |||||
| class VerificationCode < ActiveRecord::Base | |||||
| #status:发送状态 | |||||
| #code_type:发送类型:1 手机注册 2 手机找回密码 3 邮箱找回密码 | |||||
| attr_accessible :code, :code_type, :email, :phone, :status | |||||
| end | |||||
| @@ -10,14 +10,24 @@ class UsersService | |||||
| #参数约定 | #参数约定 | ||||
| #成功返回注册后的User实例,失败直接抛异常 | #成功返回注册后的User实例,失败直接抛异常 | ||||
| # 生成邀请码 | |||||
| CODES = %W(0 1 2 3 4 5 6 7 8 9) | |||||
| def generate_user_login type | |||||
| code = CODES.sample(8).join | |||||
| code = type + code.to_s | |||||
| return generate_user_login(type) if User.where(login: code).present? | |||||
| code | |||||
| end | |||||
| def register(params) | def register(params) | ||||
| @user = User.new | @user = User.new | ||||
| @user.admin = false | @user.admin = false | ||||
| @user.register | @user.register | ||||
| @user.login = params[:login] | |||||
| @user.login = generate_user_login params[:mail] ? 'm' : (params[:phone] ? 'p' : 'w') | |||||
| @user.mail = params[:mail] | @user.mail = params[:mail] | ||||
| password = params[:password] | |||||
| password_confirmation = params[:password_confirmation] | |||||
| @user.phone = params[:phone] | |||||
| password = params[:password] || params[:mail_password] | |||||
| password_confirmation = params[:password] || params[:mail_password] | |||||
| should_confirmation_password = params[:should_confirmation_password] | should_confirmation_password = params[:should_confirmation_password] | ||||
| if !password.blank? && !password_confirmation.blank? && should_confirmation_password | if !password.blank? && !password_confirmation.blank? && should_confirmation_password | ||||
| @user.password, @user.password_confirmation = password, password_confirmation | @user.password, @user.password_confirmation = password, password_confirmation | ||||
| @@ -26,13 +36,17 @@ class UsersService | |||||
| else | else | ||||
| @user.password = "" | @user.password = "" | ||||
| end | end | ||||
| case Setting.self_registration | |||||
| when '1' | |||||
| @user = email_activation_register(@user) | |||||
| when '3' | |||||
| @user = automatically_register(@user) | |||||
| else | |||||
| @user = administrator_manually__register(@user) | |||||
| if params[:mail] | |||||
| case Setting.self_registration | |||||
| when '1' | |||||
| @user = email_activation_register(@user) | |||||
| when '3' | |||||
| @user = automatically_register(@user) | |||||
| else | |||||
| @user = administrator_manually__register(@user) | |||||
| end | |||||
| else | |||||
| @user = automatically_register(@user) | |||||
| end | end | ||||
| if @user.id != nil | if @user.id != nil | ||||
| ue = @user.user_extensions ||= UserExtensions.new | ue = @user.user_extensions ||= UserExtensions.new | ||||
| @@ -0,0 +1,12 @@ | |||||
| <div class="task-popup" style="width: 550px;"> | |||||
| <div class=" task-popup-title clearfix"> | |||||
| <h3 class="fl color-grey">提示</h3> | |||||
| <a href="<%= signin_path %>"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a> | |||||
| </div> | |||||
| <div class="task-popup-content"> | |||||
| <p class="task-popup-text-center font-16">您已经成功设置密码,请使用新密码登录!</p> | |||||
| </div> | |||||
| <div class="task-popup-submit clearfix inner-t-c"> | |||||
| <a href="<%= signin_path %>" class="task-btn task-btn-green">确定</a> | |||||
| </div> | |||||
| </div> | |||||
| @@ -1,90 +1,63 @@ | |||||
| <div class="new_content"> | |||||
| <div class="email_verify"> | |||||
| <p class="email_verify_prompt"><span class="icons_email_prompt"></span>您的账号尚未激活,请先进入您的注册邮箱(<span class="c_red" id="user_email_show"><%= @user.mail %></span>),激活您的账号。</p> | |||||
| <button class="email_verify_btn mt30 ml30" onclick = "resendMail('<%= resendmail_path(@user) %>','<%= @user.id %>');">重新发送激活邮件</button> | |||||
| <%#= link_to l(:label_mail_resend), { :controller => 'account', :action => 'resendmail',:user => @user}, :class=>"email_verify_btn mt30 ml30", :remote => true, :method => 'get' %> | |||||
| <ul class="email_prompt_txt ml30 mt30" style="width:580px;margin-bottom: 20px"> | |||||
| <p class="email_prompt_p">如果您尚未收到激活邮件,请按照以下步骤操作:</p> | |||||
| <li>检查邮箱的“订阅邮件”、“垃圾邮件”,可能会发现激活邮件。 </li> | |||||
| <li>如果激活邮件已无效,请点击重新发送激活邮件按钮。</li> | |||||
| <li>如果重发注册验证邮箱邮件仍然没有收到,请<a href="javascript:void(0);" class="link-blue" id="change_email">更换邮箱地址</a>,重新发送激活邮件</li> | |||||
| <li>如果您始终无法收到激活邮件,请直接给我们留言:</li> | |||||
| <div class="mt10"> | |||||
| <textarea style="resize: none;width: 570px;" class="email_prompt_mes" placeholder="<%= l(:label_email_feedback_tips) %>"></textarea> | |||||
| <div class="c1"></div> | |||||
| <button class="email_sub_btn fr" onclick="leave_email_activation_message('<%= leave_email_activation_message_path(1)%>','<%= @user.id %>');">确定</button> | |||||
| <div class="cl"></div> | |||||
| <% email = @user.mail.split("@")[1] %> | |||||
| <div class="new_login"> | |||||
| <div class="new-login-header clearfix"> | |||||
| <h2 class="fl">激活邮箱账号</h2> | |||||
| <p class="fr mt20 font-16"> | |||||
| <%= link_to '首页', home_path %> | |||||
| <span class="ml5 mr5">|</span> | |||||
| <%= link_to "帮助中心", "#{Setting.protocol}://#{Setting.host_name}/forums/1/memos/1168" %> | |||||
| </p> | |||||
| </div> | |||||
| <div class="new_login_con"> | |||||
| <div class=" task-email-box"> | |||||
| <div class="task-email-box-pd"> | |||||
| <div class="alert alert-blue mb20"> | |||||
| 您的账号尚未激活,请先登录您的邮箱,激活您的账号 | |||||
| </div> | |||||
| <span>只需要登录邮箱(<font id="user_email_show"><%= @user.mail %></font>),点击链接激活即可</span><br/> | |||||
| <a href="http://mail.<%= email %>" id="user_email_link" class="new_login_submit mt20 mb20" target="_blank">立即去邮箱激活账号</a> | |||||
| <span class="task-line"></span> | |||||
| <ul class="clearfix"> | |||||
| <li class="font-bd">还没有收到激活账号邮件?</li> | |||||
| <li>1:尝试到广告邮件、垃圾邮件目录中找找,邮件可能被误杀了</li> | |||||
| <li>2:再次发送验证邮件</li> | |||||
| <li>3:如果仍然没有收到注册验证邮件,请更换邮件地址</li> | |||||
| <li class="mt20 mb20"> | |||||
| <%= link_to '<span class="ml10"></span><span onclick="settime(this);">重新发送激活邮件<span><span class="mr10"></span>'.html_safe, { :controller => 'account', :action => 'resendmail', :user => @user},:id => 'resend_email_a', :class => 'task-btn fl mr20', :remote => true, :method => 'get' %> | |||||
| <a href="javascript:void(0)" class="task-btn fl" id="change_user_email"><span class="ml20"></span>更换邮件地址<span class="mr20"></span></a> | |||||
| <div class="cl"></div> | |||||
| </li> | |||||
| <li class="mt20 none" id="change_user_email_block"> | |||||
| <input type="text" class="new_loggin_users fl" name="user[mail]" id="user_new_email" placeholder="请输入有效的邮箱地址" style="width:325px; padding-left:5px;"> | |||||
| <a href="javascript:void(0);" class="fr task-btn-ver" onclick="submit_user_emails('<%= @user.id %>')"><span class="ml5"></span>确定<span class="mr5"></span></a> | |||||
| <p class="color-red fl" id="mail_req" style="display: none;">请输入正确的邮箱</p> | |||||
| <div class="cl"></div> | |||||
| </li> | |||||
| </ul> | |||||
| </div> | </div> | ||||
| </ul> | |||||
| </div> | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| <script type="text/javascript"> | |||||
| $(document).ready(function(){ | |||||
| $("#change_email").click(function(){ | |||||
| $.ajax({ | |||||
| url: "<%= change_user_email_user_path(@user) %>" | |||||
| }); | |||||
| }); | |||||
| }); | |||||
| function resendMail(url,id) | |||||
| { | |||||
| $.get( | |||||
| url, | |||||
| {user: id }, | |||||
| function (data) { | |||||
| //邮箱@之前用a**b格式显示 | |||||
| var mail = data.email; | |||||
| var pos = mail.indexOf("@"); | |||||
| var restr = mail.substring(1,pos-1); | |||||
| if( mail.split("@")[0].length > 2 ){ | |||||
| mail = mail.replace(restr,"***"); | |||||
| } | |||||
| $(".email_verify_btn").replaceWith("<p class='email_verify_p mt30 ml30'>激活邮件已发送至您的注册邮箱("+mail+"),请及时登录邮箱进行验证。</p>"); | |||||
| } | |||||
| ); | |||||
| } | |||||
| function leave_email_activation_message(url,user) | |||||
| { | |||||
| if ($(".email_prompt_mes").val().length == 0){ | |||||
| //弹框请他输入文字 | |||||
| var htmlvalue = "</br><div style='width:550px;text-align:center'>您的留言不能为空</div></br><div style='width:67px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn' onclick='hideModal()'>确定</a></div>"; | |||||
| pop_up_box(htmlvalue,580,30,50); | |||||
| return; | |||||
| } | |||||
| $.ajax({ | |||||
| url: url, | |||||
| data: {user: user, text: $(".email_prompt_mes").val() }, | |||||
| type: "POST", | |||||
| success: function (data) { | |||||
| var htmlvalue = "<div class='email_tancon'><h2 class='email_tan_title'>您的留言已发送</h2><p class='email_tan_p'>我们将尽快处理好并通知您。感谢您的反馈!</p></div>" | |||||
| pop_up_box(htmlvalue, 580, 30, 45); | |||||
| $(".email_prompt_mes").val(""); | |||||
| } | |||||
| }); | |||||
| } | |||||
| function regex_mv_name() | |||||
| { | |||||
| var name = $.trim($("#subject").val()); | |||||
| if(name.length == 0) | |||||
| { | |||||
| $("#mail_valid_feedback_tip").show(); | |||||
| return false; | |||||
| } | |||||
| else | |||||
| { | |||||
| $("#mail_valid_feedback_tip").hide(); | |||||
| return true; | |||||
| <script> | |||||
| var countdown = 60; | |||||
| function settime(val) { | |||||
| if (countdown == 0) { | |||||
| val.removeAttribute("disabled"); | |||||
| $("#resend_email_a").removeClass("task-btn-grey"); | |||||
| val.innerHTML="重新发送激活邮件"; | |||||
| countdown = 60; | |||||
| } else { | |||||
| val.setAttribute("disabled", true); | |||||
| $("#resend_email_a").addClass("task-btn-grey"); | |||||
| val.innerHTML=countdown + "s后可重新发送"; | |||||
| countdown--; | |||||
| if(countdown >= 0){ | |||||
| setTimeout(function() { | |||||
| settime(val) | |||||
| },1000) | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| function f_submit() | |||||
| { | |||||
| if(regex_mv_name()){ | |||||
| $("#new_memo").submit(); | |||||
| } | |||||
| } | |||||
| </script> | |||||
| </script> | |||||
| @@ -1,97 +1,55 @@ | |||||
| <title><%= l(:label_regiter_account)%></title> | |||||
| <% email = @user.mail.split("@")[1] %> | <% email = @user.mail.split("@")[1] %> | ||||
| <div class="new_content"> | |||||
| <div class="email_verify" style="width: 580px;"> | |||||
| <p class="fb f18" style="color:green;"><i class="icon-ok mr5 f18"></i>注册成功! | |||||
| <span style=" color:#3b94d6; font-size:12px; font-weight:normal;">请在24小时内点击邮件中的链接来激活您的账号。</span></p> | |||||
| <p class="f14 mt30 mb5">请登录邮箱(<span class="c_red" id="user_email_show"><%= @user.mail %></span>)收取账号激活邮件。<br/>点击邮件中的激活链接,方可使用该账号 | |||||
| </p> | |||||
| <p> | |||||
| <a href="http://mail.<%= email %>" class="btn btn-blue" target="_blank"><%= l(:label_check_email)%></a> | |||||
| <%= link_to "<input class='btn btn-blue' type='button' id='btn' value='重新发送激活邮件' onclick='settime(this)' />".html_safe, { :controller => 'account', :action => 'resendmail', :user => @user}, :remote => true, :method => 'get' %> | |||||
| </p> | |||||
| <ul class="email_prompt_txt mt30" style="width: 580px;"> | |||||
| <p class="email_prompt_p">如果您一直收不到激活邮件,请按照以下步骤操作:</p> | |||||
| <li>请确认是否填写了正确的邮箱地址 </li> | |||||
| <li>请注意查看邮箱中的“订阅邮件”、“垃圾邮件”,可能Trustie的邮件被误杀了</li> | |||||
| <li>请点击重新发送激活邮件按钮</li> | |||||
| <li>如果重发注册验证邮箱邮件仍然没有收到,请<a href="javascript:void(0);" class="link-blue" id="change_email">更换邮箱地址</a>,重新发送激活邮件</li> | |||||
| <li>如果您始终无法收到激活邮件,请直接给我们留言:</li> | |||||
| <div class="mt10"> | |||||
| <textarea style="resize: none;width: 570px;" class="email_prompt_mes" placeholder="<%= l(:label_email_feedback_tips) %>"></textarea> | |||||
| <div class="c1"></div> | |||||
| <button class="email_sub_btn fr" onclick="leave_email_activation_message('<%= leave_email_activation_message_path(1)%>','<%= @user.id %>');">确定</button> | |||||
| <div class="cl"></div> | |||||
| <div class="new_login"> | |||||
| <div class="new-login-header clearfix"> | |||||
| <h2 class="fl">激活邮箱账号</h2> | |||||
| <p class="fr mt20 font-16"> | |||||
| <%= link_to '首页', home_path %> | |||||
| <span class="ml5 mr5">|</span> | |||||
| <%= link_to "帮助中心", "#{Setting.protocol}://#{Setting.host_name}/forums/1/memos/1168" %> | |||||
| </p> | |||||
| </div> | |||||
| <div class="new_login_con"> | |||||
| <div class=" task-email-box"> | |||||
| <div class="task-email-box-pd"> | |||||
| <h2 class="color-light-green mb10" ><i class="fa fa-envelope mr10 font-18 "></i>激活邮件已发送</h2> | |||||
| <span>只需要登录邮箱(<font id="user_email_show"><%= @user.mail %></font>),点击链接激活即可</span><br/> | |||||
| <a href="http://mail.<%= email %>" id="user_email_link" class="new_login_submit mt20 mb20" target="_blank">立即去邮箱激活账号</a> | |||||
| <span class="task-line"></span> | |||||
| <ul class="clearfix"> | |||||
| <li class="font-bd">还没有收到激活账号邮件?</li> | |||||
| <li>1:尝试到广告邮件、垃圾邮件目录中找找,邮件可能被误杀了</li> | |||||
| <li>2:再次发送验证邮件</li> | |||||
| <li>3:如果仍然没有收到注册验证邮件,请更换邮件地址</li> | |||||
| <li class="mt20 mb20"> | |||||
| <%= link_to '<span class="ml10"></span><span onclick="settime(this);">重新发送激活邮件<span><span class="mr10"></span>'.html_safe, { :controller => 'account', :action => 'resendmail', :user => @user},:id => 'resend_email_a', :class => 'task-btn fl mr20', :remote => true, :method => 'get' %> | |||||
| <a href="javascript:void(0)" class="task-btn fl" id="change_user_email"><span class="ml20"></span>更换邮件地址<span class="mr20"></span></a> | |||||
| <div class="cl"></div> | |||||
| </li> | |||||
| <li class="mt20 none" id="change_user_email_block"> | |||||
| <input type="text" class="new_loggin_users fl" name="user[mail]" id="user_new_email" placeholder="请输入有效的邮箱地址" style="width:325px; padding-left:5px;"> | |||||
| <a href="javascript:void(0);" class="fr task-btn-ver" onclick="submit_user_emails('<%= @user.id %>')"><span class="ml5"></span>确定<span class="mr5"></span></a> | |||||
| <p class="color-red fl" id="mail_req" style="display: none;">请输入正确的邮箱</p> | |||||
| <div class="cl"></div> | |||||
| </li> | |||||
| </ul> | |||||
| </div> | </div> | ||||
| </ul> | |||||
| </div> | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| <script> | <script> | ||||
| $(document).ready(function(){ | |||||
| $("#change_email").click(function(){ | |||||
| $.ajax({ | |||||
| url: "<%= change_user_email_user_path(@user) %>" | |||||
| }); | |||||
| }); | |||||
| }); | |||||
| function leave_email_activation_message(url,user) | |||||
| { | |||||
| if ($(".email_prompt_mes").val().length == 0){ | |||||
| //弹框请他输入文字 | |||||
| var htmlvalue = "</br><div style='width:550px;text-align:center'>您的留言不能为空</div></br><div style='width:67px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn' onclick='hideModal()'>确定</a></div>"; | |||||
| pop_up_box(htmlvalue,580,30,50); | |||||
| return; | |||||
| } | |||||
| $.ajax({ | |||||
| url: url, | |||||
| data: {user: user, text: $(".email_prompt_mes").val() }, | |||||
| type: "POST", | |||||
| success: function (data) { | |||||
| var htmlvalue = "<div class='email_tancon'><h2 class='email_tan_title'>您的留言已发送</h2><p class='email_tan_p'>我们将尽快处理好并通知您。感谢您的反馈!</p></div>" | |||||
| pop_up_box(htmlvalue, 580, 30, 50); | |||||
| $(".email_prompt_mes").val(""); | |||||
| } | |||||
| }); | |||||
| } | |||||
| function regex_mv_name() | |||||
| { | |||||
| var name = $.trim($("#subject").val()); | |||||
| if(name.length == 0) | |||||
| { | |||||
| $("#mail_valid_feedback_tip").show(); | |||||
| return false; | |||||
| } | |||||
| else | |||||
| { | |||||
| $("#mail_valid_feedback_tip").hide(); | |||||
| return true; | |||||
| } | |||||
| } | |||||
| function f_submit() | |||||
| { | |||||
| if(regex_mv_name()){ | |||||
| $("#new_memo").submit(); | |||||
| } | |||||
| } | |||||
| var countdown = 60; | var countdown = 60; | ||||
| function settime(val) { | function settime(val) { | ||||
| if (countdown == 0) { | if (countdown == 0) { | ||||
| val.removeAttribute("disabled"); | val.removeAttribute("disabled"); | ||||
| $("#btn").removeClass("btn-grey"); | |||||
| val.value="重新获取验证码"; | |||||
| $("#resend_email_a").removeClass("task-btn-grey"); | |||||
| val.innerHTML="重新发送激活邮件"; | |||||
| countdown = 60; | countdown = 60; | ||||
| } else { | } else { | ||||
| val.setAttribute("disabled", true); | val.setAttribute("disabled", true); | ||||
| $("#btn").addClass("btn-grey"); | |||||
| val.value="重新发送(" + countdown + ")"; | |||||
| $("#resend_email_a").addClass("task-btn-grey"); | |||||
| val.innerHTML=countdown + "s后可重新发送"; | |||||
| countdown--; | countdown--; | ||||
| if(countdown >= 0){ | if(countdown >= 0){ | ||||
| setTimeout(function() { | setTimeout(function() { | ||||
| @@ -100,51 +58,4 @@ | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| $(function(){ | |||||
| var u = navigator.userAgent; | |||||
| if((u.indexOf('Android') > -1 || u.indexOf('Linux') > -1 ||u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1)){ | |||||
| $("#scrollsidebar").css("display","none"); | |||||
| return; | |||||
| } | |||||
| $(".closeSidebar, .hide-side-bar").click(function(){ | |||||
| $(".show_btn").css("display","none"); | |||||
| $("#scrollsidebar").css("display","none"); | |||||
| return false; | |||||
| }); | |||||
| $("#button1").click(function(){ | |||||
| myTips("反馈成功","success"); | |||||
| }); | |||||
| $("#scrollsidebar").fix({ | |||||
| float: 'right', //default.left or right | |||||
| minStatue: cookieget('minStatue'), | |||||
| skin: 'green', //default.gray or blue | |||||
| durationTime: 600 | |||||
| }); | |||||
| $("#subject").keydown(function(){ | |||||
| alert("2222"); | |||||
| var curLength=$("#subject").val().length; | |||||
| if(curLength>50){ | |||||
| var num=$("#subject").val().substr(0,50); | |||||
| $("#subject").val(num); | |||||
| } | |||||
| else{ | |||||
| $("#textCount").text(50-$("#subject").val().length) | |||||
| } | |||||
| }).keyup(function(){ | |||||
| var curLength=$("#subject").val().length; | |||||
| if(curLength>50){ | |||||
| var num=$("#subject").val().substr(0,50); | |||||
| $("#subject").val(num); | |||||
| } | |||||
| else{ | |||||
| $("#textCount").text(50-$("#subject").val().length) | |||||
| } | |||||
| }); | |||||
| }); | |||||
| </script> | </script> | ||||
| @@ -1,159 +1,53 @@ | |||||
| <%= stylesheet_link_tag 'css/common'%> | |||||
| <%= stylesheet_link_tag 'css/public'%> | |||||
| <script type="text/javascript"> | |||||
| $(document).ready(function(){ | |||||
| $(".homepageSearchIcon").click(function(){ | |||||
| var val=$('input:radio[name="search_type"]:checked').val(); | |||||
| if(val==null){ | |||||
| $("#navSearchAlert").css({display:"block"}); | |||||
| } | |||||
| else { | |||||
| $("#navSearchAlert").css({display:"none"}); | |||||
| } | |||||
| }); | |||||
| }); | |||||
| $(document).ready(function(){ | |||||
| $(".navHomepageSearchBoxcontainer").mouseover(function(){ | |||||
| $(".navSearchTypeBox").css({display:"block"}); | |||||
| }); | |||||
| $(".navHomepageSearchBoxcontainer").mouseout(function(){ | |||||
| $(".navSearchTypeBox").css({display:"none"}); | |||||
| }); | |||||
| }) | |||||
| $(document).ready(function(){ | |||||
| if(<%= @login%>){ | |||||
| $("#signUpBox").css({display:"none"}); | |||||
| $("#loginInBox").css({display:"block"}); | |||||
| }else{ | |||||
| $("#signUpBox").css({display:"block"}); | |||||
| $("#loginInBox").css({display:"none"}); | |||||
| } | |||||
| }); | |||||
| var $login_correct = false; | |||||
| var $mail_correct = false; | |||||
| var $passwd_correct = false; | |||||
| var $passwd_comfirm_correct = false; | |||||
| jQuery(document).ready(function () { | |||||
| var $login = $('#user_login') | |||||
| var $mail = $('#user_mail') | |||||
| var $password = $('#user_password') | |||||
| var $password_confirmation = $('#user_password_confirmation') | |||||
| $login.blur(function (event) { | |||||
| if ($(this).is('#user_login')) { | |||||
| if (/^[a-zA-Z][a-zA-Z\d]{3,14}$/.test(this.value) == false){ | |||||
| $('#login_req').html('<span style="color: #c00202">只能使用英文字母和数字,必须以字母开头,长度不少于4个字符、不超过15个字符</span>'); | |||||
| $('#login_req').show(); | |||||
| return ; | |||||
| } | |||||
| else{ | |||||
| $.get( | |||||
| '<%=account_valid_ajax_path%>', | |||||
| { valid: "login", | |||||
| value: this.value }, | |||||
| function (data) { | |||||
| if (data.valid) { | |||||
| $('#login_req').html('<span style="color: green">'+data.message+'</span>'); | |||||
| $login_correct = true; | |||||
| } else { | |||||
| $('#login_req').html( '<span style="color: #c00202">'+data.message+'</span>'); | |||||
| $login_correct = false; | |||||
| } | |||||
| $('#login_req').css('display','block'); | |||||
| }); | |||||
| } | |||||
| } | |||||
| // ; | |||||
| }); | |||||
| $mail.blur(function (event) { | |||||
| if (/^[a-zA-Z0-9]+([._\\]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(this.value) == false){ | |||||
| $('#mail_req').html( '<span style="color: #c00202">邮件格式不对</span>').show(); | |||||
| $mail_correct = false; | |||||
| return ; | |||||
| } | |||||
| if ($(this).is('#user_mail')) { | |||||
| $.get('<%=account_valid_ajax_path%>', | |||||
| { valid: "mail", | |||||
| value: this.value }, | |||||
| function (data) { | |||||
| if (data.valid) { | |||||
| $('#mail_req').html( '<span style="color: green">'+data.message+'</span>' ); | |||||
| $mail_correct = true; | |||||
| } else { | |||||
| $('#mail_req').html( '<span style="color: #c00202">'+data.message+'</span>' ); | |||||
| $mail_correct = false; | |||||
| } | |||||
| $('#mail_req').css('display','block'); | |||||
| }); | |||||
| } | |||||
| ; | |||||
| }); | |||||
| $password.blur(function () { | |||||
| var pas1 = document.getElementById("user_password").value; | |||||
| var password_min_length = <%= Setting.password_min_length.to_i %> | |||||
| if (pas1.length >= password_min_length) { | |||||
| $('#passwd_req').html(''); | |||||
| $passwd_correct = true; | |||||
| } | |||||
| else { | |||||
| $('#passwd_req').html( '<span style="color: #c00202">'+'<%= l(:setting_password_min_length_limit, :count => Setting.password_min_length.to_i) %>'+'</span>'); | |||||
| $passwd_correct = false; | |||||
| } | |||||
| $('#passwd_req').css('display','block'); | |||||
| }); | |||||
| $password_confirmation.blur(function () { | |||||
| var password_min_length = <%= Setting.password_min_length.to_i %> | |||||
| var pas1 = document.getElementById("user_password").value; | |||||
| var pas2 = document.getElementById("user_password_confirmation").value; | |||||
| if (pas1.length >= password_min_length && pas1 == pas2 ) { | |||||
| $('#confirm_req').html('<span style="color: green">'+'<%= l(:setting_password_success) %>'+'</span>'); | |||||
| $passwd_comfirm_correct = true; | |||||
| } | |||||
| else { | |||||
| $('#confirm_req').html('<span style="color: #c00202">'+'<%= l(:setting_password_error) %>'+'</span>'); | |||||
| $passwd_comfirm_correct = false; | |||||
| } | |||||
| $('#confirm_req').css('display','block'); | |||||
| }); | |||||
| }); | |||||
| </script> | |||||
| <div class="new_login" id = "loginInBox"> | |||||
| <div class="new_login "> | |||||
| <div class="new-login-header clearfix"> | |||||
| <h2 class="fl">登录</h2> | |||||
| <p class="fr mt20 font-16"> | |||||
| <%= link_to '首页', home_path %> | |||||
| <span class="ml5 mr5">|</span> | |||||
| <%= link_to "帮助中心", "#{Setting.protocol}://#{Setting.host_name}/forums/1/memos/1168" %> | |||||
| </p> | |||||
| </div> | |||||
| <div class="new_login_con"> | <div class="new_login_con"> | ||||
| <div class="new_login_txt fl"> | |||||
| <h3> 欢迎加入Trustie创新实践社区</h3> | |||||
| <p>在这里,您的创新意识和创新潜力将得到充分发挥!目前已有超过200所高校和科研机构在平台中开展在线协同开发、协同学习和协同研究。</p> | |||||
| </div> | |||||
| <div class="new_login_box fr mr45 mt100"> | |||||
| <% if @message %> | |||||
| <p class="f14 mb5" style=" color:#fff;"><i class="icon-ok mr5"></i><%= h @message %></p> | |||||
| <% end %> | |||||
| <h2 class="new_login_h2">登录 | |||||
| <a href="<%= register_url_without_domain %>" class="fr mt5">立即注册</a><div class="cl"></div> | |||||
| </h2> | |||||
| <div class="new_login_form"> | |||||
| <%= form_tag(signin_path,:id=>'main_login_form',:method=>'post') do %> | |||||
| <div class="new_login_box clearfix"> | |||||
| <ul class="new_login_weixin clearfix"> | |||||
| <p class="" style="text-align: center; font-size: 18px;">登录</p> | |||||
| <!--<li id="login_weixin_nav_1" class="login_weixin_nav_hover" onclick="bigDataHoverLi(1);">--> | |||||
| <!--<a href="javascript:void(0);" class="login_weixin_nav_nomal" ><i class="fa fa-qrcode mr10 mt3 font-16"></i>扫码登录</a>--> | |||||
| <!--</li>--> | |||||
| <!--<li id="login_weixin_nav_2" onclick="bigDataHoverLi(2);" >--> | |||||
| <!--<a href="javascript:void(0);" class="login_weixin_nav_nomal" ><i class="fa fa-desktop mr10 mt3 "></i>密码登录</a>--> | |||||
| <!--</li>--> | |||||
| </ul> | |||||
| <div id="login_weixin_content_1" class="undis"> | |||||
| <div class="code_wxbox" > | |||||
| <div class="wx_img" id="login_QR_img"><img src="images/bigdata/trustie_QR.jpg" width="150" height="150"></div> | |||||
| <div class="wx_img" id="wx_help_img" style="display:none;"><img src="images/bigdata/wx_help.png" width="150" height="150"></div> | |||||
| <div class="wx_0s"> | |||||
| <div class="ts mb10">请使用微信扫描上方二维码登录</div> | |||||
| <div class="usehelp"> | |||||
| <a href="javascript:void(0)" onmouseover="$('#login_QR_img').hide(); $('#wx_help_img').show();" onmouseout="$('#login_QR_img').show(); $('#wx_help_img').hide();" class="wx_help">使用帮助</a> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <div id="login_weixin_content_2"> | |||||
| <div class="new_login_form"> | |||||
| <p class="fr mt10 mb10 font-12">没有账号? | |||||
| <a href="<%= user_join_path %>" class="ml10">立即注册</a> | |||||
| </p> | |||||
| <div class="cl"></div> | |||||
| <%= form_tag(signin_path,:id=>'main_login_form',:method=>'post') do %> | |||||
| <%= back_url_hidden_field_tag %> | <%= back_url_hidden_field_tag %> | ||||
| <ul> | <ul> | ||||
| <li class="new_loggin_users"> | <li class="new_loggin_users"> | ||||
| <%= text_field_tag 'username', params[:username], :tabindex => '1', :class=>'new_loggin_input',:placeholder=>'请输入邮箱地址或登录名', :onkeypress => "user_name_keypress(event);"%> | |||||
| <i class="fa fa-user font-16 ml10 color-grey"></i> | |||||
| <input type="text" id="name_loggin_input" name="username" class="new_loggin_input" placeholder="手机/邮箱" onkeypress="user_name_keypress(event);"> | |||||
| </li> | </li> | ||||
| <li class="new_login_lock"> | |||||
| <%= password_field_tag 'password', nil, :tabindex => '2', :class => 'new_loggin_input' , :placeholder => '请输入登录密码', :onkeypress => "user_name_keypress(event);"%> | |||||
| <p class="new_login_error"><%= flash.empty? || flash[:error].nil? ? "" : flash[:error].html_safe %></p> | |||||
| <li class="new_loggin_users"> | |||||
| <i class="fa fa-lock font-16 ml10 color-grey"></i> | |||||
| <input type="password" id="password_loggin_input" name="password" class="new_loggin_input" placeholder="请输入密码" onkeypress="user_name_keypress(event);"> | |||||
| </li> | </li> | ||||
| <p id="login_error_notice" class="color-red mb5" style="margin-top: -15px;"><%= flash.empty? || flash[:error].nil? ? "" : flash[:error].html_safe %></p> | |||||
| <li> | <li> | ||||
| <% if Setting.autologin? %> | <% if Setting.autologin? %> | ||||
| <label><%= check_box_tag 'autologin', 1, true, :tabindex => 4, :class => "new_login_check" %><%= l(:label_stay_logged_in) %></label> | <label><%= check_box_tag 'autologin', 1, true, :tabindex => 4, :class => "new_login_check" %><%= l(:label_stay_logged_in) %></label> | ||||
| @@ -163,59 +57,47 @@ | |||||
| </a> | </a> | ||||
| <div class="cl"></div> | <div class="cl"></div> | ||||
| </li> | </li> | ||||
| <li><button type="submit" class="new_login_submit"><a href="javascript:void(0);" id="login_btn" onclick="$('#main_login_form').submit();" style="text-decoration: none;">登录</a></button></li> | |||||
| </ul> | |||||
| <% end %> | |||||
| </div> | |||||
| </div> | |||||
| <div class="cl"></div> | |||||
| </div> | |||||
| </div> | |||||
| <%# 注册 %> | |||||
| <div class="new_register" id = "signUpBox"> | |||||
| <div class="new_register_con"> | |||||
| <div class="new_login_txt fl new_register_left"> | |||||
| <h3> 欢迎加入Trustie创新实践社区</h3> | |||||
| <p>在这里,您的创新意识和创新潜力将得到充分发挥!目前已有超过200所高校和科研机构在平台中开展在线协同开发、协同学习和协同研究。</p> | |||||
| </div> | |||||
| <div class="new_login_box fr mr45 mt50"> | |||||
| <h2 class="new_login_h2">注册<a href="<%= signin_url_without_domain %>" class="fr mt5">已有账号 请登录</a><div class="cl"></div></h2> | |||||
| <div class="new_login_form"> | |||||
| <%= form_for :user, :url => register_path,:method=>'post', :html => {:id=>'main_reg_form'} do |f| %> | |||||
| <%= error_messages_for 'user' %> | |||||
| <ul> | |||||
| <li class="new_register_li"> | |||||
| <%= f.text_field :mail, :size => 25, :class => 'new_register_input' , :placeholder => "请输入邮箱地址"%> | |||||
| <p class="new_login_error" id="mail_req" style="display: none" >请输入正确的邮箱</p> | |||||
| </li> | |||||
| <li class="new_register_li"> | |||||
| <%= f.password_field :password, :size => 25, :placeholder => "请输入密码", :class => 'new_register_input' %> | |||||
| <p class="new_login_error" id="passwd_req" style="display: none">请输入6-16位密码,区分大小写,不能使用空格!</p> | |||||
| </li> | |||||
| <li class="new_register_li"> | |||||
| <%= f.password_field :password_confirmation, :size => 25, :placeholder => "请再次输入密码", :class=> 'new_register_input' %> | |||||
| <p class="new_login_error" id="confirm_req" style="display: none">两次密码不一致!</p> | |||||
| </li> | |||||
| <li class="new_register_li mb8"> | |||||
| <%= f.text_field :login, :size => 25, :placeholder => "请输入用户登录名", :class => 'new_register_input'%> | |||||
| </li> | |||||
| <li class="mb8"> | |||||
| <p class="new_login_error" id="login_req" style="display: none">只能使用英文字母和数字,必须以字母开头,长度不少于4个字符、不超过15个字符</p> | |||||
| </li> | |||||
| <li> | <li> | ||||
| <label><input type="checkbox" checked id="read_and_confirm" onchange="changeRegisterBtn(this);" class=" new_login_check">我已阅读并接受<a href="<%= agreement_path %>" >Trustie服务协议条款</a></label> | |||||
| <button type="submit" class ="new_login_submit"><a href="javascript:void(0);" onclick="loginin();" id="login_btn" style="text-decoration:none;">登录</a></button> | |||||
| </li> | </li> | ||||
| <li> | |||||
| <div class="new_login_submit" id="loginUpButton"> | |||||
| <a href="javascript:void(0);" id="regist_btn" onclick="register();" class ="db" style="text-decoration: none;">注册</a> | |||||
| </div> | |||||
| </ul> | </ul> | ||||
| <% end %> | |||||
| <% end %> | |||||
| </div> | |||||
| </div> | </div> | ||||
| <div class="cl"></div> | |||||
| </div> | </div> | ||||
| <div class="cl"></div> | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| <script type="text/javascript" language="javascript"> | |||||
| //登录tab | |||||
| function g(o){ | |||||
| return document.getElementById(o); | |||||
| } | |||||
| function HoverLi(n){ | |||||
| for(var i=1;i<=2;i++){ | |||||
| g('login_weixin_nav_'+i).className='login_weixin_nav_nomal'; | |||||
| g('login_weixin_content_'+i).className='undis'; | |||||
| } | |||||
| g('login_weixin_nav_'+n).className='login_weixin_nav_hover'; | |||||
| g('login_weixin_content_'+n).className='dis'; | |||||
| } | |||||
| $(function(){ | |||||
| <% if flash[:error] || !flash.empty? %> | |||||
| for(var i=1;i<=2;i++){ | |||||
| g('login_weixin_nav_'+i).className='login_weixin_nav_nomal'; | |||||
| g('login_weixin_content_'+i).className='undis'; | |||||
| } | |||||
| g('login_weixin_nav_2').className='login_weixin_nav_hover'; | |||||
| g('login_weixin_content_2').className='dis'; | |||||
| <% end %> | |||||
| $("#name_loggin_input").on('focus', function(){ | |||||
| $("#login_error_notice").html(""); | |||||
| }); | |||||
| $("#password_loggin_input").on('focus', function(){ | |||||
| $("#login_error_notice").html(""); | |||||
| }); | |||||
| }); | |||||
| </script> | |||||
| @@ -1,26 +1,58 @@ | |||||
| <%= stylesheet_link_tag 'css/public'%> | |||||
| <div class="homepageContentContainer "> | |||||
| <div class="homepageContent BgBox"> | |||||
| <h2 class="BgBox_h2">忘记密码</h2> | |||||
| <div class="BgBoxCon"> | |||||
| <%= form_tag(lost_password_path) do %> | |||||
| <p class="BgBoxConP mb5">通过注册邮箱链接重设密码</p> | |||||
| <!--<input type="text" class="NomalInput mb20 " value="请输入登录邮箱地址" />--> | |||||
| <%= text_field_tag 'mail', nil, :size => 40, :placeholder => '请输入注册邮箱',:class=>'NomalInput mb20'%> | |||||
| <% if flash[:error] %> | |||||
| <p class="c_red mt-20 ml5"><%= flash[:error]%></p> | |||||
| <!--<div style="color: red" class="mb5" ><%#= flash[:error]%></div>--> | |||||
| <% elsif flash[:notice] %> | |||||
| <p class="c_green mb5"><%= flash[:notice]%></p> | |||||
| <!--<div style="color: green" class="mb5" ><%#= flash[:notice]%></div>--> | |||||
| <% end %> | |||||
| <div class="LoginButton"><a href="javascript:void(0);" class="c_white db" onclick="$(this).parent().parent().submit();">提交</a></div> | |||||
| <% end %> | |||||
| <div class="new_login"> | |||||
| <div class="new-login-header clearfix"> | |||||
| <h2 class="fl">找回密码</h2> | |||||
| <p class="fr mt20 font-16"> | |||||
| <%= link_to '首页', home_path %> | |||||
| <span class="ml5 mr5">|</span> | |||||
| <%= link_to "帮助中心", "#{Setting.protocol}://#{Setting.host_name}/forums/1/memos/1168" %> | |||||
| </p> | |||||
| </div> | |||||
| <div class="password-header clearfix"> | |||||
| <h3 class="fl ml15">找回密码</h3> | |||||
| <span class="fl ml10 mr10 mt3 " >|</span> | |||||
| <span class="fl mt3">第一步:安全验证</span> | |||||
| </div> | |||||
| <div class="new_login_con"> | |||||
| <div class="new_login_box clearfix"> | |||||
| <div class="new_login_form"> | |||||
| <form> | |||||
| <ul> | |||||
| <li class="new_loggin_users"> | |||||
| <i class="fa fa-user font-16 ml10 color-grey"></i> | |||||
| <input type="text" class="new_loggin_input" id="lost_psd_input" style="width: 290px;" placeholder="请输入邮箱或手机号"> | |||||
| <i class="fa font-16 mr5" id="user_phone_check"></i> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="user_phone_notice"></p> | |||||
| </div> | |||||
| </li> | |||||
| <li class="pr"> | |||||
| <div id="drag" class="drag_slider"></div> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="user_verification_notice"></p> | |||||
| </div> | |||||
| </li> | |||||
| <li class="pr"> | |||||
| <input type="text" class="new_loggin_input_test fl" id="psd_verification_code" placeholder="请输入收到的验证码"> | |||||
| <a href="javascript:void(0);" class="fr task-btn-ver" onclick="get_psd_verification_code(this)">获取验证码</a> | |||||
| <input class="none" id="ver_code_type"> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="phone_verification_code_notice"></p> | |||||
| </div> | |||||
| <div class="cl"></div> | |||||
| </li> | |||||
| <p id="send_success_notice" class="none" style="margin-top: -15px; margin-bottom: 10px;"></p> | |||||
| <li><a href="javascript:void(0)" class="new_login_submit" id="lost_psd_next_a" onclick="lost_psd_next();">下一步</a></li> | |||||
| </ul> | |||||
| </form> | |||||
| <div class="new-loggin-other mt50 none"> | |||||
| <a href="#"><img src="/images/login/img-weixin.png" width="50" height="50" class="task-img-weixin mb10" alt="微信登录"></a><br/> | |||||
| <span>使用第三方账号</span> | |||||
| </div> | |||||
| </div> | |||||
| </div> | </div> | ||||
| </div><!---BgBox end---> | |||||
| </div><!---homepageContentContainer end---> | |||||
| </body> | |||||
| </html> | |||||
| </div> | |||||
| </div> | |||||
| <script type="text/javascript"> | |||||
| $('#drag').drag(); | |||||
| </script> | |||||
| @@ -0,0 +1,42 @@ | |||||
| <div class="new_login"> | |||||
| <div class="new-login-header clearfix"> | |||||
| <h2 class="fl">找回密码</h2> | |||||
| <p class="fr mt20 font-16"> | |||||
| <%= link_to '首页', home_path %> | |||||
| <span class="ml5 mr5">|</span> | |||||
| <%= link_to "帮助中心", "#{Setting.protocol}://#{Setting.host_name}/forums/1/memos/1168" %> | |||||
| </p> | |||||
| </div> | |||||
| <div class="password-header clearfix"> | |||||
| <h3 class="fl ml15">找回密码</h3> | |||||
| <span class="fl ml10 mr10 mt3">|</span> | |||||
| <span class="fl mt3">第二步:设置新密码</span> | |||||
| </div> | |||||
| <div class="new_login_con"> | |||||
| <div class="new_login_box clearfix"> | |||||
| <div class="new_login_form"> | |||||
| <%= form_tag(account_reset_psd_path, :remote => true, :method => 'post') do %> | |||||
| <ul> | |||||
| <input type="hidden" name="user" value="<%= @user.id %>"> | |||||
| <input type="hidden" id="password_min_length" value="<%= Setting.password_min_length.to_i %>"> | |||||
| <li class="new_loggin_users"> | |||||
| <i class="fa fa-lock font-16 ml10 color-grey"></i> | |||||
| <input type="password" class="new_loggin_input" name="new_password" id="new_password" placeholder="设置新密码"> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="new_password_notice">至少8位由字母或特殊符号和数字结合</p> | |||||
| </div> | |||||
| </li> | |||||
| <li class="new_loggin_users"> | |||||
| <i class="fa fa-lock font-16 ml10 color-grey"></i> | |||||
| <input type="password" class="new_loggin_input" name="new_password_confirmation" id="new_password_confirmation" placeholder="确认新密码"> | |||||
| <div class="new-login-error none" style="display: none;"> | |||||
| <p id="new_password_confirmation_notice">两次密码输入不一致</p> | |||||
| </div> | |||||
| </li> | |||||
| <li><a href="javascript:void(0)" class="new_login_submit" id="new_psd_submit">完成</a></li> | |||||
| </ul> | |||||
| <% end %> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| @@ -0,0 +1,2 @@ | |||||
| var htmlvalue = "<%= j(render :partial => 'account/reset_psd_notice_box') %>"; | |||||
| pop_box_new(htmlvalue, 552, 500); | |||||
| @@ -0,0 +1,279 @@ | |||||
| <div class="new_login "> | |||||
| <div class="new-login-header clearfix"> | |||||
| <h2 class="fl">注册</h2> | |||||
| <p class="fr mt20 font-16"> | |||||
| <%= link_to '首页', home_path %> | |||||
| <span class="ml5 mr5">|</span> | |||||
| <%= link_to "帮助中心", "#{Setting.protocol}://#{Setting.host_name}/forums/1/memos/1168" %> | |||||
| </p> | |||||
| </div> | |||||
| <div class="new_login_con"> | |||||
| <div class="new_login_box clearfix"> | |||||
| <ul class="new_login_weixin fl" > | |||||
| <li id="login_weixin_nav_1" class="login_weixin_nav_hover" onclick="bigDataHoverLi(1);"> | |||||
| <a href="javascript:void(0);" class="login_weixin_nav_nomal"><i class="fa fa-mobile-phone font-16 mr10 mt3"></i>手机注册</a> | |||||
| </li> | |||||
| <li id="login_weixin_nav_2" onclick="bigDataHoverLi(2);" > | |||||
| <a href="javascript:void(0);" class="login_weixin_nav_nomal"><i class="fa fa-envelope-o font-16 mr10 mt3"></i>邮箱注册</a> | |||||
| </li> | |||||
| </ul> | |||||
| <div id="login_weixin_content_1"> | |||||
| <div class="new_login_form"> | |||||
| <p class="fr mt10 mb10 font-12">已有账号?<a href="<%= signin_path %>" class="ml10">直接登录</a> | |||||
| </p> | |||||
| <div class="cl"></div> | |||||
| <%= form_for :user, :url => register_path,:method=>'post', :html => {:id=>'main_reg_form'} do |f| %> | |||||
| <%= error_messages_for 'user' %> | |||||
| <input type="text" name="none_name" style="display: none"> | |||||
| <input type="password" name="none_psw" style="display: none"> | |||||
| <ul> | |||||
| <li class="new_loggin_users"> | |||||
| <i class="fa fa-mobile-phone font-16 ml10 color-grey"></i> | |||||
| <input type="text" id="user_phone_num" name="user[phone]" class="new_loggin_input" autocomplete="off" placeholder="请输入手机号码"> | |||||
| <i class="fa font-16 mr5" id="user_phone_check"></i> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="user_phone_notice"></p> | |||||
| </div> | |||||
| </li> | |||||
| <li class="new_loggin_users"> | |||||
| <i class="fa fa-lock font-16 ml10 color-grey"></i> | |||||
| <input type="text" onfocus="this.type='password'" class="new_loggin_input" style="width: 292px;" name="user[password]" id="user_password_1" autocomplete="off" placeholder="密码至少由8位由字母或特殊符号和数字结合"> | |||||
| <i class="fa font-16 mr5" id="user_password_1_check"></i> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="user_password_1_notice"></p> | |||||
| </div> | |||||
| </li> | |||||
| <li class="pr"> | |||||
| <div id="drag" class="drag_slider"></div> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="user_verification_notice"></p> | |||||
| </div> | |||||
| </li> | |||||
| <li class="pr"> | |||||
| <input type="text" class="new_loggin_input_test fl" name="code" id="phone_verification_code" placeholder="请输入收到的短信验证码"> | |||||
| <a href="javascript:void(0);" class="fr task-btn-ver" onclick="get_phone_verification_code(this)" id="get_verification_code">获取验证码</a> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="phone_verification_code_notice"></p> | |||||
| </div> | |||||
| <div class="cl"></div> | |||||
| </li> | |||||
| <li class="pr"> | |||||
| <label><input type="checkbox" checked="checked" id="read_and_confirm_1" class="new_login_check"> 我已阅读并同意<a href="<%= agreement_path %>" target="_blank">服务协议条款</a></label> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="user_aggre_1_notice"></p> | |||||
| </div> | |||||
| <div class="cl"></div> | |||||
| </li> | |||||
| <li> | |||||
| <a href="javascript:void(0);" id="regist_btn_phone" onclick="phone_register();" class ="new_login_submit" style="text-decoration:none; color: #fff;">注册</a> | |||||
| </li> | |||||
| </ul> | |||||
| <% end %> | |||||
| </div> | |||||
| </div> | |||||
| <div id="login_weixin_content_2" class="undis"> | |||||
| <div class="new_login_form"> | |||||
| <p class="fr mt10 mb10 font-12">已有账号?<a href="<%= signin_path %>" class="ml10">直接登录</a> | |||||
| </p> | |||||
| <div class="cl"></div> | |||||
| <%= form_for :user, :url => register_path,:method=>'post', :html => {:id=>'main_reg_email_form'} do |f| %> | |||||
| <%= error_messages_for 'user' %> | |||||
| <input type="text" style="display: none"> | |||||
| <input type="password" style="display: none"> | |||||
| <ul > | |||||
| <li class="new_loggin_users"> | |||||
| <i class="fa fa-envelope-o font-16 ml10 color-grey"></i> | |||||
| <input type="text" class="new_loggin_input" name="user[mail]" id="user_email_addr" style="width: 286px;" autocomplete="off" placeholder="请输入有效的邮箱地址"> | |||||
| <i class="fa font-16 mr5" id="user_email_check"></i> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="user_email_addr_notice"></p> | |||||
| </div> | |||||
| </li> | |||||
| <li class="new_loggin_users"> | |||||
| <i class="fa fa-lock font-16 ml10 color-grey"></i> | |||||
| <input type="text" onfocus="this.type='password'" class="new_loggin_input" style="width: 292px;" name="user[mail_password]" id="user_password_2" autocomplete="off" placeholder="密码至少由8位由字母或特殊符号和数字结合"> | |||||
| <i class="fa font-16 mr5" id="user_password_2_check"></i> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="user_password_2_notice"></p> | |||||
| </div> | |||||
| </li> | |||||
| <li class="pr"> | |||||
| <label><input type="checkbox" id="read_and_confirm_2" checked="checked" class="new_login_check" > 我已阅读并同意<a href="<%= agreement_path %>" target="_blank">服务协议条款</a></label> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="user_aggre_2_notice"></p> | |||||
| </div> | |||||
| <div class="cl"></div> | |||||
| </li> | |||||
| <li> | |||||
| <a href="javascript:void(0);" id="regist_btn_email" onclick="email_register();" class ="new_login_submit" style="text-decoration:none; color: #fff;">注册</a> | |||||
| </li> | |||||
| </ul> | |||||
| <% end %> | |||||
| </div> | |||||
| </div> | |||||
| <div class="cl"></div> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <script type="text/javascript"> | |||||
| document.onkeydown=function(event){ | |||||
| e = event ? event :(window.event ? window.event : null); | |||||
| if(e.keyCode==13){ | |||||
| if($("#login_weixin_content_1").is(":visible")){ | |||||
| phone_register(); | |||||
| } else{ | |||||
| email_register(); | |||||
| } | |||||
| } | |||||
| }; | |||||
| $('#drag').drag(); | |||||
| var wait = 60; | |||||
| function get_phone_verification_code(btn) { | |||||
| if ($phone_correct){ | |||||
| if($('.drag_text').html() == "验证通过") { | |||||
| $.get( | |||||
| '<%=account_get_verification_code_path%>', | |||||
| { value: $('#user_phone_num').val().trim(), | |||||
| type: 1}, | |||||
| function (data) { | |||||
| if (data.status == "2") { | |||||
| $('#user_phone_notice').html('该手机号已被注册'); | |||||
| $('#user_phone_notice').parent().show(); | |||||
| } else { | |||||
| $('#user_phone_notice').html(''); | |||||
| $('#user_phone_notice').parent().hide(); | |||||
| time(btn); | |||||
| } | |||||
| }); | |||||
| } else{ | |||||
| $("#user_verification_notice").html("请先拖动滑块完成验证"); | |||||
| $('#user_verification_notice').parent().show(); | |||||
| } | |||||
| } | |||||
| } | |||||
| function time(btn){ | |||||
| if (wait==0) { | |||||
| $(btn).removeClass("rest-btn-ver"); | |||||
| btn.removeAttribute("disabled"); | |||||
| btn.innerHTML = "获取验证码"; | |||||
| wait = 60; | |||||
| return; | |||||
| }else{ | |||||
| $(btn).addClass("rest-btn-ver"); | |||||
| btn.setAttribute("disabled", "disabled"); | |||||
| btn.innerHTML = wait + "s后重试"; | |||||
| wait--; | |||||
| } | |||||
| setTimeout(function(){ | |||||
| time(btn); | |||||
| },1000); | |||||
| } | |||||
| var $phone_correct = false; | |||||
| var $mail_correct = false; | |||||
| var $passwd_1_correct = false; | |||||
| var $passwd_2_correct = false; | |||||
| jQuery(document).ready(function () { | |||||
| var $phone_num = $('#user_phone_num'); | |||||
| var $mail = $('#user_email_addr'); | |||||
| var $password1 = $('#user_password_1'); | |||||
| var $password2 = $('#user_password_2'); | |||||
| $phone_num.val(""); | |||||
| $mail.val(""); | |||||
| $password1.val(""); | |||||
| $password2.val(""); | |||||
| $phone_num.blur(function (event) { | |||||
| if ($(this).is('#user_phone_num')) { | |||||
| if (/^1\d{10}$/.test(this.value) == false){ | |||||
| $('#user_phone_notice').html('请输入有效的11位手机号码'); | |||||
| $('#user_phone_notice').parent().show(); | |||||
| $("#user_phone_check").removeClass("fa-check").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orenge"); | |||||
| return false; | |||||
| } | |||||
| else{ | |||||
| $.get( | |||||
| '<%=account_valid_ajax_path%>', | |||||
| { valid: "phone", | |||||
| value: this.value }, | |||||
| function (data) { | |||||
| if (data.valid) { | |||||
| $('#user_phone_notice').html(''); | |||||
| $('#user_phone_notice').parent().hide(); | |||||
| $("#user_phone_check").removeClass("fa-times-circle").removeClass("color-orenge").addClass("fa-check").addClass("color-light-green"); | |||||
| $phone_correct = true; | |||||
| } else { | |||||
| $('#user_phone_notice').html('该手机号已被注册'); | |||||
| $('#user_phone_notice').parent().show(); | |||||
| $("#user_phone_check").removeClass("fa-check").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orenge"); | |||||
| $phone_correct = false; | |||||
| } | |||||
| }); | |||||
| } | |||||
| } | |||||
| }); | |||||
| $mail.blur(function (event) { | |||||
| if (/^[a-zA-Z0-9]+([._\\]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(this.value) == false){ | |||||
| $('#user_email_addr_notice').html('邮箱地址格式不对'); | |||||
| $('#user_email_addr_notice').parent().show(); | |||||
| $("#user_email_check").removeClass("fa-check").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orenge"); | |||||
| $mail_correct = false; | |||||
| return ; | |||||
| } | |||||
| if ($(this).is('#user_email_addr')) { | |||||
| $.get('<%=account_valid_ajax_path%>', | |||||
| { valid: "mail", | |||||
| value: this.value }, | |||||
| function (data) { | |||||
| if (data.valid) { | |||||
| $('#user_email_addr_notice').html(''); | |||||
| $('#user_email_addr_notice').parent().hide(); | |||||
| $("#user_email_check").removeClass("fa-times-circle").removeClass("color-orenge").addClass("fa-check").addClass("color-light-green"); | |||||
| $mail_correct = true; | |||||
| } else { | |||||
| $('#user_email_addr_notice').html(data.message); | |||||
| $('#user_email_addr_notice').parent().show(); | |||||
| $("#user_email_check").removeClass("fa-check").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orenge"); | |||||
| $mail_correct = false; | |||||
| } | |||||
| }); | |||||
| } | |||||
| }); | |||||
| $password1.blur(function () { | |||||
| var pas1 = document.getElementById("user_password_1").value; | |||||
| var password_min_length = <%= Setting.password_min_length.to_i %>; | |||||
| if (pas1.length >= password_min_length) { | |||||
| $('#user_password_1_notice').html(''); | |||||
| $('#user_password_1_notice').parent().hide(); | |||||
| $("#user_password_1_check").removeClass("fa-times-circle").removeClass("color-orenge").addClass("fa-check").addClass("color-light-green"); | |||||
| $passwd_1_correct = true; | |||||
| } | |||||
| else { | |||||
| $('#user_password_1_notice').html('<%= l(:setting_password_min_length_limit, :count => Setting.password_min_length.to_i) %>'); | |||||
| $('#user_password_1_notice').parent().show(); | |||||
| $("#user_password_1_check").removeClass("fa-check").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orenge"); | |||||
| $passwd_1_correct = false; | |||||
| } | |||||
| }); | |||||
| $password2.blur(function () { | |||||
| var pas1 = document.getElementById("user_password_2").value; | |||||
| var password_min_length = <%= Setting.password_min_length.to_i %>; | |||||
| if (pas1.length >= password_min_length) { | |||||
| $('#user_password_2_notice').html(''); | |||||
| $('#user_password_2_notice').parent().hide(); | |||||
| $("#user_password_2_check").removeClass("fa-times-circle").removeClass("color-orenge").addClass("fa-check").addClass("color-light-green"); | |||||
| $passwd_2_correct = true; | |||||
| } | |||||
| else { | |||||
| $('#user_password_2_notice').html('<%= l(:setting_password_min_length_limit, :count => Setting.password_min_length.to_i) %>'); | |||||
| $('#user_password_2_notice').parent().show(); | |||||
| $("#user_password_2_check").removeClass("fa-check").removeClass("color-light-green").addClass("fa-times-circle").addClass("color-orenge"); | |||||
| $passwd_2_correct = false; | |||||
| } | |||||
| }); | |||||
| }); | |||||
| </script> | |||||
| @@ -0,0 +1,155 @@ | |||||
| <div class="new_login"> | |||||
| <div class="new-login-header clearfix"> | |||||
| <h2 class="fl">绑定账号</h2> | |||||
| <p class="fr mt20 font-16"> | |||||
| <%= link_to '首页', home_path %> | |||||
| <span class="ml5 mr5">|</span> | |||||
| <%= link_to "帮助中心", "#{Setting.protocol}://#{Setting.host_name}/forums/1/memos/1168" %> | |||||
| </p> | |||||
| </div> | |||||
| <div class="new_login_con"> | |||||
| <div class="new_login_box clearfix"> | |||||
| <div class="mb30 clearfix mt20 ml50"> | |||||
| <img src="images/inner/male.jpg" width="50" height="50" class="fl task-mail-img"> | |||||
| <p class="fl font-14 mt10 ml10"><span class="task-name fl">sa~sa~</span><span class="fl ml5">,您好!</span></p> | |||||
| <div class="cl"></div> | |||||
| </div> | |||||
| <ul class="new_login_weixin clearfix"> | |||||
| <li id="login_weixin_nav_1" class="login_weixin_nav_hover" onclick="bigDataHoverLi(1);"> | |||||
| <a href="javascript:void(0);" class="login_weixin_nav_nomal">关联已有账号</a> | |||||
| </li> | |||||
| <li id="login_weixin_nav_2" onclick="bigDataHoverLi(2);"> | |||||
| <a href="javascript:void(0);" class="login_weixin_nav_nomal">关联新账号</a> | |||||
| </li> | |||||
| </ul> | |||||
| <div id="login_weixin_content_1"> | |||||
| <div class="new_login_form"> | |||||
| <form class="mt20"> | |||||
| <ul> | |||||
| <li class="new_loggin_users"> | |||||
| <i class="fa fa-user font-16 ml10 color-grey"></i> | |||||
| <input type="text" class="new_loggin_input" style="width: 290px;" placeholder="手机/邮箱"> | |||||
| <i class="fa font-16 mr5"></i> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="user_bind_login_notice"></p> | |||||
| </div> | |||||
| </li> | |||||
| <li class="new_loggin_users"> | |||||
| <i class="fa fa-lock font-16 ml10 color-grey"></i> | |||||
| <input type="text" class="new_loggin_input" placeholder="请输入密码"> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="user_bind_psd_notice"></p> | |||||
| </div> | |||||
| </li> | |||||
| <li> | |||||
| <a href="javascript:void(0);" id="wechat_bind_btn" class ="new_login_submit" style="text-decoration:none; color: #fff;">完成</a> | |||||
| </li> | |||||
| </ul> | |||||
| </form> | |||||
| </div> | |||||
| </div> | |||||
| <div id="login_weixin_content_2" class="undis"> | |||||
| <div class="new_login_form"> | |||||
| <p class="fr mt10 mb10 font-12"> | |||||
| <a href="javascript:void(0);" onclick="$(this).parent().parent().hide(); $(this).parent().parent().next().show();">使用邮箱账号</a> | |||||
| </p> | |||||
| <div class="cl"></div> | |||||
| <%= form_for :user, :url => register_path,:method=>'post', :html => {:id=>'main_reg_form'} do |f| %> | |||||
| <ul> | |||||
| <li class="new_loggin_users"> | |||||
| <i class="fa fa-mobile-phone font-16 ml10 color-grey"></i> | |||||
| <input type="text" id="user_phone_num" name="user[phone]" class="new_loggin_input" autocomplete="off" placeholder="请输入手机号码"> | |||||
| <i class="fa font-16 mr5" id="user_phone_check"></i> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="user_phone_notice"></p> | |||||
| </div> | |||||
| </li> | |||||
| <li class="new_loggin_users"> | |||||
| <i class="fa fa-lock font-16 ml10 color-grey"></i> | |||||
| <input type="text" onfocus="this.type='password'" class="new_loggin_input" style="width: 292px;" name="user[password]" id="user_password_1" autocomplete="off" placeholder="密码至少由8位由字母或特殊符号和数字结合"> | |||||
| <i class="fa font-16 mr5" id="user_password_1_check"></i> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="user_password_1_notice"></p> | |||||
| </div> | |||||
| </li> | |||||
| <li class="pr"> | |||||
| <div id="drag" class="drag_slider"></div> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="user_verification_notice"></p> | |||||
| </div> | |||||
| </li> | |||||
| <li class="pr"> | |||||
| <input type="text" class="new_loggin_input_test fl" name="code" id="phone_verification_code" placeholder="请输入收到的短信验证码"> | |||||
| <a href="javascript:void(0);" class="fr task-btn-ver" onclick="get_phone_verification_code(this)" id="get_verification_code">获取验证码</a> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="phone_verification_code_notice"></p> | |||||
| </div> | |||||
| <div class="cl"></div> | |||||
| </li> | |||||
| <li class="pr"> | |||||
| <label><input type="checkbox" checked="checked" id="read_and_confirm_1" class="new_login_check"> 我已阅读并同意<a href="<%= agreement_path %>" target="_blank">服务协议条款</a></label> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="user_aggre_1_notice"></p> | |||||
| </div> | |||||
| <div class="cl"></div> | |||||
| </li> | |||||
| <li> | |||||
| <a href="javascript:void(0);" id="regist_btn_phone" onclick="phone_register();" class ="new_login_submit" style="text-decoration:none; color: #fff;">完成</a> | |||||
| </li> | |||||
| <li style="text-align: center;"><a href="javascript:void(0);" class="link-color-green" style="text-decoration:none;">跳过,自动注册并绑定</a></li> | |||||
| </ul> | |||||
| <% end %> | |||||
| <div class="cl"></div> | |||||
| </div> | |||||
| <div class="new_login_form undis"> | |||||
| <p class="fr mt10 mb10 font-12"> | |||||
| <a href="javascript:void(0);" onclick="$(this).parent().parent().hide(); $(this).parent().parent().prev().show();">使用手机账号</a> | |||||
| </p> | |||||
| <div class="cl"></div> | |||||
| <%= form_for :user, :url => register_path,:method=>'post', :html => {:id=>'main_reg_email_form'} do |f| %> | |||||
| <%= error_messages_for 'user' %> | |||||
| <input type="text" style="display: none"> | |||||
| <input type="password" style="display: none"> | |||||
| <ul > | |||||
| <li class="new_loggin_users"> | |||||
| <i class="fa fa-envelope-o font-16 ml10 color-grey"></i> | |||||
| <input type="text" class="new_loggin_input" name="user[mail]" id="user_email_addr" style="width: 286px;" autocomplete="off" placeholder="请输入有效的邮箱地址"> | |||||
| <i class="fa font-16 mr5" id="user_email_check"></i> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="user_email_addr_notice"></p> | |||||
| </div> | |||||
| </li> | |||||
| <li class="new_loggin_users"> | |||||
| <i class="fa fa-lock font-16 ml10 color-grey"></i> | |||||
| <input type="text" onfocus="this.type='password'" class="new_loggin_input" style="width: 292px;" name="user[mail_password]" id="user_password_2" autocomplete="off" placeholder="密码至少由8位由字母或特殊符号和数字结合"> | |||||
| <i class="fa font-16 mr5" id="user_password_2_check"></i> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="user_password_2_notice"></p> | |||||
| </div> | |||||
| </li> | |||||
| <li class="pr"> | |||||
| <label><input type="checkbox" id="read_and_confirm_2" checked="checked" class="new_login_check" > 我已阅读并同意<a href="<%= agreement_path %>" target="_blank">服务协议条款</a></label> | |||||
| <div class="new-login-error" style="display: none;"> | |||||
| <p id="user_aggre_2_notice"></p> | |||||
| </div> | |||||
| <div class="cl"></div> | |||||
| </li> | |||||
| <li> | |||||
| <a href="javascript:void(0);" id="regist_btn_email" onclick="email_register();" class ="new_login_submit" style="text-decoration:none; color: #fff;">完成</a> | |||||
| </li> | |||||
| <li style="text-align: center;"> | |||||
| <a href="javascript:void(0);" class="link-color-green" style="text-decoration:none;">跳过,自动注册并绑定</a> | |||||
| </li> | |||||
| </ul> | |||||
| <% end %> | |||||
| </div> | |||||
| </div> | |||||
| <div class="cl"></div> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <script> | |||||
| $('#drag').drag(); | |||||
| </script> | |||||
| @@ -31,7 +31,7 @@ | |||||
| <div class="autoscroll"> | <div class="autoscroll"> | ||||
| <table class="list" style="width: 100%;table-layout: fixed;"> | <table class="list" style="width: 100%;table-layout: fixed;"> | ||||
| <thead> | <thead> | ||||
| <tr > | |||||
| <tr> | |||||
| <%= sort_header_tag('login', :caption => l(:field_login)) %> | <%= sort_header_tag('login', :caption => l(:field_login)) %> | ||||
| <%= sort_header_tag('firstname', :caption => l(:field_firstname)) %> | <%= sort_header_tag('firstname', :caption => l(:field_firstname)) %> | ||||
| <%= sort_header_tag('lastname', :caption => l(:field_lastname)) %> | <%= sort_header_tag('lastname', :caption => l(:field_lastname)) %> | ||||
| @@ -59,7 +59,6 @@ | |||||
| <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" align="center" align="center" title="<%= get_occupation_from_user(user) %>"> <%= truncate(get_occupation_from_user(user), :length => 12 ) %></td> | <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" align="center" align="center" title="<%= get_occupation_from_user(user) %>"> <%= truncate(get_occupation_from_user(user), :length => 12 ) %></td> | ||||
| <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="buttons" align="center" title='<%=user.id %>'> <%= change_status_link(user) %></td> | <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="buttons" align="center" title='<%=user.id %>'> <%= change_status_link(user) %></td> | ||||
| <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="buttons" align="center" title='<%=user.id %>'> <%= delete_link user_path(user, :back_url => admin_users_path(params)) unless User.current == user %></td> | <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="buttons" align="center" title='<%=user.id %>'> <%= delete_link user_path(user, :back_url => admin_users_path(params)) unless User.current == user %></td> | ||||
| </tr> | </tr> | ||||
| <% end -%> | <% end -%> | ||||
| </tbody> | </tbody> | ||||
| @@ -0,0 +1,50 @@ | |||||
| <div class="task-pm-box mt20 mb20"> | |||||
| <div class="panel-header clearfix"> | |||||
| <h3 class="fl mt5">全部任务</h3> | |||||
| <% if @challenges.count != 0 %> | |||||
| <span class="btn-cir btn-cir-grey ml5 mt8 fl"><%= @challenges.count %></span> | |||||
| <% end %> | |||||
| <% if User.current.manager_of_shixun?(@shixun) || User.current.admin? %> | |||||
| <a href="<%= new_shixun_challenge_path(@shixun) %>" class=" task-btn task-btn-green fr">新建阶段</a> | |||||
| <% end %> | |||||
| </div> | |||||
| <div class="panel-list"> | |||||
| <% @challenges.each_with_index do |challenge, index| -%> | |||||
| <div class=" clearfix panel-inner" id="shixun_index_<%= index %>"> | |||||
| <h4 class="fl panel-inner-title "><i class="fa fa-dot-circle-o font-18 color-green mr5"></i><span class="color-red mr10">第<%= challenge.position %>关</span> | |||||
| <%= link_to challenge.subject, shixun_challenge_path(@shixun.id, challenge), :target => "_blank" %> | |||||
| </h4> | |||||
| <% if User.current.manager_of_shixun?(@shixun) %> | |||||
| <p class="fr" style="display: none" id="shixun_icon_<%= index %>"> | |||||
| <% unless challenge.position < 2 %> | |||||
| <a href="<%= index_up_shixun_challenge_path(challenge, :shixun_id => @shixun) %>" title="上移" data-remote="true"><i class="fa fa-long-arrow-up color-grey font-16 mr5" ></i></a> | |||||
| <% end %> | |||||
| <% if @shixun.challenges.count != challenge.position %> | |||||
| <a href="<%= index_down_shixun_challenge_path(challenge, :shixun_id => @shixun) %>" title="下移" data-remote="true"><i class="fa fa-long-arrow-down color-grey font-16 mr5" ></i></a> | |||||
| <% end %> | |||||
| <a href="<%= edit_shixun_challenge_path(challenge, :shixun_id => @shixun) %>" title="编辑" ><i class="fa fa-pencil-square-o color-grey font-16 mr5" ></i></a> | |||||
| <!-- <a href="#" title="删除" ><i class="fa fa-trash-o color-grey font-16 mr5" ></i></a>--> | |||||
| <!--<a href="#" title="排名" ><i class="fa fa-signal color-grey font-16 mr5 " ></i></a>--> | |||||
| </p> | |||||
| <% end %> | |||||
| <div class="cl"></div> | |||||
| <p class="ml15 color-grey"> | |||||
| <span class=" mr10">正在挑战:<%= shixun_running(@shixun, challenge.position).to_i %></span> | |||||
| <span class=" mr10">完成挑战:<%= shixun_done(@shixun, challenge.position).to_i %></span> | |||||
| <span class=" mr10">最佳表现:<%= top_score(@shixun, challenge.position).to_i %>分</span> | |||||
| <span class=" mr10">平均表现:<%= shixun_avg_score(@shixun, challenge.position).to_i %>分 </span> | |||||
| </p> | |||||
| </div> | |||||
| <script> | |||||
| $(document).ready(function(){ | |||||
| $("#shixun_index_<%= index %>").mouseenter(function(){ | |||||
| $("#shixun_icon_<%= index %>").show(); | |||||
| }); | |||||
| $("#shixun_index_<%= index %>").mouseleave(function(){ | |||||
| $("#shixun_icon_<%= index %>").hide(); | |||||
| }); | |||||
| }); | |||||
| </script> | |||||
| <% end %> | |||||
| </div> | |||||
| </div> | |||||
| @@ -0,0 +1,336 @@ | |||||
| <%= javascript_include_tag 'baiduTemplate', 'jquery.datetimepicker.js' %> | |||||
| <%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %> | |||||
| <%= stylesheet_link_tag "/assets/codemirror/codemirror" %> | |||||
| <%= stylesheet_link_tag '/editormd/css/editormd','/editormd/css/editormd.min' %> | |||||
| <%= javascript_include_tag '/editormd/editormd.min.js','/editormd/examples/js/jquery.min.js' %> | |||||
| <script type="text/javascript"> | |||||
| $(function() { | |||||
| editormd("challenge_ready_konewlege", { | |||||
| width : "80%", | |||||
| height : 300, | |||||
| syncScrolling : "single", | |||||
| //你的lib目录的路径,我这边用JSP做测试的 | |||||
| path : "/editormd/lib/", | |||||
| //这个配置在simple.html中并没有,但是为了能够提交表单,使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中,方便post提交表单。 | |||||
| saveHTMLToTextarea : true | |||||
| // 用于增加自定义工具栏的功能,可以直接插入HTML标签,不使用默认的元素创建图标 | |||||
| }); | |||||
| }); | |||||
| </script> | |||||
| <script id="t:sample-answer-list" type="text/html"> | |||||
| <li class="clearfix"> | |||||
| <p class="clearfix"> | |||||
| <span class="color-green fb fl" name="sample_inputs_label"></span> | |||||
| <a href="javascript:void(0)" title="增加" class="sample_icon_add"><i class="fa fa-plus-circle color-grey font-16 ml10 fl mt7"></i></a> | |||||
| <a href="javascript:void(0)" title="删除" class="sample_icon_remove"><i class="fa fa-times-circle color-grey font-16 ml10 fl mt7"></i></a> | |||||
| </p> | |||||
| <input type="text" class="panel-form-width-100 panel-box-sizing mb10" name="sample[input][]" id="textarea_input_test" placeholder="样例输入" /> | |||||
| <input type="text" class="panel-form-width-100 panel-box-sizing mb10" name="sample[output][]" id="textarea_output_test" placeholder="样例输出" /> | |||||
| </li> | |||||
| </script> | |||||
| <script id="t:test-answer-list" type="text/html"> | |||||
| <li class="clearfix"> | |||||
| <p class="clearfix"> | |||||
| <span class="color-green fb fl" name="inputs_label"></span> | |||||
| <a href="javascript:void(0);" title="增加" class="test_icon_add"><i class="fa fa-plus-circle color-grey font-16 ml10 fl mt7"></i></a> | |||||
| <a href="javascript:void(0);" title="删除" class="test_icon_remove"><i class="fa fa-times-circle color-grey font-16 ml10 fl mt7"></i></a> | |||||
| </p> | |||||
| <!-- <input type="text" class="panel-form-width-670 panel-form-height-30 mb10" name="program[input][]" placeholder="测试输入" />--> | |||||
| <textarea class="panel-form-width-100 panel-box-sizing" id="textarea_output_test" name="program[output][]" placeholder="输入测试集内容" ></textarea> | |||||
| </li> | |||||
| </script> | |||||
| <div id="shixun_form"> | |||||
| <li class="clearfix"> | |||||
| <label class="panel-form-label fl"><span class="c_red mr5">*</span>名称:</label> | |||||
| <%= f.text_field :subject, :class => "panel-form-width-690 fl panel-box-sizing", :no_label => true, :placeholder => "请输入当前任务的名称(此信息将提前泄露给学员)" %> | |||||
| <span style="display: none" class="c_red ml90" id="new_shixun_name">任务名称不能为空</span> | |||||
| </li> | |||||
| <li class="clearfix"> | |||||
| <label class="panel-form-label fl">文件路径:</label> | |||||
| <%= f.text_field :path, :class => "panel-form-width-690 panel-box-sizing fl", :no_label => true, :placeholder => "进入实训后将默认打开该文件,如:app/controllers/welcome_controller.rb", :maxlength => "256" %> | |||||
| </li> | |||||
| <li class="clearfix"> | |||||
| <label class="panel-form-label fl">预备知识:</label> | |||||
| <%= f.kindeditor :ready_knowledge, :placeholder => "请输入完成当前任务依赖的知识点或者其它相关信息,指导学员完成任务", :width=>'87.5%', :height => 159, :resizeType => 0, :no_label => true %> | |||||
| </li> | |||||
| <li class="clearfix"> | |||||
| <label class="panel-form-label fl"><span class="c_red mr5">*</span>过关任务:</label> | |||||
| <%#= f.kindeditor :task_pass, :editor_id => "challenge_task_pass", :width=>'87.5%', :height => 159, :resizeType => 0, :no_label => true %> | |||||
| <%= f.text_area :task_pass, :class => "panel-form-width-690 panel-box-sizing", :no_label => true %> | |||||
| <span style="display: none" class="c_red ml90" id="new_shixun_pass">过关任务不能为空</span> | |||||
| </li> | |||||
| <li class="clearfix"> | |||||
| <% if params[:action] == "edit" && @challenge.challenge_samples.count > 0 %> | |||||
| <label class="panel-form-label fl">样例设置:</label> | |||||
| <ul class="fl task-bg-grey panel-box-sizing" > | |||||
| <% @challenge.challenge_samples.each_with_index do |sample, index| %> | |||||
| <li class="clearfix"> | |||||
| <p class="clearfix"> | |||||
| <span class="color-green fb fl" name="sample_inputs_label">样例<%= index + 1 %></span> | |||||
| <% if index == 0 %> | |||||
| <span class="color-grey fr" style="font-size:12px;">温馨提示:输入样例供学员参考。</span> | |||||
| <% end %> | |||||
| <a href="javascript:void(0)" title="增加" class="sample_icon_add"><i class="fa fa-plus-circle color-grey font-16 ml10 fl mt7"></i></a> | |||||
| <% if index > 0 %> | |||||
| <a href="javascript:void(0)" title="删除" class="sample_icon_remove"><i class="fa fa-times-circle color-grey font-16 ml10 fl mt7"></i></a> | |||||
| <% end %> | |||||
| </p> | |||||
| <input type="text" class="panel-form-width-100 panel-box-sizing mb10" name="sample[input][]" id="textarea_sample_input_test" placeholder="样例输入" value="<%= sample.input %>" /> | |||||
| <input type="text" class="panel-form-width-100 panel-box-sizing" name="sample[output][]" id="textarea_sample_output_test" placeholder="样例输出" value="<%= sample.output %>" /> | |||||
| </li> | |||||
| <% end %> | |||||
| </ul> | |||||
| <% else %> | |||||
| <label class="panel-form-label fl">样例设置:</label> | |||||
| <ul class="fl task-bg-grey panel-box-sizing"> | |||||
| <li class="clearfix"> | |||||
| <p class="clearfix"> | |||||
| <span class="color-green fb fl" name="sample_inputs_label">样例1</span> | |||||
| <span class="color-grey fr" style="font-size:12px;">温馨提示:输入样例供学员参考。</span> | |||||
| <a href="javascript:void(0)" title="增加" class="sample_icon_add"><i class="fa fa-plus-circle color-grey font-16 ml10 fl mt7"></i></a> | |||||
| </p> | |||||
| <input type="text" class="panel-form-width-100 panel-box-sizing mb10" name="sample[input][]" id="textarea_sample_input_test" placeholder="样例输入" /> | |||||
| <input type="text" class="panel-form-width-100 panel-box-sizing mb10" name="sample[output][]" id="textarea_sample_output_test" placeholder="样例输出" /> | |||||
| </li> | |||||
| </ul> | |||||
| <% end %> | |||||
| </li> | |||||
| <li class="clearfix"> | |||||
| <% if params[:action] == "edit" && @challenge.test_sets.count > 0 %> | |||||
| <label class="panel-form-label fl">测试集设置:</label> | |||||
| <ul class="fl task-bg-grey panel-box-sizing" > | |||||
| <% @challenge.test_sets.each_with_index do |test, index| %> | |||||
| <li class="clearfix"> | |||||
| <p class="clearfix"> | |||||
| <span class="color-green fb fl" name="inputs_label">测试集<%= index + 1 %></span> | |||||
| <% if index == 0%> | |||||
| <span class="color-grey fr" style="font-size:12px;">温馨提示:在学员"提交评测"时进行自动检测。</span> | |||||
| <% end %> | |||||
| <a href="javascript:void(0);" title="增加" class="test_icon_add"><i class="fa fa-plus-circle color-grey font-16 ml10 fl mt7"></i></a> | |||||
| <% if index > 0 %> | |||||
| <a href="javascript:void(0);" title="删除" class="test_icon_remove"><i class="fa fa-times-circle color-grey font-16 ml10 fl mt7"></i></a> | |||||
| <% end %> | |||||
| </p> | |||||
| <!--<input type="text" class="panel-form-width-670 panel-form-height-30 mb10" name="program[input][]" id="textarea_input_test" value="<%#= test.input %>"/>--> | |||||
| <textarea class="panel-form-width-100 panel-box-sizing" id="textarea_output_test" name="program[output][]" placeholder="输入测试集内容" ><%= test.output %></textarea> | |||||
| </li> | |||||
| <% end %> | |||||
| </ul> | |||||
| <% else %> | |||||
| <label class="panel-form-label fl">测试集设置:</label> | |||||
| <ul class="fl task-bg-grey panel-box-sizing"> | |||||
| <li class="clearfix"> | |||||
| <p class="clearfix"> | |||||
| <span class="color-green fb fl" name="inputs_label">测试集1</span> | |||||
| <span class="color-grey fr" style="font-size:12px;">温馨提示:在学员"提交评测"时进行自动检测。</span> | |||||
| <a href="javascript:void(0);" title="增加" class="test_icon_add"><i class="fa fa-plus-circle color-grey font-16 ml10 fl mt7"></i></a> | |||||
| </p> | |||||
| <!-- <input type="text" class="panel-form-width-670 panel-form-height-30 mb10" name="program[input][]" id="textarea_input_test" placeholder="测试输入" />--> | |||||
| <textarea class="panel-form-width-100 panel-box-sizing " id="textarea_output_test" name="program[output][]" placeholder="输入用例内容" ></textarea> | |||||
| </li> | |||||
| </ul> | |||||
| <% end %> | |||||
| </li> | |||||
| <li class="clearfix"> | |||||
| <label class=" panel-form-label fl"> 知识/技能点:</label> | |||||
| <div class="fl task-bd-grey"> | |||||
| <% if params[:action] == "edit" && @challenge_tags.count > 0 %> | |||||
| <% @challenge_tags.each do |tag| %> | |||||
| <div class="task-tag tag-grey mt5 mr10 fl"> | |||||
| <button data-dismiss="alert" class="close fr mt3 ml5" type="button" onclick="close_tag(this)">×</button> | |||||
| <input class='knowledge_frame' name='knowledge[input][]' value="<%= tag.try(:name)%>" /> | |||||
| </div> | |||||
| <% end %> | |||||
| <% end %> | |||||
| <button class="close fl mt8 mr10" type="button" onclick="$('#add_shixun_skill').slideToggle();" id="add_knowledge">+</button> | |||||
| <div class="task-tag tag-grey mt5 mr10 fl undis" id="add_shixun_skill"> | |||||
| <button data-dismiss="alert" class="close fr mt3 ml5" type="button" onclick="$('#add_shixun_skill').slideToggle();">×</button> | |||||
| <input type="text" class="task-tag-input" onblur="add_tag();" placeholder="请输入知识/技能点" /> | |||||
| </div> | |||||
| </div> | |||||
| </li> | |||||
| <li class="clearfix" style="line-height:1.9;"> | |||||
| <label class=" panel-form-label fl"> 参考答案:</label> | |||||
| <%= f.text_area :answer, :class => "panel-form-width-690 panel-form-height-150 fl task-textarea-pd", :no_label => true, :style => "line-height:1.9;" %> | |||||
| </li> | |||||
| <li class="clearfix"> | |||||
| <label class=" panel-form-label fl"><span class="c_red mr5">*</span>分值设定:</label> | |||||
| <%= f.text_field :score, :class => "panel-form-height-30 fl", :no_label => true, :style => "padding:5px;", :placeholder => "请输入分值(只能是数字)" %> | |||||
| <span class="fl ml5" style="line-height: 40px;">分</span> | |||||
| <div class="clear"></div> | |||||
| <span style="display: none" class="c_red ml90" id="new_shixun_score">分值设定不能为空</span> | |||||
| </li> | |||||
| <li class="clearfix"> | |||||
| <% if params[:action] == "edit" %> | |||||
| <a href="javascript:void(0)" class="task-btn task-btn-green fr " onclick="challenge_update()">保存</a> | |||||
| <a href="<%= shixun_challenge_path(@challenge, :shixun_id => @shixun) %>" class="task-btn fr mr10">取消</a> | |||||
| <% else %> | |||||
| <a href="javascript:void(0)" class="task-btn task-btn-green fr " onclick="challenge_create()">保存</a> | |||||
| <a href="<%= shixun_challenges_path(@shixun) %>" class="task-btn fr mr10">取消</a> | |||||
| <% end %> | |||||
| </li> | |||||
| </div> | |||||
| <script type="text/javascript"> | |||||
| $(function () { | |||||
| var bt = baidu.template; | |||||
| bt.LEFT_DELIMITER = '<!'; | |||||
| bt.RIGHT_DELIMITER = '!>'; | |||||
| $("#shixun_form").on('click', 'a.test_icon_add', function () { | |||||
| var html = bt('t:test-answer-list', null); | |||||
| $(this).parent().parent('.clearfix').after(html); | |||||
| var inputs = document.getElementsByName("program[input][]"); | |||||
| var outputs = document.getElementsByName("program[output][]"); | |||||
| var inputs_labels = document.getElementsByName("inputs_label"); | |||||
| for (var j = 0; j < inputs_labels.length; j++) { | |||||
| $(inputs_labels[j]).html("测试集"+ (j + 1)); | |||||
| } | |||||
| if (inputs.length == outputs.length) { | |||||
| for (var i = 0; i < inputs.length; i++) { | |||||
| // autoTextarea2(inputs[i], outputs[i], 0, 140); | |||||
| // autoTextarea2(outputs[i], inputs[i], 0, 140); | |||||
| } | |||||
| } | |||||
| $(inputs[inputs.length - 1]).focus(); | |||||
| }); | |||||
| $("#shixun_form").on('click', 'a.test_icon_remove', function () { | |||||
| $(this).parent().parent('.clearfix').remove(); | |||||
| var inputs_labels = document.getElementsByName("inputs_label"); | |||||
| for (var j = 0; j < inputs_labels.length; j++) { | |||||
| $(inputs_labels[j]).html("测试集" + (j + 1)); | |||||
| } | |||||
| }); | |||||
| $("#shixun_form").on('click', 'a.sample_icon_add', function () { | |||||
| var html = bt('t:sample-answer-list', null); | |||||
| $(this).parent().parent('.clearfix').after(html); | |||||
| var inputs = document.getElementsByName("sample[input][]"); | |||||
| var outputs = document.getElementsByName("sample[output][]"); | |||||
| var inputs_labels = document.getElementsByName("sample_inputs_label"); | |||||
| for (var j = 0; j < inputs_labels.length; j++) { | |||||
| $(inputs_labels[j]).html("样例" + (j + 1)); | |||||
| } | |||||
| if (inputs.length == outputs.length) { | |||||
| for (var i = 0; i < inputs.length; i++) { | |||||
| autoTextarea(inputs[i], 0, 140); | |||||
| autoTextarea(outputs[i], 0, 140); | |||||
| } | |||||
| } | |||||
| $(inputs[inputs.length - 1]).focus(); | |||||
| }); | |||||
| $("#shixun_form").on('click', 'a.sample_icon_remove', function () { | |||||
| $(this).parent().parent('.clearfix').remove(); | |||||
| var inputs_labels = document.getElementsByName("sample_inputs_label"); | |||||
| for (var j = 0; j < inputs_labels.length; j++) { | |||||
| $(inputs_labels[j]).html("样例" + (j + 1)); | |||||
| } | |||||
| }); | |||||
| }); | |||||
| var text1 = document.getElementById("textarea_sample_input_test"); | |||||
| var text2 = document.getElementById("textarea_sample_output_test"); | |||||
| // autoTextarea(text1, 0, 140); | |||||
| // autoTextarea(text2, 0, 140); | |||||
| var text3 = document.getElementById("textarea_input_test"); | |||||
| var text4 = document.getElementById("textarea_output_test"); | |||||
| // autoTextarea2(text3, text4, 0, 140); | |||||
| // autoTextarea2(text4, text3, 0, 140); | |||||
| $("#challenge_score").keyup(function(){ | |||||
| (this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this) | |||||
| }); | |||||
| $("#challenge_score").keyup(function(){ | |||||
| this.v(); | |||||
| }); | |||||
| $("#challenge_subject").keydown(function(){ | |||||
| $("#new_shixun_name").hide(); | |||||
| }); | |||||
| $("#challenge_subject").keydown(function(){ | |||||
| $("#new_shixun_pass").hide(); | |||||
| }); | |||||
| function challenge_create(){ | |||||
| if($('#challenge_subject').val().trim() == ""){ | |||||
| $("#new_shixun_name").show(); | |||||
| }else if($("#challenge_task_pass").val().trim() == ""){ | |||||
| $("#new_shixun_pass").show(); | |||||
| }else if($("#challenge_score").val().trim()==""){ | |||||
| $("#new_shixun_score").show(); | |||||
| }else{ | |||||
| $('#challenge_shixun_create').submit(); | |||||
| } | |||||
| } | |||||
| function challenge_update(){ | |||||
| if($('#challenge_subject').val().trim() == ""){ | |||||
| $("#new_shixun_name").show(); | |||||
| }else if($("#challenge_task_pass").val().trim() == ""){ | |||||
| $("#new_shixun_pass").show(); | |||||
| }else if($("#challenge_score").val().trim()==""){ | |||||
| $("#new_shixun_score").show(); | |||||
| }else{ | |||||
| $('#edit_challenge_<%= @challenge.id %>').submit(); | |||||
| } | |||||
| } | |||||
| var editor = CodeMirror.fromTextArea(document.getElementById("challenge_answer"), { | |||||
| mode: {name: '<%= @language %>', | |||||
| version: 2, | |||||
| singleLineStringErrors: false}, | |||||
| lineNumbers: true, | |||||
| indentUnit: 2, | |||||
| matchBrackets: true | |||||
| }); | |||||
| editor.on('change',function(cMirror){ | |||||
| // get value right from instance | |||||
| $('#challenge_answer').val(cMirror.getValue()); | |||||
| }); | |||||
| challenge_task_pass_editor = KindEditor.create('#challenge_task_pass', | |||||
| {"width":"89.7%", | |||||
| "resizeType":0, | |||||
| "no_label":true, | |||||
| "autoHeightMode":true, | |||||
| "height":200, | |||||
| "allowFileManager":true, | |||||
| afterBlur:function () { this.sync(); }, | |||||
| "uploadJson":"/kindeditor/upload", | |||||
| "fileManagerJson":"/kindeditor/filemanager" | |||||
| }); | |||||
| challenge_task_editor = KindEditor.create('#challenge_ready_knowledge', | |||||
| {"width":"89.7%", | |||||
| "resizeType":0, | |||||
| "no_label":true, | |||||
| "autoHeightMode":true, | |||||
| "height":200, | |||||
| "allowFileManager":true, | |||||
| afterBlur:function () { this.sync(); }, | |||||
| "uploadJson":"/kindeditor/upload", | |||||
| "fileManagerJson":"/kindeditor/filemanager" | |||||
| }); | |||||
| function add_tag(){ | |||||
| var num = $(".task-bd-grey").children('div').length; | |||||
| var val = $(".task-tag-input").val().trim(); | |||||
| if (val != ""){ | |||||
| testLength = $(".task-tag-input").val().trim().length; | |||||
| $("#add_knowledge").before("<div class='task-tag tag-grey mt5 mr10 fl' id='knowledge_" + num + "'>" + | |||||
| "<button data-dismiss='alert' class='close fr mt3 ml5' type='button' onclick='close_tag(this)'>×</button>" + | |||||
| "<input style='width:"+ testLength*12 +"px' class='knowledge_frame' name='knowledge[input][]' value='" + val +"'>" + | |||||
| " </div>"); | |||||
| $(".task-tag-input").attr("value",""); | |||||
| } | |||||
| } | |||||
| function close_tag(thisObj){ | |||||
| // 获取父节点的id | |||||
| var obj = thisObj.parentNode.id; | |||||
| $("#"+obj).remove(); | |||||
| } | |||||
| </script> | |||||
| @@ -0,0 +1,22 @@ | |||||
| <%= content_for(:header_tags) do %> | |||||
| <%= import_ke(enable_at: true, prettify: false, init_activity: false) %> | |||||
| <%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %> | |||||
| <%= stylesheet_link_tag "/assets/codemirror/codemirror" %> | |||||
| <% end %> | |||||
| <div class="task-pm-content mb20"> | |||||
| <div class="task-pm-box mt20"> | |||||
| <div class="panel-header clearfix"> | |||||
| <h3 class="fl mt5">编辑阶段</h3> | |||||
| </div> | |||||
| <div class=" panel-form "> | |||||
| <ul> | |||||
| <%= labelled_form_for @challenge, :url => shixun_challenge_path(@challenge, :shixun_id => @shixun) do |f| %> | |||||
| <%= render :partial => "form", :locals => {:f => f} %> | |||||
| <% end %> | |||||
| </ul> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| @@ -0,0 +1,21 @@ | |||||
| <%= content_for(:header_tags) do %> | |||||
| <%= import_ke(enable_at: true,init_activity: true) %> | |||||
| <% end %> | |||||
| <div class="task-pm-content"> | |||||
| <div class="task-pm-box mt20"> | |||||
| <div class="panel-header "> | |||||
| <h3>简介</h3> | |||||
| </div> | |||||
| <div class="task-paner-con break_full_word"> | |||||
| <p> | |||||
| <%= h @shixun.description.html_safe %> | |||||
| </p> | |||||
| </div> | |||||
| </div> | |||||
| <div id="challenge_list"> | |||||
| <%= render :partial => "content_list" %> | |||||
| </div> | |||||
| </div> | |||||
| @@ -0,0 +1 @@ | |||||
| $("#challenge_list").html('<%= escape_javascript( render :partial => 'content_list') %>'); | |||||
| @@ -0,0 +1 @@ | |||||
| $("#challenge_list").html('<%= escape_javascript( render :partial => 'content_list') %>'); | |||||
| @@ -0,0 +1,22 @@ | |||||
| <%= content_for(:header_tags) do %> | |||||
| <%= import_ke(enable_at: true, prettify: false, init_activity: false) %> | |||||
| <%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %> | |||||
| <%= stylesheet_link_tag "/assets/codemirror/codemirror" %> | |||||
| <% end %> | |||||
| <div class="task-pm-box mt20"> | |||||
| <div class="panel-header clearfix"> | |||||
| <h3 class="fl mt5">新建阶段</h3> | |||||
| </div> | |||||
| <div class=" panel-form "> | |||||
| <ul> | |||||
| <%= labelled_form_for @challenge, :url => shixun_challenges_path(@shixun), :html => {:id => "challenge_shixun_create"} do |f| %> | |||||
| <%= render :partial => "form", :locals => {:f => f} %> | |||||
| <% end %> | |||||
| </ul> | |||||
| </div> | |||||
| </div> | |||||
| @@ -0,0 +1,117 @@ | |||||
| <%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %> | |||||
| <%= stylesheet_link_tag "/assets/codemirror/codemirror" %> | |||||
| <%= stylesheet_link_tag "/assets/kindeditor/plugins/code/previewcode" %> | |||||
| <div class="task-pm-content mb20"> | |||||
| <div class="task-pm-box mt20"> | |||||
| <div class="panel-header clearfix"> | |||||
| <h3 class="fl mt5">阶段详情</h3> | |||||
| <a href="<%= new_shixun_challenge_path(@shixun) %>" class=" task-btn task-btn-green fr">新建阶段</a> | |||||
| </div> | |||||
| <div class="panel-form "> | |||||
| <div class="clearfix mb20"> | |||||
| <h3 class="fl panel-inner-title"><span class="color-red mr10">第<%= @challenge.position %>关</span><%= @challenge.subject %></h3> | |||||
| <p class="fr"> | |||||
| <a href="<%= edit_shixun_challenge_path(@challenge, :shixun_id => @shixun) %>" title="编辑"><i class="fa fa-pencil-square-o color-grey font-16 mr5"></i></a> | |||||
| <!-- <a href="<%#= shixun_challenge_path(@challenge, :shixun_id => @shixun) %>" title="删除" method="delete" ><i class="fa fa-trash-o color-grey font-16 mr5"></i></a>--> | |||||
| <!--<a href="#" title="复制"><i class="fa fa-files-o color-grey font-16 mr5"></i></a>--> | |||||
| </p> | |||||
| </div> | |||||
| <ul> | |||||
| <li class="clearfix"> | |||||
| <label class="panel-form-label fl">文件路径:</label> | |||||
| <div class="fl task-bg-grey panel-box-sizing panel-form-width-690"> | |||||
| <%= @challenge.path.blank? ? "无" : (h @challenge.path.html_safe) %> | |||||
| </div> | |||||
| </li> | |||||
| <li class="clearfix challenge_bottom"> | |||||
| <label class="panel-form-label fl">预备知识:</label> | |||||
| <div class="fl task-bg-grey panel-box-sizing panel-form-width-690"> | |||||
| <%= @challenge.ready_knowledge.blank? ? "无" : (h @challenge.ready_knowledge.html_safe) %> | |||||
| </div> | |||||
| </li> | |||||
| <li class="clearfix"> | |||||
| <label class="panel-form-label fl"><span class="c_red mr5">*</span>过关任务:</label> | |||||
| <div class="fl task-bg-grey panel-box-sizing panel-form-width-690" id="challenge_task_pass"> | |||||
| <%= h @challenge.task_pass.html_safe %> | |||||
| </div> | |||||
| </li> | |||||
| <li class="clearfix"> | |||||
| <label class="panel-form-label fl">样例设置:</label> | |||||
| <ul class="fl task-bg-grey panel-box-sizing panel-form-width-690"> | |||||
| <% if @challenge_samples.count > 0 %> | |||||
| <% @challenge_samples.each_with_index do |sample, index| %> | |||||
| <li class="clearfix"> | |||||
| <p class="clearfix"> | |||||
| <span class="color-green fb">样例<%= index + 1 %></span> | |||||
| </p> | |||||
| <div class="clearfix"><span class="fl fb">样例输入:</span><p class="fl"><%= sample.input %></p></div> | |||||
| <div class="clearfix"><span class="fl fb">样例输出:</span><p class="fl"><%= sample.output %></p></div> | |||||
| </li> | |||||
| <% end %> | |||||
| <% else %> | |||||
| 无 | |||||
| <% end %> | |||||
| </ul> | |||||
| </li> | |||||
| <li class="clearfix"> | |||||
| <label class="panel-form-label fl">测试集设置:</label> | |||||
| <ul class="fl task-bg-grey panel-box-sizing panel-form-width-690"> | |||||
| <% if @test_sets.count > 0 %> | |||||
| <% @test_sets.each_with_index do |test, index| %> | |||||
| <li class="clearfix"> | |||||
| <p class="clearfix"> | |||||
| <span class="color-green fb">测试集<%= index + 1 %></span> | |||||
| </p> | |||||
| <div class="clearfix"><p class="fl"><%= test.output %></p></div> | |||||
| </li> | |||||
| <% end %> | |||||
| <% else %> | |||||
| 无 | |||||
| <% end %> | |||||
| </ul> | |||||
| </li> | |||||
| <li class="clearfix"> | |||||
| <% unless @challenge_tags.blank? %> | |||||
| <label class="panel-form-label fl"> 知识/技能点:</label> | |||||
| <div class="fl task-bd-grey panel-box-sizing panel-form-width-690"> | |||||
| <% @challenge_tags.each do |tag| %> | |||||
| <div class="task-tag tag-grey mb10 mr10 fl"> | |||||
| <%= tag.name %> | |||||
| </div> | |||||
| <% end %> | |||||
| </div> | |||||
| <% end %> | |||||
| </li> | |||||
| <li class="clearfix"> | |||||
| <label class=" panel-form-label fl"> 参考答案:</label> | |||||
| <div class="fl " id="tpm_answer_show" style="line-height: 1.2;="></div> | |||||
| <div id="hidden_tpm_answer_show" class="undis"><%= @challenge.answer.blank? ? "无" : (@challenge.answer) %></div> | |||||
| </li> | |||||
| <li class="clearfix"> | |||||
| <label class="panel-form-label fl"><span class="c_red mr5">*</span>分值设定:</label> | |||||
| <div class="fl task-bg-grey panel-box-sizing panel-form-width-690"> | |||||
| <%= @challenge.score %>分 | |||||
| </div> | |||||
| </li> | |||||
| </ul> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <script> | |||||
| $('#challenge_task_pass').find('img').css("max-width", "680px"); | |||||
| var tpmMirror = $("#tpm_answer_show")[0]; | |||||
| var TpmCodeMirror = CodeMirror(tpmMirror, { | |||||
| value: $("#hidden_tpm_answer_show").text(), | |||||
| mode: "<%= @language %>", | |||||
| readOnly: "nocursor", //只读,并隐藏光标 | |||||
| //cursorBlinkRate: -1, //隐藏光标 | |||||
| autofocus: true, | |||||
| border: 0, | |||||
| lineNumbers: true | |||||
| }); | |||||
| $(document).ready(function(){ | |||||
| TpmCodeMirror.setSize('860px','auto');//设置版本库codemirror的高度 | |||||
| }); | |||||
| </script> | |||||
| @@ -0,0 +1,18 @@ | |||||
| <div class="autoscroll_extend"> | |||||
| <table class="filecontent syntaxhl mt5" style="width:100%"> | |||||
| <tbody> | |||||
| <% line_num = 1 %> | |||||
| <% syntax_highlight_lines(filename, Redmine::CodesetUtil.to_utf8_by_setting(content)).each do |line| %> | |||||
| <tr> | |||||
| <th class="line-num" id="L<%= line_num %>" style="vertical-align: top;"> | |||||
| <a href="#L<%= line_num %>" style="padding-top: 0px;"><%= line_num %></a> | |||||
| </th> | |||||
| <td class="line-code"> | |||||
| <pre style="width:auto;overflow: auto; "><%= line.html_safe %></pre> | |||||
| </td> | |||||
| </tr> | |||||
| <% line_num += 1 %> | |||||
| <% end %> | |||||
| </tbody> | |||||
| </table> | |||||
| </div> | |||||
| @@ -1,4 +1,4 @@ | |||||
| <div class="autoscroll"> | |||||
| <div class="autoscroll_new"> | |||||
| <table class="filecontent syntaxhl mt5" style="width:100%"> | <table class="filecontent syntaxhl mt5" style="width:100%"> | ||||
| <tbody> | <tbody> | ||||
| <% line_num = 1 %> | <% line_num = 1 %> | ||||
| @@ -15,4 +15,4 @@ | |||||
| <% end %> | <% end %> | ||||
| </tbody> | </tbody> | ||||
| </table> | </table> | ||||
| </div> | |||||
| </div> | |||||
| @@ -0,0 +1,27 @@ | |||||
| <div class="col-width fl content-submit ml15 mt15"> | |||||
| <div class="panel-header "> | |||||
| <h3 >操作</h3> | |||||
| </div> | |||||
| <div class="content-submitbox"> | |||||
| <a href="#" class="task-btn mb10">保存修改</a> | |||||
| <% if @game.status == 0 %> | |||||
| <%= link_to "提交评测", { :controller => 'games', | |||||
| :action => "game_build", | |||||
| :id => @game, | |||||
| :myshixun_id => @myshixun}, | |||||
| :class => "task-btn task-btn-green", | |||||
| :onclick => "training_task_submmit();", | |||||
| :remote => true %> | |||||
| <% elsif @game.status == 2 %> | |||||
| <a class="task-btn mb10">评测中..</a> | |||||
| <% elsif @game.status == 1 %> | |||||
| <%= link_to "下 一 步 ", {:controller => 'games', | |||||
| :action => "next_step", | |||||
| :id => @game, | |||||
| :myshixun_id => @myshixun}, | |||||
| :class => "task-btn task-btn-green", | |||||
| :onclick => "training_task_submmit();", | |||||
| :remote => true %> | |||||
| <% end %> | |||||
| </div> | |||||
| </div> | |||||
| @@ -0,0 +1,9 @@ | |||||
| <div class=" col-width fl content-output ml15 mt15"> | |||||
| <div class="panel-header "> | |||||
| <h3 >测试输出</h3> | |||||
| </div> | |||||
| <div class="content-history-inner"> | |||||
| Thor position=(32,4).Light position={32,4}<br/> | |||||
| Engryg=74 | |||||
| </div> | |||||
| </div> | |||||
| @@ -0,0 +1,74 @@ | |||||
| <div class="content-info col-width content-all-fix undis" id="game_left_contents"> | |||||
| <div class="panel-header clearfix"> | |||||
| <h3 class="fl">第<%= @game_challenge.position %>关:<%= @game_challenge.subject %></h3> | |||||
| <div class="fr mt5"> | |||||
| <a href="javascript:void(0);" onclick="close_game_descpition()"><i class="fa fa-compress font-14 fl color-grey"></i></a> | |||||
| </div> | |||||
| </div> | |||||
| <div class="tab_content clearfix" > | |||||
| <ul id="tab_nav"> | |||||
| <li id="big_tab_nav_1" class="tab_hover " onclick="HoverLi_new(1);"> | |||||
| <a href="javascript:void(0);" class="tab_type">过关任务</a> | |||||
| </li> | |||||
| <li id="big_tab_nav_2" onclick="HoverLi_new(2);"> | |||||
| <a href="javascript:void(0);" class="tab_type" >预备知识</a> | |||||
| </li> | |||||
| <li id="big_tab_nav_3" onclick="HoverLi_new(3);"> | |||||
| <a href="javascript:void(0);" class="tab_type" >参考答案</a> | |||||
| </li> | |||||
| </ul> | |||||
| <div class="cl"></div> | |||||
| <div id="big_tab_con_1" class="tab-info" > | |||||
| <div class="big-tab-info-inner"> | |||||
| <%= h @game_challenge.task_pass.try(:html_safe) %> | |||||
| </div> | |||||
| </div> | |||||
| <div id="big_tab_con_2" class="undis tab-info" > | |||||
| <div class="big-tab-info-inner"> | |||||
| <%= h @game_challenge.ready_knowledge.try(:html_safe) %> | |||||
| </div> | |||||
| </div> | |||||
| <div id="big_tab_con_3" class="undis tab-info" > | |||||
| <div class="big-tab-info-inner" id="extend_game_answer_show"></div> | |||||
| <div class="undis" id="hidden_extend_game_answer"><%= h @game_challenge.answer.try(:html_safe) %></div> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <script type="text/javascript" language="javascript"> | |||||
| var ExtendMirror = $("#extend_game_answer_show")[0]; | |||||
| var ExtendCodeMirror = CodeMirror(ExtendMirror, { | |||||
| value: $("#hidden_extend_game_answer").text(), | |||||
| mode: "<%= @language %>", | |||||
| readOnly: "nocursor", //只读 | |||||
| //cursorBlinkRate: -1, //隐藏光标 | |||||
| autofocus: true, | |||||
| border: 0 | |||||
| }); | |||||
| // 设置参考答案的line-height | |||||
| $("#extend_game_answer_show" ).children(".CodeMirror").css("line-height", 1.2); | |||||
| $(document).ready(function(){ | |||||
| var web_h = window.innerHeight; | |||||
| // codemirror的高度 | |||||
| var Cm_h = web_h - 185; | |||||
| // 设置版本库codemirror的高度 | |||||
| ExtendCodeMirror.setSize('auto', Cm_h+'px'); | |||||
| // 设置codemirror无边框 | |||||
| $("#extend_game_answer_show").children().css("border", 0); | |||||
| }); | |||||
| function close_game_descpition(){ | |||||
| $("#game_left_contents").hide(); | |||||
| } | |||||
| function HoverLi_new(n){ | |||||
| for(var i=1;i<=3;i++){ | |||||
| g('big_tab_nav_'+i).className='tab_nomal'; | |||||
| g('big_tab_con_'+i).className='undis'; | |||||
| } | |||||
| g('big_tab_con_'+n).className='dis'; | |||||
| g('big_tab_nav_'+n).className='tab_hover'; | |||||
| if(n==3){ | |||||
| ExtendCodeMirror.refresh(); | |||||
| } | |||||
| } | |||||
| </script> | |||||
| @@ -0,0 +1,150 @@ | |||||
| <%= content_for(:header_tags) do %> | |||||
| <%= javascript_include_tag 'baiduTemplate', 'jquery.datetimepicker.js' %> | |||||
| <% end %> | |||||
| <div id="code_results" class="panel-footer CELL COLS mt15 ml15"> | |||||
| </div> | |||||
| <script id="t:exec_results" type="text/html"> | |||||
| <div class="col-width content-history CELL mb15" > | |||||
| <div class="panel-header clearfix"> | |||||
| <h3 class="fl">测评历史</h3> | |||||
| <div class="fr mt5"> | |||||
| <a href="javascript:void(0)" onclick="extend_window()"><i class="fa fa-expand font-14 fl color-grey"></i></a> | |||||
| </div> | |||||
| </div> | |||||
| <div class="content-history-inner"> | |||||
| <!--<! if (results.length != 0) { !>--> | |||||
| <! for(var i=0;i< results.length; i++) { !> | |||||
| <! if(results[i][0] == 0){ !> | |||||
| <div class="clearfix history-success mb10"> | |||||
| <span class="icon-success fl mr5"><!= results.length - i !></span> | |||||
| <p class="fl">恭喜,您已经完成了本任务!</p> | |||||
| <a href="/myshixuns/<%= @myshixun.id %>/games/<%= @game.id %>/outputs_show?game_output_id=<!= results[i][1] !>" class="fr mr10" data-remote="true">详情</a> | |||||
| </div> | |||||
| <! }else{ !> | |||||
| <div class="clearfix history-fail mb10"> | |||||
| <span class="icon-fail fl mr5"><!= results.length - i !></span> | |||||
| <p class="fl">错误结果!</p> | |||||
| <a href="/myshixuns/<%= @myshixun.id %>/games/<%= @game.id %>/outputs_show?game_output_id=<!= results[i][1] !>" class="fr mr10" data-remote="true">详情</a> | |||||
| <div class="cl"></div> | |||||
| </div> | |||||
| <div class="undis" style="background: #f5f9fc;padding: 10px;margin-top:-10px;margin-bottom: 10px" id="game_exception_results_<!= results[i][1] !>"></div> | |||||
| <! } !> | |||||
| <! } !> | |||||
| <!--<! } !>--> | |||||
| </div> | |||||
| </div> | |||||
| <div class="col-width content-output ml15 CELL mb15"> | |||||
| <div class="panel-header clearfix"> | |||||
| <h3>测试输出</h3> | |||||
| </div> | |||||
| <div class="content-history-inner" id="game_test_output"></div> | |||||
| <div class="undis" id="game_test_output1"> | |||||
| <%= h @latest_output %> | |||||
| </div> | |||||
| </div> | |||||
| <div class="col-width content-submit ml15 CELL mb15"> | |||||
| <div class="panel-header"> | |||||
| <h3 >操作</h3> | |||||
| </div> | |||||
| <div class="content-submitbox"> | |||||
| <div id="game_rep_modify"> | |||||
| </div> | |||||
| <! if(status == 0){ !> | |||||
| <div id="game_commit"> | |||||
| <a href="javascript:void(0)" class="task-btn task-btn-green" onclick="training_task_submmit();">提交评测</a> | |||||
| </div> | |||||
| <! }else if(status == 1){ !> | |||||
| <a class="task-btn mb10">评测中..</a> | |||||
| <! }else if(status == 2 && had_done != 1){ !> | |||||
| <%= link_to "下 一 关", {:controller => 'games', :action => "next_step", :id => @game, :myshixun_id => @myshixun}, :class => "task-btn task-btn-green", :remote => true %> | |||||
| <! } !> | |||||
| <! if(had_done == 1) { !> | |||||
| <a href="javascript:void(0)" class="task-btn mb10" >已通关</a> | |||||
| <! } !> | |||||
| </div> | |||||
| </div> | |||||
| </script> | |||||
| <script > | |||||
| var bt = baidu.template; | |||||
| bt.LEFT_DELIMITER = '<!'; | |||||
| bt.RIGHT_DELIMITER = '!>'; | |||||
| $(function(){ | |||||
| var html = bt('t:exec_results',{status: <%= @game.status %>, results: <%= @results %>, had_done: "<%= @had_done %>"}); | |||||
| $("#code_results").html(html); | |||||
| $("#game_test_output").html($("#game_test_output1").text()) | |||||
| }); | |||||
| function training_task_submmit(){ | |||||
| var i = 0; | |||||
| $("#ajax-indicator").show(); | |||||
| $("#game_commit").html("<a class='task-btn mb10'>评测中..</a>"); | |||||
| $.ajax({ | |||||
| url: '<%= game_build_myshixun_game_path(@game, :myshixun_id => @myshixun) %>', | |||||
| success: function (){ | |||||
| //移除载入 | |||||
| var temp = $("#ajax-indicator").children('span')[0]; | |||||
| $("#ajax-indicator").children('span')[0].remove(); | |||||
| $("#ajax-indicator").css('border', 0); | |||||
| $("#ajax-indicator").css('padding', 0); | |||||
| var intId = setInterval(function(){ | |||||
| var ajaxTimeoutTest = $.ajax({ | |||||
| url: '<%= game_status_myshixun_game_path(@game, :myshixun_id => @myshixun) %>', | |||||
| timeout : 50000, | |||||
| data:'test', | |||||
| success:function(data){ | |||||
| //如果查到了,就退出 | |||||
| // i变量用来统计setInterval执行了多少次,便于统计访问时间 | |||||
| i = i + 1; | |||||
| if(data.status == 2 || data.status == 0){ | |||||
| clearInterval(intId); | |||||
| // 显示载入 | |||||
| $("#ajax-indicator").html(temp); | |||||
| $("#ajax-indicator").css('border', "1px solid #bbb"); | |||||
| $("#ajax-indicator").css('padding', "0.6em"); | |||||
| var html = bt('t:exec_results',{status: data.status, results: data.results, had_done: data.had_done}); | |||||
| $("#code_results").html(html); | |||||
| console.log(data.output) | |||||
| $("#game_test_output").html(data.output) | |||||
| var html = bt('t:extend_exec_results',{status: data.status, output: data.output, results: data.results, had_done: data.had_done}); | |||||
| $("#extend_code_results").html(html); | |||||
| if(data.status == 2){ | |||||
| if( data.had_done == 0 ) { | |||||
| var htmlvalue = "<%= j (render :partial => 'games/pass_game_show', :locals => { :game=> @game, :myshixun => @myshixun, :had_done => 0}) %>"; | |||||
| }else{ | |||||
| var htmlvalue = "<%= j (render :partial => 'games/pass_game_show', :locals => { :game=> @game, :myshixun => @myshixun, :had_done => 1}) %>"; | |||||
| } | |||||
| // 传递具体屏幕的宽高,实现不同浏览器与不同分辨率都能撑满屏幕 | |||||
| pop_box_new2(htmlvalue, window.innerWidth, window.innerHeight); | |||||
| } | |||||
| } | |||||
| // 访问30次,即60s后后台还未改变状态即执行 | |||||
| if(i == 30){ | |||||
| $.ajax({ | |||||
| url: '<%= change_status_myshixun_game_path(@game, :myshixun_id => @myshixun) %>', | |||||
| success:function(data){ | |||||
| clearInterval(intId); | |||||
| var html = bt('t:exec_results',{status: data.status, output: data.output, results: data.results, had_done: data.had_done}); | |||||
| $("#code_results").html(html); | |||||
| } | |||||
| }); | |||||
| } | |||||
| }, | |||||
| complete: function(XMLHttpRequest,status){if(status=='timeout'){ | |||||
| ajaxTimeoutTest.abort(); | |||||
| clearInterval(intId); | |||||
| }} | |||||
| }); | |||||
| }, 2000); | |||||
| } | |||||
| }); | |||||
| } | |||||
| function extend_window(){ | |||||
| $("#extend_code_results").show(); | |||||
| } | |||||
| function file_edit_submit1(){ | |||||
| $('#file_update_id').submit(); | |||||
| $("#bottom_save_edit").hide(); | |||||
| } | |||||
| </script> | |||||
| @@ -0,0 +1,29 @@ | |||||
| <form action="/myshixuns/<%= @myshixun.id %>/games/<%= @game.id %>/file_update?path=<%= @path %>" method="post" id="extend_file_update_id" data-remote="true"> | |||||
| <li class="clearfix" xmlns="http://www.w3.org/1999/html" style="height: 700px"> | |||||
| <textarea class = "" id="extend-challenge-file-edit" name="content"><%= Redmine::CodesetUtil.replace_invalid_utf8(@content) %></textarea> | |||||
| <script> | |||||
| var text = document.getElementById("extend-challenge-file-edit"); | |||||
| </script> | |||||
| </li> | |||||
| </form> | |||||
| <script type="text/javascript"> | |||||
| var extend_editor = CodeMirror.fromTextArea(document.getElementById("extend-challenge-file-edit"), { | |||||
| mode: {name: '<%= @language %>', | |||||
| version: 2, | |||||
| singleLineStringErrors: false}, | |||||
| lineNumbers: true, | |||||
| indentUnit: 2, | |||||
| matchBrackets: true | |||||
| }); | |||||
| extend_editor.on('change',function(cMirror){ | |||||
| // get value right from instance | |||||
| $('#extend-challenge-file-edit').val(cMirror.getValue()); | |||||
| }); | |||||
| // $(".CodeMirror").css("line-height", 1.2); | |||||
| extend_editor.refresh(); | |||||
| var web_h = window.innerHeight; | |||||
| extend_editor.setSize("auto", web_h - 135 + "px") | |||||
| </script> | |||||
| @@ -0,0 +1,43 @@ | |||||
| <div id="extend_code_results" class="undis"> | |||||
| </div> | |||||
| <script id="t:extend_exec_results" type="text/html"> | |||||
| <div class="col-width content-history content-half-fix" id="game_text_results"> | |||||
| <div class="panel-header clearfix"> | |||||
| <h3 class="fl">测评历史</h3> | |||||
| <div class="fr mt5"> | |||||
| <a href="javascript:void(0)" onclick="hide_windows();"><i class="fa fa-compress font-14 fl color-grey"></i></a> | |||||
| </div> | |||||
| </div> | |||||
| <div class="content-history-inner" style="height: 90%;"> | |||||
| <! for(var i=0;i< results.length; i++) { !> | |||||
| <! if(results[i][0] == 0){ !> | |||||
| <div class="clearfix history-success mb10"> | |||||
| <span class="icon-success fl mr5"><!= results.length - i !></span> | |||||
| <p class="fl">恭喜,您已经完成了本任务!</p> | |||||
| <a href="/myshixuns/<%= @myshixun.id %>/games/<%= @game.id %>/outputs_show?game_output_id=<!= results[i][1] !>" class="fr mr10" data-remote="true">详情</a> | |||||
| </div> | |||||
| <! }else{ !> | |||||
| <div class="clearfix history-fail mb10"> | |||||
| <span class="icon-fail fl mr5"><!= results.length - i !></span> | |||||
| <p class="fl">错误结果!</p> | |||||
| <a href="/myshixuns/<%= @myshixun.id %>/games/<%= @game.id %>/outputs_show?game_output_id=<!= results[i][1] !>" class="fr mr10" data-remote="true">详情</a> | |||||
| <div class="cl"></div> | |||||
| </div> | |||||
| <div class="undis" style="background: #f5f9fc;padding: 10px;margin-top:-10px;margin-bottom: 10px" id="extend_game_exception_results_<!= results[i][1] !>"></div> | |||||
| <! } !> | |||||
| <! } !> | |||||
| </div> | |||||
| </div> | |||||
| </script> | |||||
| <script> | |||||
| var bt = baidu.template; | |||||
| bt.LEFT_DELIMITER = '<!'; | |||||
| bt.RIGHT_DELIMITER = '!>'; | |||||
| $(function(){ | |||||
| var html = bt('t:extend_exec_results',{status: <%= @game.status %>, output:"<%= @latest_output %>", results: <%= @results %>, had_done: "<%= @had_done %>"}); | |||||
| $("#extend_code_results").html(html); | |||||
| }); | |||||
| function hide_windows(){ | |||||
| $("#extend_code_results").hide(); | |||||
| } | |||||
| </script> | |||||
| @@ -0,0 +1,22 @@ | |||||
| <div class="autoscroll_extend" style="line-height: 1.9;"> | |||||
| <table class="list entries" id="browser" style="table-layout: fixed;"> | |||||
| <tbody> | |||||
| <% @entries.each do |entry| %> | |||||
| <% tr_id = Digest::MD5.hexdigest(entry.path) | |||||
| depth = params[:depth].to_i %> | |||||
| <% sub_path = entry.path[0] == "/" ? entry.path.sub("/", "") : entry.path %> | |||||
| <% ent_path = Redmine::CodesetUtil.replace_invalid_utf8(sub_path) %> | |||||
| <% ent_name = Redmine::CodesetUtil.replace_invalid_utf8(entry.name) %> | |||||
| <tr id="<%= tr_id %>" class="<%= h params[:parent_id] %> entry <%= entry.kind %>"> | |||||
| <td class="filename_no_report hidden"> | |||||
| <%= link_to h(ent_name), | |||||
| {:action => (entry.is_dir? ? 'show' : 'entry'), :id => @game, :myshixun_id => @myshixun, :path => to_path_param(ent_path), :rev => @rev, :extend => extend }, | |||||
| :remote => true, | |||||
| :class => (entry.is_dir? ? 'old-icon old-icon-folder' : "old-icon old-icon-file #{Redmine::MimeType.css_class_of(ent_name)}")%> | |||||
| </td> | |||||
| </tr> | |||||
| <% end %> | |||||
| </tbody> | |||||
| </table> | |||||
| </div> | |||||
| @@ -0,0 +1,41 @@ | |||||
| <style type="text/css"> | |||||
| .CodeMirror{line-height: 1.2} | |||||
| </style> | |||||
| <form action="/myshixuns/<%= @myshixun.id %>/games/<%= @game.id %>/file_update?path=<%= @path %>" method="post" id="file_update_id" data-remote="true"> | |||||
| <li class="clearfix" xmlns="http://www.w3.org/1999/html" id="edit_code_contents"> | |||||
| <textarea class = "" id="challenge-answer-edit-small" name="content" style="height: 98%;width: 98%;"><%= Redmine::CodesetUtil.replace_invalid_utf8(@content) %></textarea> | |||||
| <script> | |||||
| var text = document.getElementById("challenge-answer-edit-small"); | |||||
| </script> | |||||
| </li> | |||||
| </form> | |||||
| <script type="text/javascript"> | |||||
| var editor_CodeMirror = CodeMirror.fromTextArea(document.getElementById("challenge-answer-edit-small"), { | |||||
| mode: {name: 'text/x-ruby', | |||||
| // version: 2, | |||||
| singleLineStringErrors: false}, | |||||
| lineNumbers: true, | |||||
| indentUnit: 4, //代码缩进为一个tab的距离 | |||||
| matchBrackets: true, | |||||
| autoRefresh: true, | |||||
| smartIndent: true //智能换行 | |||||
| }); | |||||
| editor_CodeMirror.on('change',function(cMirror){ | |||||
| // get value right from instance | |||||
| $('#challenge-answer-edit-small').val(cMirror.getValue()); | |||||
| }); | |||||
| editor_CodeMirror.on('blur',function(cMirror){ | |||||
| $('#file_update_id').submit(); | |||||
| }); | |||||
| // 设置版本库字体间距 | |||||
| // $("#challenge-answer-edit-small" ).nextAll(".CodeMirror").css("line-height", 1.2); | |||||
| $(document).ready(function(){ | |||||
| // 设置codemirror的高度/宽度自适应 | |||||
| editor_CodeMirror.setSize("auto",residue_h+50+"px"); | |||||
| editor_CodeMirror.refresh(); | |||||
| }); | |||||
| </script> | |||||
| @@ -0,0 +1,68 @@ | |||||
| <div class="content clearfix CELL _FLEX COLS ml15 mr15 mt15"> | |||||
| <div class="content-info col-width CELL" id="tpi_contents_info"> | |||||
| <div class="panel-header clearfix" id="contents_top"> | |||||
| <h3 class="fl">第<%= @game_challenge.position %>关:<%= @game_challenge.subject %></h3> | |||||
| <div class="fr mt5"> | |||||
| <a href="javascript:void(0);" onclick="extend_game_description();"><i class="fa fa-expand font-14 fl color-grey"></i></a> | |||||
| </div> | |||||
| </div> | |||||
| <div class="tab_content clearfix"> | |||||
| <ul id="tab_nav"> | |||||
| <li id="tab_nav_1" class="tab_hover" onclick="HoverLi(1);"> | |||||
| <a href="javascript:void(0);" class="tab_type">过关任务</a> | |||||
| </li> | |||||
| <li id="tab_nav_2" onclick="HoverLi(2);"> | |||||
| <a href="javascript:void(0);" class="tab_type" >预备知识</a> | |||||
| </li> | |||||
| <li id="tab_nav_3" onclick="HoverLi(3);"> | |||||
| <a href="javascript:void(0);" class="tab_type" >参考答案</a> | |||||
| </li> | |||||
| </ul> | |||||
| <div class="cl"></div> | |||||
| <div id="tab_con_1" class="tab-info" > | |||||
| <div class="tab-info-inner" id="task_pass_contents"> | |||||
| <%= h @game_challenge.task_pass.try(:html_safe) %> | |||||
| </div> | |||||
| </div> | |||||
| <div id="tab_con_2" class="undis tab-info"> | |||||
| <div class="tab-info-inner" id="task_pass_contents"> | |||||
| <%= h @game_challenge.ready_knowledge.try(:html_safe) %> | |||||
| </div> | |||||
| </div> | |||||
| <div id="tab_con_3" class="undis tab-info"> | |||||
| <div class="tab-info-inner" style="line-height: 1.9" id="game_answer_show"></div> | |||||
| <div class="undis" id="hidden_game_answer"><%= @game_challenge.answer %></div> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <%= render :partial => 'games/repository' %> | |||||
| </div> | |||||
| <%= render :partial => 'games/exec_results' %> | |||||
| <%#= render :partial => 'games/desc_full_show' %> | |||||
| <script type="text/javascript" language="javascript"> | |||||
| var myMirror = $("#game_answer_show")[0]; | |||||
| var myCodeMirror = CodeMirror(myMirror, { | |||||
| value: $("#hidden_game_answer").text(), | |||||
| mode: "<%= @language %>", | |||||
| readOnly: "nocursor", //只读 | |||||
| //cursorBlinkRate: -1, //隐藏光标 | |||||
| autofocus: true, | |||||
| border: 0 | |||||
| }); | |||||
| $(document).ready(function(){ | |||||
| myCodeMirror.setSize('auto','auto');//设置版本库codemirror的高度 | |||||
| $("#game_answer_show" ).children(".CodeMirror").css("line-height", 1.2); | |||||
| $("#game_answer_show").children().css("border", 0); | |||||
| // 设置图片最大宽度不能超出边框 | |||||
| $('#task_pass_contents').find('img').css("max-width", "100%"); | |||||
| $("#task_pass_contents").css("height", residue_h + "px"); | |||||
| $(".tab-info-inner").css("height", residue_h+"px"); | |||||
| }); | |||||
| //课程大纲tab | |||||
| function extend_game_description(){ | |||||
| $("#game_left_contents").show(); | |||||
| } | |||||
| </script> | |||||
| @@ -0,0 +1,66 @@ | |||||
| <div class="content clearfix" > | |||||
| <div class="col-width-10 ml15 mt15 mr15"> | |||||
| <div class="panel-header clearfix"> | |||||
| <h3 class="fl">全部任务</h3><span class="btn-cir btn-cir-grey ml5 mt3 fl"><%= @games_count %></span> | |||||
| </div> | |||||
| <% @games.each do |game| %> | |||||
| <div class="panel-list"> | |||||
| <div class=" clearfix panel-inner"> | |||||
| <% if game.status == 0 %> | |||||
| <div class="fl"> | |||||
| <h4 class=" panel-inner-title "><i class="fa fa-dot-circle-o font-18 color-green mr5"></i><span class="color-red">第<%= game.challenge.try(:position) %>关</span> | |||||
| <%= link_to game.challenge.try(:subject), myshixun_game_path(game, :myshixun_id => @myshixun), :remote => true %></h4> | |||||
| <p class="ml15 mt15 color-grey"> | |||||
| <span class=" mr10">已闯关:<%= had_pass(@myshixun.shixun_id, game.challenge.try(:position)) %>人</span> | |||||
| <span class=" mr10">平均耗时:<%= game_spend_time(avg_spend_time(@myshixun.shixun_id, game.challenge.try(:position)), 0) %></span> | |||||
| </p> | |||||
| </div> | |||||
| <a href="<%= game_build_myshixun_game_path(game, :myshixun_id => @myshixun) %>" class="task-btn task-btn-green fr" id="open_game" data-remote="true">马上开启</a> | |||||
| <div class="cl"></div> | |||||
| <% elsif game.status == 1 %> | |||||
| <div class="fl"> | |||||
| <h4 class=" panel-inner-title "><i class="fa fa-dot-circle-o font-18 color-green mr5"></i><span class="color-red">第<%= game.challenge.try(:position) %>关</span> | |||||
| <%= game.challenge.try(:subject) %></h4> | |||||
| <p class="ml15 mt15 color-grey"> | |||||
| <span class=" mr10">已闯关:<%= had_pass(@myshixun.shixun_id, game.challenge.try(:position)) %>人</span> | |||||
| <span class=" mr10">平均耗时:<%= game_spend_time(avg_spend_time(@myshixun.shixun_id, game.challenge.try(:position)), 0) %></span> | |||||
| </p> | |||||
| </div> | |||||
| <a href="#" class=" fr link-color-green">正在解决中</a> | |||||
| <div class="cl"></div> | |||||
| <% elsif game.status == 2 %> | |||||
| <h4 class="fl panel-inner-title "><i class="fa fa-check-circle font-18 color-green mr5"></i><span class="color-red">第<%= game.challenge.try(:position) %>关</span> | |||||
| <%= link_to game.challenge.try(:subject), myshixun_game_path(game, :myshixun_id => @myshixun), :remote => true %></h4> | |||||
| <!--<p class="fr "><i class="fa fa-trophy color-yellow font-16 mr5 "></i><span class=" color-grey">NO.120</span></p>--> | |||||
| <div class="cl"></div> | |||||
| <p class="ml15 mt15 color-grey"> | |||||
| <span class=" mr10">开始时间:<%= format_time(game.created_at) %></span> | |||||
| <span class=" mr10">完成时间:<%= format_time(game.updated_at) %></span> | |||||
| <span class=" mr10">耗时:<%= game_spend_time(game.created_at, game.updated_at) %></span> | |||||
| <span class=" mr10">已闯关:<%= had_pass(@myshixun.shixun_id, game.challenge.try(:position)) %>人</span> | |||||
| <span class=" mr10">得分:<%= game.final_score %>分</span> | |||||
| </p> | |||||
| <% elsif game.status == 3 %> | |||||
| <div class="fl"> | |||||
| <h4 class=" panel-inner-title "><i class="fa fa-lock font-18 color-grey mr5"></i><span class="color-red">第<%= game.challenge.try(:position) %>关</span> | |||||
| <%= game.challenge.try(:subject) %></h4> | |||||
| <p class="ml15 mt15 color-grey"> | |||||
| <span class=" mr10">已闯关:<%= had_pass(@myshixun.shixun_id, game.challenge.try(:position)) %>人</span> | |||||
| <span class=" mr10">平均耗时:<%= game_spend_time(avg_spend_time(@myshixun.shixun_id, game.challenge.try(:position)), 0) %></span> | |||||
| </p> | |||||
| </div> | |||||
| <a href="#" class=" task-btn fr"> 已锁定 </a> | |||||
| <div class="cl"></div> | |||||
| <% end %> | |||||
| </div> | |||||
| </div> | |||||
| <% end %> | |||||
| </div> | |||||
| </div> | |||||
| <script> | |||||
| $("#open_game").click(function(){ | |||||
| $("#open_game").removeClass("task-btn-green"); | |||||
| $("#open_game").html("评测中..") | |||||
| }); | |||||
| </script> | |||||
| @@ -0,0 +1,23 @@ | |||||
| <div style="width:460px;"> | |||||
| <div class="task-popup-title clearfix"> | |||||
| <h3 class="fl color-grey">提示</h3> | |||||
| <a href="javascript:void(0);" onclick="hideModal()"><i class="fa fa-times-circle font-18 link-color-grey fr"></i></a> | |||||
| <div class="cl"></div> | |||||
| </div> | |||||
| <div class="sy_popup_con" style="width:380px;"> | |||||
| <ul class="sy_popup_add" > | |||||
| <li class="center mb30" style="line-height:20px"> | |||||
| 您将离开此页面<br/>请问是否确定继续? | |||||
| </li> | |||||
| <div class="task-popup-submit clearfix"> | |||||
| <a href="javascript:void(0);" class="task-btn fl" onclick="hideModal()">取消</a> | |||||
| <a href="javascript:void(0);" class="task-btn task-btn-green fr" onclick="hideModal();close_web();">确定</a> | |||||
| </div> | |||||
| </ul> | |||||
| </div> | |||||
| </div> | |||||
| <script> | |||||
| function close_web(){ | |||||
| window.location.href = '<%= user_path(User.current) %>'; | |||||
| } | |||||
| </script> | |||||
| @@ -0,0 +1,25 @@ | |||||
| <% if @path.blank? %> | |||||
| <%= @repository.identifier %> | |||||
| <% else %> | |||||
| <%= link_to "#{@repository.identifier.present? ? h(@repository.identifier) : 'root'}", myshixun_game_path(@game, :myshixun_id => @myshixun, :type => "root"), :remote => true %> | |||||
| <% | |||||
| dirs = path.split('/') | |||||
| if 'file' == kind | |||||
| filename = dirs.pop | |||||
| end | |||||
| link_path = '' | |||||
| dirs.each do |dir| | |||||
| next if dir.blank? | |||||
| link_path << '/' unless link_path.empty? | |||||
| link_path << "#{dir}" | |||||
| %> | |||||
| <% if dir.include?(".") %> | |||||
| <span class="c_grey">/</span> <%= link_to h(dir), {:action => 'entry', :id => @game, :myshixun_id => @myshixun, :path => to_path_param(link_path), :rev => @rev}, | |||||
| :remote => true, :class => "f14 fb" %> | |||||
| <% else %> | |||||
| <span class="c_grey">/</span> <%= link_to h(dir), {:action => 'show', :id => @game, :myshixun_id => @myshixun, :path => to_path_param(link_path), :rev => @rev}, | |||||
| :remote => true, :class => "f14 fb" %> | |||||
| <% end %> | |||||
| <% end %> | |||||
| <% end %> | |||||
| @@ -0,0 +1,25 @@ | |||||
| <div class="panel-header clearfix" style="border: none"> | |||||
| <h3 class="fl"><%= render :partial => 'myshixun_breadcrumbs', :locals => {:path => @path, :kind => 'dir'} %></h3> | |||||
| <div class="fr mt5"> | |||||
| <% if params[:action] == "entry" || @file_open %> | |||||
| <a href="javascript:void(0)" id="sava_edit_btn" onclick="extend_file_edit_submit();" title="保存修改"><i class="fa fa-save font-18 fl color-grey mr10"></i></a> | |||||
| <% end %> | |||||
| <a href="javascript:void(0)" onclick="close_big_repository()"><i class="fa fa-compress font-14 fl color-grey"></i></a> | |||||
| </div> | |||||
| </div> | |||||
| <div class="content-history-extend"> | |||||
| <% if params[:action] == "entry" || @file_open %> | |||||
| <div id="file_entry_content_inner"> | |||||
| <%= render :partial => 'extend_edit_file_form', :locals => {:filename => @path, :content => @content, :extend => true} %> | |||||
| </div> | |||||
| <% else %> | |||||
| <% unless @entries.blank? %> | |||||
| <%= render :partial => 'extend_tree', :locals => { :extend => true} %> | |||||
| <% end %> | |||||
| <% end %> | |||||
| </div> | |||||
| <script> | |||||
| function extend_file_edit_submit(){ | |||||
| $("#extend_file_update_id").submit() | |||||
| } | |||||
| </script> | |||||
| @@ -0,0 +1,33 @@ | |||||
| <div class="panel-header-border clearfix"> | |||||
| <h3 class="fl"> | |||||
| <%= render :partial => 'myshixun_breadcrumbs', :locals => {:path => @path, :kind => 'dir'} %> | |||||
| </h3> | |||||
| <div class="fr mt5"> | |||||
| <% if params[:action] == "entry" || @file_open %> | |||||
| <a href="javascript:void(0)" id="sava_edit_btn1" onclick="file_edit_submit()" title="保存修改"><i class="fa fa-save font-18 fl color-grey mr10"></i></a> | |||||
| <% end %> | |||||
| <a href="javascript:void(0)" onclick="extend_repository();"><i class="fa fa-expand font-18 fl color-grey"></i></a> | |||||
| </div> | |||||
| </div> | |||||
| <div class="content-editor-inner" id="repository_contents_show"> | |||||
| <% if params[:action] == "entry" || @file_open %> | |||||
| <div id="file_entry_content"> | |||||
| <%= render :partial => 'games/file_edit_form', :locals => {:filename => @path, :content => @content} %> | |||||
| </div> | |||||
| <% else %> | |||||
| <% unless @entries.blank? %> | |||||
| <%= render :partial => 'tree', :locals => { :extend => false}%> | |||||
| <% end %> | |||||
| <% end %> | |||||
| </div> | |||||
| <script> | |||||
| var web_h = window.innerHeight; | |||||
| $(document).ready(function(){ | |||||
| // 右侧版本库内容 | |||||
| $("#repository_contents_show").css("height", residue_h + 55 + "px"); | |||||
| }); | |||||
| function file_edit_submit(){ | |||||
| $('#file_update_id').submit(); | |||||
| $("#bottom_save_edit").hide(); | |||||
| } | |||||
| </script> | |||||
| @@ -0,0 +1,15 @@ | |||||
| <%= stylesheet_link_tag 'css/bigdata-common', 'css/bigdata-popup' %> | |||||
| <div class="task-popup-warp" style="background-color: rgba(0,0,0,0.7);"> | |||||
| <div class="task-popup-box <%= had_done == 0 ? "task-box1" : "task-box2" %>"> | |||||
| <a href="javascript:void(0)" class="task-popup-close" onclick="hideModal();"></a> | |||||
| <div class="task-su-con"> | |||||
| <% if had_done == 0 %> | |||||
| <p class="task-su-p">恭喜您通过本关</p> | |||||
| <%= link_to "下 一 关", {:controller => 'games', :action => "next_step", :id => game, :myshixun_id => myshixun}, :class => "task-su-btn", :onclick => "hideModal();",:remote => true %> | |||||
| <% else %> | |||||
| <a href="<%= myshixun_games_path(myshixun) %>" class="task-su-btn-white mt50" onclick="hideModal();" data-remote="true">查看光辉历史</a> | |||||
| <% end %> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| @@ -0,0 +1,16 @@ | |||||
| <div class="content-editor col-width2 CELL" id="myshixun_repository"> | |||||
| <%= render :partial => 'myshixun_repository' %> | |||||
| </div> | |||||
| <div class="cl"></div> | |||||
| <script> | |||||
| var web_h = window.innerHeight; | |||||
| $(document).ready(function(){ | |||||
| }); | |||||
| function extend_repository(){ | |||||
| $("#extend_code_results").hide(); | |||||
| $("#myshixun_extend_repository").show(); | |||||
| extend_editor.refresh(); | |||||
| } | |||||
| </script> | |||||
| @@ -0,0 +1,21 @@ | |||||
| <div class="autoscroll_new" style="line-height: 1.9;"> | |||||
| <table class="list entries" id="browser" style="table-layout: fixed;"> | |||||
| <tbody> | |||||
| <% @entries.each do |entry| %> | |||||
| <% tr_id = Digest::MD5.hexdigest(entry.path) | |||||
| depth = params[:depth].to_i %> | |||||
| <% sub_path = entry.path[0] == "/" ? entry.path.sub("/", "") : entry.path %> | |||||
| <% ent_path = Redmine::CodesetUtil.replace_invalid_utf8(sub_path) %> | |||||
| <% ent_name = Redmine::CodesetUtil.replace_invalid_utf8(entry.name) %> | |||||
| <tr id="<%= tr_id %>" class="<%= h params[:parent_id] %> entry <%= entry.kind %>"> | |||||
| <td class="filename_no_report hidden"> | |||||
| <%= link_to h(ent_name), | |||||
| {:action => (entry.is_dir? ? 'show' : 'entry'), :id => @game, :myshixun_id => @myshixun, :path => to_path_param(ent_path), :rev => @rev, :extend => extend }, | |||||
| :remote => true, | |||||
| :class => (entry.is_dir? ? 'old-icon old-icon-folder' : "old-icon old-icon-file #{Redmine::MimeType.css_class_of(ent_name)}")%> | |||||
| </td> | |||||
| </tr> | |||||
| <% end %> | |||||
| </tbody> | |||||
| </table> | |||||
| </div> | |||||
| @@ -0,0 +1,3 @@ | |||||
| <textarea> | |||||
| </textarea> | |||||
| @@ -0,0 +1,6 @@ | |||||
| $("#myshixun_repository").html('<%= escape_javascript(render :partial => 'games/myshixun_repository') %>'); | |||||
| $("#myshixun_extend_repository").html('<%= escape_javascript(render :partial => 'games/myshixun_extend_repository') %>'); | |||||
| //$("#game_rep_modify").html('<a href="javascript:void(0)" class="task-btn task-btn-green mb10" id="bottom_save_edit" onclick="file_edit_submit1()">保存修改</a>'); | |||||
| @@ -0,0 +1,7 @@ | |||||
| //$("#file_entry_content").html('<%#= escape_javascript(render :partial => 'games/file_edit_form') %>'); | |||||
| //$("#file_entry_content_inner").html('<%#= escape_javascript(render :partial => 'games/extend_file_edit_form') %>'); | |||||
| //$("#sava_edit_btn1").show(); | |||||
| //$("#sava_edit_btn").show(); | |||||
| //$("#bottom_save_edit").show(); | |||||
| //editor_CodeMirror.refresh(); | |||||
| //editor.refresh(); | |||||
| @@ -0,0 +1 @@ | |||||
| //$("#code_results").html('<%#= escape_javascript(render :partial => 'games/exec_results') %>'); | |||||
| @@ -0,0 +1,3 @@ | |||||
| <div id="content_list"> | |||||
| <%= render :partial => "games_list" %> | |||||
| </div> | |||||
| @@ -0,0 +1,10 @@ | |||||
| $("#content_list").html('<%= escape_javascript(render :partial => 'games/games_list') %>'); | |||||
| $("#current_task_tab").attr('href','<%= myshixun_game_path(@myshixun.current_task, :myshixun_id => @myshixun) %>'); | |||||
| $("#myshixun_top").html('<%= escape_javascript(render :partial => 'myshixuns/myshixun_top') %>'); | |||||
| // 左侧导航样式改动 | |||||
| $("#current_task_tab").removeClass("leftnav-active"); | |||||
| $("#all_task_tab").addClass("leftnav-active"); | |||||
| // 宽版隐藏 | |||||
| $("#myshixun_extend_repository").hide(); | |||||
| $("#game_left_contents").hide(); | |||||
| $("#extend_code_results").hide(); | |||||
| @@ -0,0 +1,8 @@ | |||||
| $("#game_test_output").html("<%= @output.out_put.nil? ? "没有编译结果" : @output.out_put.html_safe %>"); | |||||
| // 窄版 | |||||
| $("#game_exception_results_<%= @output.id %>").html("<%= @output.msg.html_safe %>"); | |||||
| $("#game_exception_results_<%= @output.id %>").toggle(); | |||||
| // 宽版 | |||||
| $("#extend_game_exception_results_<%= @output.id %>").html("<%= @output.msg.html_safe %>"); | |||||
| $("#extend_game_exception_results_<%= @output.id %>").toggle(); | |||||
| @@ -0,0 +1,51 @@ | |||||
| <%= javascript_include_tag 'baiduTemplate', 'jquery.datetimepicker.js' %> | |||||
| <%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %> | |||||
| <%= stylesheet_link_tag "/assets/codemirror/codemirror" %> | |||||
| <div id="content_list" class="CELL _FLEX ROWS"> | |||||
| <%= render :partial => "game_show" %> | |||||
| </div> | |||||
| <div id="content_attr_1"> | |||||
| <%= render :partial => 'desc_full_show'%> | |||||
| </div> | |||||
| <div class="col-width content-all-fix undis" style="border: none" id="myshixun_extend_repository"> | |||||
| <%= render :partial => 'myshixun_extend_repository' %> | |||||
| </div> | |||||
| <div id="content_attr_2"> | |||||
| <%= render :partial => 'extend_test_output' %> | |||||
| </div> | |||||
| <script type="text/javascript" language="javascript"> | |||||
| // contents_h 是中间左侧内容页的高度,不同浏览器的得到高度不一致 | |||||
| // contents_top_h 是内容页头部的高度 | |||||
| // contents_tab_nav是三个tab的高度 | |||||
| // residue_h contents剩余展示内容的高度 | |||||
| // 左侧内容 | |||||
| var contents_h = $("#tpi_contents_info").height(); | |||||
| var contents_top_h = $("#contents_top").height() + 20; | |||||
| var contents_tab_nav = $("#tab_nav").height(); | |||||
| var residue_h = contents_h - contents_top_h - contents_tab_nav - 10; | |||||
| $(document).ready(function(){ | |||||
| $(".tab-info-inner").css("height", residue_h+"px"); | |||||
| $(".content-half-fix").css("height", residue_h + 310 +"px") | |||||
| }); | |||||
| //课程大纲tab | |||||
| function g(o){return document.getElementById(o);} | |||||
| function HoverLi(n){ | |||||
| for(var i=1;i<=3;i++){ | |||||
| g('tab_nav_'+i).className='tab_nomal'; | |||||
| g('tab_con_'+i).className='undis'; | |||||
| } | |||||
| g('tab_con_'+n).className='dis'; | |||||
| g('tab_nav_'+n).className='tab_hover'; | |||||
| if(n == 3){ | |||||
| // 点击参考答案时,让codemirror展示,如果不refresh的话,第一次展示会隐藏 | |||||
| myCodeMirror.refresh(); | |||||
| } | |||||
| } | |||||
| $("#close_myshixun_tip").click(function(){ | |||||
| $("#myshixun_tip").hide(); | |||||
| }); | |||||
| function close_big_repository(){ | |||||
| $("#myshixun_extend_repository").hide() | |||||
| } | |||||
| </script> | |||||
| @@ -0,0 +1,6 @@ | |||||
| $("#content_list").html('<%= escape_javascript(render :partial => 'games/game_show') %>'); | |||||
| $("#content_attr_1").html('<%= escape_javascript(render :partial => 'games/desc_full_show') %>'); | |||||
| $("#myshixun_extend_repository").html('<%= escape_javascript(render :partial => 'games/myshixun_extend_repository') %>'); | |||||
| $("#content_attr_2").html('<%= escape_javascript(render :partial => 'games/extend_test_output') %>'); | |||||
| $("#myshixun_top").html('<%= escape_javascript(render :partial => 'myshixuns/myshixun_top') %>'); | |||||
| $("#current_task_tab").attr('href','<%= myshixun_game_path(@myshixun.current_task, :myshixun_id => @myshixun) %>'); | |||||
| @@ -66,7 +66,8 @@ | |||||
| <% end %> | <% end %> | ||||
| <!--版本库--> | <!--版本库--> | ||||
| <% if !@project.enabled_modules.where("name = 'repository'").empty? && !Repository.where(:project_id => @project.id, :type => "Repository::Gitlab").first.nil? %> | <% if !@project.enabled_modules.where("name = 'repository'").empty? && !Repository.where(:project_id => @project.id, :type => "Repository::Gitlab").first.nil? %> | ||||
| <li id="project_menu_05"><%= link_to @project.project_score.changeset_num.to_i > 0 ? "#{l(:project_module_repository)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k project_score.changeset_num}</span>".html_safe : "#{l(:project_module_repository)}",({:controller => 'repositories', :action => 'show', :id => @project, :repository_id => gitlab_repository(@project).try(:identifier)}), :class => "pro_new_proname", :title => "#{project_score.changeset_num}" %></li> | |||||
| <li id="project_menu_05"><%= link_to @project.project_score.changeset_num.to_i > 0 ? "#{l(:project_module_repository)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k project_score.changeset_num}</span>".html_safe : "#{l(:project_module_repository)}", | |||||
| ({:controller => 'repositories', :action => 'show', :id => @project, :repository_id => gitlab_repository(@project).try(:identifier)}), :class => "pro_new_proname", :title => "#{project_score.changeset_num}" %></li> | |||||
| <% end %> | <% end %> | ||||
| <!--Pull Request--> | <!--Pull Request--> | ||||
| <% unless @project.gpid.nil? %> | <% unless @project.gpid.nil? %> | ||||
| @@ -0,0 +1,10 @@ | |||||
| <footer class="footer"> | |||||
| <div class="footer_con"> | |||||
| <ul class="clearfix footer_con-inner"> | |||||
| <li><a href="<%= agreement_path %>" class="fl" target="_blank">服务协议</a></li> | |||||
| <li><%= link_to l(:label_surpport_group), "#{Setting.protocol}://#{Setting.host_name}/forums/1/memos/1168", :class => "fl", :target=>"_blank" %></li> | |||||
| <li><a href="<%= forums_path %>" class="fl" target="_blank" style="border:none;"><%= l(:label_forums)%></a></li> | |||||
| </ul> | |||||
| <p class="footer_con-p">Copyright 2007~2016, All Rights Reserved湘ICP备09019772</p> | |||||
| </div> | |||||
| </footer> | |||||
| @@ -0,0 +1,45 @@ | |||||
| <div class="header_con"> | |||||
| <div class="fl clearfix new-logo"> | |||||
| <%= link_to image_tag("../images/bigdata/new-logo.png",width:"51px", height: "45px", alt:"高校教育大数据服务平台", class:"fl "), home_path %> | |||||
| <p class="fl ml10 ">高校教育大数据服务平台</p> | |||||
| </div> | |||||
| <a href="<%= user_join_path %>" class="fr new-btn mt10">注册</a> | |||||
| <a href="<%= signin_url %>" class="fr new-btn new-btn-blue mr5 mt10">登录</a> | |||||
| <div id="navHomepageSearch"> | |||||
| <% name = name%> | |||||
| <%= form_tag({controller: :welcome, action: :search },:class=>'navHomepageSearchBox', method: :get) do %> | |||||
| <input type="text" name="q" value="<%= name.nil? ? "" : name %>" id="navHomepageSearchInput" class="new-search fr mr10" placeholder="请输入关键词进行搜索" onkeypress="search_in_header_I(event,$(this));"/> | |||||
| <input type="hidden" name="search_type" id="type" value="all"/> | |||||
| <input type="text" style="display: none;"/> | |||||
| <a href="javascript:void(0);" class="homepageSearchIcon" onclick="search_in_header($(this));"></a> | |||||
| <% end %> | |||||
| </div> | |||||
| <%= link_to "问吧", forums_path, :class =>"fr new-nav-a mr10", :target => "_blank" %> | |||||
| </div> | |||||
| <script> | |||||
| //搜索相关 | |||||
| $("#navHomepageSearch").mouseover(function(){ | |||||
| $("#navHomepageSearchType").show(); | |||||
| }).mouseout(function(){ | |||||
| $("#navHomepageSearchType").hide(); | |||||
| }); | |||||
| function search(doc){ | |||||
| $(doc).parent().submit(); | |||||
| } | |||||
| function search_in_header(obj){ | |||||
| var name = $.trim($('#navHomepageSearchInput').val()); | |||||
| if (name != "" && name.length != 0) { | |||||
| obj.parent().submit(); | |||||
| } | |||||
| } | |||||
| function search_in_header_I(e,obj){ | |||||
| var name = $.trim($('#navHomepageSearchInput').val()); | |||||
| if (e.keyCode == '13' && name != "" && name.length != 0) { | |||||
| obj.parent().submit(); | |||||
| } | |||||
| } | |||||
| </script> | |||||