Commit 9e6a4d29 authored by Lingnan Wu's avatar Lingnan Wu

add the required js for using the jio and also change the main page for jio storage

parent 2eb0b865
...@@ -5,6 +5,16 @@ ...@@ -5,6 +5,16 @@
<link rel="stylesheet" href="css/themes/default/jquery.mobile-1.1.0.css" /> <link rel="stylesheet" href="css/themes/default/jquery.mobile-1.1.0.css" />
<script src="js/jquery.js"></script> <script src="js/jquery.js"></script>
<script src="js/jquery.mobile-1.1.0.js"></script> <script src="js/jquery.mobile-1.1.0.js"></script>
<script type="text/javascript" src="lib/jstorage/jstorage.js"></script>
<script type="text/javascript" src="src/localorcookiestorage.js"></script>
<script type="text/javascript" src="src/jio.js"></script>
<script type="text/javascript" src="lib/base64/base64.js"></script>
<script type="text/javascript" src="lib/sjcl/sjcl.min.js"></script>
<script type="text/javascript" src="src/jio.storage.js"></script>
<script type="text/javascript" src="js/officejs.js"></script>
</head> </head>
<body> <body>
<!-- Home --> <!-- Home -->
...@@ -13,27 +23,37 @@ ...@@ -13,27 +23,37 @@
<div data-role="header"> <div data-role="header">
<h1>OfficeJs-Mobile</h1> <h1>OfficeJs-Mobile</h1>
</div> </div>
<div data-role="content" style="padding: 15px"> <div data-role="content" style="padding: 15px">
<div data-role="fieldcontain"> <div data-role="fieldcontain">
<fieldset data-role="controlgroup"> <fieldset data-role="controlgroup">
<label for="textinput1"> <label class="control-label" for="input_json_storage">
JSON Storage JSON Storage
</label> </label>
<input id="textinput1" placeholder="" value="{&quot;type&quot;:&quot;local&quot;,&quot;userName&quot;:&quot;lingnan&quot;}"
type="text"> <input class="input-xlarge"
type="text" name="JSONstorage" id="input_json_storage" placeholder="storage" value="{&quot;type&quot;:&quot;local&quot;,&quot;userName&quot;:&quot;lingnan&quot;}" >
</fieldset> </fieldset>
</div> </div>
<div data-role="fieldcontain"> <div data-role="fieldcontain">
<fieldset data-role="controlgroup"> <fieldset data-role="controlgroup">
<label for="textinput2"> <label class="control-label" for="JSONapplicantID">
JSON Application JSON Application
</label> </label>
<input id="textinput2" placeholder="" value="{&quot;ID&quot;:&quot;jiotests&quot;}"
type="text"> <input class="input-xlarge"
type="text" name="JSONapplicant" id="input_json_applicant"
value="{&quot;ID&quot;:&quot;jiotests&quot;}"
placeholder="applicant" />
</fieldset> </fieldset>
</div> </div>
<a href="#tools" data-role="button" data-transition="slideup" data-theme="b">Go Docs </a>
<a href="#tools" data-role="button" data-transition="slideup" data-theme="b" onclick="console.log('asdf');OfficeJS.setJio(
$('#input_json_storage').attr('value'),
$('#input_json_applicant').attr('value'));">Create New JIO</a>
</div> </div>
</div> </div>
......
define ('Base64',['Base64API'], function () {
return Base64;
});
\ No newline at end of file
This diff is collapsed.
/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
*
**/
var Base64 = {
// private property
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
// public method for encoding
encode : function (input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
input = Base64._utf8_encode(input);
while (i < input.length) {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
}
return output;
},
// public method for decoding
decode : function (input) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) {
enc1 = this._keyStr.indexOf(input.charAt(i++));
enc2 = this._keyStr.indexOf(input.charAt(i++));
enc3 = this._keyStr.indexOf(input.charAt(i++));
enc4 = this._keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
}
output = Base64._utf8_decode(output);
return output;
},
// private method for UTF-8 encoding
_utf8_encode : function (string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
},
// private method for UTF-8 decoding
_utf8_decode : function (utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;
while ( i < utftext.length ) {
c = utftext.charCodeAt(i);
if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return string;
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
var LocalOrCookieStorage =
(function () { var local_cookie_loader_function = function () {
// localorcookiestorage.js
// Creates an object that can store persistent information in localStorage.
// If it is not supported by the browser, it will store in cookies.
// Methods :
// - LocalOrCookieStorage.setItem('name',value);
// Sets an item with its value.
// - LocalOrCookieStorage.getItem('name');
// Returns a copy of the item.
// - LocalOrCookieStorage.deleteItem('name');
// Deletes an item forever.
// - LocalOrCookieStorage.getAll();
// Returns a new object containing all items and their values.
////////////////////////////////////////////////////////////////////////////
// cookies & localStorage
var BrowserStorage = function () {
};
BrowserStorage.prototype = {
getItem: function (name) {
return JSON.parse(localStorage.getItem(name));
},
setItem: function (name,value) {
if (name) {
return localStorage.setItem(name,JSON.stringify(value));
}
},
getAll: function() {
return localStorage;
},
deleteItem: function (name) {
if (name) {
delete localStorage[name];
}
}
};
var CookieStorage = function () {
};
CookieStorage.prototype = {
getItem: function (name) {
var cookies = document.cookie.split(';'), i;
for (i = 0; i < cookies.length; i += 1) {
var x = cookies[i].substr(0, cookies[i].indexOf('=')),
y = cookies[i].substr(cookies[i].indexOf('=')+1);
x = x.replace(/^\s+|\s+$/g,"");
if( x === name ) { return unescape(y); }
}
return null;
},
setItem: function (name,value) {
// function to store into cookies
if (value !== undefined) {
document.cookie = name+'='+JSON.stringify(value)+';domain='+
window.location.hostname+
';path='+window.location.pathname;
return true;
}
return false;
},
getAll: function() {
var retObject = {}, i,
cookies = document.cookie.split(':');
for (i = 0; i < cookies.length; i += 1) {
var x = cookies[i].substr(0, cookies[i].indexOf('=')),
y = cookies[i].substr(cookies[i].indexOf('=')+1);
x = x.replace(/^\s+|\s+$/g,"");
retObject[x] = unescape(y);
}
return retObject;
},
deleteItem: function (name) {
document.cookie = name+'=null;domain='+window.location.hostname+
';path='+window.location.pathname+
';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}
};
// set good localStorage
try {
if (localStorage.getItem) {
return new BrowserStorage();
} else {
return new CookieStorage();
}
}
catch (e) {
return new CookieStorage();
}
// end cookies & localStorages
////////////////////////////////////////////////////////////////////////////
};
if (window.requirejs) {
define ('LocalOrCookieStorage',[], local_cookie_loader_function);
return undefined;
} else {
return local_cookie_loader_function ();
}
}());
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment