Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
officejs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
officejs
Commits
b2654ba5
Commit
b2654ba5
authored
Apr 30, 2012
by
Tristan Cavelier
Committed by
Sebastien Robin
May 18, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QUnit&Sinon tests are improved!
Developping DavStorage.
parent
6cb31064
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
422 additions
and
321 deletions
+422
-321
jiotest/index.html
jiotest/index.html
+1
-0
jiotest/jiotests.js
jiotest/jiotests.js
+130
-96
jiotest/unhosted/jio.js
jiotest/unhosted/jio.js
+18
-91
jiotest/unhosted/jio.storage.js
jiotest/unhosted/jio.storage.js
+181
-134
jiotest/unhosted/localorcookiestorage.js
jiotest/unhosted/localorcookiestorage.js
+92
-0
No files found.
jiotest/index.html
View file @
b2654ba5
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
<div
id=
"qunit"
></div>
<div
id=
"qunit"
></div>
<script
type=
"text/javascript"
src=
"qunit/qunit-1.5.0.js"
></script>
<script
type=
"text/javascript"
src=
"qunit/qunit-1.5.0.js"
></script>
<script
type=
"text/javascript"
src=
"js/jquery/jquery.js"
></script>
<script
type=
"text/javascript"
src=
"js/jquery/jquery.js"
></script>
<script
type=
"text/javascript"
src=
"unhosted/localorcookiestorage.js"
></script>
<script
type=
"text/javascript"
src=
"unhosted/jio.js"
></script>
<script
type=
"text/javascript"
src=
"unhosted/jio.js"
></script>
<script
type=
"text/javascript"
src=
"unhosted/base64.js"
></script>
<script
type=
"text/javascript"
src=
"unhosted/base64.js"
></script>
<script
type=
"text/javascript"
src=
"unhosted/jio.storage.js"
></script>
<script
type=
"text/javascript"
src=
"unhosted/jio.storage.js"
></script>
...
...
jiotest/jiotests.js
View file @
b2654ba5
This diff is collapsed.
Click to expand it.
jiotest/unhosted/jio.js
View file @
b2654ba5
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
// check dependencies
// check dependencies
var
errorDependencies
=
function
(){
console
.
error
(
'
Cannot find jQuery.
'
);};
var
errorDependencies
=
function
(){
console
.
error
(
'
Cannot find jQuery.
'
);};
try
{
if
(
!
jQuery
){
try
{
if
(
!
(
jQuery
&&
LocalOrCookieStorage
)
){
errorDependencies
();
return
null
;
errorDependencies
();
return
null
;
}}
catch
(
e
){
}}
catch
(
e
){
errorDependencies
();
return
null
;}
errorDependencies
();
return
null
;}
...
@@ -25,10 +25,6 @@
...
@@ -25,10 +25,6 @@
'
start_event
'
:
'
start_loading
'
,
'
start_event
'
:
'
start_loading
'
,
'
stop_event
'
:
'
stop_loading
'
,
'
stop_event
'
:
'
stop_loading
'
,
'
retvalue
'
:
'
fileContent
'
},
// returns the file content 'string'
'
retvalue
'
:
'
fileContent
'
},
// returns the file content 'string'
'
getDocument
'
:
{
'
start_event
'
:
'
start_gettingDocument
'
,
'
stop_event
'
:
'
stop_gettingDocument
'
,
'
retvalue
'
:
'
document
'
},
// returns the document object
'
getDocumentList
'
:
{
'
getDocumentList
'
:
{
'
start_event
'
:
'
start_gettingList
'
,
'
start_event
'
:
'
start_gettingList
'
,
'
stop_event
'
:
'
stop_gettingList
'
,
'
stop_event
'
:
'
stop_gettingList
'
,
...
@@ -43,87 +39,13 @@
...
@@ -43,87 +39,13 @@
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// jio globals
// jio globals
var
jioGlobalObj
=
{
var
jioGlobalObj
=
{
'
localStorage
'
:
null
,
// where the browser stores data
'
localStorage
'
:
LocalOrCookieStorage
,
// where the browser stores data
'
queueID
'
:
1
,
'
queueID
'
:
1
,
'
storageTypeObject
'
:
{}
// ex: {'type':'local','creator': fun ...}
'
storageTypeObject
'
:
{}
// ex: {'type':'local','creator': fun ...}
};
};
// end jio globals
// end jio globals
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// cookies & localStorage
var
browserStorage
=
function
()
{
};
browserStorage
.
prototype
=
{
getItem
:
function
(
name
)
{
return
JSON
.
parse
(
localStorage
.
getItem
(
name
));
},
setItem
:
function
(
name
,
value
)
{
if
(
name
)
return
localStorage
.
setItem
(
name
,
JSON
.
stringify
(
value
));
},
getAll
:
function
()
{
return
localStorage
;
},
deleteItem
:
function
(
name
)
{
if
(
name
)
delete
localStorage
[
name
];
}
};
var
cookieStorage
=
function
()
{
};
cookieStorage
.
prototype
=
{
getItem
:
function
(
name
)
{
var
cookies
=
document
.
cookie
.
split
(
'
;
'
);
for
(
var
i
in
cookies
)
{
var
x
=
cookies
[
i
].
substr
(
0
,
cookies
[
i
].
indexOf
(
'
=
'
));
var
y
=
cookies
[
i
].
substr
(
cookies
[
i
].
indexOf
(
'
=
'
)
+
1
);
x
=
x
.
replace
(
/^
\s
+|
\s
+$/g
,
""
);
if
(
x
==
name
)
return
unescape
(
y
);
}
return
null
;
},
setItem
:
function
(
name
,
value
)
{
// function to store into cookies
if
(
value
!=
undefined
)
{
document
.
cookie
=
name
+
'
=
'
+
JSON
.
stringify
(
value
)
+
'
;domain=
'
+
window
.
location
.
hostname
+
'
;path=
'
+
window
.
location
.
pathname
;
return
true
;
}
return
false
;
},
getAll
:
function
()
{
var
retObject
=
{};
var
cookies
=
document
.
cookie
.
split
(
'
:
'
);
for
(
var
i
in
cookies
)
{
var
x
=
cookies
[
i
].
substr
(
0
,
cookies
[
i
].
indexOf
(
'
=
'
));
var
y
=
cookies
[
i
].
substr
(
cookies
[
i
].
indexOf
(
'
=
'
)
+
1
);
x
=
x
.
replace
(
/^
\s
+|
\s
+$/g
,
""
);
retObject
[
x
]
=
unescape
(
y
);
}
return
retObject
;
},
deleteItem
:
function
(
name
)
{
document
.
cookie
=
name
+
'
=null;domain=
'
+
window
.
location
.
hostname
+
'
;path=
'
+
window
.
location
.
pathname
+
'
;expires=Thu, 01-Jan-1970 00:00:01 GMT
'
;
}
};
// set good localStorage
try
{
if
(
localStorage
.
getItem
)
{
jioGlobalObj
.
localStorage
=
new
browserStorage
();
}
else
{
jioGlobalObj
.
localStorage
=
new
cookieStorage
();
}
}
catch
(
e
)
{
jioGlobalObj
.
localStorage
=
new
cookieStorage
();
}
// end cookies & localStorages
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Tools
// Tools
var
createStorageObject
=
function
(
options
)
{
var
createStorageObject
=
function
(
options
)
{
...
@@ -369,6 +291,9 @@
...
@@ -369,6 +291,9 @@
},
},
ended
:
function
(
job
)
{
ended
:
function
(
job
)
{
// It is a callback function called just before user callback.
// It is called to manage jobObject according to the ended job.
console
.
log
(
'
ended
'
);
console
.
log
(
'
ended
'
);
switch
(
job
.
status
)
{
switch
(
job
.
status
)
{
case
'
done
'
:
case
'
done
'
:
...
@@ -461,15 +386,17 @@
...
@@ -461,15 +386,17 @@
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Toucher
// ActivityUpdater
var
Toucher
=
function
()
{
var
ActivityUpdater
=
function
()
{
// The toucher is a little thread that show activity of this jio.
// The activity updater is a little thread that proves activity of this
// jio instance.
this
.
interval
=
400
;
this
.
interval
=
400
;
this
.
id
=
null
;
this
.
id
=
null
;
};
};
Touch
er
.
prototype
=
{
ActivityUpdat
er
.
prototype
=
{
start
:
function
(
id
)
{
start
:
function
(
id
)
{
// start the
touch
er
// start the
updat
er
console
.
log
(
'
start touching jio/id/
'
+
id
);
console
.
log
(
'
start touching jio/id/
'
+
id
);
if
(
!
this
.
id
)
{
if
(
!
this
.
id
)
{
this
.
touch
(
id
);
this
.
touch
(
id
);
...
@@ -483,7 +410,7 @@
...
@@ -483,7 +410,7 @@
}
}
},
},
stop
:
function
()
{
stop
:
function
()
{
// stop the
touch
er
// stop the
updat
er
console
.
log
(
'
stop touching
'
);
console
.
log
(
'
stop touching
'
);
if
(
this
.
id
)
{
if
(
this
.
id
)
{
clearInterval
(
this
.
id
);
clearInterval
(
this
.
id
);
...
@@ -497,7 +424,7 @@
...
@@ -497,7 +424,7 @@
Date
.
now
()
);
Date
.
now
()
);
}
}
};
};
// end
Touch
er
// end
ActivityUpdat
er
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
...
@@ -522,7 +449,7 @@
...
@@ -522,7 +449,7 @@
this
[
'
pubsub
'
]
=
new
PubSub
();
this
[
'
pubsub
'
]
=
new
PubSub
();
this
[
'
queue
'
]
=
new
JobQueue
(
this
.
pubsub
);
this
[
'
queue
'
]
=
new
JobQueue
(
this
.
pubsub
);
this
[
'
listener
'
]
=
new
JobListener
(
this
.
queue
);
this
[
'
listener
'
]
=
new
JobListener
(
this
.
queue
);
this
[
'
toucher
'
]
=
new
Touch
er
();
this
[
'
updater
'
]
=
new
ActivityUpdat
er
();
this
[
'
ready
'
]
=
false
;
this
[
'
ready
'
]
=
false
;
// check storage type
// check storage type
...
@@ -544,7 +471,7 @@
...
@@ -544,7 +471,7 @@
// initializing objects
// initializing objects
this
.
queue
.
init
({
'
jioID
'
:
this
.
id
});
this
.
queue
.
init
({
'
jioID
'
:
this
.
id
});
// start touching
// start touching
this
.
touch
er
.
start
(
this
.
id
);
this
.
updat
er
.
start
(
this
.
id
);
// start listening
// start listening
this
.
listener
.
start
();
this
.
listener
.
start
();
// is now ready
// is now ready
...
@@ -557,7 +484,7 @@
...
@@ -557,7 +484,7 @@
this
.
queue
.
close
();
this
.
queue
.
close
();
this
.
listener
.
stop
();
this
.
listener
.
stop
();
this
.
touch
er
.
stop
();
this
.
updat
er
.
stop
();
this
.
ready
=
false
;
this
.
ready
=
false
;
this
.
id
=
0
;
this
.
id
=
0
;
return
true
;
return
true
;
...
@@ -568,7 +495,7 @@
...
@@ -568,7 +495,7 @@
this
.
queue
.
close
();
this
.
queue
.
close
();
this
.
listener
.
stop
();
this
.
listener
.
stop
();
this
.
touch
er
.
stop
();
this
.
updat
er
.
stop
();
// TODO
// TODO
this
.
ready
=
false
;
this
.
ready
=
false
;
return
true
;
return
true
;
...
...
jiotest/unhosted/jio.storage.js
View file @
b2654ba5
This diff is collapsed.
Click to expand it.
jiotest/unhosted/localorcookiestorage.js
0 → 100644
View file @
b2654ba5
;
var
LocalOrCookieStorage
=
(
function
()
{
// localorcookiestorage.js
// Creates an object that can store persistent information in localStorage.
// If it is not supported by the browser, it will store in cookies.
// Methods :
// - LocalOrCookieStorage.setItem('name',value);
// Sets an item with its value.
// - LocalOrCookieStorage.getItem('name');
// Returns a copy of the item.
// - LocalOrCookieStorage.deleteItem('name');
// Deletes an item forever.
// - LocalOrCookieStorage.getAll();
// Returns a new object containing all items and their values.
////////////////////////////////////////////////////////////////////////////
// cookies & localStorage
var
browserStorage
=
function
()
{
};
browserStorage
.
prototype
=
{
getItem
:
function
(
name
)
{
return
JSON
.
parse
(
localStorage
.
getItem
(
name
));
},
setItem
:
function
(
name
,
value
)
{
if
(
name
)
return
localStorage
.
setItem
(
name
,
JSON
.
stringify
(
value
));
},
getAll
:
function
()
{
return
localStorage
;
},
deleteItem
:
function
(
name
)
{
if
(
name
)
delete
localStorage
[
name
];
}
};
var
cookieStorage
=
function
()
{
};
cookieStorage
.
prototype
=
{
getItem
:
function
(
name
)
{
var
cookies
=
document
.
cookie
.
split
(
'
;
'
);
for
(
var
i
in
cookies
)
{
var
x
=
cookies
[
i
].
substr
(
0
,
cookies
[
i
].
indexOf
(
'
=
'
));
var
y
=
cookies
[
i
].
substr
(
cookies
[
i
].
indexOf
(
'
=
'
)
+
1
);
x
=
x
.
replace
(
/^
\s
+|
\s
+$/g
,
""
);
if
(
x
==
name
)
return
unescape
(
y
);
}
return
null
;
},
setItem
:
function
(
name
,
value
)
{
// function to store into cookies
if
(
value
!=
undefined
)
{
document
.
cookie
=
name
+
'
=
'
+
JSON
.
stringify
(
value
)
+
'
;domain=
'
+
window
.
location
.
hostname
+
'
;path=
'
+
window
.
location
.
pathname
;
return
true
;
}
return
false
;
},
getAll
:
function
()
{
var
retObject
=
{};
var
cookies
=
document
.
cookie
.
split
(
'
:
'
);
for
(
var
i
in
cookies
)
{
var
x
=
cookies
[
i
].
substr
(
0
,
cookies
[
i
].
indexOf
(
'
=
'
));
var
y
=
cookies
[
i
].
substr
(
cookies
[
i
].
indexOf
(
'
=
'
)
+
1
);
x
=
x
.
replace
(
/^
\s
+|
\s
+$/g
,
""
);
retObject
[
x
]
=
unescape
(
y
);
}
return
retObject
;
},
deleteItem
:
function
(
name
)
{
document
.
cookie
=
name
+
'
=null;domain=
'
+
window
.
location
.
hostname
+
'
;path=
'
+
window
.
location
.
pathname
+
'
;expires=Thu, 01-Jan-1970 00:00:01 GMT
'
;
}
};
// set good localStorage
try
{
if
(
localStorage
.
getItem
)
{
return
new
browserStorage
();
}
else
{
return
new
cookieStorage
();
}
}
catch
(
e
)
{
return
new
cookieStorage
();
}
// end cookies & localStorages
////////////////////////////////////////////////////////////////////////////
})();
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment