From 675b1ad40392e805a84c67a5d28d622940208e6e Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 22 Mar 2016 13:51:19 +0800 Subject: [PATCH] =?UTF-8?q?1.=E7=BB=84=E7=BB=87=E9=85=8D=E7=BD=AE=E4=B8=AD?= =?UTF-8?q?=EF=BC=8C=E8=BE=93=E5=85=A5=E7=BB=84=E7=BB=87=E5=90=8D=E5=AD=97?= =?UTF-8?q?=E3=80=81=E5=AD=90=E6=A0=8F=E7=9B=AE=E5=9F=9F=E5=90=8D=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E5=90=8E=EF=BC=8C=E8=87=AA=E5=8A=A8=E5=8F=98=E6=88=90?= =?UTF-8?q?=E5=B0=8F=E5=86=99=E5=AD=97=E6=AF=8D=EF=BC=9B2.=E5=B0=86?= =?UTF-8?q?=E6=89=80=E6=9C=89=E5=AD=90=E5=9F=9F=E5=90=8D=E5=8F=8A=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=E7=9B=AE=E5=BD=95=E6=94=B9=E6=88=90=E5=B0=8F=E5=86=99?= =?UTF-8?q?=EF=BC=9B3.=E7=BB=84=E7=BB=87=E9=85=8D=E7=BD=AE=E4=B8=AD?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=AD=90=E6=A0=8F=E7=9B=AE=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=A6=82=E6=9E=9C=E6=B2=A1=E6=9C=89=E7=82=B9=E7=A1=AE?= =?UTF-8?q?=E5=AE=9A=EF=BC=8C=E8=BE=93=E5=85=A5=E6=A1=86=E7=9A=84=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E4=BF=9D=E6=8C=81=E4=B8=8D=E5=8F=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/org_subfields_controller.rb | 2 +- .../organizations/_subfield_list.html.erb | 11 +++++- app/views/organizations/setting.html.erb | 35 +++++++++++++------ ...2032610_change_domain_name_to_lowercase.rb | 14 ++++++++ 4 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 db/migrate/20160322032610_change_domain_name_to_lowercase.rb diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index ba4c1f18f..bc339319b 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -11,7 +11,7 @@ class OrgSubfieldsController < ApplicationController sql = "select subfield_subdomain_dirs.* from subfield_subdomain_dirs, org_subfields where subfield_subdomain_dirs.org_subfield_id = org_subfields.id "+ "and org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir]}'" if SubfieldSubdomainDir.find_by_sql(sql).count == 0 - SubfieldSubdomainDir.create(:org_subfield_id => @subfield.id, :name => params[:sub_dir]) + SubfieldSubdomainDir.create(:org_subfield_id => @subfield.id, :name => params[:sub_dir].downcase) end end @subfield.update_attributes(:field_type => params[:field_type]) diff --git a/app/views/organizations/_subfield_list.html.erb b/app/views/organizations/_subfield_list.html.erb index 0d490df77..133217c70 100644 --- a/app/views/organizations/_subfield_list.html.erb +++ b/app/views/organizations/_subfield_list.html.erb @@ -54,7 +54,7 @@ <% end %> <%#= link_to "隐藏", hide_org_subfield_organizations_path(field), :method => 'post', :remote => true, :id => "hide_#{field.id}", :class => "linkBlue fr mr5" %> @@ -85,6 +85,9 @@ url: "/org_subfields/" + field_id + "?name=" + input_value, type: 'put' }); + else{ + $(edit_id).children("input").val($(show_id).html().trim()); + } } $(show_id).show(); $(edit_id).hide(); @@ -109,6 +112,9 @@ url: "/org_subfields/" + field_id + "/update_sub_dir?sub_dir_name=" + input_value, type: 'put' }); + else{ + $(edit_id).children("input").val($(show_id).html().trim()); + } } $(show_id).show(); $(edit_id).hide(); @@ -134,6 +140,9 @@ type: 'put' }); } + else{ + $(edit_id).children("input").val($(show_id).html().trim()); + } } else { diff --git a/app/views/organizations/setting.html.erb b/app/views/organizations/setting.html.erb index 854c7d12e..ce02a0557 100644 --- a/app/views/organizations/setting.html.erb +++ b/app/views/organizations/setting.html.erb @@ -57,7 +57,7 @@
组织URL:
http:// - + .trustie.net申请 <% record = OrgMessage.where("organization_id=? and message_type='ApplySubdomain'", @organization.id).order("updated_at desc").first %> <% if domain.present? and record.present? and record.content == domain.subname %> @@ -129,9 +129,9 @@

域名目录(用户自定义url,可选)

<% if domain %> - <%= domain.subname %>.trustie.net/ + <%= domain.subname %>.trustie.net/ <% else %> - 您还没有子域名,请先在左侧信息栏申请子域名 + 您还没有子域名,请先在左侧信息栏申请子域名 <% end %>
@@ -195,12 +195,25 @@ } } -// $(document).ready(function(){ -// if ( $("#is_public").attr("checked") != true){ -// alert($(this).attr("checked")); -// $("#allow_download").attr("checked", false); -// $("#allow_download").attr("disabled", true); -// $("#allow_down_hint").html(""); -// } -// }); + //输入子域名或者二级目录,自动将输入换成小写 + function observe_input_to_lowercase(id){ + $(id).each(function(){ + var $this = $(this); + var old_input = $this.val(); + var check=function(){ + var val = $this.val(); + if ( old_input != val){ + $this.val(val.toLowerCase()); + old_input = val.toLowerCase(); + } + }; + var reset = function() { + if (timer) { + clearInterval(timer); + } + }; + var timer = setInterval(check, 300); + $this.bind('blur', reset); + }); + } \ No newline at end of file diff --git a/db/migrate/20160322032610_change_domain_name_to_lowercase.rb b/db/migrate/20160322032610_change_domain_name_to_lowercase.rb new file mode 100644 index 000000000..35a82477d --- /dev/null +++ b/db/migrate/20160322032610_change_domain_name_to_lowercase.rb @@ -0,0 +1,14 @@ +class ChangeDomainNameToLowercase < ActiveRecord::Migration + def up + Secdomain.all.each do |domain| + domain.update_attribute(:subname, domain.subname.downcase) + end + + SubfieldSubdomainDir.all.each do |dir| + dir.update_attribute(:name, dir.name.downcase) + end + end + + def down + end +end