aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps2015-05-08 13:02:09 +0300
committerCamil Staps2015-05-08 13:02:09 +0300
commitf714efc1b0b88ec5041c1acb5405e0dc34553815 (patch)
treebea85a9c544e0ebc064199e83b3a3398d59e624a
parentThis seems to work (diff)
Bugfix; licensing; copyright & contact details; readme
-rw-r--r--LICENSE2
-rw-r--r--README.md3
-rw-r--r--coqCounter.js74
-rw-r--r--index.html11
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 <info@camilstaps.nl>
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 <info@camilstaps.nl>
+ *
+ * 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 @@
<title>Coq commands counter</title>
</head>
<body>
- <textarea id="input" cols="60" rows="20"></textarea><br/>
+ <h1>Count commands used in a Coq script</h1>
+ <p>Copyright &copy; 2015 <a href="http://www.camilstaps.nl/">Camil Staps</a> - licensed under <a href="LICENSE">MIT</a>.</p>
+
+ <textarea id="input" cols="60" rows="20">Enter Coq script here</textarea><br/>
<textarea id="output" cols="60" rows="2"></textarea>
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="coqCounter.js"></script>
<script type="text/javascript">
$(function(){
- $('#input').coqCounter('#output');
+ $('#input')
+ .coqCounter('#output')
+ .focus(function(){
+ $(this).val('');
+ });
});
</script>
</body>