From f714efc1b0b88ec5041c1acb5405e0dc34553815 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Fri, 8 May 2015 13:02:09 +0300 Subject: Bugfix; licensing; copyright & contact details; readme --- LICENSE | 2 +- README.md | 3 +++ coqCounter.js | 74 ++++++++++++++++++++++++++++++++++++++++------------------- index.html | 11 +++++++-- 4 files changed, 64 insertions(+), 26 deletions(-) diff --git a/LICENSE b/LICENSE index fd8fd93..b8901b0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 Camil Staps +Copyright (c) 2015 Camil Staps Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 88d59bb..742886c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # CoqCommandsCounter Count used coq commands + +# Usage +Simply open `index.html` in your browser. A working internet connection is required, since jQuery is loaded from CDN. diff --git a/coqCounter.js b/coqCounter.js index 72f7ad7..1f81915 100644 --- a/coqCounter.js +++ b/coqCounter.js @@ -1,30 +1,58 @@ -$.fn.coqCounter = function(output) { - $(this).change(function(){ - var regex = /[\n^]([a-zA-Z_'0-9]+)/g; - var value = $(this).val(); - var matches = [], i = 0; +/* + * The MIT License (MIT) + * + * Copyright (c) 2015 Camil Staps + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ - do { - match = regex.exec(value); - if (match != null) { - matches[i++] = match[1]; - } - } while (match != null); +(function($){ + $.fn.coqCounter = function(output) { + $(this).change(function(){ + var regex = /(?:^|\n)([a-zA-Z_'0-9]+)/g; + var value = $(this).val(); + var matches = [], i = 0; - matches.sort(); + do { + match = regex.exec(value); + if (match != null) { + matches[i++] = match[1]; + } + } while (match != null); - var counts = {}; - matches.forEach(function(x) { counts[x] = (counts[x] || 0)+1; }); + if (matches.length == 0) { + $(output).val("No Coq commands found."); + } else { + matches.sort(); - var counts_output = [], i = 0; - for (cmd in counts) { - counts_output[i++] = counts[cmd] + "x " + cmd; - } + var counts = {}; + matches.forEach(function(x) { counts[x] = (counts[x] || 0)+1; }); - console.log(counts_output); + var counts_output = [], i = 0; + for (cmd in counts) { + counts_output[i++] = counts[cmd] + "x " + cmd; + } - $(output).val(counts_output.join(", ")); - }); + $(output).val(counts_output.join(", ")); + } + }); - return this; -}; \ No newline at end of file + return this; + }; +})(jQuery); \ No newline at end of file diff --git a/index.html b/index.html index 549b2cb..038f9ee 100644 --- a/index.html +++ b/index.html @@ -4,14 +4,21 @@ Coq commands counter -
+

Count commands used in a Coq script

+

Copyright © 2015 Camil Staps - licensed under MIT.

+ +
-- cgit v1.2.3