change tab to space and add the feature that repair the module_app multuple existed problem

This commit is contained in:
chiu 2020-02-23 11:47:27 +08:00
parent eba222a9da
commit 4b56e7b5ee
3 changed files with 468 additions and 430 deletions

View File

@ -9,9 +9,39 @@ class Admin::PatchfilesController < OrbitAdminController
super super
@app_title = "patchfile" @app_title = "patchfile"
end end
def repair_module
ModuleApp.all.map{|v| v}.group_by{|v| [v.key,v.title]}.select{|k,v| Array(v).length>1}.each do |k,vs|
array_vs = Array(vs)
cats = array_vs.collect{|v| v.categories}.flatten.uniq
tags = array_vs.collect{|v| v.tags}.flatten.uniq
auths = array_vs.collect{|v| v.authorizations}.flatten.uniq
array_vs.reverse.each_with_index do |v,i|
if i == 0
tags = tags.collect do |tag|
tag.module_app_ids = [v.id]
tag.save
tag
end
cats = cats.collect do |cat|
cat.module_app_id = v.id
cat.save
cat
end
auths = auths.collect do |auth|
auth.module_app_id = v.id
auth.save
auth
end
else
v.tag_ids = []
v.destroy
end
end
end
render :text => 'repair finish'
end
def index def index
#@tags = @module_app.tags #@tags = @module_app.tags
#@categories = @module_app.categories.enabled #@categories = @module_app.categories.enabled
#@filter_fields = filter_fields(@categories, @tags) #@filter_fields = filter_fields(@categories, @tags)
#@table_fields = [:status, :category, :title, :start_date, :end_date, :last_modified] #@table_fields = [:status, :category, :title, :start_date, :end_date, :last_modified]
@ -20,34 +50,34 @@ class Admin::PatchfilesController < OrbitAdminController
end end
end end
def edit def edit
params["filefield"]["file_show"].each do |name,status| params["filefield"]["file_show"].each do |name,status|
@file_to_show.file_show[name][:status] = status.to_i @file_to_show.file_show[name][:status] = status.to_i
end end
params["filefield"]["sub_file_fields"].each do |name,files| params["filefield"]["sub_file_fields"].each do |name,files|
files.each do |index,file_and_status| files.each do |index,file_and_status|
file_and_status.each do |file_name,status| file_and_status.each do |file_name,status|
@file_to_show["file_show"][name]["files"][file_name]["status"] = status.to_i @file_to_show["file_show"][name]["files"][file_name]["status"] = status.to_i
end end
end end
end end
if params["filefield"]["refresh_btn"] == "true" if params["filefield"]["refresh_btn"] == "true"
@last_message = @file_to_show.last_message @last_message = @file_to_show.last_message
@active_file_arr = @file_to_show.file_show.values.map{|hash| hash.values.first}.map{|hash| hash.keys.zip(hash.values.map{|hash| hash[:status]}).to_h}.select{|hash| hash.values.include?(1)}.flat_map{|hash| hash.values.map.with_index{|status,i| (status != 1) ? nil : i}.select{|index| !index.nil?}.map{|index| hash.keys[index]}} @active_file_arr = @file_to_show.file_show.values.map{|hash| hash.values.first}.map{|hash| hash.keys.zip(hash.values.map{|hash| hash[:status]}).to_h}.select{|hash| hash.values.include?(1)}.flat_map{|hash| hash.values.map.with_index{|status,i| (status != 1) ? nil : i}.select{|index| !index.nil?}.map{|index| hash.keys[index]}}
@file_to_show.destroy @file_to_show.destroy
@file_to_show = Filefield.new() @file_to_show = Filefield.new()
@file_to_show.last_message = @last_message @file_to_show.last_message = @last_message
@active_file_arr.each{|active_file| @file_to_show.file_show.keys.each{|file_group| (@file_to_show.file_show[file_group][:files].keys.include?(active_file)) ? (@file_to_show.file_show[file_group][:files][active_file][:status] = 1) : nil }} @active_file_arr.each{|active_file| @file_to_show.file_show.keys.each{|file_group| (@file_to_show.file_show[file_group][:files].keys.include?(active_file)) ? (@file_to_show.file_show[file_group][:files][active_file][:status] = 1) : nil }}
@file_to_show.save @file_to_show.save
end end
if params["filefield"]["recovery_btn"] == "true" if params["filefield"]["recovery_btn"] == "true"
@file_to_show.recovery = "true" @file_to_show.recovery = "true"
else else
@file_to_show.recovery = "false" @file_to_show.recovery = "false"
end end
@file_to_show.num = 0 @file_to_show.num = 0
@file_to_show.update @file_to_show.update
@file_to_show = Filefield.where("title"=>@app_title).first @file_to_show = Filefield.where("title"=>@app_title).first
redirect_to admin_patchfiles_path and return redirect_to admin_patchfiles_path and return
end end
def showckeditor def showckeditor
end end
@ -56,186 +86,186 @@ class Admin::PatchfilesController < OrbitAdminController
def editfontfile def editfontfile
end end
def update def update
if params[:id] == "editfontfile" if params[:id] == "editfontfile"
@field_name @field_name
params["fontfile"]["font_file"] = "" if params["fontfile"]["font_file"].nil? == true params["fontfile"]["font_file"] = "" if params["fontfile"]["font_file"].nil? == true
params["fontfile"].each do |update_key,update_value| params["fontfile"].each do |update_key,update_value|
if update_key != "font_file" if update_key != "font_file"
@font_settings["old_"+update_key] = @font_settings[update_key] rescue nil @font_settings["old_"+update_key] = @font_settings[update_key] rescue nil
@font_settings[update_key] = update_value @font_settings[update_key] = update_value
else else
@file = params["fontfile"]["font_file"] if params["fontfile"]["font_file"] != "" @file = params["fontfile"]["font_file"] if params["fontfile"]["font_file"] != ""
@file_path = Rails.root.to_s + '/app/assets/fonts' @file_path = Rails.root.to_s + '/app/assets/fonts'
if @file.nil? != true if @file.nil? != true
@file_name = @file.original_filename @file_name = @file.original_filename
@file_content = @file.read @file_content = @file.read
@file_content.force_encoding('UTF-8') @file_content.force_encoding('UTF-8')
Dir.chdir(@file_path) Dir.chdir(@file_path)
@filetowrite @filetowrite
if !File.file?(@file_name) if !File.file?(@file_name)
@filetowrite = File.new(@file_name,"w") @filetowrite = File.new(@file_name,"w")
else else
@filetowrite = File.open(@file_name,"w") @filetowrite = File.open(@file_name,"w")
end end
@filetowrite.write(@file_content) @filetowrite.write(@file_content)
@filetowrite.close @filetowrite.close
Dir.chdir(Rails.root.to_s) Dir.chdir(Rails.root.to_s)
else else
@file_name = @font_settings.font_file_name @file_name = @font_settings.font_file_name
end end
@field_name = {"font_file_name" => @file_name,"font_dir" => @file_path} @field_name = {"font_file_name" => @file_name,"font_dir" => @file_path}
@field_name.each do |name,value| @field_name.each do |name,value|
@font_settings["old_" + name.to_s] = @font_settings[name.to_s] @font_settings["old_" + name.to_s] = @font_settings[name.to_s]
@font_settings[name.to_s] = value.to_s @font_settings[name.to_s] = value.to_s
end end
end end
end end
@font_settings.update @font_settings.update
end end
redirect_to admin_patchfiles_showckeditor_path redirect_to admin_patchfiles_showckeditor_path
end end
def newfont def newfont
if params["patchfilefield"]["initial_btn"] == "true" if params["patchfilefield"]["initial_btn"] == "true"
#render :html => @field.id and return #render :html => @field.id and return
@field_to_copy = Patchfilefield.where("title"=>(@app_title + "_back")).take_while{true}.last @field_to_copy = Patchfilefield.where("title"=>(@app_title + "_back")).take_while{true}.last
@field_to_copy.attributes.each do |copy_field,value| @field_to_copy.attributes.each do |copy_field,value|
if copy_field != "_id" || copy_field != "title" if copy_field != "_id" || copy_field != "title"
@field[copy_field] = value @field[copy_field] = value
end end
end end
@field.update @field.update
@field = Patchfilefield.where("title"=>@app_title).first @field = Patchfilefield.where("title"=>@app_title).first
@field.update @field.update
@field = Patchfilefield.where("title"=>@app_title).first @field = Patchfilefield.where("title"=>@app_title).first
@font_arr = [] @font_arr = []
@field.font_array.each do |font,istrue| @field.font_array.each do |font,istrue|
@font_arr.push font @font_arr.push font
end end
@font_arr.each do |font,istrue| @font_arr.each do |font,istrue|
if (@field_to_copy.font_array.keys.include? font) == false if (@field_to_copy.font_array.keys.include? font) == false
@field.font_array.delete(font) @field.font_array.delete(font)
@field.delete_font = font @field.delete_font = font
@field.update @field.update
@field = Patchfilefield.where("title"=>@app_title).first @field = Patchfilefield.where("title"=>@app_title).first
end end
end end
redirect_to admin_patchfiles_editckeditor_path and return redirect_to admin_patchfiles_editckeditor_path and return
elsif params["patchfilefield"]["delete_btn"] == "true" elsif params["patchfilefield"]["delete_btn"] == "true"
params["patchfilefield"]["font_array"] = {} if params["patchfilefield"]["font_array"].nil? == true params["patchfilefield"]["font_array"] = {} if params["patchfilefield"]["font_array"].nil? == true
params["patchfilefield"]["font_array"].each do |font,istrue| params["patchfilefield"]["font_array"].each do |font,istrue|
if istrue =="1" if istrue =="1"
@field.font_array.delete(font) @field.font_array.delete(font)
@field.delete_font = font @field.delete_font = font
@field.update @field.update
@field = Patchfilefield.where("title"=>@app_title).first @field = Patchfilefield.where("title"=>@app_title).first
end end
end end
redirect_to admin_patchfiles_editckeditor_path and return redirect_to admin_patchfiles_editckeditor_path and return
else else
params["patchfilefield"]["new_add_font"] = params["patchfilefield"]["new_add_font"].gsub('\"','').gsub("\'",'').gsub(";",'').gsub('\\','') params["patchfilefield"]["new_add_font"] = params["patchfilefield"]["new_add_font"].gsub('\"','').gsub("\'",'').gsub(";",'').gsub('\\','')
@field.new_add_font = params["patchfilefield"]["new_add_font"] rescue (redirect_to admin_patchfiles_showckeditor_path and return) @field.new_add_font = params["patchfilefield"]["new_add_font"] rescue (redirect_to admin_patchfiles_showckeditor_path and return)
@key_arr = @field.font_array.keys @key_arr = @field.font_array.keys
params["patchfilefield"]["font_array"] = {} if params["patchfilefield"]["font_array"].nil? == true params["patchfilefield"]["font_array"] = {} if params["patchfilefield"]["font_array"].nil? == true
params["patchfilefield"]["font_array"].each do |font,istrue| params["patchfilefield"]["font_array"].each do |font,istrue|
if istrue =="0" if istrue =="0"
@field.font_array[font] = false @field.font_array[font] = false
elsif istrue =="1" elsif istrue =="1"
@field.font_array[font] = true @field.font_array[font] = true
end end
end end
@field.update @field.update
redirect_to admin_patchfiles_showckeditor_path and return redirect_to admin_patchfiles_showckeditor_path and return
end end
end end
def getfont def getfont
@font_array = [] @font_array = []
@ckeditor_path = ENV['PWD'] + '/app/assets/javascripts/ckeditor' @ckeditor_path = ENV['PWD'] + '/app/assets/javascripts/ckeditor'
@filedata = File.read(@ckeditor_path+"/config.js.erb") rescue return @filedata = File.read(@ckeditor_path+"/config.js.erb") rescue return
@name_to_search ="config.font_names" @name_to_search ="config.font_names"
@index_of_font = @filedata.index(@name_to_search) @index_of_font = @filedata.index(@name_to_search)
@font_str = "" @font_str = ""
@end_character @end_character
@str_start @str_start
@str_end @str_end
if @index_of_font != nil if @index_of_font != nil
@inex_start_to_search = @index_of_font + @name_to_search.length @inex_start_to_search = @index_of_font + @name_to_search.length
@str_start = @inex_start_to_search @str_start = @inex_start_to_search
if (@filedata[@inex_start_to_search] != "\'" && @filedata[@inex_start_to_search] != "\"") if (@filedata[@inex_start_to_search] != "\'" && @filedata[@inex_start_to_search] != "\"")
for @str_start in @inex_start_to_search..@filedata.length for @str_start in @inex_start_to_search..@filedata.length
break if (@filedata[@str_start] == "\'" || @filedata[@str_start] == "\"") break if (@filedata[@str_start] == "\'" || @filedata[@str_start] == "\"")
end end
end end
@end_character = @filedata[@str_start] @end_character = @filedata[@str_start]
@str_end = @str_start+1 @str_end = @str_start+1
if @str_start+1 < @filedata.length if @str_start+1 < @filedata.length
@str_end = @str_start+1 @str_end = @str_start+1
for @str_end in @str_start+1..@filedata.length for @str_end in @str_start+1..@filedata.length
break if @filedata[@str_end] == @end_character || @str_end == @str_start break if @filedata[@str_end] == @end_character || @str_end == @str_start
if @filedata[@str_end] == "=" if @filedata[@str_end] == "="
@str_end = @str_start @str_end = @str_start
break break
end end
end end
if @str_end != @str_start if @str_end != @str_start
@font_str = @filedata[@str_start+1...@str_end] @font_str = @filedata[@str_start+1...@str_end]
else else
@font_str = "" @font_str = ""
end end
end end
@font_array = @font_str.split("\;") @font_array = @font_str.split("\;")
@font_array.map!{|i| i.strip} @font_array.map!{|i| i.strip}
@font_array.delete("") @font_array.delete("")
end end
end
def create_first_field
@app_title = "patchfile"
if Patchfilefield.where("title"=>(@app_title + "_back")).take_while{true}.count == 0
@field = Patchfilefield.new()
@field.title = @app_title +"_back"
@field.save
end
@field
if Patchfilefield.where("title"=>@app_title).take_while{true}.count == 0
@field = Patchfilefield.new()
@field.title=@app_title
@field.save
@field = Patchfilefield.where("title"=>@app_title).first
else
@field = Patchfilefield.where("title"=>@app_title).first
end
if params[:font] != nil
if Fontfile.where("title"=>params[:font]).first.nil? == true
@font_settings = Fontfile.new
@font_settings.title = params[:font]
@font_settings.save
end
@font_settings = Fontfile.where("title"=>params[:font]).first
end
if Filefield.where("title"=>@app_title).take_while{true}.count == 0
@file_to_show = Filefield.new()
@file_to_show.title=@app_title
@file_to_show.save
@file_to_show = Filefield.where("title"=>@app_title).first
else
@default_field = Filefield.new()
@file_to_show = Filefield.where("title"=>@app_title).first
@default_field.file_show.each do |name,property|
if @file_to_show.file_show[name] == nil
@file_to_show.file_show[name] = property
@file_to_show.save
@file_to_show = Filefield.where("title"=>@app_title).first
end
end
@default_field.file_show.each do |name,property|
property[:files].each do |file_name,sub_property|
if @file_to_show.file_show[name][:files][file_name] == nil
@file_to_show.file_show[name][:files][file_name] = sub_property
@file_to_show.save
@file_to_show = Filefield.where("title"=>@app_title).first
end
end
end
end
end end
def create_first_field
@app_title = "patchfile"
if Patchfilefield.where("title"=>(@app_title + "_back")).take_while{true}.count == 0
@field = Patchfilefield.new()
@field.title = @app_title +"_back"
@field.save
end
@field
if Patchfilefield.where("title"=>@app_title).take_while{true}.count == 0
@field = Patchfilefield.new()
@field.title=@app_title
@field.save
@field = Patchfilefield.where("title"=>@app_title).first
else
@field = Patchfilefield.where("title"=>@app_title).first
end
if params[:font] != nil
if Fontfile.where("title"=>params[:font]).first.nil? == true
@font_settings = Fontfile.new
@font_settings.title = params[:font]
@font_settings.save
end
@font_settings = Fontfile.where("title"=>params[:font]).first
end
if Filefield.where("title"=>@app_title).take_while{true}.count == 0
@file_to_show = Filefield.new()
@file_to_show.title=@app_title
@file_to_show.save
@file_to_show = Filefield.where("title"=>@app_title).first
else
@default_field = Filefield.new()
@file_to_show = Filefield.where("title"=>@app_title).first
@default_field.file_show.each do |name,property|
if @file_to_show.file_show[name] == nil
@file_to_show.file_show[name] = property
@file_to_show.save
@file_to_show = Filefield.where("title"=>@app_title).first
end
end
@default_field.file_show.each do |name,property|
property[:files].each do |file_name,sub_property|
if @file_to_show.file_show[name][:files][file_name] == nil
@file_to_show.file_show[name][:files][file_name] = sub_property
@file_to_show.save
@file_to_show = Filefield.where("title"=>@app_title).first
end
end
end
end
end
end end

