summaryrefslogtreecommitdiff
path: root/js/codeq/core.js
diff options
context:
space:
mode:
authorAleš Smodiš <aless@guru.si>2015-08-24 19:17:43 +0200
committerAleš Smodiš <aless@guru.si>2015-08-24 19:17:43 +0200
commit21d213dcff1367c16dc0c3f6585b8e35d7c2f0c7 (patch)
treeea7164cde0b4ad7ab42b94b291f690813c22b65b /js/codeq/core.js
parent42ee67384fa52bc3db4716ffb9aff2cd0dda3f5e (diff)
Introduced the Q promises library, created a basic login page to test prolog examples, and started tying the terminal and editor activity to the REST services.
Diffstat (limited to 'js/codeq/core.js')
-rw-r--r--js/codeq/core.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/js/codeq/core.js b/js/codeq/core.js
new file mode 100644
index 0000000..f13a019
--- /dev/null
+++ b/js/codeq/core.js
@@ -0,0 +1,33 @@
+window.siteDefinition = { logLevel: 'debug' }; // for debug purposes
+
+window.codeq = {
+ /**
+ * XML namespaces.
+ */
+ ns: {
+ svg: 'http://www.w3.org/2000/svg'
+ },
+
+ noOnlineStatus: !('onLine' in navigator),
+
+ /**
+ * REST API URL prefix.
+ */
+ urlPrefix: '/codeq/',
+
+ /**
+ * Returns the number of Unicode code points in the given string.
+ *
+ * @param s {string}
+ * @returns {number}
+ */
+ codePointCount: function (s) {
+ var n = 0, i, code;
+ for (i = s.length - 1; i >= 0; i--) {
+ code = s.charCodeAt(i);
+ if ((code >= 0xd800) && (code < 0xe000)) i++;
+ n++;
+ }
+ return n;
+ }
+};