Commit 4fb5516e authored by Tristan Cavelier's avatar Tristan Cavelier

make old storages pass jslint

parent 21fc131a
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */ /*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*global jIO: true, sjcl: true, $: true, setTimeout: true */ /*global jIO: true, sjcl: true, $: true, setTimeout: true */
jIO.addStorageType('crypt', function (spec, my) { jIO.addStorageType('crypt', function (spec, my) {
/*jslint todo: true*/
spec = spec || {}; spec = spec || {};
var that = my.basicStorage(spec, my), var that = my.basicStorage(spec, my),
priv = {}, priv = {},
...@@ -80,7 +81,9 @@ jIO.addStorageType('crypt', function (spec, my) { ...@@ -80,7 +81,9 @@ jIO.addStorageType('crypt', function (spec, my) {
obj._wait = obj._wait || {}; obj._wait = obj._wait || {};
if (obj._wait[function_name]) { if (obj._wait[function_name]) {
obj._wait[function_name] -= 1; obj._wait[function_name] -= 1;
return function () {}; return function () {
return;
};
} }
// ok if undef or 0 // ok if undef or 0
arglist = arglist || []; arglist = arglist || [];
...@@ -97,7 +100,9 @@ jIO.addStorageType('crypt', function (spec, my) { ...@@ -97,7 +100,9 @@ jIO.addStorageType('crypt', function (spec, my) {
obj._wait[function_name] = times; obj._wait[function_name] = times;
}; };
async.end = function () { async.end = function () {
async.call = function () {}; async.call = function () {
return;
};
}; };
return async; return async;
}; };
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
var b64_hmac_sha1 = sha1.b64_hmac_sha1; var b64_hmac_sha1 = sha1.b64_hmac_sha1;
jIO.addStorageType("s3", function (spec, my) { jIO.addStorageType("s3", function (spec, my) {
var evt, that, priv = {}; var that, priv = {};
spec = spec || {}; spec = spec || {};
that = my.basicStorage(spec, my); that = my.basicStorage(spec, my);
...@@ -258,10 +258,10 @@ ...@@ -258,10 +258,10 @@
that.encodePolicy = function (form) { that.encodePolicy = function () {
//generates the policy //generates the policy
//enables the choice for the http response code //enables the choice for the http response code
var http_code, s3_policy, Signature = ''; var s3_policy;
s3_policy = { s3_policy = {
"expiration": "2020-01-01T00:00:00Z", "expiration": "2020-01-01T00:00:00Z",
"conditions": [ "conditions": [
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
["starts-with", "$key", ""], ["starts-with", "$key", ""],
{"acl": priv.acl }, {"acl": priv.acl },
{"success_action_redirect": ""}, {"success_action_redirect": ""},
{"success_action_status": http_code }, {"success_action_status": undefined }, // http_code
["starts-with", "$Content-Type", ""], ["starts-with", "$Content-Type", ""],
["content-length-range", 0, 524288000] ["content-length-range", 0, 524288000]
] ]
...@@ -280,7 +280,7 @@ ...@@ -280,7 +280,7 @@
priv.b64_policy = btoa(JSON.stringify(s3_policy)); priv.b64_policy = btoa(JSON.stringify(s3_policy));
//generates the signature value using the policy and the secret access key //generates the signature value using the policy and the secret access key
//use of sha1.js to generate the signature //use of sha1.js to generate the signature
Signature = that.signature(priv.b64_policy); //Signature = that.signature(priv.b64_policy);
}; };
...@@ -407,6 +407,7 @@ ...@@ -407,6 +407,7 @@
} }
priv.updateMeta = function (doc, docid, attachid, action, data) { priv.updateMeta = function (doc, docid, attachid, action, data) {
/*jslint unparam: true */
doc._attachments = doc._attachments || {}; doc._attachments = doc._attachments || {};
switch (action) { switch (action) {
case "add": case "add":
...@@ -453,7 +454,7 @@ ...@@ -453,7 +454,7 @@
return error; return error;
}; };
that.encodeAuthorization = function (key, mime) { that.encodeAuthorization = function (key) {
//GET oriented method //GET oriented method
var requestUTC, httpVerb, StringToSign, Signature; var requestUTC, httpVerb, StringToSign, Signature;
requestUTC = new Date().toUTCString(); requestUTC = new Date().toUTCString();
...@@ -670,7 +671,6 @@ ...@@ -670,7 +671,6 @@
docId, docId,
attachId, attachId,
mime, mime,
attachment_id,
attachment_data, attachment_data,
attachment_md5, attachment_md5,
attachment_mimetype, attachment_mimetype,
...@@ -682,7 +682,7 @@ ...@@ -682,7 +682,7 @@
mime = 'text/plain; charset=UTF-8'; mime = 'text/plain; charset=UTF-8';
//récupération des variables de l'attachement //récupération des variables de l'attachement
attachment_id = command.getAttachmentId(); //attachment_id = command.getAttachmentId();
attachment_data = command.getAttachmentData(); attachment_data = command.getAttachmentData();
attachment_md5 = command.md5SumAttachmentData(); attachment_md5 = command.md5SumAttachmentData();
attachment_mimetype = command.getAttachmentMimeType(); attachment_mimetype = command.getAttachmentMimeType();
...@@ -697,7 +697,7 @@ ...@@ -697,7 +697,7 @@
attachment_data, attachment_data,
false, false,
true, true,
function (reponse) { function () {
that.success({ that.success({
// response // response
"ok": true, "ok": true,
...@@ -722,7 +722,7 @@ ...@@ -722,7 +722,7 @@
doc = priv.updateMeta(data, docId, attachId, "add", attachment_obj); doc = priv.updateMeta(data, docId, attachId, "add", attachment_obj);
that.XHRwrapper(command, docId, '', 'PUT', mime, doc, false, false, that.XHRwrapper(command, docId, '', 'PUT', mime, doc, false, false,
function (reponse) { function () {
putAttachment(); putAttachment();
} }
); );
...@@ -760,7 +760,7 @@ ...@@ -760,7 +760,7 @@
function deleteDocument() { function deleteDocument() {
that.XHRwrapper(command, docId, '', 'DELETE', mime, '', true, false, that.XHRwrapper(command, docId, '', 'DELETE', mime, '', true, false,
function (reponse) { function () {
that.success({ that.success({
// response // response
"ok": true, "ok": true,
...@@ -771,7 +771,8 @@ ...@@ -771,7 +771,8 @@
); );
} }
function myCallback(response) { function myCallback() {
return;
} }
that.XHRwrapper(command, docId, '', 'GET', mime, '', false, false, that.XHRwrapper(command, docId, '', 'GET', mime, '', false, false,
...@@ -801,12 +802,7 @@ ...@@ -801,12 +802,7 @@
var mon_document, var mon_document,
docId, docId,
attachId, attachId,
mime, mime;
attachment_id,
attachment_data,
attachment_md5,
attachment_mimetype,
attachment_length;
mon_document = null; mon_document = null;
docId = command.getDocId(); docId = command.getDocId();
...@@ -814,17 +810,17 @@ ...@@ -814,17 +810,17 @@
mime = 'text/plain; charset=UTF-8'; mime = 'text/plain; charset=UTF-8';
//récupération des variables de l'attachement //récupération des variables de l'attachement
attachment_id = command.getAttachmentId(); // attachment_id = command.getAttachmentId();
attachment_data = command.getAttachmentData(); // attachment_data = command.getAttachmentData();
attachment_md5 = command.md5SumAttachmentData(); // attachment_md5 = command.md5SumAttachmentData();
attachment_mimetype = command.getAttachmentMimeType(); // attachment_mimetype = command.getAttachmentMimeType();
attachment_length = command.getAttachmentLength(); // attachment_length = command.getAttachmentLength();
function removeAttachment() { function removeAttachment() {
that.XHRwrapper(command, docId, attachId, 'DELETE', mime, '', true, that.XHRwrapper(command, docId, attachId, 'DELETE', mime, '', true,
true, function (reponse) { true, function () {
} return;
); });
} }
function putDocument() { function putDocument() {
...@@ -832,10 +828,9 @@ ...@@ -832,10 +828,9 @@
data = JSON.parse(mon_document); data = JSON.parse(mon_document);
doc = priv.updateMeta(data, docId, attachId, "remove", ''); doc = priv.updateMeta(data, docId, attachId, "remove", '');
that.XHRwrapper(command, docId, '', 'PUT', mime, doc, that.XHRwrapper(command, docId, '', 'PUT', mime, doc,
false, false, function (reponse) { false, false, function () {
removeAttachment(); removeAttachment();
} });
);
} }
function getDocument() { function getDocument() {
...@@ -873,16 +868,14 @@ ...@@ -873,16 +868,14 @@
keyId, keyId,
Signature, Signature,
callURL, callURL,
requestUTC, requestUTC;
parse,
checkCounter;
keys = $(mon_document).find('Key'); keys = $(mon_document).find('Key');
resultTable = []; resultTable = [];
counter = 0; counter = 0;
keys.each(function (index) { keys.each(function () {
var that, filename, docId; var that, filename, docId;
that = $(this); that = $(this);
filename = that.context.textContent; filename = that.context.textContent;
...@@ -908,6 +901,7 @@ ...@@ -908,6 +901,7 @@
countB = 0; countB = 0;
dealCallback = function (i, countB, allDoc) { dealCallback = function (i, countB, allDoc) {
/*jslint unparam: true */
return function (doc, statustext, response) { return function (doc, statustext, response) {
allDoc.rows[i].doc = response.responseText; allDoc.rows[i].doc = response.responseText;
if (count === 0) { if (count === 0) {
...@@ -941,14 +935,12 @@ ...@@ -941,14 +935,12 @@
Signature = that.encodeAuthorization(keyId); Signature = that.encodeAuthorization(keyId);
callURL = 'http://' + priv.server + '.s3.amazonaws.com/' + keyId; callURL = 'http://' + priv.server + '.s3.amazonaws.com/' + keyId;
requestUTC = new Date().toUTCString(); requestUTC = new Date().toUTCString();
parse = true;
allDocResponse.rows[i] = { allDocResponse.rows[i] = {
"id": priv.fileNameToIds(keyId).join(), "id": priv.fileNameToIds(keyId).join(),
"key": keyId, "key": keyId,
"value": {} "value": {}
}; };
checkCounter = i;
$.ajax({ $.ajax({
contentType : '', contentType : '',
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
XMLHttpRequest: true, XMLHttpRequest: true,
Blob: true, Blob: true,
FormData: true, FormData: true,
window: true window: true,
setTimeout: true
*/ */
/** /**
* JIO XWiki Storage. Type = 'xwiki'. * JIO XWiki Storage. Type = 'xwiki'.
...@@ -86,7 +87,7 @@ ...@@ -86,7 +87,7 @@
priv.xwikiurl + "]", priv.xwikiurl + "]",
"reason": cause "reason": cause
}); });
}, }
}); });
}; };
...@@ -125,7 +126,7 @@ ...@@ -125,7 +126,7 @@
}; };
priv.isBlob = function (potentialBlob) { priv.isBlob = function (potentialBlob) {
return typeof (potentialBlob) !== 'undefined' && return potentialBlob !== undefined &&
potentialBlob.toString() === "[object Blob]"; potentialBlob.toString() === "[object Blob]";
}; };
...@@ -225,7 +226,7 @@ ...@@ -225,7 +226,7 @@
xhr.responseType = 'text'; xhr.responseType = 'text';
} }
xhr.onload = function (e) { xhr.onload = function () {
if (xhr.status === 200) { if (xhr.status === 200) {
var contentType = xhr.getResponseHeader("Content-Type"); var contentType = xhr.getResponseHeader("Content-Type");
if (contentType.indexOf(';') > -1) { if (contentType.indexOf(';') > -1) {
...@@ -327,7 +328,7 @@ ...@@ -327,7 +328,7 @@
xhr = new XMLHttpRequest(); xhr = new XMLHttpRequest();
xhr.open('POST', priv.xwikiurl + "/bin/upload/" + xhr.open('POST', priv.xwikiurl + "/bin/upload/" +
parts.space + '/' + parts.page, true); parts.space + '/' + parts.page, true);
xhr.onload = function (e) { xhr.onload = function () {
if (xhr.status === 302 || xhr.status === 200) { if (xhr.status === 302 || xhr.status === 200) {
andThen(null); andThen(null);
} else { } else {
...@@ -490,7 +491,7 @@ ...@@ -490,7 +491,7 @@
return { return {
"username": priv.username, "username": priv.username,
"language": priv.language, "language": priv.language,
"xwikiurl": priv.xwikiurl, "xwikiurl": priv.xwikiurl
}; };
}; };
...@@ -666,16 +667,16 @@ ...@@ -666,16 +667,16 @@
* @param {object} command The JIO command * @param {object} command The JIO command
*/ */
that.remove = that.removeAttachment = function (command) { that.remove = that.removeAttachment = function (command) {
var notFoundError, objId, complete; var objId, complete;
notFoundError = function (word) { // notFoundError = function (word) {
that.error({ // that.error({
"status": 404, // "status": 404,
"statusText": "Not Found", // "statusText": "Not Found",
"error": "not_found", // "error": "not_found",
"message": word + " not found", // "message": word + " not found",
"reason": "missing" // "reason": "missing"
}); // });
}; // };
objId = command.getDocId(); objId = command.getDocId();
complete = function (err) { complete = function (err) {
...@@ -718,7 +719,7 @@ ...@@ -718,7 +719,7 @@
return that; return that;
}; };
if (typeof (define) === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
define(['jquery', 'jio'], function (jquery, jIO) { define(['jquery', 'jio'], function (jquery, jIO) {
$ = jquery; $ = jquery;
jIO.addStorageType('xwiki', store); jIO.addStorageType('xwiki', store);
......
/*jslint indent: 2, maxlen: 80, nomen: true */ /*jslint indent: 2, maxlen: 80, nomen: true */
/*global define, jIO, jio_tests, hex_sha256, test, ok, deepEqual, sinon, /*global define, jIO, jio_tests, hex_sha256, test, ok, deepEqual, sinon,
expect */ expect, module */
// define([module_name], [dependencies], module); // define([module_name], [dependencies], module);
(function (dependencies, module) { (function (dependencies, module) {
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
module("Replicate Revision Storage"); module("Replicate Revision Storage");
var testReplicateRevisionStorage = function (sinon, jio_description) { var testReplicateRevisionStorage = function (sinon, jio_description) {
/*jslint unparam: true */
var o = generateTools(), leavesAction, generateLocalPath; var o = generateTools(), leavesAction, generateLocalPath;
...@@ -778,6 +779,7 @@ ...@@ -778,6 +779,7 @@
description, description,
index index
) { ) {
/*jslint unparam: true */
var o = generateTools(); var o = generateTools();
o.jio = jIO.newJio(description); o.jio = jIO.newJio(description);
...@@ -792,7 +794,7 @@ ...@@ -792,7 +794,7 @@
"children": [{ "children": [{
"rev": "1-111", "rev": "1-111",
"status": "available", "status": "available",
"children": [], "children": []
}] }]
}; };
o.doc1_1 = {"_id": "doc1.1-111", "title": "A"}; o.doc1_1 = {"_id": "doc1.1-111", "title": "A"};
......
/*jslint indent: 2, maxlen: 80, nomen: true */ /*jslint indent: 2, maxlen: 80, nomen: true */
/*global define, jIO, jio_tests, window, test, ok, deepEqual, sinon, expect */ /*global define, jIO, jio_tests, window, test, ok, deepEqual, sinon, expect,
module */
// define([module_name], [dependencies], module); // define([module_name], [dependencies], module);
(function (dependencies, module) { (function (dependencies, module) {
......
/*jslint indent: 2, maxlen: 80, nomen: true */ /*jslint indent: 2, maxlen: 80, nomen: true */
/*global define, jIO, jio_tests, test, ok, deepEqual, sinon */ /*global define, jIO, jio_tests, test, ok, deepEqual, sinon, module */
// define([module_name], [dependencies], module); // define([module_name], [dependencies], module);
(function (dependencies, module) { (function (dependencies, module) {
......
/*jslint indent: 2, maxlen: 80, nomen: true */ /*jslint indent: 2, maxlen: 80, nomen: true */
/*global define, jIO, jio_tests, test, ok, sinon */ /*global define, jIO, jio_tests, test, ok, sinon, module */
// define([module_name], [dependencies], module); // define([module_name], [dependencies], module);
(function (dependencies, module) { (function (dependencies, module) {
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
tick: util.otick tick: util.otick
}; };
function addFakeServerResponse(type, method, path, status, response) { function addFakeServerResponse(type, method, path, status, response) {
/*jslint unparam: true */
o.server.respondWith(method, new RegExp(path), [ o.server.respondWith(method, new RegExp(path), [
status, status,
{"Content-Type": 'application/xml'}, {"Content-Type": 'application/xml'},
...@@ -30,7 +31,7 @@ ...@@ -30,7 +31,7 @@
module('XWikiStorage'); module('XWikiStorage');
function setUp(that, liveTest) { function setUp(that) {
var o = generateTools(that); var o = generateTools(that);
o.server = sinon.fakeServer.create(); o.server = sinon.fakeServer.create();
o.jio = jIO.newJio({type: 'xwiki', formTokenPath: 'form_token'}); o.jio = jIO.newJio({type: 'xwiki', formTokenPath: 'form_token'});
......
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