nitdoc: merge js utils and base64 into lib/utils
[nit.git] / share / nitdoc / js / plugins / utils.js
diff --git a/share/nitdoc/js/plugins/utils.js b/share/nitdoc/js/plugins/utils.js
deleted file mode 100644 (file)
index 397ec12..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/* This file is part of NIT ( http://www.nitlanguage.org ).\r
-\r
-   Licensed under the Apache License, Version 2.0 (the "License");\r
-   you may not use this file except in compliance with the License.\r
-   You may obtain a copy of the License at\r
-\r
-   http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-\r
-   Documentation generator for the nit language.\r
-   Generate API documentation in HTML format from nit source code.\r
-*/\r
-\r
-/*\r
- * Utils module\r
- */\r
-define([\r
-       "jquery",\r
-], function($) {\r
-\r
-       String.prototype.startsWith = function(prefix, caseSensitive) {\r
-               if(caseSensitive) {\r
-                       return this.toUpperCase().indexOf(prefix.toUpperCase()) === 0;\r
-               }\r
-               return this.indexOf(prefix) === 0;\r
-       }\r
-\r
-       // Compare two strings using Sorensen-Dice Coefficient\r
-       // see: http://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient\r
-       String.prototype.dice = function(other) {\r
-               var length1 = this.length - 1;\r
-               var length2 = other.length - 1;\r
-               if(length1 < 1 || length2 < 1) return 0;\r
-\r
-               var bigrams2 = [];\r
-               for(var i = 0; i < length2; i++) {\r
-                       bigrams2.push(other.substr(i, 2));\r
-               }\r
-\r
-               var intersection = 0;\r
-               for(var i = 0; i < length1; i++) {\r
-                       var bigram1 = this.substr(i, 2);\r
-                       for(var j = 0; j < length2; j++) {\r
-                               if(bigram1 == bigrams2[j]) {\r
-                                       intersection++;\r
-                                       bigrams2[j] = null;\r
-                                       break;\r
-                               }\r
-                       }\r
-               }\r
-               return (2.0 * intersection) / (length1 + length2);\r
-       }\r
-\r
-       // JQuery Case Insensitive :icontains selector\r
-       $.expr[':'].icontains = function(obj, index, meta, stack){\r
-               return (obj.textContent.replace(/\[[0-9]+\]/g, "") || obj.innerText.replace(/\[[0-9]+\]/g, "") || jQuery(obj).text().replace(/\[[0-9]+\]/g, "") || '').toLowerCase().indexOf(meta[3].toLowerCase()) >= 0;\r
-       };\r
-\r
-       return {\r
-               // Extract anchor part (after #) from URL string\r
-               extractAnchor: function(url) {\r
-                       var index = url.indexOf("#");\r
-                       if (index >= 0) {\r
-                               return url.substring(index + 1);\r
-                       }\r
-                       return null;\r
-               },\r
-\r
-               delayEvent: function(handler, event) {\r
-                       if(this.delayEvent.timeout) {\r
-                               clearTimeout(this.delayEvent.timeout);\r
-                       }\r
-                       this.delayEvent.timeout = setTimeout(function() {\r
-                           handler.call(event);\r
-                       }, 50);\r
-               }\r
-       };\r
-});\r