View File

@ -55,226 +55,234 @@
<link rel="stylesheet" href="/assets/lib/jquery-ui-1.12.1/jquery-ui.min.css"> <link rel="stylesheet" href="/assets/lib/jquery-ui-1.12.1/jquery-ui.min.css">
<div style="clear:both;"></div> <div style="clear:both;"></div>
<% @i = 0 %> <% @i = 0 %>
<button id="repair_module"><%= (I18n.locale.to_s == "zh_tw") ? "修復模組在admin/item重複出現問題" : "repair module multiple existed in admin/item page" %></button>
<br>
<button id="clickall"><%= (I18n.locale.to_s == "zh_tw") ? "全選" : "select all" %></button> <button id="clickall"><%= (I18n.locale.to_s == "zh_tw") ? "全選" : "select all" %></button>
<button id="unclickall"><%= (I18n.locale.to_s == "zh_tw") ? "取消全選" : "unselect all" %></button> <button id="unclickall"><%= (I18n.locale.to_s == "zh_tw") ? "取消全選" : "unselect all" %></button>
<%=form_for @file_to_show ,:url=>{:controller=>"patchfiles" ,:action=>"edit"} do |file|%> <%=form_for @file_to_show ,:url=>{:controller=>"patchfiles" ,:action=>"edit"} do |file|%>
<%= file.fields_for :file_show do |filefield|%> <%= file.fields_for :file_show do |filefield|%>
<div id="fileform"> <div id="fileform">
<% @file_to_show.file_show.each do |name,property| %> <% @file_to_show.file_show.each do |name,property| %>
<span style="clear:both;"> <span style="clear:both;">
<%if property[:status].to_i == 1%> <%if property[:status].to_i == 1%>
<%=filefield.check_box name,{:checked=>true,:id=>"checkbox"+@i.to_s,:class=>"checkbox",:style=>"float:left;"}%> <%=filefield.check_box name,{:checked=>true,:id=>"checkbox"+@i.to_s,:class=>"checkbox",:style=>"float:left;"}%>
<%else%> <%else%>
<%=filefield.check_box name,{:checked=>false,:id=>"checkbox"+@i.to_s,:class=>"checkbox",:style=>"float:left;"}%> <%=filefield.check_box name,{:checked=>false,:id=>"checkbox"+@i.to_s,:class=>"checkbox",:style=>"float:left;"}%>
<%end%> <%end%>
<label for="<%="checkbox"+@i.to_s%>" class="checklabel" style="float:left;"><%=name%></label> <label for="<%="checkbox"+@i.to_s%>" class="checklabel" style="float:left;"><%=name%></label>
<div style="clear:both;"></div> <div style="clear:both;"></div>
<% @i = @i+1 %> <% @i = @i+1 %>
<% @j = 0 %> <% @j = 0 %>
<%= file.fields_for :sub_file_fields do |each_files|%> <%= file.fields_for :sub_file_fields do |each_files|%>
<%= each_files.fields_for name do |each_file|%> <%= each_files.fields_for name do |each_file|%>
<% property[:files].each do |file_name,sub_property| %> <% property[:files].each do |file_name,sub_property| %>
<%if sub_property[:status].to_i == 1%> <%if sub_property[:status].to_i == 1%>
<%=each_file.check_box file_name,{:checked=>true,:id=>"checkbox"+@i.to_s,:class=>"sub_checkbox",:style=>"float:left;margin-left:1em;",:index=>@j}%> <%=each_file.check_box file_name,{:checked=>true,:id=>"checkbox"+@i.to_s,:class=>"sub_checkbox",:style=>"float:left;margin-left:1em;",:index=>@j}%>
<%else%> <%else%>
<%=each_file.check_box file_name,{:checked=>false,:id=>"checkbox"+@i.to_s,:class=>"sub_checkbox",:style=>"float:left;margin-left:1em;",:index=>@j}%> <%=each_file.check_box file_name,{:checked=>false,:id=>"checkbox"+@i.to_s,:class=>"sub_checkbox",:style=>"float:left;margin-left:1em;",:index=>@j}%>
<%end%> <%end%>
<% file_name = file_name.gsub("@",".") %> <% file_name = file_name.gsub("@",".") %>
<label for="<%="checkbox"+@i.to_s%>" class="sub_checklabel" style="float:left;"><%=file_name%></label> <label for="<%="checkbox"+@i.to_s%>" class="sub_checklabel" style="float:left;"><%=file_name%></label>
<div style="clear:both;"></div> <div style="clear:both;"></div>
<% @i = @i+1 %> <% @i = @i+1 %>
<% @j = @j+1 %> <% @j = @j+1 %>
<% end %> <% end %>
<%end%> <%end%>
<%end%> <%end%>
</span> </span>
<%end%> <%end%>
</div> </div>
<%end%> <%end%>
<%=file.submit "#{t(:updatefont)}",{:id=>"updatebtn",:onclick=>"return updatefcn()"}%> <%=file.submit "#{t(:updatefont)}",{:id=>"updatebtn",:onclick=>"return updatefcn()"}%>
<%=file.text_field :recovery_btn, {:id=>"hidden-recovery",:type => "hidden",:value=>"false"} %> <%=file.text_field :recovery_btn, {:id=>"hidden-recovery",:type => "hidden",:value=>"false"} %>
<%=file.text_field :refresh_btn, {:id=>"hidden-refresh",:type => "hidden",:value=>"false"} %> <%=file.text_field :refresh_btn, {:id=>"hidden-refresh",:type => "hidden",:value=>"false"} %>
<button id="seemessage" onclick="return seelogfcn()"><%=(I18n.locale.to_s =="zh_tw") ? "查看上次更新的logs" : "see logs of prev update "%></button> <button id="seemessage" onclick="return seelogfcn()"><%=(I18n.locale.to_s =="zh_tw") ? "查看上次更新的logs" : "see logs of prev update "%></button>
<button id="recoverybtn" onclick="return recoveryfcn()"><%=(I18n.locale.to_s =="zh_tw") ? "復原到上次更新的檔案狀態" : "recovery to prev file status"%></button> <button id="recoverybtn" onclick="return recoveryfcn()"><%=(I18n.locale.to_s =="zh_tw") ? "復原到上次更新的檔案狀態" : "recovery to prev file status"%></button>
<button id="destroy_mongofield" onclick="return destroy_mongofield_fcn()"><%=(I18n.locale.to_s =="zh_tw") ? "刷新可更新的檔案狀態" : "refresh the status of the update files"%></button> <button id="destroy_mongofield" onclick="return destroy_mongofield_fcn()"><%=(I18n.locale.to_s =="zh_tw") ? "刷新可更新的檔案狀態" : "refresh the status of the update files"%></button>
<%end%> <%end%>
<a>網站目錄根路徑:<%=Dir.pwd.to_s%></a> <a>網站目錄根路徑:<%=Dir.pwd.to_s%></a>
<li id ="ckeditorFont" class="show_li"> <li id ="ckeditorFont" class="show_li">
<a title="CKEDITOR現有字形">CKEDITOR現有字形</a> <a title="CKEDITOR現有字形">CKEDITOR現有字形</a>
<% @ckicktosee_str = (I18n.locale.to_s == "en") ? "click me to see all font which CKEDITOR have now" : "點擊我來查看編輯器所有目前擁有的字形" %> <% @ckicktosee_str = (I18n.locale.to_s == "en") ? "click me to see all font which CKEDITOR have now" : "點擊我來查看編輯器所有目前擁有的字形" %>
<a id="clicktosee" title="<%= @ckicktosee_str %>" class="Toggleclass"><%= @ckicktosee_str %></a> <a id="clicktosee" title="<%= @ckicktosee_str %>" class="Toggleclass"><%= @ckicktosee_str %></a>
<ul> <ul>
<% @font_array.each do |font|%> <% @font_array.each do |font|%>
<li><a title="<%= font %>"><%= font %></a></li> <li><a title="<%= font %>"><%= font %></a></li>
<%end%> <%end%>
</ul> </ul>
</li> </li>
<a></a> <a></a>
<style type="text/css"> <style type="text/css">
.show_li,.show_li *{ .show_li,.show_li *{
list-style:none; list-style:none;
color:balck; color:balck;
} }
.show_li ul{ .show_li ul{
display:none; display:none;
} }
#clicktosee{ #clicktosee{
color:blue; color:blue;
cursor:pointer; cursor:pointer;
} }
</style> </style>
<script> <script>
$('.Toggleclass').off("click").on("click",function(){ $("#repair_module").click(function(){
$(this).parent().find(">ul").slideToggle(); alert("repairing")
}); $.get('/admin/patchfiles/repair_module',{},function(data){
$('.checkbox').off('click').on('click',function(){ alert(data)
for(var i = 0;i<$(this).parent().find('.sub_checkbox').length;i++){ })
if($(this).is(":checked") == false){ })
if($(this).parent().find('.sub_checkbox').eq(i).is(":checked") == true) $('.Toggleclass').off("click").on("click",function(){
$(this).parent().find('.sub_checkbox').eq(i).click(); $(this).parent().find(">ul").slideToggle();
}else{ });
if($(this).parent().find('.sub_checkbox').eq(i).is(":checked") == false) $('.checkbox').off('click').on('click',function(){
$(this).parent().find('.sub_checkbox').eq(i).click(); for(var i = 0;i<$(this).parent().find('.sub_checkbox').length;i++){
}; if($(this).is(":checked") == false){
}; if($(this).parent().find('.sub_checkbox').eq(i).is(":checked") == true)
}); $(this).parent().find('.sub_checkbox').eq(i).click();
$('.sub_checkbox').off('click').on('click',function(){ }else{
var num = 0; if($(this).parent().find('.sub_checkbox').eq(i).is(":checked") == false)
var index = 0; $(this).parent().find('.sub_checkbox').eq(i).click();
for(var i = 0;i<$(this).parent().find('.sub_checkbox').length;i++){ };
if($(this).parent().find('.sub_checkbox').eq(i).is(":checked") == true){ };
num += 1; });
}; $('.sub_checkbox').off('click').on('click',function(){
}; var num = 0;
if( num == $(this).parent().find('.sub_checkbox').length){ var index = 0;
if( $(this).parent().find('.checkbox').is(":checked") == false) for(var i = 0;i<$(this).parent().find('.sub_checkbox').length;i++){
$(this).parent().find('.checkbox').click(); if($(this).parent().find('.sub_checkbox').eq(i).is(":checked") == true){
}else{ num += 1;
if( $(this).parent().find('.checkbox').is(":checked") == true){ };
$(this).parent().find('.checkbox').click(); };
for(var i = 0;i<$(this).parent().find('.sub_checkbox').length;i++){ if( num == $(this).parent().find('.sub_checkbox').length){
if($(this).parent().find('.sub_checkbox').eq(i).attr('id') != $(this).attr('id')) if( $(this).parent().find('.checkbox').is(":checked") == false)
$(this).parent().find('.sub_checkbox').eq(i).click(); $(this).parent().find('.checkbox').click();
} }else{
}; if( $(this).parent().find('.checkbox').is(":checked") == true){
} $(this).parent().find('.checkbox').click();
}); for(var i = 0;i<$(this).parent().find('.sub_checkbox').length;i++){
$("#clickall").off("click").on("click",function(){ if($(this).parent().find('.sub_checkbox').eq(i).attr('id') != $(this).attr('id'))
for(var i =0;i<$(".sub_checkbox").length ; i++){ $(this).parent().find('.sub_checkbox').eq(i).click();
if($(".checkbox").eq(i).is(":checked") == false) }
$(".checkbox").eq(i).click(); };
} }
}); });
$("#unclickall").off("click").on("click",function(){ $("#clickall").off("click").on("click",function(){
for(var i =0;i<$(".sub_checkbox").length ; i++){ for(var i =0;i<$(".sub_checkbox").length ; i++){
if($(".checkbox").eq(i).is(":checked") == true) if($(".checkbox").eq(i).is(":checked") == false)
$(".checkbox").eq(i).click(); $(".checkbox").eq(i).click();
} }
}); });
function seelogfcn(){ $("#unclickall").off("click").on("click",function(){
if($( "#dialog-confirm" ).length != 0) for(var i =0;i<$(".sub_checkbox").length ; i++){
$( "#dialog-confirm" ).remove(); if($(".checkbox").eq(i).is(":checked") == true)
if(I18n.locale == "zh_tw"){ $(".checkbox").eq(i).click();
$('body').after("<div id='dialog-confirm' title='上次更新的logs'></div>"); }
}else{ });
$('body').after("<div id='dialog-confirm' title='logs of prev update'></div>"); function seelogfcn(){
}; if($( "#dialog-confirm" ).length != 0)
$( "#dialog-confirm" ).append($.parseHTML("<%= @file_to_show.last_message.gsub("\"","\'").html_safe %>")); $( "#dialog-confirm" ).remove();
$( "#dialog-confirm" ).dialog({ if(I18n.locale == "zh_tw"){
resizable: true, $('body').after("<div id='dialog-confirm' title='上次更新的logs'></div>");
height:200, }else{
modal: true, $('body').after("<div id='dialog-confirm' title='logs of prev update'></div>");
buttons: { };
<%=(I18n.locale == "zh_tw") ? "確認" : "confirm"%>: function(){ $( "#dialog-confirm" ).append($.parseHTML("<%= @file_to_show.last_message.gsub("\"","\'").html_safe %>"));
$( this ).dialog( "close" ); $( "#dialog-confirm" ).dialog({
}, resizable: true,
<%=(I18n.locale == "zh_tw") ? "取消" : "Cancel"%>: function() { height:200,
$( this ).dialog( "close" ); modal: true,
} buttons: {
} <%=(I18n.locale == "zh_tw") ? "確認" : "confirm"%>: function(){
}); $( this ).dialog( "close" );
return false; },
}; <%=(I18n.locale == "zh_tw") ? "取消" : "Cancel"%>: function() {
function updatefcn(){ $( this ).dialog( "close" );
var str=""; }
var num =1; }
for(var i =0;i<$(".sub_checkbox").length ; i++){ });
if($(".sub_checkbox").eq(i).is(":checked") == true){ return false;
str += ("</br><i style='color:red;'>"+num+". "+$(".sub_checklabel").eq(i).html()+"</i>"); };
num += 1; function updatefcn(){
} var str="";
} var num =1;
if($( "#dialog-confirm" ).length != 0) for(var i =0;i<$(".sub_checkbox").length ; i++){
$( "#dialog-confirm" ).remove(); if($(".sub_checkbox").eq(i).is(":checked") == true){
if(I18n.locale == "zh_tw"){ str += ("</br><i style='color:red;'>"+num+". "+$(".sub_checklabel").eq(i).html()+"</i>");
$('body').after("<div id='dialog-confirm' title='你確定要更新嗎?'>"+ num += 1;
"<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 0 0;'></span>"+ }
"按下確認鍵後,你將更新你所選的檔案。"+str+"</p>" }
+"</div>"); if($( "#dialog-confirm" ).length != 0)
}else{ $( "#dialog-confirm" ).remove();
$('body').after("<div id='dialog-confirm' title='Are you sure to update'>"+ if(I18n.locale == "zh_tw"){
"<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 0 0;'></span>"+ $('body').after("<div id='dialog-confirm' title='你確定要更新嗎?'>"+
"After click confirm button,you will update the selected file."+str+"</p>" "<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 0 0;'></span>"+
+"</div>"); "按下確認鍵後,你將更新你所選的檔案。"+str+"</p>"
}; +"</div>");
$( "#dialog-confirm" ).dialog({ }else{
resizable: true, $('body').after("<div id='dialog-confirm' title='Are you sure to update'>"+
height:200, "<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 0 0;'></span>"+
modal: true, "After click confirm button,you will update the selected file."+str+"</p>"
buttons: { +"</div>");
<%=(I18n.locale == "zh_tw") ? "確認" : "confirm"%>: function(){ };
$( this ).dialog( "close" ); $( "#dialog-confirm" ).dialog({
$('.edit_filefield').submit(); resizable: true,
}, height:200,
<%=(I18n.locale == "zh_tw") ? "取消" : "Cancel"%>: function() { modal: true,
$( this ).dialog( "close" ); buttons: {
} <%=(I18n.locale == "zh_tw") ? "確認" : "confirm"%>: function(){
} $( this ).dialog( "close" );
}); $('.edit_filefield').submit();
return false; },
}; <%=(I18n.locale == "zh_tw") ? "取消" : "Cancel"%>: function() {
function recoveryfcn(){ $( this ).dialog( "close" );
var str=""; }
var num =1; }
for(var i =0;i<$(".sub_checkbox").length ; i++){ });
if($(".sub_checkbox").eq(i).is(":checked") == true){ return false;
str += ("</br><i style='color:red;'>"+num+". "+$(".sub_checklabel").eq(i).html()+"</i>"); };
num += 1; function recoveryfcn(){
} var str="";
} var num =1;
if($( "#dialog-confirm" ).length != 0) for(var i =0;i<$(".sub_checkbox").length ; i++){
$( "#dialog-confirm" ).remove(); if($(".sub_checkbox").eq(i).is(":checked") == true){
if(I18n.locale == "zh_tw"){ str += ("</br><i style='color:red;'>"+num+". "+$(".sub_checklabel").eq(i).html()+"</i>");
$('body').after("<div id='dialog-confirm' title='你確定要還原嗎?'>"+ num += 1;
"<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 0 0;'></span>"+ }
"按下確認鍵後,你將還原你所選的檔案。"+str+"</p>" }
+"</div>"); if($( "#dialog-confirm" ).length != 0)
}else{ $( "#dialog-confirm" ).remove();
$('body').after("<div id='dialog-confirm' title='Are you sure to recover'>"+ if(I18n.locale == "zh_tw"){
"<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 0 0;'></span>"+ $('body').after("<div id='dialog-confirm' title='你確定要還原嗎?'>"+
"After click confirm button,you will recover the selected file."+str+"</p>" "<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 0 0;'></span>"+
+"</div>"); "按下確認鍵後,你將還原你所選的檔案。"+str+"</p>"
} +"</div>");
$( "#dialog-confirm" ).dialog({ }else{
resizable: true, $('body').after("<div id='dialog-confirm' title='Are you sure to recover'>"+
height:200, "<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 0 0;'></span>"+
modal: true, "After click confirm button,you will recover the selected file."+str+"</p>"
buttons: { +"</div>");
<%=(I18n.locale == "zh_tw") ? "確認" : "confirm"%>: function(){ }
$('#hidden-recovery').val("true"); $( "#dialog-confirm" ).dialog({
$( this ).dialog( "close" ); resizable: true,
$('.edit_filefield').submit(); height:200,
}, modal: true,
<%=(I18n.locale == "zh_tw") ? "取消" : "Cancel"%>: function() { buttons: {
$('#hidden-recovery').val("false"); <%=(I18n.locale == "zh_tw") ? "確認" : "confirm"%>: function(){
$( this ).dialog( "close" ); $('#hidden-recovery').val("true");
} $( this ).dialog( "close" );
} $('.edit_filefield').submit();
}); },
return false; <%=(I18n.locale == "zh_tw") ? "取消" : "Cancel"%>: function() {
}; $('#hidden-recovery').val("false");
function destroy_mongofield_fcn(){ $( this ).dialog( "close" );
$('#hidden-refresh').val('true'); }
}; }
});
return false;
};
function destroy_mongofield_fcn(){
$('#hidden-refresh').val('true');
};
</script> </script>

View File

@ -4,18 +4,18 @@ Rails.application.routes.draw do
scope "(:locale)", locale: Regexp.new(locales.join("|")) do scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do namespace :admin do
get 'patchfiles' , to: 'patchfiles#index' get 'patchfiles' , to: 'patchfiles#index'
get 'patchfiles/showckeditor' , to: 'patchfiles#showckeditor' get 'patchfiles/repair_module' , to: 'patchfiles#repair_module'
get 'patchfiles/editckeditor' , to: 'patchfiles#editckeditor' get 'patchfiles/showckeditor' , to: 'patchfiles#showckeditor'
get 'patchfiles/editfontfile' , to: 'patchfiles#editfontfile' get 'patchfiles/editckeditor' , to: 'patchfiles#editckeditor'
post 'patchfiles/newfont' , to: 'patchfiles#newfont' get 'patchfiles/editfontfile' , to: 'patchfiles#editfontfile'
get 'patchfiles/newfont' , to: 'patchfiles#newfont' post 'patchfiles/newfont' , to: 'patchfiles#newfont'
patch 'patchfiles/newfont' , to: 'patchfiles#newfont' get 'patchfiles/newfont' , to: 'patchfiles#newfont'
post 'patchfiles/edit' , to: 'patchfiles#edit' patch 'patchfiles/newfont' , to: 'patchfiles#newfont'
get 'patchfiles/edit' , to: 'patchfiles#edit' post 'patchfiles/edit' , to: 'patchfiles#edit'
patch 'patchfiles/edit' , to: 'patchfiles#edit' get 'patchfiles/edit' , to: 'patchfiles#edit'
patch 'patchfiles/edit' , to: 'patchfiles#edit'
resources :patchfiles resources :patchfiles
end end
end end