Skip to content
Browse files

not accepting any incorrect regexps silently

  • Loading branch information...
1 parent c72dd01 commit c8fb124b228873bb80d58cd81457f49b531049a2 @bobrik committed Jul 28, 2012
Showing with 36 additions and 22 deletions.
  1. +36 −22 public/index.html
View
58 public/index.html
@@ -137,6 +137,7 @@
logNameFilter = jQuery("#log-name-filter"),
fontSizeSelector = jQuery("#font-size"),
currentLink = jQuery("#current-link"),
+ taggedInputs = jQuery('#highlight-items, #grep-items'),
currentLog = undefined,
bufferLength = 20,
outputPaused = false,
@@ -213,14 +214,34 @@
fontSizeSelector.val(+fontSizeSelector.val() - 1).change();
});
- jQuery('#highlight-items, #grep-items').textext({ plugins : 'tags' });
- jQuery('#highlight-items, #grep-items').textext()[0].getFormData();
- jQuery('#highlight-items, #grep-items').bind('setFormData', function(e, data, isEmpty) {
+ taggedInputs.textext({ plugins : 'tags' });
+ taggedInputs.textext()[0].getFormData();
+ taggedInputs.bind('isTagAllowed', function(e, data) {
+ try {
+ new RegExp(data.tag);
+ } catch (e) {
+ data.result = false;
+ }
+ });
+ taggedInputs.bind('setFormData', function(e, data, isEmpty) {
var $target = jQuery(e.target);
$target.data('tags', data);
rebuildCurrentLink();
});
+
+ taggedInputs.keyup(function() {
+ var input = jQuery(this),
+ container = input.parent().parent().parent();
+
+ try {
+ new RegExp(input.val());
+ container.removeClass("error");
+ } catch (e) {
+ container.addClass("error");
+ }
+ });
+
logNameFilter.keyup(function() {
logNameFilter.change();
});
@@ -374,17 +395,14 @@
function isHighlightedLine(text) {
var tags = jQuery("#highlight-items").data('tags');
- try {
- if (tags && tags.length) {
- for (var i in tags) {
- var tag = tags[i];
- if (tag && text.match(new RegExp(tag))) {
- return true;
- }
+
+ if (tags && tags.length) {
+ for (var i in tags) {
+ var tag = tags[i];
+ if (tag && text.match(new RegExp(tag))) {
+ return true;
}
}
- } catch (e) {
- console.log(e);
}
return false;
@@ -397,23 +415,19 @@
function isGrepAcceptedLine(text) {
var tags = jQuery("#grep-items").data('tags');
- try {
- if (tags && tags.length) {
- for (var i in tags) {
- var tag = tags[i];
- if (tag && !text.match(new RegExp(tag))) {
- return false;
- }
+
+ if (tags && tags.length) {
+ for (var i in tags) {
+ var tag = tags[i];
+ if (tag && !text.match(new RegExp(tag))) {
+ return false;
}
}
- } catch (e) {
- console.log(e);
}
return true;
}
-
socket.on("line", function(data) {
if (outputPaused) {
return;

0 comments on commit c8fb124

Please sign in to comment.
Something went wrong with that request. Please try again.