简要姿势点
1.Controller::Action 写
respond_to do |format|
format.js
format.html
format.xls
end
Rails会对应去render
controller_name/action_name.js.erb
controller_name/action_name.html.erb
controller_name/action_name.xls.eku
2.在xxx.js.erb render yyy.html.erb
$("#captcha_layer").html("<%=escape_javascript(render file: 'home/captcha_pop_up.html.erb')%>");
3.jQuery Ajax dataType: 'script'
ref: http://www.w3cschool.cn/ajax_ajax.html
$.ajax({
url: '/get_captcha_pop_up',
data: {form_id : 'user_design_form', is_on_submit : true},
dataType: 'script',
type: 'get'
});
贴一下代码
app/assets/javascripts/main.js
... | ... | @@ -1225,6 +1225,13 @@ $(function(){ |
1225 | 1225 | // alert('请选择分类') |
1226 | 1226 | // return false; |
1227 | 1227 | // }; |
1228 | + $.ajax({ | |
1229 | + url: '/get_captcha_pop_up', | |
1230 | + data: {form_id : 'famous_ask_form'}, | |
1231 | + dataType: 'script', | |
1232 | + type: 'get' | |
1233 | + }); | |
1234 | + return false; | |
1228 | 1235 | }) |
1229 | 1236 | }($)); |
1230 | 1237 | }); |
1231 | 1238 | \ No newline at end of file |
... | ... |
app/assets/stylesheets/home_manage.css
... | ... | @@ -18,4 +18,35 @@ |
18 | 18 | .colorbox_ul { |
19 | 19 | width: 528px; |
20 | 20 | height: 35px; |
21 | -} | |
22 | 21 | \ No newline at end of file |
22 | +} | |
23 | + | |
24 | +#layer { | |
25 | + position: fixed; | |
26 | + width: 100%; | |
27 | + height: 100%; | |
28 | + left: 0; | |
29 | + top: 0; | |
30 | + background: #000; | |
31 | + opacity: 0.5; | |
32 | + filter: alpha(opacity=50); | |
33 | + z-index: 10; | |
34 | +} | |
35 | +.introNew_pop{ width:400px; border-radius:6px; background:#fff; position:fixed; height:310px; top:50%; left:50%; margin:-154px 0 0 -140px; z-index:12; display:none; background-image:url(/assets/captcha_layer/bg.png)} | |
36 | +.introNew_pop_con{ margin:0px; float:left; display:inline-block; width:400px; } | |
37 | + | |
38 | +.introNew_pop_con h2{ margin-left:30px; line-height:10px;} | |
39 | +.news_info{ margin-left:40px; margin-top:2px;width:100%; text-align:left; float:left; padding:2px 0; color:#898989; } | |
40 | +.news_info input{border: 1px solid; border-color: #CCC #EEE #EEE #CCC; | |
41 | +color: #000; background: #fff; | |
42 | +width: 304px; height:40px;} | |
43 | +.news_info em{ font-style:normal; padding-right:15px; color:#b2b2b2; } | |
44 | +.news_info em.red{ color:#f47389; } | |
45 | + | |
46 | +.newsInfo_con{ margin-left:40px;padding-bottom:10px; width:100%; } | |
47 | +.newsInfo_scroll{ width:100%; height:310px; overflow:auto; margin:40px 0 0 0; display:inline-block; } | |
48 | +.newsInfo_scroll p{ text-align:left; line-height:20px; padding:10px 0; width:98%; font-size:14px; line-height:22px; color:#6f6f6f; } | |
49 | +.newspop_close{ width:70px; height:60px; display:inline-block; background:#f47389; line-height:60px; color:#fff; font-size:30px; text-align:center; margin:40px 0 0 0; } | |
50 | +.button{ margin-left:40px;padding-bottom:30px; width:100%; } | |
51 | +.goback{ color:#0c90b1; font-size:12px; line-height:35px;} | |
52 | +.closeicon{margin-top:17px; height:22px;width:22px;cursor:pointer; margin-left:362px; } | |
53 | +.textinput{font-size:12px; margin-top:10px; line-height:29px;} | |
23 | 54 | \ No newline at end of file |
... | ... |
app/controllers/designs_controller.rb
... | ... | @@ -148,6 +148,10 @@ class DesignsController < ApplicationController |
148 | 148 | flash[:design_errors] = [] |
149 | 149 | flag = true |
150 | 150 | @design = current_user.designs.build(params[:design]) |
151 | + unless simple_captcha_valid? | |
152 | + flash[:design_errors] << "验证码错误" | |
153 | + flag = false | |
154 | + end | |
151 | 155 | if params[:story_id].present? |
152 | 156 | @design.story_id = params[:story_id] |
153 | 157 | @design.baicheng_active = true |
... | ... |
app/controllers/dialog_celebrity/celebrity_questions_controller.rb
... | ... | @@ -15,6 +15,10 @@ class DialogCelebrity::CelebrityQuestionsController < ApplicationController |
15 | 15 | |
16 | 16 | def create |
17 | 17 | question = CelebrityQuestion.new params[:celebrity_question] |
18 | + unless simple_captcha_valid? | |
19 | + flash[:notice] = "验证码错误" | |
20 | + redirect_to new_dialog_celebrity_celebrity_question_path and return | |
21 | + end | |
18 | 22 | question.keyword = "" |
19 | 23 | unless question.save |
20 | 24 | flash[:notice] = "描述文字不少于6个字" |
... | ... |
app/controllers/home_controller.rb
... | ... | @@ -227,4 +227,12 @@ class HomeController < ApplicationController |
227 | 227 | def get_user_sign_status |
228 | 228 | render :json => { code: current_user.present? ? 1 : 0, content: render_to_string(partial: "layouts/navbar-fixed-top") } |
229 | 229 | end |
230 | + | |
231 | + def get_captcha_pop_up | |
232 | + @form_id = params[:form_id] | |
233 | + @is_on_submit = params[:is_on_submit] | |
234 | + respond_to do |format| | |
235 | + format.js | |
236 | + end | |
237 | + end | |
230 | 238 | end |
231 | 239 | \ No newline at end of file |
... | ... |
app/views/designs/new.html.erb
... | ... | @@ -65,7 +65,17 @@ |
65 | 65 | alert(falg) |
66 | 66 | return false |
67 | 67 | }else{ |
68 | - return true | |
68 | + if ('true'==$('#user_design_form_commit_flag').val() ) { | |
69 | + return true; | |
70 | + }else{ | |
71 | + $.ajax({ | |
72 | + url: '/get_captcha_pop_up', | |
73 | + data: {form_id : 'user_design_form', is_on_submit : true}, | |
74 | + dataType: 'script', | |
75 | + type: 'get' | |
76 | + }); | |
77 | + return false | |
78 | + }; | |
69 | 79 | } |
70 | 80 | |
71 | 81 | }) |
... | ... | @@ -110,7 +120,9 @@ |
110 | 120 | |
111 | 121 | <div class="tab-content upload_content"> |
112 | 122 | <div class="tab-pane active" id="upload_tab1"> |
113 | - <%= form_for([current_user, @design], html: {:class=>"form-horizontal index_main noborder nopadding nomargin js-commit"}) do |f| %> | |
123 | + <%= form_for([current_user, @design], html: {:id=>'user_design_form', :class=>"form-horizontal index_main noborder nopadding nomargin js-commit"}) do |f| %> | |
124 | + <input id="user_design_form_captcha" name="captcha" type="hidden"> | |
125 | + <input id="user_design_form_commit_flag" value="false" type="hidden"> | |
114 | 126 | <%= hidden_field_tag "story_id", params[:story_id] %> |
115 | 127 | <fieldset class="text-center"> |
116 | 128 | <label class="radio inline"> |
... | ... |
app/views/dialog_celebrity/celebrity_questions/new.html.erb
... | ... | @@ -167,7 +167,8 @@ |
167 | 167 | |
168 | 168 | <div class="tab-content famous_ask_content"> |
169 | 169 | <div class="tab-pane active" id="famous_tab1"> |
170 | - <form action="<%=dialog_celebrity_celebrity_questions_path%>" method="post" class="famous_ask_form nomargin pt15 pb25"> | |
170 | + <form id="famous_ask_form" action="<%=dialog_celebrity_celebrity_questions_path%>" method="post" class="famous_ask_form nomargin pt15 pb25"> | |
171 | + <input id="famous_ask_form_captcha" name="captcha" type="hidden"> | |
171 | 172 | <% if current_user.present? -%> |
172 | 173 | <input type="hidden" name="celebrity_question[user_id]" value="<%= current_user.id %>"> |
173 | 174 | <%else -%> |
... | ... |
app/views/home/captcha_pop_up.html.erb
... | ... | @@ -0,0 +1,20 @@ |
1 | +<div class="introNew_pop" style="display: block;"> | |
2 | + <div class="introNew_pop_con"> | |
3 | + <div class="closeicon"><a href="#"></a></div> | |
4 | + <h2></h2> | |
5 | + <div class="news_info"> | |
6 | + <br /> | |
7 | + <span class="textinput">按下图中的字符填写,不区分大小写。</span> | |
8 | + </div> | |
9 | + <div class="newsInfo_con"> | |
10 | + <%= show_simple_captcha %> | |
11 | + <span id="lab_captcha" class="label label-important hide vadil">请输入验证码</span> | |
12 | + </div> | |
13 | + <div class="button"> | |
14 | + <a href="#"> | |
15 | + <span style="margin-left:9px;"><img id="quit_captcha_layer" src="<%= asset_path "captcha_layer/button2.png" %>" /></span> | |
16 | + <span style="float:left; "><img id="submit_captcha_layer" src="<%= asset_path "captcha_layer/button1.png" %>" /></span> | |
17 | + </a> | |
18 | + </div> | |
19 | + </div> | |
20 | +</div> | |
0 | 21 | \ No newline at end of file |
... | ... |
app/views/home/get_captcha_pop_up.js.erb
... | ... | @@ -0,0 +1,25 @@ |
1 | + $("#captcha_layer").html("<%=escape_javascript(render file: 'home/captcha_pop_up.html.erb')%>"); | |
2 | + $("#layer").show(); | |
3 | + $("#captcha_layer").show(); | |
4 | + | |
5 | + $(".closeicon").click(function(){ | |
6 | + $("#layer").hide(); | |
7 | + $("#captcha_layer").hide(); | |
8 | + }); | |
9 | + $("#quit_captcha_layer").click(function(){ | |
10 | + $("#layer").hide(); | |
11 | + $("#captcha_layer").hide(); | |
12 | + }); | |
13 | + $("#submit_captcha_layer").click(function(){ | |
14 | + if ($('#captcha').val() == "") { | |
15 | + $("#lab_captcha").addClass('label-important').show().text('请输入验证码'); | |
16 | + } else { | |
17 | + $("#layer").hide(); | |
18 | + $("#captcha_layer").hide(); | |
19 | + $('#<%= @form_id %>_captcha').val( $('#captcha').val() ); | |
20 | + <% if @is_on_submit %> | |
21 | + $('#<%= @form_id %>_commit_flag').val( 'true' ); | |
22 | + <% end %> | |
23 | + $('#<%= @form_id %>').submit(); | |
24 | + } | |
25 | + }); | |
0 | 26 | \ No newline at end of file |
... | ... |
app/views/layouts/home_manage.html.erb
... | ... | @@ -38,6 +38,8 @@ |
38 | 38 | <%= yield :body_head %> |
39 | 39 | <!-- <%#= render "layouts/navbar-fixed-top" %> --> |
40 | 40 | |
41 | + <div id="layer" style="display: none;"></div> | |
42 | + <div id="captcha_layer" style="display: none;"></div> | |
41 | 43 | <div class="navbar nomargin" id="navbar-warp"> |
42 | 44 | <div class="container"> |
43 | 45 | <div style="display:none"> |
... | ... | @@ -356,7 +358,6 @@ |
356 | 358 | |
357 | 359 | <%#= render "layouts/login" %> |
358 | 360 | <script type="text/javascript"> |
359 | - | |
360 | 361 | jQuery(function($){ |
361 | 362 | var form = $('form.float_login') |
362 | 363 | form.hover(function(){ |
... | ... |
config/routes.rb
... | ... | @@ -77,6 +77,7 @@ Icolor::Application.routes.draw do |
77 | 77 | get "home/home_overall" => "home#home_overall" |
78 | 78 | get "home/image_show_loading" => "home#image_show_loading" |
79 | 79 | get "/get_user_sign_status" => "home#get_user_sign_status" |
80 | + get "/get_captcha_pop_up" => "home#get_captcha_pop_up" | |
80 | 81 | |
81 | 82 | root :to => 'home#index' |
82 | 83 | get "home/design_show" |
... | ... |
相关推荐
【AI】从头到脚详解如何创建部署Azure Web App的OpenAI项目源码
人脸识别项目实战
人工智能-人脸识别代码,采用cnn的架构识别代码
汽车配件制造业企业信息化整体解决方案
短期风速预测模型,IDBO-BiTCN-BiGRU-Multihead-Attention IDBO是,网上复现 评价指标:R方、MAE、MAPE、RMSE 附带测试数据集运行(风速数据) 提示:在MATLAB2024a上测试正常 ,短期风速预测模型; IDBO-BiTCN-BiGRU-Multihead-Attention; 评价指标: R方、MAE、MAPE、RMSE; 复现; 测试数据集; MATLAB 2024a,短期风速预测模型:IDBO-BiTCN-BiGRU-Attention集成模型
手势识别项目实战
在智慧园区建设的浪潮中,一个集高效、安全、便捷于一体的综合解决方案正逐步成为现代园区管理的标配。这一方案旨在解决传统园区面临的智能化水平低、信息孤岛、管理手段落后等痛点,通过信息化平台与智能硬件的深度融合,为园区带来前所未有的变革。 首先,智慧园区综合解决方案以提升园区整体智能化水平为核心,打破了信息孤岛现象。通过构建统一的智能运营中心(IOC),采用1+N模式,即一个智能运营中心集成多个应用系统,实现了园区内各系统的互联互通与数据共享。IOC运营中心如同园区的“智慧大脑”,利用大数据可视化技术,将园区安防、机电设备运行、车辆通行、人员流动、能源能耗等关键信息实时呈现在拼接巨屏上,管理者可直观掌握园区运行状态,实现科学决策。这种“万物互联”的能力不仅消除了系统间的壁垒,还大幅提升了管理效率,让园区管理更加精细化、智能化。 更令人兴奋的是,该方案融入了诸多前沿科技,让智慧园区充满了未来感。例如,利用AI视频分析技术,智慧园区实现了对人脸、车辆、行为的智能识别与追踪,不仅极大提升了安防水平,还能为园区提供精准的人流分析、车辆管理等增值服务。同时,无人机巡查、巡逻机器人等智能设备的加入,让园区安全无死角,管理更轻松。特别是巡逻机器人,不仅能进行360度地面全天候巡检,还能自主绕障、充电,甚至具备火灾预警、空气质量检测等环境感知能力,成为了园区管理的得力助手。此外,通过构建高精度数字孪生系统,将园区现实场景与数字世界完美融合,管理者可借助VR/AR技术进行远程巡检、设备维护等操作,仿佛置身于一个虚拟与现实交织的智慧世界。 最值得关注的是,智慧园区综合解决方案还带来了显著的经济与社会效益。通过优化园区管理流程,实现降本增效。例如,智能库存管理、及时响应采购需求等举措,大幅减少了库存积压与浪费;而设备自动化与远程监控则降低了维修与人力成本。同时,借助大数据分析技术,园区可精准把握产业趋势,优化招商策略,提高入驻企业满意度与营收水平。此外,智慧园区的低碳节能设计,通过能源分析与精细化管理,实现了能耗的显著降低,为园区可持续发展奠定了坚实基础。总之,这一综合解决方案不仅让园区管理变得更加智慧、高效,更为入驻企业与员工带来了更加舒适、便捷的工作与生活环境,是未来园区建设的必然趋势。
相亲交友系统源码 V10.5支持婚恋相亲、媒婆返利、红娘系统、商城系统等等 这款交友系统功能太多了,适合婚恋相亲,还有媒婆婚庆等等支持 PC和 H5还有小程序,可封装红年、APP,里面带安装教程
本资源《单片机也能玩双核之你想不到的C技巧系列——嵌入式实战》涵盖 双核单片机开发、C语言高级技巧、嵌入式系统优化 等核心内容,结合 实战案例与视频教程,帮助开发者深入理解并掌握高效编程技巧。 适用人群: 适合 嵌入式开发工程师、单片机开发者、电子信息相关专业学生,以及希望提升 C语言编程能力 和 嵌入式项目经验 的技术人员。 能学到什么: 双核单片机开发思路,提高并行处理能力。 C语言高级技巧,提升代码优化与执行效率。 嵌入式系统调试方法,掌握实际项目中的调试策略。 实战案例解析,学习如何在实际工程中应用双核技术。 阅读建议: 建议 先学习基础知识,再结合 示例代码与视频教程 进行实操,重点关注 代码优化、调试技巧与双核应用模式,通过实战演练提高嵌入式开发能力。
人脸识别项目源码实战
人脸识别项目源码实战
c语言学习
红外光伏缺陷目标检测模型,YOLOv8模型 基于红外光伏缺陷目标检测数据集训练,做了必要的数据增强处理,以达到缺陷类别间的平衡 可检测大面积热斑,单一热斑,二极管短路和异常低温四类缺陷 测试集指标如图所示 ,核心关键词:红外光伏缺陷目标检测模型; YOLOv8模型; 数据增强处理; 缺陷类别平衡; 大面积热斑; 单一热斑; 二极管短路; 异常低温。,基于YOLOv8的红外光伏缺陷检测模型
基于PLC的自动浇花控制系统 西门子1200PLC博途仿真,提供HMI画面,接线图,IO分配表,演示视频,简单讲解视频 博图15.1及以上版本均可使用 ,核心关键词: PLC自动浇花控制系统; 西门子1200PLC博途仿真; HMI画面; 接线图; IO分配表; 演示视频; 简单讲解视频; 博图15.1及以上版本。,基于PLC的自动浇花系统:西门子1200PLC博途仿真实践教程
在智慧园区建设的浪潮中,一个集高效、安全、便捷于一体的综合解决方案正逐步成为现代园区管理的标配。这一方案旨在解决传统园区面临的智能化水平低、信息孤岛、管理手段落后等痛点,通过信息化平台与智能硬件的深度融合,为园区带来前所未有的变革。 首先,智慧园区综合解决方案以提升园区整体智能化水平为核心,打破了信息孤岛现象。通过构建统一的智能运营中心(IOC),采用1+N模式,即一个智能运营中心集成多个应用系统,实现了园区内各系统的互联互通与数据共享。IOC运营中心如同园区的“智慧大脑”,利用大数据可视化技术,将园区安防、机电设备运行、车辆通行、人员流动、能源能耗等关键信息实时呈现在拼接巨屏上,管理者可直观掌握园区运行状态,实现科学决策。这种“万物互联”的能力不仅消除了系统间的壁垒,还大幅提升了管理效率,让园区管理更加精细化、智能化。 更令人兴奋的是,该方案融入了诸多前沿科技,让智慧园区充满了未来感。例如,利用AI视频分析技术,智慧园区实现了对人脸、车辆、行为的智能识别与追踪,不仅极大提升了安防水平,还能为园区提供精准的人流分析、车辆管理等增值服务。同时,无人机巡查、巡逻机器人等智能设备的加入,让园区安全无死角,管理更轻松。特别是巡逻机器人,不仅能进行360度地面全天候巡检,还能自主绕障、充电,甚至具备火灾预警、空气质量检测等环境感知能力,成为了园区管理的得力助手。此外,通过构建高精度数字孪生系统,将园区现实场景与数字世界完美融合,管理者可借助VR/AR技术进行远程巡检、设备维护等操作,仿佛置身于一个虚拟与现实交织的智慧世界。 最值得关注的是,智慧园区综合解决方案还带来了显著的经济与社会效益。通过优化园区管理流程,实现降本增效。例如,智能库存管理、及时响应采购需求等举措,大幅减少了库存积压与浪费;而设备自动化与远程监控则降低了维修与人力成本。同时,借助大数据分析技术,园区可精准把握产业趋势,优化招商策略,提高入驻企业满意度与营收水平。此外,智慧园区的低碳节能设计,通过能源分析与精细化管理,实现了能耗的显著降低,为园区可持续发展奠定了坚实基础。总之,这一综合解决方案不仅让园区管理变得更加智慧、高效,更为入驻企业与员工带来了更加舒适、便捷的工作与生活环境,是未来园区建设的必然趋势。
大型集团用户画像系统化标准化数字化用户主数据管理项目规划方案
基于STM32的水质 浊度检测仪设计与实现(详细设计说明书+ 10008-基于STM32的水质 浊度检测仪设计与实现(详细设计说明书+原理图PCB工程+源码工程+实物照片) 本次设计是设计一款水质检测设备,实现温度检查、水质检测的功能,将检测到的数据显示到显示器中,并实时记录系统的参数 本次系统需要对温度检测,使用的传感器为DS18B20,通过单总线的方式来完成系统温度检测 使用水质检测模块检查水的质量 通过传感器检测到的数据计算后的值实时刷新到显示器中,主要的功能包括以下几点: ①可以对温度实时检测; ②可以对水质实际值实时检测; ③水质浑浊预警 主要特点: 1.以STM32单片机为核心,配合水质模块; 2.主要完成系统的 功能控制、状态显示、信息检测以及报警硬件组建所单片机和传感器等元器件的选择; 3.完成系统控制的软件设计编程; 4.实现对水质检测、温度检查、预警的功能 内容包含: 1、原理图工程 2、PCB工程 3、源码工程 4、实物照片 5、详细介绍说明书-22531字 6、实物照片 7、浊度传感器资料
人脸识别项目实战
华中科技大学计算机科学研究生复试上机测试题.zip
YOLOv8部署到web上(Django+html)