[LNT] r239469 - Factor out common javascript regex search code & simplify it a bit. NFC.
Kristof Beyls
kristof.beyls at arm.com
Wed Jun 10 05:16:20 PDT 2015
Author: kbeyls
Date: Wed Jun 10 07:16:20 2015
New Revision: 239469
URL: http://llvm.org/viewvc/llvm-project?rev=239469&view=rev
Log:
Factor out common javascript regex search code & simplify it a bit. NFC.
Modified:
lnt/trunk/lnt/server/ui/templates/all_machines.html
lnt/trunk/lnt/server/ui/templates/utils.html
lnt/trunk/lnt/server/ui/templates/v4_run.html
Modified: lnt/trunk/lnt/server/ui/templates/all_machines.html
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/all_machines.html?rev=239469&r1=239468&r2=239469&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/templates/all_machines.html (original)
+++ lnt/trunk/lnt/server/ui/templates/all_machines.html Wed Jun 10 07:16:20 2015
@@ -4,36 +4,8 @@
{% set components = [(ts.name, v4_url_for("v4_recent_activity"))] %}
{% block title %}Machines{%endblock%}
-
-{# Add JS to initialize the graph. #}
-{% block onload %}init(){% endblock %}
-
-{% block javascript %}
-
-function init() {
- // Filter table by filter text box.
- $(document).ready(function() {
- (function ($) {
- $('#filter').keyup(function () {
-
- var filter_regex = new RegExp($(this).val(), 'i');
- $('.searchable tr').hide();
- $('.searchable tr').filter(function () {
- return filter_regex.test($(this).text());
- }).show();
- })
- }(jQuery));
- });
-}
-
-{% endblock %}
-
-</script>
-
{% block body %}
-<div class="input-group"> <span class="input-group-addon">Filter</span>
- <input id="filter" type="text" class="form-control" placeholder="Machines...">
-</div>
+ {{ utils.regex_filter_box('filter', '.searchable tr', "Machines...") }}
<section id="machines" />
{# List all Machines which reported for this database. #}
Modified: lnt/trunk/lnt/server/ui/templates/utils.html
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/utils.html?rev=239469&r1=239468&r2=239469&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/templates/utils.html (original)
+++ lnt/trunk/lnt/server/ui/templates/utils.html Wed Jun 10 07:16:20 2015
@@ -21,3 +21,24 @@
{% macro render_machine(m) -%}
<a href="{{v4_url_for('v4_machine', id=m.id)}}">{{m.name}}:{{m.id}}</a>
{%- endmacro %}
+
+{% macro regex_filter_box(input_id, selector, placeholder) -%}
+<div class="input-group"> <span class="input-group-addon">Filter</span>
+ <input id="{{input_id}}" type="text" class="form-control"
+ placeholder="{{placeholder}}"/>
+</div>
+<script type="text/javascript">
+// Filter table by filter text box.
+$(document).ready(function() {
+ (function ($) {
+ $('#{{input_id}}').keyup(function () {
+ var filter_regex = new RegExp($(this).val(), 'i');
+ $('{{selector}}').hide();
+ $('{{selector}}').filter(function () {
+ return filter_regex.test($(this).text());
+ }).show();
+ })
+ }(jQuery));
+});
+</script>
+{%- endmacro %}
Modified: lnt/trunk/lnt/server/ui/templates/v4_run.html
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/v4_run.html?rev=239469&r1=239468&r2=239469&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/templates/v4_run.html (original)
+++ lnt/trunk/lnt/server/ui/templates/v4_run.html Wed Jun 10 07:16:20 2015
@@ -23,30 +23,6 @@
</script>
{% endblock %}
-{# Add JS to initialize the run page. #}
-{% block onload %}init(){% endblock %}
-
-{% block javascript %}
-
-function init() {
- // Filter table by filter text box.
- $(document).ready(function() {
- (function ($) {
- $('#filter').keyup(function () {
-
- var filter_regex = new RegExp($(this).val(), 'i');
- $('.searchable tr').hide();
- $('.searchable tr').filter(function () {
- return filter_regex.test($(this).text());
- }).show();
- })
- }(jQuery));
- });
-}
-
-{% endblock %}
-
-
{% block title %}Run Results{% endblock %}
{% macro get_cell_value(cr) %}
@@ -309,11 +285,11 @@ function init() {
<section id="report" />
{{ utils.render_popup_begin('html_report', 'Report',
options.hide_report_by_default) }}
-
- <div class="input-group"> <span class="input-group-addon">Benchmark Filter: </span>
- <input id="filter" type="text" class="form-control" placeholder="Benchmark name regex...">
- </div>
-
+
+ {{ utils.regex_filter_box(input_id='filter',
+ selector='.searchable tr',
+ placeholder="Benchmark name regex...") }}
+
{{request_info.html_report|safe}}
{{ utils.render_popup_end() }}
More information about the llvm-commits
mailing list