Use requirejs for clientside scripting
diff --git a/dev/js/src/session.js b/dev/js/src/session.js
index a10ce81..f81eb8f 100644
--- a/dev/js/src/session.js
+++ b/dev/js/src/session.js
@@ -4,77 +4,68 @@
*
* @author Nils Diewald
*/
-var KorAP = KorAP || {};
+define({
+ /**
+ * Create a new session.
+ * Expects a name or defaults to 'korap'
+ */
+ create : function (name) {
+ var obj = Object.create(this);
+ if (name === undefined)
+ name = 'korap';
+ obj._name = name.toLowerCase();
+ obj._hash = {};
+ obj._parse();
+ return obj;
+ },
-(function (KorAP) {
- "use strict";
+ /**
+ * Get a value based on a key.
+ * The value can be complex, as the value is stored as JSON.
+ */
+ get : function (key) {
+ return this._hash[key.toLowerCase()];
+ },
-
- KorAP.Session = {
+ /**
+ * Set a value based on a key.
+ * The value can be complex, as the value is stored as JSON.
+ */
+ set : function (key, value) {
+ this._hash[key] = value;
+ this._store();
+ },
- /**
- * Create a new session.
- * Expects a name or defaults to 'korap'
- */
- create : function (name) {
- var obj = Object.create(KorAP.Session);
- if (name === undefined)
- name = 'korap';
- obj._name = name.toLowerCase();
- obj._hash = {};
- obj._parse();
- return obj;
- },
+ /**
+ * Clears the session by removing the cookie
+ */
+ clear : function () {
+ document.cookie = this._name + '=; expires=-1';
+ },
- /**
- * Get a value based on a key.
- * The value can be complex, as the value is stored as JSON.
- */
- get : function (key) {
- return this._hash[key.toLowerCase()];
- },
+ /* Store cookie */
+ _store : function () {
+ /*
+ var date = new Date();
+ date.setYear(date.getFullYear() + 1);
+ */
+ document.cookie =
+ this._name + '=' + encodeURIComponent(JSON.stringify(this._hash)) + ';';
+ },
- /**
- * Set a value based on a key.
- * The value can be complex, as the value is stored as JSON.
- */
- set : function (key, value) {
- this._hash[key] = value;
- this._store();
- },
-
- /**
- * Clears the session by removing the cookie
- */
- clear : function () {
- document.cookie = this._name + '=; expires=-1';
- },
-
- /* Store cookie */
- _store : function () {
- /*
- var date = new Date();
- date.setYear(date.getFullYear() + 1);
- */
- document.cookie =
- this._name + '=' + encodeURIComponent(JSON.stringify(this._hash)) + ';';
- },
-
- /* Parse cookie */
- _parse : function () {
- var c = document.cookie;
- var part = document.cookie.split(';');
- for(var i = 0; i < part.length; i++) {
- var pair = part[i].split('=');
- var name = pair[0].trim().toLowerCase();
- if (name === this._name) {
- if (pair.length === 1 || pair[1].length === 0)
- return;
- this._hash = JSON.parse(decodeURIComponent(pair[1]));
+ /* Parse cookie */
+ _parse : function () {
+ var c = document.cookie;
+ var part = document.cookie.split(';');
+ for(var i = 0; i < part.length; i++) {
+ var pair = part[i].split('=');
+ var name = pair[0].trim().toLowerCase();
+ if (name === this._name) {
+ if (pair.length === 1 || pair[1].length === 0)
return;
- };
+ this._hash = JSON.parse(decodeURIComponent(pair[1]));
+ return;
};
- }
+ };
}
-
-}(this.KorAP));
+});