Changeset 2305


Ignore:
Timestamp:
Sep 2, 2013, 4:24:43 PM (5 years ago)
Author:
matthijs
Message:

plugin-debug: Allow filtering the log view

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/luci/applications/luci-debug/luasrc/view/fon_debug/log.htm

    r2304 r2305  
    33log = util.exec("logread")
    44%>
    5 <textarea readonly wrap="off" style="width: 100%; height: 400px; margin-bottom: 20px;">
     5
     6<p>Show only log lines containing: <input type="text" id="log_filter" onkeypress="filter_log(this)"></input></p>
     7<textarea readonly id="log" wrap="off" style="width: 100%; height: 400px; margin-bottom: 20px;">
    68<%= log:gsub("&", "&amp;"):gsub("<", "&lt;"):gsub(">", "&gt;") %>
    79</textarea>
     10
     11<script type="text/javascript">
     12  // Store the original text, split into lines
     13  var original_lines = document.getElementById("log").value.match(/^.*((\r\n|\n|\r)|$)/gm);
     14  function filter_log(input) {
     15    var text = "";
     16    for (var i = 0; i < original_lines.length; i++) {
     17        if (original_lines[i].indexOf(input.value) !== -1)
     18          text += original_lines[i];
     19    }
     20    document.getElementById("log").value = text;
     21  }
     22</script>
Note: See TracChangeset for help on using the changeset viewer.