Commit 1c0444c6 authored by Tristan Cavelier's avatar Tristan Cavelier

Merge branch 'master' into queries

Conflicts:
	examples/example-queries.html
	src/queries/begin.js
	src/queries/parser-begin.js
	src/queries/parser-end.js
	src/queries/query.js
parents 02e546dd ac7b4ae5
# dir
JIO_DIR = src/jio
STORAGE_DIR = src/jio.storage
QUERIES_DIR = src/queries
# files
JIO = jio.js
JIO_MIN = jio.min.js
COMPLEX = complex_queries.js
COMPLEX_MIN = complex_queries.min.js
PARSER_PAR = $(QUERIES_DIR)/parser.par
PARSER_OUT = $(QUERIES_DIR)/parser.js
## js/cc using rhino
#JSCC_CMD = rhino ~/modules/jscc/jscc.js -t ~/modules/jscc/driver_web.js_
# sh -c 'cd ; npm install jscc-node'
JSCC_CMD = node ~/node_modules/jscc-node/jscc.js -t ~/node_modules/jscc-node/driver_node.js_
# sh -c 'cd ; npm install jslint'
LINT_CMD = $(shell which jslint || echo node ~/node_modules/jslint/bin/jslint.js) --terse
# sh -c 'cd ; npm install uglify-js'
UGLIFY_CMD = $(shell which uglifyjs || echo node ~/node_modules/uglify-js/bin/uglifyjs)
auto: compile build lint
build: concat uglify
# The order is important!
CONCAT_JIO_NAMES = intro exceptions jio.intro storages/* commands/* jobs/status/* jobs/job announcements/announcement activityUpdater announcements/announcer jobs/jobIdHandler jobs/jobManager jobs/jobRules jio.core jio.outro jioNamespace outro
CONCAT_STORAGE_NAMES = *
CONCAT_QUERIES_NAMES = begin parser-begin parser parser-end serializer query end
LINT_NAMES = exceptions storages/* commands/* jobs/status/* jobs/* announcements/* activityUpdater jio.core jioNamespace
CONCAT_QUERIES_FILES = $(CONCAT_QUERIES_NAMES:%=$(QUERIES_DIR)/%.js)
CONCAT_JIO_FILES = $(CONCAT_JIO_NAMES:%=$(JIO_DIR)/%.js)
LINT_FILES = $(LINT_NAMES:%=$(JIO_DIR)/%.js) $(CONCAT_STORAGE_NAMES:%=$(STORAGE_DIR)/%.js)
# build parser.js
compile:
$(JSCC_CMD) -o $(PARSER_OUT) $(PARSER_PAR)
# concat source files into jio.js and complex-queries.js
concat:
cat $(CONCAT_JIO_FILES) > "$(JIO)"
cat $(CONCAT_QUERIES_FILES) > "$(COMPLEX)"
# uglify into jio.min.js and complex.min.js
uglify:
$(UGLIFY_CMD) "$(JIO)" > "$(JIO_MIN)"
$(UGLIFY_CMD) "$(COMPLEX)" > "$(COMPLEX_MIN)"
# lint all files in JIO and STORAGE and QUERIES DIR
# command: jslint [options] file
# [options] are defined at the top of the source file:
# Example:
# /*jslint indent: 2, maxlen: 80 */
# /*global hex_sha256: true, jQuery: true */
lint:
$(LINT_CMD) $(LINT_FILES)
.phony: clean
clean:
find -name '*~' -delete
realclean:
rm -f "$(JIO)"
rm -f "$(JIO_MIN)"
rm -f "$(COMPLEX)"
rm -f "$(COMPLEX_MIN)"
rm -f "$(PARSER_OUT)"
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jIO Complex Example</title>
</head>
<body>
<script type="text/javascript">
<!--
var logcolor = 'cyan';
var logGetColor = function () {
if (logcolor === 'white') {
logcolor = 'cyan';
} else {
logcolor = 'white';
}
return logcolor;
};
var log = function (o) {
var node = document.createElement ('div');
node.setAttribute('style','background-color:'+logGetColor()+';');
if (typeof o === 'string') {
node.textContent = o;
} else {
node.textContent = JSON.stringify (o);
}
document.getElementById('log').appendChild(node);
};
var error = function (o) {
var node = document.createElement ('div');
node.setAttribute('style','background-color:'+logGetColor()+
';color:red;font-weight:bold');
if (typeof o === 'string') {
node.textContent = o;
} else {
node.textContent = JSON.stringify (o);
}
document.getElementById('log').appendChild(node);
};
var clearlog = function () {
document.getElementById('log').innerHTML = '';
};
//-->
</script>
<div id="main">
<table>
<tr style="font-style:italic;">
<th>simple storage</th><th>multi storage</th><th>distant storage</th>
<th>conflict managing</th><th>custom storage description</th>
</tr>
<tr>
<th>local</th><th>crypt & local</th><th>dav</th>
<th>conflictmanager & local</th><th>custom</th>
</tr>
<tr>
<th>
<input type="text" id="localuser" value="localuser" placeholder="username" /><br />
<input type="text" id="localapp" value="localapp" placeholder="applicationname" /><br />
</th>
<th>
<input type="text" id="cryptuser" value="cryptuser" placeholder="username" /><br />
<input type="text" id="cryptapp" value="cryptapp" placeholder="applicationname" /><br />
<input type="password" id="cryptpassword" value="pwd" placeholder="password" /><br />
</th>
<th>
<input type="text" id="davuser" value="" placeholder="username" /><br />
<input type="text" id="davapp" value="" placeholder="applicationname" /><br />
<input type="password" id="davpassword" value="" placeholder="password" /><br />
<input type="text" id="davurl" value="" placeholder="url" /><br />
</th>
<th>
<input type="text" id="conflictuser" value="localuser" placeholder="username" /><br />
<input type="text" id="conflictapp" value="localapp" placeholder="applicationname" /><br />
</th>
<th style="width:100%;">
<textarea id="customstorage" style="width:100%;">{&quot;type&quot;:&quot;local&quot;,&quot;username&quot;:&quot;customuser&quot;,&quot;applicationname&quot;:&quot;customapp&quot;,&quot;customkey&quot;:&quot;customvalue&quot;}</textarea>
</th>
</tr>
<tr>
<th><button onclick="newLocalJio()">Create New jIO</button></th>
<th><button onclick="newCryptJio()">Create New jIO</button></th>
<th><button onclick="newDavJio()">Create New jIO</button></th>
<th><button onclick="newConflictJio()">Create New jIO</button></th>
<th><button onclick="newCustomJio()">Create New jIO</button></th>
</tr>
</table>
</div>
<hr />
<input type="text" id="filepath" value="" placeholder="filepath" />
<input type="text" id="content" value="" placeholder="content" />
<input type="text" id="prev_rev" value="" placeholder="previous revision" />
<br />
<label for="show_conflicts">Show Conflicts</label>
<input type="checkbox" id="show_conflicts" />,
<label for="show_revision_history">Show Revision History</label>
<input type="checkbox" id="show_revision_history" />,
<label for="show_revision_info">Show Revision Info</label>
<input type="checkbox" id="show_revision_info" />,
<label for="last_revision">Remove Last Revision</label>
<input type="checkbox" id="last_revision" />,<br />
<label for="max_retry">Max Retry</label>
<input type="number" id="max_retry" value="0" style="width:30px;"/>
(0 = infinite),
<label for="metadata_only">Metadata Only</label>
<input type="checkbox" id="metadata_only" />
<hr />
<button onclick="post()">post</button>
<button onclick="put()">put</button>
<button onclick="get()">get</button>
<button onclick="remove()">remove</button>
<button onclick="allDocs()">allDocs</button><br />
<button onclick="printLocalStorage()">print localStorage</button>
<button onclick="localStorage.clear()">clear localStorage</button><br />
<button onclick="clearlog()">Clear Log</button>
<hr />
<div id="log">
</div>
<script type="text/javascript" src="../localorcookiestorage.js"></script>
<script type="text/javascript" src="../jio.js"></script>
<script type="text/javascript" src="../lib/jquery/jquery.min.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="../lib/jsSha2/sha2.js"></script>
<script type="text/javascript" src="../jio.storage.js"></script>
<script type="text/javascript">
<!--
var my_jio = null;
var newLocalJio = function () {
var localuser, localapp;
localuser = $('#localuser').attr('value');
localapp = $('#localapp').attr('value');
var spec = {type: 'local', username: localuser, applicationname: localapp};
if (my_jio) { log('closing older jio'); my_jio.close(); }
log ('local storage description object: ' + JSON.stringify (spec));
my_jio = jIO.newJio(spec);
};
var newCryptJio = function () {
var user, app, pwd;
user = $('#cryptuser').attr('value');
app = $('#cryptapp').attr('value');
pwd = $('#cryptpassword').attr('value');
var spec = {type: 'crypt', username: user, password: pwd, storage:{
type: 'local', username: user, applicationname: app
}};
if (my_jio) { log('closing older jio'); my_jio.close(); }
log ('crypt storage description object: ' + JSON.stringify (spec));
my_jio = jIO.newJio(spec);
};
var newDavJio = function () {
var user, app, pwd, url;
user = $('#davuser').attr('value');
app = $('#davapp').attr('value');
pwd = $('#davpassword').attr('value');
url = $('#davurl').attr('value');
var spec = {
type: 'dav', username: user, applicationname: app,
password: pwd, url: url
};
if (my_jio) { log('closing older jio'); my_jio.close(); }
log ('dav storage description object: ' + JSON.stringify (spec));
my_jio = jIO.newJio(spec);
};
var newConflictJio = function () {
var user, app;
user = $('#conflictuser').attr('value');
app = $('#conflictapp').attr('value');
var spec = {
type: 'conflictmanager', storage: {
type: 'local', username: user, applicationname: app
}
};
if (my_jio) { log('closing older jio'); my_jio.close(); }
log ('conflict manager storage description object: '+JSON.stringify (spec));
my_jio = jIO.newJio(spec);
};
var newCustomJio = function () {
var spec = JSON.parse ($('#customstorage').attr('value'));
if (my_jio) { log('closing older jio'); my_jio.close(); }
log ('custom storage description object: '+JSON.stringify (spec));
my_jio = jIO.newJio(spec);
};
var printLocalStorage = function () {
var i;
log ('LOCALSTORAGE');
for (i in localStorage) {
log ('- '+ i +': '+localStorage[i]);
}
log ('------------------------------');
};
var callback = function (err,val,begin_date) {
log ('time : ' + (Date.now() - begin_date));
if (err) {
return error ('return :' + JSON.stringify (err));
}
log ('return : ' + JSON.stringify (val));
};
var command = function (method) {
var begin_date = Date.now(), doc = {}, opts = {};
log (method);
if (!my_jio) {
return error ('no jio set');
}
opts.conflicts = $('#show_conflicts').attr('checked')?true:false;
opts.revs = $('#show_revision_history').attr('checked')?true:false;
opts.revs_info = $('#show_revision_info').attr('checked')?true:false;
opts.max_retry = parseInt($('#max_retry').attr('value') || '0');
opts.metadata_only = $('#metadata_only').attr('checked')?true:false;
switch (method) {
case 'post':
case 'put':
doc.content = $('#content').attr('value');
doc._id = $('#filepath').attr('value');
doc._rev = $('#prev_rev').attr('value') || undefined;
break;
case 'remove':
doc._id = $('#filepath').attr('value');
opts.rev = ($('#last_revision').attr('checked')?'last':undefined) ||
$('#prev_rev').attr('value') || undefined;
break;
case 'get':
doc = $('#filepath').attr('value');
case 'allDocs':
break;
}
log ('doc: ' + JSON.stringify (doc));
log ('opts: ' + JSON.stringify (opts));
switch (method) {
case 'remove':
case 'post':
case 'put':
case 'get':
my_jio[method](doc,opts,function (err,val) {
callback(err,val,begin_date);
});
break;
case 'allDocs':
my_jio[method](opts,function (err,val) {
callback(err,val,begin_date);
});
break;
}
};
var post = function () {
command('post');
};
var put = function () {
command('put');
};
var get = function () {
command('get');
};
var remove = function () {
command('remove');
};
var allDocs = function () {
command('allDocs');
}
//-->
</script>
</body>
</html>
......@@ -42,9 +42,13 @@
<button onclick="parse()">Parse</button>
<button onclick="serialize()">Serialize</button>
<button onclick="query()">Query</button>
<script type="text/javascript" src="../lib/md5/md5.js"></script>
<script type="text/javascript" src="../lib/jsSha2/sha2.js"></script>
<script type="text/javascript" src="../lib/sjcl/sjcl.min.js"></script>
<script type="text/javascript" src="../jio.min.js"></script>
<script type="text/javascript" src="../complex-queries.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../complex_queries.min.js"></script>
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
<!--
var parse = function () {
......
......@@ -16,41 +16,67 @@ var log = function (o) {
</script>
<div id="log">
</div>
<script type="text/javascript" src="../localorcookiestorage.js"></script>
<script type="text/javascript" src="../lib/md5/md5.js"></script>
<script type="text/javascript" src="../jio.js"></script>
<script type="text/javascript" src="../src/jio.storage/localstorage.js">
</script>
<script type="text/javascript" src="../lib/jquery/jquery.min.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/davstorage.js">
</script>
<script type="text/javascript" src="../lib/jsSha2/sha2.js"></script>
<script type="text/javascript" src="../jio.storage.js"></script>
<script type="text/javascript" src="../src/jio.storage/revisionstorage.js">
</script>
<script type="text/javascript" src="../lib/sjcl/sjcl.min.js"></script>
<script type="text/javascript">
<!--
var my_jio = null;
log ('Welcome to the jIO example.html!')
log ('--> Create jIO instance');
log ('-> Create jIO instance');
my_jio = jIO.newJio({
type: 'local', username: 'jIOtest', applicationname: 'example'
});
log ('--> put "hello" document to localStorage');
// careful ! asynchronous method
my_jio.put({_id:'hello',content:'world'},function (val) {
log ('done');
// careful ! asynchronous methods
log ('-> post "video" document metadata to localStorage');
my_jio.post({_id:'video', title:'My Video Title', codec:'vorbis', language:'en', description: 'Image compilation'}, function (val) {
log ('-> put "thumbnail" attachment to localStorage');
my_jio.putAttachment({id:"video/thumb.jpg", data:"BASE64DATA", mimetype:'image/jpeg'}, function (val) {
log ('-> put "video" attachment to localStorage');
my_jio.putAttachment({id:"video/myvideo.ogg", data:"BASE64DATATOO", mimetype:'video/ogg'}, function (val) {
log ('Done! Refresh the page to see get and remove command.');
}, function (err) {
log ('Error! '+ err.reason);
});
}, function (err) {
log ('Error! ' + err.reason);
});
}, function (err) {
log ('error!');
});
log ('Error! ' + err.reason);
log ('-> get "video" document metadata from localStorage');
my_jio.get('video', function (val) {
log ('Title is: "' + val["title"] + '"');
setTimeout ( function () {
log ('--> get "hello" document from localStorage');
log ('-> remove "video" document from localStorage');
my_jio.remove({_id:'video'}, function (val) {
log ('Done! Refresh the page to see post and putAttachment command.');
}, function (err) {
log ('Error! ' + err.reason);
});
my_jio.get('hello',function (val) {
log ('done, content: ' + val.content);
}, function (err) {
log ('error!');
log ('Error! ' + err.reason);
});
}, 500);
});
//-->
</script>
</body>
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jIO Dashboard</title>
</head>
<body>
<script type="text/javascript">
<!--
var log_color = 'cyan';
var logGetColor = function () {
if (log_color === 'white') {
log_color = 'cyan';
} else {
log_color = 'white';
}
return log_color;
};
var log = function (o) {
var node = document.createElement('div');
node.setAttribute('style', 'background-color:'+logGetColor()+';');
if (typeof o === 'string') {
node.textContent = o;
} else {
node.textContent = JSON.stringify(o);
}
document.getElementById('log').appendChild(node);
};
var error = function (o) {
var node = document.createElement('div');
node.setAttribute('style', 'background-color:'+logGetColor()+
';color:red;font-weight:bold');
if (typeof o === 'string') {
node.textContent = o;
} else {
node.textContent = JSON.stringify(o);
}
document.getElementById('log').appendChild(node);
};
var clearlog = function () {
document.getElementById('log').innerHTML = '';
};
//-->
</script>
<table border="1" style="width: 100%;">
<tr style="font-style:italic;">
<th>simple storage</th><th>multi storage</th><th>distant storage</th>
<th>revision managing</th><th>custom storage description</th>
</tr>
<tr>
<th>local</th><th>crypt & local</th><th>dav</th>
<th>revision & local</th><th>custom</th>
</tr>
<tr>
<th>
<input type="text" id="localuser" value="localuser" placeholder="username" /><br />
<input type="text" id="localapp" value="localapp" placeholder="application_name" /><br />
</th>
<th>
<input type="text" id="cryptuser" value="cryptuser" placeholder="username" /><br />
<input type="text" id="cryptapp" value="cryptapp" placeholder="application_name" /><br />
<input type="password" id="cryptpassword" value="pwd" placeholder="password" /><br />
</th>
<th>
<input type="text" id="davurl" value="http://dav.com/uploads" placeholder="url" /><br />
<input type="text" id="davauthtype" value="basic" placeholder="auth_type" disabled /> <br />
<input type="text" id="davuser" value="davuser" placeholder="username" /><br />
<input type="password" id="davpassword" value="pwd" placeholder="password" /><br />
</th>
<th>
<input type="text" id="revisionuser" value="localuser" placeholder="username" /><br />
<input type="text" id="revisionapp" value="localapp" placeholder="application_name" /><br />
</th>
<th style="width:100%;">
<textarea id="customstorage" style="width:98%;">{&quot;type&quot;:&quot;local&quot;,&quot;username&quot;:&quot;customuser&quot;,&quot;application_name&quot;:&quot;customapp&quot;,&quot;customkey&quot;:&quot;customvalue&quot;}</textarea>
</th>
</tr>
<tr>
<th><button onclick="newLocalJio()">Create New jIO</button></th>
<th><button onclick="newCryptJio()">Create New jIO</button></th>
<th><button onclick="newDavJio()">Create New jIO</button></th>
<th><button onclick="newRevisionJio()">Create New jIO</button></th>
<th><button onclick="newCustomJio()">Create New jIO</button></th>
</tr>
</table>
<br />
<table border="1" style="width: 100%;">
<tr>
<td colspan="1" style="width: 50%;">
<label for="metadata">Metadata or document id:</label>
<textarea id="metadata" rows="3" style="width: 98%;">{}</textarea>
</td>
<td colspan="1" style="text-align: center;">
Options:<br />
<label for="include_docs">Include Docs</label>
<input type="checkbox" id="include_docs" /><br />
<label for="show_conflicts">Get Conflicts</label>
<input type="checkbox" id="show_conflicts" /><br />
<label for="show_revision_history">Get Revision History</label>
<input type="checkbox" id="show_revision_history" /><br />
<label for="show_revision_info">Get Revision Info</label>
<input type="checkbox" id="show_revision_info" /><br />
<label for="max_retry">Max Retry</label>
<input type="number" id="max_retry" value="0" style="width:30px;"/>
(0 = infinite)
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center;">
<button onclick="post()">post</button>
<button onclick="put()">put</button>
<button onclick="get()">get</button>
<button onclick="remove()">remove</button>
<button onclick="allDocs()">allDocs</button>
<!-- </td> -->
<!-- <td style="text-align: center;"> -->
- <button onclick="putAttachment()">putAttachment</button>
<button onclick="getAttachment()">getAttachment</button>
<button onclick="removeAttachment()">removeAttachment</button>
</td>
</tr>
</table>
<br />
<div style="text-align: center;">
<button onclick="printLocalStorage()">print localStorage</button>
<button onclick="localStorage.clear()">clear localStorage</button><br />
<button onclick="clearlog()">Clear Log</button>
</div>
<hr />
<div id="log">
</div>
<script type="text/javascript" src="../lib/md5/md5.js"></script>
<script type="text/javascript" src="../jio.js"></script>
<script type="text/javascript" src="../src/jio.storage/localstorage.js">
</script>
<script type="text/javascript" src="../lib/jquery/jquery.min.js"></script>
<script type="text/javascript" src="../src/jio.storage/davstorage.js">
</script>
<script type="text/javascript" src="../src/jio.storage/erp5storage.js">
</script>
<script type="text/javascript" src="../lib/jsSha2/sha2.js"></script>
<script type="text/javascript" src="../src/jio.storage/revisionstorage.js">
</script>
<script type="text/javascript" src="../lib/sjcl/sjcl.min.js"></script>
<script type="text/javascript">
<!--
var my_jio = null;
var newLocalJio = function () {
var localuser, localapp;
localuser = $('#localuser').attr('value');
localapp = $('#localapp').attr('value');
var spec = {type: 'local', username: localuser, application_name: localapp};
if (my_jio) { log('closing older jio'); my_jio.close(); }
log('local storage description object: ' + JSON.stringify(spec));
my_jio = jIO.newJio(spec);
};
var newCryptJio = function () {
var user, app, pwd;
user = $('#cryptuser').attr('value');
app = $('#cryptapp').attr('value');
pwd = $('#cryptpassword').attr('value');
var spec = {type: 'crypt', username: user, password: pwd, storage:{
type: 'local', username: user, application_name: app
}};
if (my_jio) { log('closing older jio'); my_jio.close(); }
log('crypt storage description object: ' + JSON.stringify(spec));
my_jio = jIO.newJio(spec);
};
var newDavJio = function () {
var user, app, pwd, url;
user = $('#davuser').attr('value');
pwd = $('#davpassword').attr('value');
url = $('#davurl').attr('value');
var spec = {
"type": "dav",
"url": url,
"auth_type": "basic",
"username": user,
"password": pwd
};
if (my_jio) { log('closing older jio'); my_jio.close(); }
log('dav storage description object: ' + JSON.stringify(spec));
my_jio = jIO.newJio(spec);
};
var newRevisionJio = function () {
var user, app;
user = $('#revisionuser').attr('value');
app = $('#revisionapp').attr('value');
var spec = {
type: 'revision', sub_storage: {
type: 'local', username: user, application_name: app
}
};
if (my_jio) { log('closing older jio'); my_jio.close(); }
log('revision storage description object: '+JSON.stringify(spec));
my_jio = jIO.newJio(spec);
};
var newCustomJio = function () {
var spec = JSON.parse ($('#customstorage').attr('value'));
if (my_jio) { log('closing older jio'); my_jio.close(); }
log('custom storage description object: '+JSON.stringify(spec));
my_jio = jIO.newJio(spec);
};
var printLocalStorage = function () {
var i;
log('LOCALSTORAGE');
for (i in localStorage) {
log('- '+ i +': '+localStorage[i]);
}
log('------------------------------');
};
var callback = function (err, val, begin_date) {
log('time : ' + (Date.now() - begin_date));
if (err) {
return error('return :' + JSON.stringify(err));
}
log('return : ' + JSON.stringify(val));
};
var command = function (method) {
var begin_date = Date.now(), doc = {}, opts = {};
log(method);
if (!my_jio) {
return error('no jio set');
}
opts.include_docs = $('#include_docs').attr('checked') ? true : false;
opts.conflicts = $('#show_conflicts').attr('checked') ? true : false;
opts.revs = $('#show_revision_history').attr('checked') ? true : false;
opts.revs_info = $('#show_revision_info').attr('checked') ? true : false;
opts.max_retry = parseInt($('#max_retry').attr('value') || '0');
doc = JSON.parse($('#metadata').attr('value'));
log('doc: ' + JSON.stringify(doc));
log('opts: ' + JSON.stringify(opts));
my_jio[method](doc, opts, function (err, val) {
callback(err, val, begin_date);
});
};
var post = function () {
command('post');
};
var put = function () {
command('put');
};
var get = function () {
command('get');
};
var remove = function () {
command('remove');
};
var allDocs = function () {
command('allDocs');
};
var putAttachment = function () {
command('putAttachment');
};
var getAttachment = function () {
command('getAttachment');
};
var removeAttachment = function () {
command('removeAttachment');
};
//-->
</script>
</body>
</html>
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: '<json:package.json>',
meta: {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - '+
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> Nexedi;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
},
concat: {
dist: {
src: ['<banner:meta.banner>',
'<file_strip_banner:../../src/<%= pkg.name %>.js>'],
dest: '../../<%= pkg.name %>.js'
}
},
min: {
dist: {
src: ['<banner:meta.banner>', '<config:concat.dist.dest>'],
dest: '../../<%= pkg.name %>.min.js'
}
},
qunit: {
files: []
},
lint: {
files: ['grunt.js','../../src/<%= pkg.name %>.js']
},
watch: {
files: '<config:lint.files>',
tasks: 'lint'
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true
},
globals: {
jQuery: true,
LocalOrCookieStorage: true,
Base64: true,
JIO: true,
console: true,
unescape: true,
// Needed to avoid "not defined error" with requireJs
define: true,
require: true,
// Needed to avoid "not defined error" with sinonJs
sinon: true,
module: true,
test: true,
ok: true,
deepEqual: true,
expect: true,
stop: true,
start: true,
equal: true
}
},
uglify: {}
});
// Default task.
grunt.registerTask('default', 'lint concat min');
};
{
"name": "localorcookiestorage",
"title": "Local Or Cookie Storage",
"description": "A small API which can manipulate data into local persistent storage.",
"version": "0.1.0",
"homepage": "",
"author": {
"name": "Tristan Cavelier",
"email": "tristan.cavelier@tiolive.com"
},
"repository": {
"type": "git",
"url": "http://git.erp5.org/repos/jio.git"
},
"bugs": {
"url": ""
},
"licenses": [
],
"dependencies": {
},
"keywords": []
}
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: '<json:package.json>',
meta: {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - '+
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> Nexedi;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
},
concat: {
dist: {
src: ['<banner:meta.banner>',
'<file_strip_banner:../../src/<%= pkg.name %>/intro.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/localstorage.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/davstorage.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/replicatestorage.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/indexstorage.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/cryptstorage.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/conflictmanagerstorage.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/outro.js>'],
dest: '../../<%= pkg.name %>.js'
}
},
min: {
dist: {
src: ['<banner:meta.banner>', '<config:concat.dist.dest>'],
dest: '../../<%= pkg.name %>.min.js'
}
},
qunit: {
files: []
},
lint: {
files: ['grunt.js','../../<%= pkg.name %>.js']
},
watch: {
files: '<config:lint.files>',
tasks: 'lint'
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true
},
globals: {
jQuery: true,
sjcl: true,
LocalOrCookieStorage: true,
Base64: true,
MD5: true,
hex_sha256: true,
jIO: true,
console: true,
unescape: true,
// Needed to avoid "not defined error" with requireJs
define: true,
require: true,
// Needed to avoid "not defined error" with sinonJs
sinon: true,
module: true,
test: true,
ok: true,
deepEqual: true,
expect: true,
stop: true,
start: true,
equal: true
}
},
uglify: {}
});
// Default task.
grunt.registerTask('default', 'concat lint min');
};
{
"name": "jio.storage",
"title": "JIO Storage",
"description": "Javascript Input Output Storage",
"version": "0.1.0",
"homepage": "",
"author": {
"name": "Tristan Cavelier",
"email": "tristan.cavelier@tiolive.com"
},
"repository": {
"type": "git",
"url": "http://git.erp5.org/repos/jio.git"
},
"bugs": {
"url": ""
},
"licenses": [
],
"dependencies": {
"jquery": "~1.7"
},
"keywords": []
}
auto: grunt
grunt:
grunt
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: '<json:package.json>',
meta: {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - '+
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> Nexedi;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
},
concat: {
dist: {
src: ['<banner:meta.banner>',
// Wrapper top
'<file_strip_banner:../../src/<%= pkg.name %>/intro.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/exceptions.js>',
// Jio wrapper top
'<file_strip_banner:../../src/<%= pkg.name %>/jio.intro.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/storages/storage.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/commands/command.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/commands/allDocsCommand.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/commands/getCommand.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/commands/removeCommand.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/commands/putCommand.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/commands/postCommand.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/status/jobStatus.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/status/doneStatus.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/status/failStatus.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/status/initialStatus.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/status/onGoingStatus.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/status/waitStatus.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/job.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/announcements/announcement.js>',
// Singletons
'<file_strip_banner:../../src/<%= pkg.name %>/activityUpdater.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/announcements/announcer.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/jobIdHandler.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/jobManager.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/jobRules.js>',
// Jio wrappor bottem
'<file_strip_banner:../../src/<%= pkg.name %>/jio.outro.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jioNamespace.js>',
// Wrapper bottom
'<file_strip_banner:../../src/<%= pkg.name %>/outro.js>'],
dest: '../../<%= pkg.name %>.js'
}
},
min: {
dist: {
src: ['<banner:meta.banner>', '<config:concat.dist.dest>'],
dest: '../../<%= pkg.name %>.min.js'
}
},
qunit: {
files: [// '../../test/jiotests.html',
'../../test/jiotests_withoutrequirejs.html']
},
lint: {
files: ['grunt.js',
'../../<%= pkg.name %>.js']
// '../../js/base64.requirejs_module.js',
// '../../src/jio.dummystorages.js',
// '../../js/jquery.requirejs_module.js',
// '../../test/jiotests.js',
// '../../test/jiotests.loader.js']
},
watch: {
files: '<config:lint.files>',
tasks: 'lint qunit'
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true
},
globals: {
LocalOrCookieStorage: true,
console: true,
unescape: true,
// Needed to avoid "not defined error" with requireJs
define: true,
require: true,
// Needed to avoid "not defined error" with sinonJs
sinon: true,
module: true,
test: true,
ok: true,
deepEqual: true,
expect: true,
stop: true,
start: true,
equal: true
}
},
uglify: {}
});
// Default task.
grunt.registerTask('default', 'concat lint min');
};
{
"name": "jio",
"title": "JIO",
"description": "Javascript Input Output",
"version": "0.1.0",
"homepage": "",
"author": {
"name": "Tristan Cavelier",
"email": "tristan.cavelier@tiolive.com"
},
"repository": {
"type": "git",
"url": "http://git.erp5.org/repos/jio.git"
},
"bugs": {
"url": ""
},
"licenses": [
],
"dependencies": {
"jquery": "~1.7"
},
"keywords": []
}
#!/bin/bash
for node in `ls -1` ; do
if [ -d "$node" ] ; then
printf "\n\033[1m\033[36mmake -C %s\033[0m\n" "$node"
make -C "$node"
fi
done
<html>
<head>
<title></title>
<script type="text/javascript" src="lib/md5/md5.js"></script>
<script type="text/javascript" src="jio.js"></script>
<script type="text/javascript" src="lib/jquery/jquery.min.js"></script>
<script type="text/javascript" src="lib/jsSha1/sha1.js"></script>
<script type="text/javascript" src="src/jio.storage/s3storage.js"></script>
</head>
<body>
<div class="put form ajaxWITH">
<h2>JIO-S3 PUT form</h2>
<form id="s3AJAXUP" action="https://s3.amazonaws.com/jiobucket/" method="post" enctype="multipart/form-data">
<div class="text_holder">
<p>Give a name to your attachment :</p>
<input type="text">
<p>Below text will be uploaded as an attachment to my_2nd_document :</p>
<textarea name="text_area">Contenu de l'attachement</textarea>
</div>
<div class="submit">Put the attachment</div>
</form>
</div>
<div class="ALLDOCS">
<h2>All docs</h2>
<div class="button">
Get all the docs
</div>
<div class="content"></div>
</div>
<style type="text/css" media="screen">
.button {cursor: pointer;margin:4px;}
.text-holder {width:100%;clear:both;float:left;width:140px;}
.text-holder > input {float:left}
.text-holder > textarea {clear:both;float:left;margin:10px;font-size:10px;}
div.submit, .ALLDOCS .button {background:silver;border-radius: 3px;color:black;width:150px;height:auto;box-shadow:0px 0px 1px 1px black;cursor:pointer;margin:4px;padding:2px;}
</style>
<script>
var alldocsDATA = '';
$(document).ready(function(){
//mise en cache des éléments DOM
var alldocsAREA = $('.ALLDOCS');
var alldocsButton = alldocsAREA.find('.button');
var alldocsContent = alldocsAREA.find('.content');
var metaAREA = $('.META');
var metaContent = metaAREA.find('.content');
var outputAREA = $('.OUTPUT');
var outputContent = outputAREA.find('.content');
//mise en cache des éléments DOM
var jioform = $('#s3AJAXUP');
var submitButton = $('div.submit');
var textTitle = jioform.find('input[type="text"]').val();
var textContent = jioform.find('textarea').val();
//Initiation JIO
var jio_instance = jIO.newJio({
"type":"s3",
"AWSIdentifier":"AKIAJLNYGVLTV66RHPEQ",
"password":"/YHoa5r2X6EUHfvP31jdYx6t75h81pAjIZ4Mt94y",
"server":"jiobucket",
"url":"https://jiobucket.s3.amazonaws.com"
});
//jio_instance.get({"_id": "my_1st_document", "title": "myDoc1"}, function(err, response){
//console.log("GET response :"+ response);
//});
//
//jio_instance.getAttachment({"_id": "my_1st_document","_attachment": "1er_attachment"}, function(err, response){
//console.log("GET Attachment response :"+ response);
//});
//
//jio_instance.put({"_id": "my_6th_document", "title": "myDoc6"}, function(err, response){
//console.log('PUT response : '+JSON.stringify(response));
//});
//
//
jio_instance.post({"_id": 'documentONE', "title": "doc1"}, function(err, response){
console.log('POST response :'+ JSON.stringify(response));
//removeWrapper();
});
jio_instance.putAttachment({
"_id": "documentONE",
"_attachment": '1st_Attachment_manual',
"_data": "Ceci est le contenu de l'attachment",
"_mimetype": "text/plain"
}, function(err, response){
console.log("PUT Attachment response :"+ JSON.stringify(response));
//removeAttachmentWrapper();
});
//
//function removeWrapper(){
//jio_instance.remove({"_id":"my_5th_document","title":"myDoc5"}, function(err,response){
//console.log('REMOVE response : '+ response);
//});
//};
//
//function removeAttachmentWrapper(){
//jio_instance.removeAttachment({
//"_id": "my_1st_document",
//"_attachment": '99rd_Attachment_manual'
//}, function(err,response){
//console.log(response);
//});
//};
//jio_instance.remove({"_id":"documentONE","title":"doc1"}, function(err,response){
//console.log('REMOVE response : '+ response);
//});
//Sera utile plus tard
jioform.on('change',function(){
textTitle = jioform.find('input[type="text"]').val();
textContent = jioform.find('textarea').val();
});
//Ajout de l'attachment
submitButton.on('click',function(){
//console.log("putAttachment");
if (textTitle == ''){
alert("Veuillez donner un titre pour l'attachment.");
}
else {
jio_instance.putAttachment({
"_id": "documentONE",
"_attachment": textTitle,
"_data": textContent,
"_mimetype": "text/plain"
}, function (err, response) {
console.log('Put Attachment response :'+JSON.stringify(response));
});
}
});
alldocsButton.on('click',function(){
//console.log("alldocs");
jio_instance.allDocs({"include_docs": true},function (err, response){
console.log(JSON.stringify(response));
console.log(response);
var doc_keys = $(response.rows);
//console.log(doc_keys.length);
doc_keys.each(function(index){
var that = $(this);
var filename = that[0]["id"];
//console.log(filename);
var DOCAttachment = that[0]["doc"]["_attachments"];
//console.log(DOCAttachment);
if (DOCAttachment == undefined){
//n'a pas d'attachment
alldocsContent.append('<a alt="click to remove" title="click to remove" href="#" rel="'+filename+'">'+filename+'</a><br>');
}
else {
for ( property in that[0]["doc"]) {
//console.log( property ); // Outputs: foo, fiz or fiz, foo
}
var names = '';
names += '<a alt="click to remove" title="click to remove" href="#" rel="'+filename+'">'+filename+'</a><br>';
for(var key in DOCAttachment) {
if(DOCAttachment.hasOwnProperty(key)) {
//names += '<a alt="click to remove" title="click to remove" type="attachment" href="#" rel="'+filename+'/'+key+'">'+filename+'/'+key+'</a><br>';
}
}
// console.log(names.join(', ')); //a, b
//console.log(names);
alldocsContent.append(names);
//console.log(DOCAttachment);
}
//alldocsContent.append('<a alt="click to remove" title="click to remove" href="#" rel="'+filename+'">'+filename+'</a><br>');
});
alldocsContent.html(JSON.stringify(response));
//addRemove();
});
});
function addRemove(){
var linksToRemove = alldocsContent.find('a');
//console.log(linksToRemove);
linksToRemove.on('click',function(){
var that = $(this);
console.log(that.attr('type'));
if (that.attr('type') !== 'attachment'){
var docID = that.text();
jio_instance.remove({"_id": docID},function(err, response){
console.log(err);
console.log(response);
});
}
else {
var docID = that.text();
var splitDoc = docID.split('/');
jio_instance.removeAttachment({"_id": splitDoc[0], "_attachment": splitDoc[1]},function(err, response){
console.log(err);
console.log(response);
});
}
})
};
//function addRemove(){
//var linksToRemove = alldocsContent.find('a');
////console.log(linksToRemove);
//linksToRemove.on('click',function(){
//var that = $(this);
//console.log(that.attr('type'));
//if (that.attr('type') == 'attachment'){
//var docID = that.text();
//jio_instance.remove({"_id": docID},function(){});
//}
//else {
//var docID = that.text();
//jio_instance.removeAttachment({"_id": "my_document", "_attachment": "its_attachment"},function(){});
//}
//
//})
//};
/*fin document ready*/
});
</script>
</body>
</html>
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;
}
}
/*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
* in FIPS PUB 180-1
* Version 2.1a Copyright Paul Johnston 2000 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for details.
*/
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
*/
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
var b64pad = "="; /* base-64 pad character. "=" for strict RFC compliance */
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}
function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}
function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}
function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}
function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}
function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}
/*
* Perform a simple self-test to see if the VM is working
*/
function sha1_vm_test()
{
return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d";
}
/*
* Calculate the SHA-1 of an array of big-endian words, and a bit length
*/
function core_sha1(x, len)
{
/* append padding */
x[len >> 5] |= 0x80 << (24 - len % 32);
x[((len + 64 >> 9) << 4) + 15] = len;
var w = Array(80);
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
var e = -1009589776;
for(var i = 0; i < x.length; i += 16)
{
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
var olde = e;
for(var j = 0; j < 80; j++)
{
if(j < 16) w[j] = x[i + j];
else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),
safe_add(safe_add(e, w[j]), sha1_kt(j)));
e = d;
d = c;
c = rol(b, 30);
b = a;
a = t;
}
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
e = safe_add(e, olde);
}
return Array(a, b, c, d, e);
}
/*
* Perform the appropriate triplet combination function for the current
* iteration
*/
function sha1_ft(t, b, c, d)
{
if(t < 20) return (b & c) | ((~b) & d);
if(t < 40) return b ^ c ^ d;
if(t < 60) return (b & c) | (b & d) | (c & d);
return b ^ c ^ d;
}
/*
* Determine the appropriate additive constant for the current iteration
*/
function sha1_kt(t)
{
return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
(t < 60) ? -1894007588 : -899497514;
}
/*
* Calculate the HMAC-SHA1 of a key and some data
*/
function core_hmac_sha1(key, data)
{
var bkey = str2binb(key);
if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz);
var ipad = Array(16), opad = Array(16);
for(var i = 0; i < 16; i++)
{
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
return core_sha1(opad.concat(hash), 512 + 160);
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function rol(num, cnt)
{
return (num << cnt) | (num >>> (32 - cnt));
}
/*
* Convert an 8-bit or 16-bit string to an array of big-endian words
* In 8-bit function, characters >255 have their hi-byte silently ignored.
*/
function str2binb(str)
{
var bin = Array();
var mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz)
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32);
return bin;
}
/*
* Convert an array of big-endian words to a string
*/
function binb2str(bin)
{
var str = "";
var mask = (1 << chrsz) - 1;
for(var i = 0; i < bin.length * 32; i += chrsz)
str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask);
return str;
}
/*
* Convert an array of big-endian words to a hex string.
*/
function binb2hex(binarray)
{
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for(var i = 0; i < binarray.length * 4; i++)
{
str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF);
}
return str;
}
/*
* Convert an array of big-endian words to a base-64 string
*/
function binb2b64(binarray)
{
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var str = "";
for(var i = 0; i < binarray.length * 4; i += 3)
{
var triplet = (((binarray[i >> 2] >> 8 * (3 - i %4)) & 0xFF) << 16)
| (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 )
| ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF);
for(var j = 0; j < 4; j++)
{
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
}
}
return str;
}
\ No newline at end of file
This diff is collapsed.
/**
* QUnit v1.5.0 - A JavaScript Unit Testing Framework
* QUnit v1.11.0 - A JavaScript Unit Testing Framework
*
* http://docs.jquery.com/QUnit
* http://qunitjs.com
*
* Copyright (c) 2012 John Resig, Jörn Zaefferer
* Dual licensed under the MIT (MIT-LICENSE.txt)
* or GPL (GPL-LICENSE.txt) licenses.
* Copyright 2012 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*/
/** Font Family and Sizes */
......@@ -20,7 +20,7 @@
/** Resets */
#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
#qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
margin: 0;
padding: 0;
}
......@@ -38,10 +38,10 @@
line-height: 1em;
font-weight: normal;
border-radius: 15px 15px 0 0;
-moz-border-radius: 15px 15px 0 0;
-webkit-border-top-right-radius: 15px;
-webkit-border-top-left-radius: 15px;
border-radius: 5px 5px 0 0;
-moz-border-radius: 5px 5px 0 0;
-webkit-border-top-right-radius: 5px;
-webkit-border-top-left-radius: 5px;
}
#qunit-header a {
......@@ -54,8 +54,9 @@
color: #fff;
}
#qunit-header label {
#qunit-testrunner-toolbar label {
display: inline-block;
padding: 0 .5em 0 .1em;
}
#qunit-banner {
......@@ -66,6 +67,7 @@
padding: 0.5em 0 0.5em 2em;
color: #5E740B;
background-color: #eee;
overflow: hidden;
}
#qunit-userAgent {
......@@ -75,6 +77,9 @@
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
}
#qunit-modulefilter-container {
float: right;
}
/** Tests: Pass/Fail */
......@@ -106,19 +111,24 @@
color: #000;
}
#qunit-tests ol {
#qunit-tests li .runtime {
float: right;
font-size: smaller;
}
.qunit-assert-list {
margin-top: 0.5em;
padding: 0.5em;
background-color: #fff;
border-radius: 15px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
box-shadow: inset 0px 2px 13px #999;
-moz-box-shadow: inset 0px 2px 13px #999;
-webkit-box-shadow: inset 0px 2px 13px #999;
.qunit-collapsed {
display: none;
}
#qunit-tests table {
......@@ -161,8 +171,7 @@
#qunit-tests b.failed { color: #710909; }
#qunit-tests li li {
margin: 0.5em;
padding: 0.4em 0.5em 0.4em 0.5em;
padding: 5px;
background-color: #fff;
border-bottom: none;
list-style-position: inside;
......@@ -171,9 +180,9 @@
/*** Passing Styles */
#qunit-tests li li.pass {
color: #5E740B;
color: #3c510c;
background-color: #fff;
border-left: 26px solid #C6E746;
border-left: 10px solid #C6E746;
}
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
......@@ -189,15 +198,15 @@
#qunit-tests li li.fail {
color: #710909;
background-color: #fff;
border-left: 26px solid #EE5757;
border-left: 10px solid #EE5757;
white-space: pre;
}
#qunit-tests > li:last-child {
border-radius: 0 0 15px 15px;
-moz-border-radius: 0 0 15px 15px;
-webkit-border-bottom-right-radius: 15px;
-webkit-border-bottom-left-radius: 15px;
border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
-webkit-border-bottom-right-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
}
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
......
This diff is collapsed.
This diff is collapsed.
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
import os
from setuptools import setup, find_packages
setup(
name = "test_launcher_for_jio",
version = "0.0.4",
author = "Sebastien Robin",
author_email = "andrewjcarter@gmail.com",
description = ("only launch jio test."),
license = "GPL",
keywords = "jio test",
url = "http://j-io.org",
packages=['test_launcher_for_jio', 'test_launcher_for_jio.tests'],
long_description="",
classifiers=[
"Development Status :: 3 - Alpha",
"Topic :: Utilities",
"License :: OSI Approved :: GPL License",
],
test_suite='test_launcher_for_jio.tests',
)
\ No newline at end of file
This diff is collapsed.
auto: grunt
check-syntax: grunt
grunt:
make -C ../../grunt/*_gruntJIOStorage > /dev/null 2>&1
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/**
* Adds 6 storages to JIO.
* - LocalStorage ('local')
* - DAVStorage ('dav')
* - ReplicateStorage ('replicate')
* - IndexedStorage ('indexed')
* - CryptedStorage ('crypted')
* - ConflictManagerStorage ('conflictmanager')
*
* @module JIOStorages
*/
(function(LocalOrCookieStorage, $, Base64, sjcl, hex_sha256, jIO) {
This diff is collapsed.
}( LocalOrCookieStorage, jQuery, Base64, sjcl, hex_sha256, jIO ));
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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