Commit f6d1f243 authored by Tristan Cavelier's avatar Tristan Cavelier Committed by Sebastien Robin

Redesigning file tree.

parent b2fba5af
div.gadget-action div.front_pad {
font-size: 10px;
}
div.draggable_wrapper {
background-color: #FFFFFF;
}
#gadget_area_wrapper {
margin-top: 0.5em;
}
div#pad-navigation-wrapper {
border: 0 none !important;
}
#pad-navigation-wrapper {
border-bottom: 1px solid #3D6474;
height: 38px;
margin-top: 10px;
width: 96%;
}
/* tabs */
#tabs_switcher {
background: none repeat scroll 0 0 transparent;
border-style: none;
cursor: pointer;
float: left;
font-weight: bold;
margin: 0;
padding-top: 5px;
width: 10%;
}
div#tabs, div#pad-navigation-wrapper div#tabs_switcher.tab {
display: none !important;
}
#tabs {
float: left;
padding-left: 0;
width: 78%;
}
#tabs ul {
list-style: none outside none;
margin: 0;
padding: 0;
width: 100%;
}
li.tab_selected {
background-color: #DAE6F6;
border-bottom: 1px solid #DAE6F6;
font-weight: bold;
}
li.tab {
background-color: #BDD0F0;
border: 1px solid #3D6474;
cursor: pointer;
display: block;
float: left;
font-size: 12px;
height: 24px;
margin-right: 1px;
padding-right: 5px;
}
#tabs li span {
display: block;
float: left;
height: 19px;
padding: 5px 10px 0;
}
div.pad-actions {
float: left;
}
#tabs li span.rename_tab_dialog_image {
background: url("../img/officejs/icon_edit.gif") no-repeat scroll 0 0 transparent;
padding-right: 6px;
}
#tabs li span.remove_tab_dialog_image {
background: url("../img/officejs/icon_remove.gif") no-repeat scroll 0 0 transparent;
padding-right: 6px;
}
#add_new_tab_dialog_link {
background: none repeat scroll 0 0 transparent;
border-style: none;
cursor: pointer;
display: block;
float: left;
font-weight: bold;
height: 19px;
margin-left: 5px;
padding-left: 5px;
padding-top: 5px;
}
span.clickable_image {
cursor: pointer;
display: block;
float: left;
margin-top: 5px;
}
div#add_new_gadget_link {
border-bottom: 0 none;
padding-top: 5px;
width: 50% !important;
float: right;
font-weight: bold;
height: 20px;
padding-top: 5px;
text-align: right;
}
#add-gadgets {
cursor: pointer;
font-size: 11px;
}
#loading-wrapper {
background-color: #FFFFFF;
left: 50%;
margin-left: -150px;
padding: 7px 0 0;
position: absolute;
text-align: center;
top: 80px;
width: 250px;
z-index: 1000;
}
#loading-wrapper p {
font-size: 90%;
font-weight: bold;
}
div.front_pad div#page_wrapper {
margin: -0.5em 0 0 !important;
}
#page_wrapper {
background-color: inherit;
float: left;
margin: 0.5em 0 0;
padding: 0;
text-align: left;
width: 100%;
}
div.portal-column {
float: left;
margin-right: 3px;
width: 100% !important;
}
div.block {
margin: 1px 1px 3px;
padding: 0;
width: 100%;
}
span.handle, h3.handle {
cursor: move;
}
h3.handle {
background: url("../img/officejs/tab_left_selected.png") no-repeat scroll left top transparent;
border-bottom: 1px solid #3D6474;
color: #FFFFFF;
font-size: 14px;
margin: 0;
padding: 0 0 0 10px;
}
/*h3.handle {
background: none repeat scroll 0 0 white !important;
border-bottom: 0 none !important;
color: #222222 !important;
font-size: 13px !important;
}*/
h3.handle span.handle {
background: url("../img/officejs/tab_right_selected.png") no-repeat scroll right top transparent;
display: block;
min-height: 20px;
padding: 5px 5px 0 0;
}
/*h3.handle span.handle {
background: none repeat scroll 0 0 white !important;
}*/
a.block-remove {
background-image: url("../img/officejs/icon_remove.gif");
}
a.block-edit-form {
background-image: url("../img/officejs/icon_edit.png") !important;
}
a.block-minimize {
background-image: url("../img/officejs/icon_minimize.png") !important;
}
a.clickable-block {
background-position: center center;
background-repeat: no-repeat;
cursor: pointer;
display: block;
float: right;
height: 15px;
margin: 0;
padding: 0;
width: 15px;
}
div.block h3 span.gadget_title {
min-width: 100px;
}
div.edit-form {
-moz-border-bottom-colors: none;
-moz-border-image: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
background-color: #BDD0F0;
border-color: black;
border-style: solid;
border-width: 0 1px 1px;
overflow: auto;
padding-bottom: 0.5em;
padding-left: 1em;
padding-top: 0.5em;
width: auto;
height: 176px !important;
background-color: #FFFFFF !important;
border: 0 none !important;
padding-left: 0 !important;
}
div#page_wrapper div.minimize_wrapper div.edit-form fieldset.left, div#page_wrapper div.minimize_wrapper div.edit-form fieldset.left label {
display: inline !important;
}
div.edit-form fieldset {
border: 0 solid black;
}
div.block div.input {
margin-left: 0;
}
div.edit-form button {
margin-top: 0.5em;
margin-top: -0.3em !important;
}
div.block div.content {
padding: 0;
border-bottom: 1px solid #DDDDDD !important;
border-top: 0 none !important;
background: none repeat scroll 0 0 #DAE6F6;
border-bottom: 4px solid #BBCCFF;
border-top: 4px solid #BBCCFF;
background-color: #FFFFFF;
clear: left;
overflow: visible;
padding: 0.1em;
}
div.block table, div.block table tr, div.block table tr td {
border: medium none;
}
.ig_tbl_img table, .ig_tbl_img tr, .ig_tbl_img td, .ig_tbl_img a, .ig_tbl_img span, .ig_tbl_line table, .ig_tbl_line tr, .ig_tbl_line td, .ig_tbl_line a, .ig_tbl_line span, ig_reset {
background: none repeat scroll 0 50% transparent;
border: 0 none;
border-collapse: collapse;
bottom: auto;
clear: none;
float: none;
font-family: arial,sans-serif;
font-style: normal;
font-variant: normal;
height: auto;
letter-spacing: normal;
line-height: 1;
margin: 0;
padding: 0;
text-indent: 0;
text-transform: none;
top: auto;
vertical-align: middle;
white-space: normal;
width: auto;
word-spacing: normal;
}
div.toggable_dialog {
background-color: #97B0D1;
border: 5px solid #BDD0F0;
display: none;
left: 400px;
padding: 0 1em 0.5em;
position: absolute;
top: 75px;
z-index: 10000;
}
body {
background-color: white;
margin: 0;
padding: 0;
}
header {
background-color: #DDDDFF;
height: 50px;
padding-left: 30px;
padding-right: 30px;
}
aside {
float: right;
}
nav#header_navbar li {
display: inline;
list-style: none outside none;
margin-left: 30px;
}
nav#left_navbar {
background-color: #DDDDDD;
display: inline-block;
width: 15%;
}
.nav_header
{
font-style: italic;
list-style: none outside none;
}
section {
display: inline-block;
margin: 0;
padding: 0;
vertical-align: top;
}
......@@ -31,9 +31,9 @@ module.exports = function(grunt) {
lint: {
files: ['grunt.js',
'../../src/<%= pkg.name %>.js',
'../../lib/jio/base64.requirejs_module.js',
'../../lib/jio/jio.dummystorages.js',
'../../lib/jio/jquery.requirejs_module.js',
'../../js/base64.requirejs_module.js',
'../../src/jio.dummystorages.js',
'../../js/jquery.requirejs_module.js',
'../../test/jiotests.js',
'../../test/jiotests.loader.js']
},
......
......@@ -3,12 +3,12 @@
<head>
<meta charset="utf-8" />
<litk rel="icon" href="img/officejs/favicon.png" />
<link rel="shortcut icon" href="img/officejs/favicon.png" />
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="shortcut icon" href="img/icons/favicon.png" />
<link rel="stylesheet" href="lib/bootstrap/css/bootstrap.min.css" />
<title>OfficeJS</title>
<!-- js scripts -->
<script type="text/javascript" src="lib/icanhaz/ICanHaz.min.js"></script>
<script data-main="script/loader"
<script data-main="js/officejs"
type="text/javascript"
src="lib/require/require.js"></script>
<!-- html scripts -->
......
......@@ -6,13 +6,13 @@ require.config ({
paths: {
LocalOrCookieStorage: '../lib/jio/localorcookiestorage.min',
jQueryAPI: '../lib/jquery/jquery',
jQuery: '../lib/jio/jquery.requirejs_module',
jQuery: '../js/jquery.requirejs_module',
JIO: '../src/jio',
Base64API: '../lib/base64/base64',
Base64: '../lib/jio/base64.requirejs_module',
Base64: '../js/base64.requirejs_module',
JIOStorages: '../lib/jio/jio.storage.min',
OfficeJS: '../script/officejs'
OfficeJS: 'moduleloader'
}
});
require(['OfficeJS'],function (OJS) {
......
......@@ -252,20 +252,27 @@ var JIO =
// options.useLocalStorage: if true, save jobs into localStorage,
// else only save on memory.
var that = {}, priv = {};
var that = {}, priv = {},
jioIdArrayName = 'jio/idArray';
that.init = function ( options ) {
// initialize the JobQueue
// options.publisher : is the publisher to use to send events
// options.jioID : the jio ID
var k, emptyfun = function (){};
var k, emptyfun = function (){},
jioIdArray = jioGlobalObj.localStorage.getItem (jioIdArrayName);
if (jioIdArray === null) {
jioIdArray = [];
}
if (options.publisher) {
priv.publisher = publisher;
}
priv.jioID = options.jioID;
priv.jobObjectName = 'jio/jobObject/'+options.jioID;
priv.jobObject = {};
jioIdArray.push (priv.jioID);
jioGlobalObj.localStorage.setItem (jioIdArrayName,jioIdArray);
that.copyJobQueueToLocalStorage();
for (k in priv.recoveredJobObject) {
priv.recoveredJobObject[k].callback = emptyfun;
......@@ -283,15 +290,12 @@ var JIO =
};
that.getNewQueueID = function () {
// Returns a new queueID
var localStorageObject = jioGlobalObj.localStorage.getAll(),
id = 0, k = 'key', splitk = ['splitedkey'];
for (k in localStorageObject) {
splitk = k.split('/');
if (splitk[0] === 'jio' &&
splitk[1] === 'id') {
if (JSON.parse(splitk[2]) >= jioGlobalObj.queueID) {
jioGlobalObj.queueID = JSON.parse(splitk[2]) + 1;
}
var k = null, id = 0,
jioIdArray = jioGlobalObj.localStorage.getItem (jioIdArrayName);
for (k in jioIdArray) {
if (jioIdArray[k] >= jioGlobalObj.queueID) {
jioGlobalObj.queueID = jioIdArray[k] + 1;
}
}
id = jioGlobalObj.queueID;
......@@ -301,24 +305,30 @@ var JIO =
that.recoverOlderJobObject = function () {
// recover job object from older inactive jio
var localStorageObject = jioGlobalObj.localStorage.getAll(),
k = 'key', splitk = ['splitedkey'];
for (k in localStorageObject) {
splitk = k.split('/');
if (splitk[0] === 'jio' &&
splitk[1] === 'id' ) {
if (localStorageObject[k] < Date.now() - 10000){
// 10 sec ? delete item
jioGlobalObj.localStorage.deleteItem(k);
// job recovery
priv.recoveredJobObject = jioGlobalObj.
localStorage.getItem('jio/jioObject/'+splitk[2]);
// remove ex job object
jioGlobalObj.localStorage.deleteItem(
'jio/jobObject/'+splitk[2]);
}
var k = null, newJioIdArray = [], jioIdArrayChanged = false,
jioIdArray = jioGlobalObj.localStorage.getItem (jioIdArrayName);
for (k in jioIdArray) {
if (jioGlobalObj.localStorage.getItem (
'jio/id/'+jioIdArray[k]) < Date.now () - 10000) {
// remove id from jioIdArray
// 10000 sec ? delete item
jioGlobalObj.localStorage.deleteItem('jio/id/'+
jioIdArray[k]);
// job recovery
priv.recoveredJobObject = jioGlobalObj.
localStorage.getItem('jio/jioObject/'+ jioIdArray[k]);
// remove ex job object
jioGlobalObj.localStorage.deleteItem(
'jio/jobObject/'+ jioIdArray[k]);
jioIdArrayChanged = true;
} else {
newJioIdArray.push (jioIdArray[k]);
}
}
if (jioIdArrayChanged) {
jioGlobalObj.localStorage.setItem(jioIdArrayName,newJioIdArray);
}
};
that.isThereJobsWhere = function( func ) {
// Check if there is jobs, in the queue,
......
/*! JIO - v0.1.0 - 2012-05-18
* Copyright (c) 2012 Nexedi; Licensed */
var JIO=function(){var a=function(a,b){var c={jobMethodObject:{checkNameAvailability:{start_event:"start_checkingNameAvailability",stop_event:"stop_checkingNameAvailability",retvalue:"isAvailable"},saveDocument:{start_event:"start_saving",stop_event:"stop_saving",retvalue:"isSaved"},loadDocument:{start_event:"start_loading",stop_event:"stop_loading",retvalue:"fileContent"},getDocumentList:{start_event:"start_gettingList",stop_event:"stop_gettingList",retvalue:"list"},removeDocument:{start_event:"start_removing",stop_event:"stop_removing",retvalue:"isRemoved"}}},d={jobManagingMethod:{canSelect:function(a,b){return JSON.stringify(a.storage)===JSON.stringify(b.storage)&&JSON.stringify(a.applicant)===JSON.stringify(b.applicant)&&a.fileName===b.fileName?!0:!1},canRemoveFailOrDone:function(a,b){return a.status==="fail"||a.status==="done"?!0:!1},canEliminate:function(a,b){return a.status!=="ongoing"&&(a.method==="removeDocument"&&b.method==="saveDocument"||a.method==="saveDocument"&&b.method==="removeDocument")?!0:!1},canReplace:function(a,b){return a.status!=="ongoing"&&a.method===b.method&&a.date<b.date?!0:!1},cannotAccept:function(a,b){if(a.status!=="ongoing"){if(a.method==="removeDocument"&&b.method==="loadDocument")return!0}else{if(a.method===b.method==="loadDocument")return!0;if(a.method==="removeDocument"&&(b.method==="loadDocument"||b.method==="removeDocument"))return!0;if(a.method===b.method==="saveDocument"&&a.fileContent===b.fileContent)return!0;if(a.method===b.method==="getDocumentList"||a.method===b.method==="checkNameAvailability")return!0}return!1},mustWait:function(a,b){return a.method==="getDocumentList"||a.method==="checkNameAvailability"||b.method==="getDocumentList"||b.method==="checkNameAvailability"?!1:!0}},localStorage:null,queueID:1,storageTypeObject:{}},e,f,g,h,i,j,k,l;return e=function(){var a={},c={},d={},e,f;return c.eventAction=function(a){return f=a&&d[a],f||(e=b.Callbacks(),f={publish:e.fire,subscribe:e.add,unsubscribe:e.remove},a&&(d[a]=f)),f},a.publish=function(a,b){c.eventAction(a).publish(b)},a.subscribe=function(a,b){return c.eventAction(a).subscribe(b),b},a.unsubscribe=function(a,b){c.eventAction(a).unsubscribe(b)},a},f=function(a){var c=b.extend({},a);return c.id=0,c.status="initial",c.date=Date.now(),c},g=function(a,e){var g={},h={};return g.init=function(b){var c,d=function(){};b.publisher&&(h.publisher=a),h.jioID=b.jioID,h.jobObjectName="jio/jobObject/"+b.jioID,h.jobObject={},g.copyJobQueueToLocalStorage();for(c in h.recoveredJobObject)h.recoveredJobObject[c].callback=d,g.addJob(h.recoveredJobObject[c])},g.close=function(){JSON.stringify(h.jobObject)==="{}"&&d.localStorage.deleteItem(h.jobObjectName)},g.getNewQueueID=function(){var a=d.localStorage.getAll(),b=0,c="key",e=["splitedkey"];for(c in a)e=c.split("/"),e[0]==="jio"&&e[1]==="id"&&JSON.parse(e[2])>=d.queueID&&(d.queueID=JSON.parse(e[2])+1);return b=d.queueID,d.queueID++,b},g.recoverOlderJobObject=function(){var a=d.localStorage.getAll(),b="key",c=["splitedkey"];for(b in a)c=b.split("/"),c[0]==="jio"&&c[1]==="id"&&a[b]<Date.now()-1e4&&(d.localStorage.deleteItem(b),h.recoveredJobObject=d.localStorage.getItem("jio/jioObject/"+c[2]),d.localStorage.deleteItem("jio/jobObject/"+c[2]))},g.isThereJobsWhere=function(a){var b="id";if(!a)return!0;for(b in h.jobObject)if(a(h.jobObject[b]))return!0;return!1},g.copyJobQueueToLocalStorage=function(){return h.useLocalStorage?d.localStorage.setItem(h.jobObjectName,h.jobObject):!1},g.createJob=function(a){return g.addJob(new f(a))},g.addJob=function(a){var b={newone:!0,elimArray:[],waitArray:[],removeArray:[]},c=null,e="id";for(e in h.jobObject){if(d.jobManagingMethod.canRemoveFailOrDone(h.jobObject[e],a)){b.removeArray.push(e);continue}if(d.jobManagingMethod.canSelect(h.jobObject[e],a)){if(d.jobManagingMethod.canEliminate(h.jobObject[e],a)){b.elimArray.push(e);continue}if(d.jobManagingMethod.canReplace(h.jobObject[e],a)){c=new j({queue:g,job:h.jobObject[e]}),c.replace(a),b.newone=!1;break}if(d.jobManagingMethod.cannotAccept(h.jobObject[e],a))return!1;if(d.jobManagingMethod.mustWait(h.jobObject[e],a)){b.waitArray.push(e);continue}}}if(b.newone){for(e in b.elimArray)c=new j({queue:g,job:h.jobObject[b.elimArray[e]]}),c.eliminate();if(b.waitArray.length>0){a.status="wait",a.waitingFor={jobIdArray:b.waitArray};for(e in b.waitArray)h.jobObject[b.waitArray[e]]&&(h.jobObject[b.waitArray[e]].maxtries=1)}for(e in b.removeArray)g.removeJob(h.jobObject[b.removeArray[e]]);a.id=h.jobid,a.tries=0,h.jobid++,h.jobObject[a.id]=a}return g.copyJobQueueToLocalStorage(),!0},g.removeJob=function(a){var c=b.extend({where:function(a){return!0}},a),d,e=!1,f="key";if(c.job)h.jobObject[c.job.id]&&c.where(h.jobObject[c.job.id])&&(delete h.jobObject[c.job.id],e=!0);else for(f in h.jobObject)c.where(h.jobObject[f])&&(delete h.jobObject[f],e=!0);e||b.error("No jobs was found, when trying to remove some."),g.copyJobQueueToLocalStorage()},g.resetAll=function(){var a="id";for(a in h.jobObject)h.jobObject[a].status="initial";g.copyJobQueueToLocalStorage()},g.invokeAll=function(){var a="id",b;for(a in h.jobObject){b=!1;if(h.jobObject[a].status==="initial")g.invoke(h.jobObject[a]);else if(h.jobObject[a].status==="wait"){b=!0;if(h.jobObject[a].waitingFor.jobIdArray)for(var c in h.jobObject[a].waitingFor.jobIdArray)if(h.jobObject[h.jobObject[a].waitingFor.jobIdArray[c]]){b=!1;break}h.jobObject[a].waitingFor.time&&h.jobObject[a].waitingFor.time>Date.now()&&(b=!1),b&&g.invoke(h.jobObject[a])}}this.copyJobQueueToLocalStorage()},g.invoke=function(a){var b;if(!c.jobMethodObject[a.method])return!1;g.isThereJobsWhere(function(b){return b.method===a.method&&b.method==="initial"})?a.status="ongoing":(a.status="ongoing",h.publisher.publish(c.jobMethodObject[a.method].start_event)),b=new j({queue:this,job:a}),b.execute()},g.ended=function(a){var d=b.extend({},a);g.removeJob({job:d});if(!c.jobMethodObject[d.method])return!1;if(!g.isThereJobsWhere(function(a){return a.method===d.method&&a.status==="ongoing"||a.status==="initial"})){h.publisher.publish(c.jobMethodObject[d.method].stop_event);return}},g.clean=function(){g.removeJob(undefined,{where:function(a){return a.status==="fail"}})},h.useLocalStorage=e.useLocalStorage,h.publisher=a,h.jobid=1,h.jioID=0,h.jobObjectName="",h.jobObject={},h.recoveredJobObject={},g},h=function(a){var b={},c={};return c.interval=200,c.id=null,c.queue=a,b.setIntervalDelay=function(a){c.interval=a},b.start=function(){return c.id?!1:(c.id=setInterval(function(){c.queue.recoverOlderJobObject(),c.queue.invokeAll()},c.interval),!0)},b.stop=function(){return c.id?(clearInterval(c.id),c.id=null,!0):!1},b},i=function(){var a={},b={};return b.interval=400,b.id=null,a.start=function(c){return b.id?!1:(a.touch(c),b.id=setInterval(function(){a.touch(c)},b.interval),!0)},a.stop=function(){return b.id?(clearInterval(b.id),b.id=null,!0):!1},a.touch=function(a){d.localStorage.setItem("jio/id/"+a,Date.now())},a},j=function(a){var c={},e={};return e.job=a.job,e.callback=a.job.callback,e.queue=a.queue,e.res={status:"done",message:""},e.fail_checkNameAvailability=function(){e.res.isAvailable=!1},e.done_checkNameAvailability=function(a){e.res.message=e.job.userName+" is "+(a?"":"not ")+"available.",e.res.isAvailable=a},e.fail_loadDocument=function(){e.res.document={}},e.done_loadDocument=function(a){e.res.message="Document loaded.",e.res.document=a,e.res.document.lastModified=(new Date(e.res.document.lastModified)).getTime(),e.res.document.creationDate=(new Date(e.res.document.creationDate)).getTime()},e.fail_saveDocument=function(){e.res.isSaved=!1},e.done_saveDocument=function(){e.res.message="Document saved.",e.res.isSaved=!0},e.fail_getDocumentList=function(){e.res.list=[]},e.done_getDocumentList=function(a){var b;e.res.message="Document list received.",e.res.list=a;for(b in e.res.list)e.res.list[b].lastModified=(new Date(e.res.list[b].lastModified)).getTime(),e.res.list[b].creationDate=(new Date(e.res.list[b].creationDate)).getTime()},e.fail_removeDocument=function(){e.res.isRemoved=!1},e.done_removeDocument=function(){e.res.message="Document removed.",e.res.isRemoved=!0},e.retryLater=function(){e.job.status="wait",e.job.waitingFor={time:Date.now()+e.job.tries*e.job.tries*1e3}},c.cloneJob=function(){return b.extend({},e.job)},c.getUserName=function(){return e.job.userName||""},c.getApplicantID=function(){return e.job.applicant.ID||""},c.getStorageUserName=function(){return e.job.storage.userName||""},c.getStoragePassword=function(){return e.job.storage.password||""},c.getStorageLocation=function(){return e.job.storage.location||""},c.getStorageArray=function(){return e.job.storage.storageArray||[]},c.getFileName=function(){return e.job.fileName||""},c.getFileContent=function(){return e.job.fileContent||""},c.cloneOptionObject=function(){return b.extend({},e.job.options)},c.getMaxTries=function(){return e.job.maxtries},c.getTries=function(){return e.job.tries||0},c.setMaxTries=function(a){e.job.maxtries=a},c.addJob=function(a){return e.queue.createJob(a)},c.eliminate=function(){e.job.maxtries=1,e.job.tries=1,c.fail("Job Stopped!",0)},c.replace=function(a){e.job.tries=0,e.job.date=a.date,e.job.callback=a.callback,e.res.status="fail",e.res.message="Job Stopped!",e.res.errno=0,e["fail_"+e.job.method](),e.callback(e.res)},c.fail=function(a,b){e.res.status="fail",e.res.message=a,e.res.errno=b,!e.job.maxtries||e.job.tries<e.job.maxtries?e.retryLater():(e.job.status="fail",e["fail_"+e.job.method](),e.queue.ended(e.job),e.callback(e.res))},c.done=function(a){e.job.status="done",e["done_"+e.job.method](a),e.queue.ended(e.job),e.callback(e.res)},c.execute=function(){return e.job.tries=c.getTries()+1,d.storageTypeObject[e.job.storage.type]?d.storageTypeObject[e.job.storage.type]({job:e.job,queue:e.queue})[e.job.method]():null},c.checkNameAvailability=function(){c.fail("This method must be redefined!",0)},c.loadDocument=function(){c.fail("This method must be redefined!",0)},c.saveDocument=function(){c.fail("This method must be redefined!",0)},c.getDocumentList=function(){c.fail("This method must be redefined!",0)},c.removeDocument=function(){c.fail("This method must be redefined!",0)},c},k=function(a,c,f){var j={},k={};j.getID=function(){return k.id},j.start=function(){return k.id!==0?!1:(k.id=k.queue.getNewQueueID(),k.queue.init({jioID:k.id}),k.updater&&k.updater.start(k.id),k.listener.start(),k.ready=!0,j.isReady())},j.stop=function(){return k.queue.close(),k.listener.stop(),k.updater&&k.updater.stop(),k.ready=!1,k.id=0,!0},j.kill=function(){return k.queue.close(),k.listener.stop(),k.updater&&k.updater.stop(),k.ready=!1,!0},j.isReady=function(){return k.ready},j.publish=function(a,b){if(!j.isReady())return;return k.pubsub.publish(a,b)},j.subscribe=function(a,b){return k.pubsub.subscribe(a,b)},j.unsubscribe=function(a,b){return k.pubsub.unsubscribe(a,b)},j.checkNameAvailability=function(a){var c=b.extend({userName:k.storage.userName,storage:k.storage,applicant:k.applicant,method:"checkNameAvailability",callback:function(){}},a);return j.isReady()&&c.userName&&c.storage&&c.applicant?k.queue.createJob(c):null},j.saveDocument=function(a){var c=b.extend({storage:k.storage,applicant:k.applicant,method:"saveDocument",callback:function(){}},a);return j.isReady()&&c.fileName&&c.fileContent&&c.storage&&c.applicant?k.queue.createJob(c):null},j.loadDocument=function(a){var c=b.extend({storage:k.storage,applicant:k.applicant,method:"loadDocument",callback:function(){}},a);return j.isReady()&&c.fileName&&c.storage&&c.applicant?k.queue.createJob(c):null},j.getDocumentList=function(a){var c=b.extend({storage:k.storage,applicant:k.applicant,method:"getDocumentList",callback:function(){}},a);return j.isReady()&&c.storage&&c.applicant?k.queue.createJob(c):null},j.removeDocument=function(a){var c=b.extend({storage:k.storage,applicant:k.applicant,method:"removeDocument",callback:function(){}},a);return j.isReady()&&c.fileName&&c.storage&&c.applicant?k.queue.createJob(c):null};var l=b.extend({useLocalStorage:!0},f);return typeof a=="string"&&(a=JSON.parse(f.storage)),typeof c=="string"&&(c=JSON.parse(f.applicant)),k.storage=a,k.applicant=c,k.id=0,k.pubsub=new e(l),k.queue=new g(k.pubsub,l),k.listener=new h(k.queue,l),k.ready=!1,l.useLocalStorage?k.updater=new i(l):k.updater=null,k.storage&&!d.storageTypeObject[k.storage.type]&&b.error('Unknown storage type "'+k.storage.type+'"'),j.start(),j},l=function(){var e={};return e.createNew=function(c,e,f){var g=b.extend({useLocalStorage:!0},f);return d.localStorage===null&&(d.localStorage=a),new k(c,e,g)},e.newBaseStorage=function(a){return new j(a)},e.addStorageType=function(a,b){return a&&b?(d.storageTypeObject[a]=b,!0):!1},e.getGlobalObject=function(){return d},e.getConstObject=function(){return b.extend({},c)},e},new l};return window.requirejs?(define("JIO",["LocalOrCookieStorage","jQuery"],a),undefined):a(LocalOrCookieStorage,jQuery)}();
\ No newline at end of file
var JIO=function(){var a=function(a,b){var c={jobMethodObject:{checkNameAvailability:{start_event:"start_checkingNameAvailability",stop_event:"stop_checkingNameAvailability",retvalue:"isAvailable"},saveDocument:{start_event:"start_saving",stop_event:"stop_saving",retvalue:"isSaved"},loadDocument:{start_event:"start_loading",stop_event:"stop_loading",retvalue:"fileContent"},getDocumentList:{start_event:"start_gettingList",stop_event:"stop_gettingList",retvalue:"list"},removeDocument:{start_event:"start_removing",stop_event:"stop_removing",retvalue:"isRemoved"}}},d={jobManagingMethod:{canSelect:function(a,b){return JSON.stringify(a.storage)===JSON.stringify(b.storage)&&JSON.stringify(a.applicant)===JSON.stringify(b.applicant)&&a.fileName===b.fileName?!0:!1},canRemoveFailOrDone:function(a,b){return a.status==="fail"||a.status==="done"?!0:!1},canEliminate:function(a,b){return a.status!=="ongoing"&&(a.method==="removeDocument"&&b.method==="saveDocument"||a.method==="saveDocument"&&b.method==="removeDocument")?!0:!1},canReplace:function(a,b){return a.status!=="ongoing"&&a.method===b.method&&a.date<b.date?!0:!1},cannotAccept:function(a,b){if(a.status!=="ongoing"){if(a.method==="removeDocument"&&b.method==="loadDocument")return!0}else{if(a.method===b.method==="loadDocument")return!0;if(a.method==="removeDocument"&&(b.method==="loadDocument"||b.method==="removeDocument"))return!0;if(a.method===b.method==="saveDocument"&&a.fileContent===b.fileContent)return!0;if(a.method===b.method==="getDocumentList"||a.method===b.method==="checkNameAvailability")return!0}return!1},mustWait:function(a,b){return a.method==="getDocumentList"||a.method==="checkNameAvailability"||b.method==="getDocumentList"||b.method==="checkNameAvailability"?!1:!0}},localStorage:null,queueID:1,storageTypeObject:{}},e,f,g,h,i,j,k,l;return e=function(){var a={},c={},d={},e,f;return c.eventAction=function(a){return f=a&&d[a],f||(e=b.Callbacks(),f={publish:e.fire,subscribe:e.add,unsubscribe:e.remove},a&&(d[a]=f)),f},a.publish=function(a,b){c.eventAction(a).publish(b)},a.subscribe=function(a,b){return c.eventAction(a).subscribe(b),b},a.unsubscribe=function(a,b){c.eventAction(a).unsubscribe(b)},a},f=function(a){var c=b.extend({},a);return c.id=0,c.status="initial",c.date=Date.now(),c},g=function(a,e){var g={},h={},i="jio/idArray";return g.init=function(b){var c,e=function(){},f=d.localStorage.getItem(i);f===null&&(f=[]),b.publisher&&(h.publisher=a),h.jioID=b.jioID,h.jobObjectName="jio/jobObject/"+b.jioID,h.jobObject={},f.push(h.jioID),d.localStorage.setItem(i,f),g.copyJobQueueToLocalStorage();for(c in h.recoveredJobObject)h.recoveredJobObject[c].callback=e,g.addJob(h.recoveredJobObject[c])},g.close=function(){JSON.stringify(h.jobObject)==="{}"&&d.localStorage.deleteItem(h.jobObjectName)},g.getNewQueueID=function(){var a=null,b=0,c=d.localStorage.getItem(i);for(a in c)c[a]>=d.queueID&&(d.queueID=c[a]+1);return b=d.queueID,d.queueID++,b},g.recoverOlderJobObject=function(){var a=null,b=[],c=!1,e=d.localStorage.getItem(i);for(a in e)d.localStorage.getItem("jio/id/"+e[a])<Date.now()-1e4?(d.localStorage.deleteItem("jio/id/"+e[a]),h.recoveredJobObject=d.localStorage.getItem("jio/jioObject/"+e[a]),d.localStorage.deleteItem("jio/jobObject/"+e[a]),c=!0):b.push(e[a]);c&&d.localStorage.setItem(i,b)},g.isThereJobsWhere=function(a){var b="id";if(!a)return!0;for(b in h.jobObject)if(a(h.jobObject[b]))return!0;return!1},g.copyJobQueueToLocalStorage=function(){return h.useLocalStorage?d.localStorage.setItem(h.jobObjectName,h.jobObject):!1},g.createJob=function(a){return g.addJob(new f(a))},g.addJob=function(a){var b={newone:!0,elimArray:[],waitArray:[],removeArray:[]},c=null,e="id";for(e in h.jobObject){if(d.jobManagingMethod.canRemoveFailOrDone(h.jobObject[e],a)){b.removeArray.push(e);continue}if(d.jobManagingMethod.canSelect(h.jobObject[e],a)){if(d.jobManagingMethod.canEliminate(h.jobObject[e],a)){b.elimArray.push(e);continue}if(d.jobManagingMethod.canReplace(h.jobObject[e],a)){c=new j({queue:g,job:h.jobObject[e]}),c.replace(a),b.newone=!1;break}if(d.jobManagingMethod.cannotAccept(h.jobObject[e],a))return!1;if(d.jobManagingMethod.mustWait(h.jobObject[e],a)){b.waitArray.push(e);continue}}}if(b.newone){for(e in b.elimArray)c=new j({queue:g,job:h.jobObject[b.elimArray[e]]}),c.eliminate();if(b.waitArray.length>0){a.status="wait",a.waitingFor={jobIdArray:b.waitArray};for(e in b.waitArray)h.jobObject[b.waitArray[e]]&&(h.jobObject[b.waitArray[e]].maxtries=1)}for(e in b.removeArray)g.removeJob(h.jobObject[b.removeArray[e]]);a.id=h.jobid,a.tries=0,h.jobid++,h.jobObject[a.id]=a}return g.copyJobQueueToLocalStorage(),!0},g.removeJob=function(a){var c=b.extend({where:function(a){return!0}},a),d,e=!1,f="key";if(c.job)h.jobObject[c.job.id]&&c.where(h.jobObject[c.job.id])&&(delete h.jobObject[c.job.id],e=!0);else for(f in h.jobObject)c.where(h.jobObject[f])&&(delete h.jobObject[f],e=!0);e||b.error("No jobs was found, when trying to remove some."),g.copyJobQueueToLocalStorage()},g.resetAll=function(){var a="id";for(a in h.jobObject)h.jobObject[a].status="initial";g.copyJobQueueToLocalStorage()},g.invokeAll=function(){var a="id",b;for(a in h.jobObject){b=!1;if(h.jobObject[a].status==="initial")g.invoke(h.jobObject[a]);else if(h.jobObject[a].status==="wait"){b=!0;if(h.jobObject[a].waitingFor.jobIdArray)for(var c in h.jobObject[a].waitingFor.jobIdArray)if(h.jobObject[h.jobObject[a].waitingFor.jobIdArray[c]]){b=!1;break}h.jobObject[a].waitingFor.time&&h.jobObject[a].waitingFor.time>Date.now()&&(b=!1),b&&g.invoke(h.jobObject[a])}}this.copyJobQueueToLocalStorage()},g.invoke=function(a){var b;if(!c.jobMethodObject[a.method])return!1;g.isThereJobsWhere(function(b){return b.method===a.method&&b.method==="initial"})?a.status="ongoing":(a.status="ongoing",h.publisher.publish(c.jobMethodObject[a.method].start_event)),b=new j({queue:this,job:a}),b.execute()},g.ended=function(a){var d=b.extend({},a);g.removeJob({job:d});if(!c.jobMethodObject[d.method])return!1;if(!g.isThereJobsWhere(function(a){return a.method===d.method&&a.status==="ongoing"||a.status==="initial"})){h.publisher.publish(c.jobMethodObject[d.method].stop_event);return}},g.clean=function(){g.removeJob(undefined,{where:function(a){return a.status==="fail"}})},h.useLocalStorage=e.useLocalStorage,h.publisher=a,h.jobid=1,h.jioID=0,h.jobObjectName="",h.jobObject={},h.recoveredJobObject={},g},h=function(a){var b={},c={};return c.interval=200,c.id=null,c.queue=a,b.setIntervalDelay=function(a){c.interval=a},b.start=function(){return c.id?!1:(c.id=setInterval(function(){c.queue.recoverOlderJobObject(),c.queue.invokeAll()},c.interval),!0)},b.stop=function(){return c.id?(clearInterval(c.id),c.id=null,!0):!1},b},i=function(){var a={},b={};return b.interval=400,b.id=null,a.start=function(c){return b.id?!1:(a.touch(c),b.id=setInterval(function(){a.touch(c)},b.interval),!0)},a.stop=function(){return b.id?(clearInterval(b.id),b.id=null,!0):!1},a.touch=function(a){d.localStorage.setItem("jio/id/"+a,Date.now())},a},j=function(a){var c={},e={};return e.job=a.job,e.callback=a.job.callback,e.queue=a.queue,e.res={status:"done",message:""},e.fail_checkNameAvailability=function(){e.res.isAvailable=!1},e.done_checkNameAvailability=function(a){e.res.message=e.job.userName+" is "+(a?"":"not ")+"available.",e.res.isAvailable=a},e.fail_loadDocument=function(){e.res.document={}},e.done_loadDocument=function(a){e.res.message="Document loaded.",e.res.document=a,e.res.document.lastModified=(new Date(e.res.document.lastModified)).getTime(),e.res.document.creationDate=(new Date(e.res.document.creationDate)).getTime()},e.fail_saveDocument=function(){e.res.isSaved=!1},e.done_saveDocument=function(){e.res.message="Document saved.",e.res.isSaved=!0},e.fail_getDocumentList=function(){e.res.list=[]},e.done_getDocumentList=function(a){var b;e.res.message="Document list received.",e.res.list=a;for(b in e.res.list)e.res.list[b].lastModified=(new Date(e.res.list[b].lastModified)).getTime(),e.res.list[b].creationDate=(new Date(e.res.list[b].creationDate)).getTime()},e.fail_removeDocument=function(){e.res.isRemoved=!1},e.done_removeDocument=function(){e.res.message="Document removed.",e.res.isRemoved=!0},e.retryLater=function(){e.job.status="wait",e.job.waitingFor={time:Date.now()+e.job.tries*e.job.tries*1e3}},c.cloneJob=function(){return b.extend({},e.job)},c.getUserName=function(){return e.job.userName||""},c.getApplicantID=function(){return e.job.applicant.ID||""},c.getStorageUserName=function(){return e.job.storage.userName||""},c.getStoragePassword=function(){return e.job.storage.password||""},c.getStorageLocation=function(){return e.job.storage.location||""},c.getStorageArray=function(){return e.job.storage.storageArray||[]},c.getFileName=function(){return e.job.fileName||""},c.getFileContent=function(){return e.job.fileContent||""},c.cloneOptionObject=function(){return b.extend({},e.job.options)},c.getMaxTries=function(){return e.job.maxtries},c.getTries=function(){return e.job.tries||0},c.setMaxTries=function(a){e.job.maxtries=a},c.addJob=function(a){return e.queue.createJob(a)},c.eliminate=function(){e.job.maxtries=1,e.job.tries=1,c.fail("Job Stopped!",0)},c.replace=function(a){e.job.tries=0,e.job.date=a.date,e.job.callback=a.callback,e.res.status="fail",e.res.message="Job Stopped!",e.res.errno=0,e["fail_"+e.job.method](),e.callback(e.res)},c.fail=function(a,b){e.res.status="fail",e.res.message=a,e.res.errno=b,!e.job.maxtries||e.job.tries<e.job.maxtries?e.retryLater():(e.job.status="fail",e["fail_"+e.job.method](),e.queue.ended(e.job),e.callback(e.res))},c.done=function(a){e.job.status="done",e["done_"+e.job.method](a),e.queue.ended(e.job),e.callback(e.res)},c.execute=function(){return e.job.tries=c.getTries()+1,d.storageTypeObject[e.job.storage.type]?d.storageTypeObject[e.job.storage.type]({job:e.job,queue:e.queue})[e.job.method]():null},c.checkNameAvailability=function(){c.fail("This method must be redefined!",0)},c.loadDocument=function(){c.fail("This method must be redefined!",0)},c.saveDocument=function(){c.fail("This method must be redefined!",0)},c.getDocumentList=function(){c.fail("This method must be redefined!",0)},c.removeDocument=function(){c.fail("This method must be redefined!",0)},c},k=function(a,c,f){var j={},k={};j.getID=function(){return k.id},j.start=function(){return k.id!==0?!1:(k.id=k.queue.getNewQueueID(),k.queue.init({jioID:k.id}),k.updater&&k.updater.start(k.id),k.listener.start(),k.ready=!0,j.isReady())},j.stop=function(){return k.queue.close(),k.listener.stop(),k.updater&&k.updater.stop(),k.ready=!1,k.id=0,!0},j.kill=function(){return k.queue.close(),k.listener.stop(),k.updater&&k.updater.stop(),k.ready=!1,!0},j.isReady=function(){return k.ready},j.publish=function(a,b){if(!j.isReady())return;return k.pubsub.publish(a,b)},j.subscribe=function(a,b){return k.pubsub.subscribe(a,b)},j.unsubscribe=function(a,b){return k.pubsub.unsubscribe(a,b)},j.checkNameAvailability=function(a){var c=b.extend({userName:k.storage.userName,storage:k.storage,applicant:k.applicant,method:"checkNameAvailability",callback:function(){}},a);return j.isReady()&&c.userName&&c.storage&&c.applicant?k.queue.createJob(c):null},j.saveDocument=function(a){var c=b.extend({storage:k.storage,applicant:k.applicant,method:"saveDocument",callback:function(){}},a);return j.isReady()&&c.fileName&&c.fileContent&&c.storage&&c.applicant?k.queue.createJob(c):null},j.loadDocument=function(a){var c=b.extend({storage:k.storage,applicant:k.applicant,method:"loadDocument",callback:function(){}},a);return j.isReady()&&c.fileName&&c.storage&&c.applicant?k.queue.createJob(c):null},j.getDocumentList=function(a){var c=b.extend({storage:k.storage,applicant:k.applicant,method:"getDocumentList",callback:function(){}},a);return j.isReady()&&c.storage&&c.applicant?k.queue.createJob(c):null},j.removeDocument=function(a){var c=b.extend({storage:k.storage,applicant:k.applicant,method:"removeDocument",callback:function(){}},a);return j.isReady()&&c.fileName&&c.storage&&c.applicant?k.queue.createJob(c):null};var l=b.extend({useLocalStorage:!0},f);return typeof a=="string"&&(a=JSON.parse(f.storage)),typeof c=="string"&&(c=JSON.parse(f.applicant)),k.storage=a,k.applicant=c,k.id=0,k.pubsub=new e(l),k.queue=new g(k.pubsub,l),k.listener=new h(k.queue,l),k.ready=!1,l.useLocalStorage?k.updater=new i(l):k.updater=null,k.storage&&!d.storageTypeObject[k.storage.type]&&b.error('Unknown storage type "'+k.storage.type+'"'),j.start(),j},l=function(){var e={};return e.createNew=function(c,e,f){var g=b.extend({useLocalStorage:!0},f);return d.localStorage===null&&(d.localStorage=a),new k(c,e,g)},e.newBaseStorage=function(a){return new j(a)},e.addStorageType=function(a,b){return a&&b?(d.storageTypeObject[a]=b,!0):!1},e.getGlobalObject=function(){return d},e.getConstObject=function(){return b.extend({},c)},e},new l};return window.requirejs?(define("JIO",["LocalOrCookieStorage","jQuery"],a),undefined):a(LocalOrCookieStorage,jQuery)}();
\ No newline at end of file
......@@ -838,11 +838,11 @@ if (window.requirejs) {
LocalOrCookieStorage: '../lib/jio/localorcookiestorage.min',
jQueryAPI: '../lib/jquery/jquery',
jQuery: '../lib/jio/jquery.requirejs_module',
jQuery: '../js/jquery.requirejs_module',
JIO: '../src/jio',
Base64API: '../lib/base64/base64',
Base64: '../lib/jio/base64.requirejs_module',
JIODummyStorages: '../lib/jio/jio.dummystorages',
Base64: '../js/base64.requirejs_module',
JIODummyStorages: '../src/jio.dummystorages',
JIOStorages: '../lib/jio/jio.storage.min'
}
});
......
......@@ -15,7 +15,7 @@
</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/jio/jio.dummystorages.js"></script>
<script type="text/javascript" src="../src/jio.dummystorages.js"></script>
<script type="text/javascript" src="../lib/jio/jio.storage.min.js"></script>
<script type="text/javascript" src="jiotests.js"></script>
</body>
......
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