Skip to content

Commit

Permalink
限制:工具执行后禁用按钮一段时间
Browse files Browse the repository at this point in the history
  • Loading branch information
hopetree committed Dec 26, 2023
1 parent 2ba5e8f commit 81a4d08
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/blog/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'js_blog_code': '20230730.01',

'css_tool_tool': '20230713.01',
'js_tool_tool': '20230713.01',
'js_tool_tool': '20231226.01',
}


Expand Down
10 changes: 10 additions & 0 deletions apps/tool/static/tool/js/tool.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//禁用按钮一段时间后自动启用
function disableButton(button,t=5000) {
// 禁用按钮
button.prop("disabled", true);

// t毫秒后启用按钮
setTimeout(function() {
button.prop("disabled", false);
}, t);
}
//get url params
var getParam = function (name) {
var search = document.location.search;
Expand Down
2 changes: 2 additions & 0 deletions apps/tool/templates/tool/bd_push.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ <h3 class="mb-3 pl-2 title-info">推送结果参数解读:</h3>
<script>
$('#start-push').click(function() {
push_spider("{{ csrf_token }}", "{% url 'tool:baidu_push' %}");
//禁用按钮
disableButton($('#start-push'),2000);
})

</script>
Expand Down
2 changes: 2 additions & 0 deletions apps/tool/templates/tool/bd_push_site.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ <h3 class="mb-3 pl-2 title-info">推送结果参数解读:</h3>
<script>
$('#start-push').click(function() {
site_push_spider("{{ csrf_token }}", "{% url 'tool:baidu_push_site' %}");
//禁用按钮
disableButton($('#start-push'),2000);
})

</script>
Expand Down
2 changes: 2 additions & 0 deletions apps/tool/templates/tool/docker_search.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ <h3 class="card-title pl-2 title-info">工具说明:</h3>
$('#start-push').click(function () {
docker_search("{{ csrf_token }}", "{% url 'tool:docker_search' %}");
{#docker_search_from_hub();#}
//禁用按钮
disableButton($('#start-push'),3000);
})

</script>
Expand Down
2 changes: 2 additions & 0 deletions apps/tool/templates/tool/regex.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ <h3 class="card-title pl-2 title-info">工具说明:</h3>
<script>
$('#start-re').click(function() {
regex_api("{{ csrf_token }}", "{% url 'tool:regex' %}");
//禁用按钮
disableButton($('#start-re'),2000);
})

</script>
Expand Down
4 changes: 3 additions & 1 deletion apps/tool/templates/tool/useragent.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ <h3 class="card-title pl-2 title-info">请求头参数选择</h3>
<script>
{#useragent_api("{{ csrf_token }}","{% url 'tool:useragent' %}");#}
$("#get_useragent").click(function(){
useragent_api("{{ csrf_token }}","{% url 'tool:useragent' %}")
useragent_api("{{ csrf_token }}","{% url 'tool:useragent' %}");
//禁用按钮
disableButton($("#get_useragent"),2000);
})
</script>
{% endblock %}
2 changes: 2 additions & 0 deletions apps/tool/templates/tool/word_cloud.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ <h3 class="card-title pl-2 title-info">工具说明:</h3>
<script>
$('#start-wc').click(function () {
word_cloud("{{ csrf_token }}", "{% url 'tool:word_cloud' %}", 500000);
//禁用按钮
disableButton($('#start-wc'),2000);
})
</script>
{% endblock %}

0 comments on commit 81a4d08

Please sign in to comment.