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
4525e4b7
Commit
4525e4b7
authored
Oct 03, 2011
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fixes done by Francois (sorry, I do not have details)
parent
2e3330ea
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
81 deletions
+90
-81
UNGProject/js/login.js
UNGProject/js/login.js
+84
-77
UNGProject/js/theme.js
UNGProject/js/theme.js
+3
-3
UNGProject/js/tools.js
UNGProject/js/tools.js
+3
-1
No files found.
UNGProject/js/login.js
View file @
4525e4b7
...
...
@@ -13,67 +13,24 @@ var displayNewAccountForm = function(bool) {
$
(
"
table#new-account-table
"
).
css
(
"
display
"
,
"
table
"
);
}
}
function
logIntoDav
(
wallet
)
{
var
recall
=
window
.
location
;
window
.
location
.
href
=
wallet
.
storageLocation
+
"
#
"
+
recall
;
}
/**
* create a new storage
*/
function
initStorage
(
wallet
)
{
if
(
!
wallet
.
provider
)
{
//local storage
/**
* load JIO file from a DAV and create and return the JIO object
* This function will be replaced. The aim is to load JIO in more various ways, and use JIO.initialize after
* @param userName : name of the user
* @param location : server location
* @param applicant : (optional) information about the person/application needing this JIO object (allow limited access)
* @return JIO object
*/
(
function
initializeFromDav
(
userName
,
location
,
applicant
)
{
//get the user personal JIO file
$
.
ajax
({
url
:
location
+
"
/dav/
"
+
userName
+
"
/
"
+
applicant
.
ID
+
"
/
"
+
"
jio.json
"
,
//we could use userAdress instead...
type
:
"
GET
"
,
async
:
false
,
dataType
:
"
text
"
,
headers
:
{
Authorization
:
"
Basic
"
+
Base64
.
encode
(
userName
+
"
:
"
+
applicant
.
password
)},
fields
:
{
withCredentials
:
"
true
"
},
success
:
function
(
jioContent
){
Storage
.
create
(
jioContent
);
},
error
:
function
(
type
)
{
alert
(
"
Error
"
+
type
.
status
+
"
: fail while trying to load jio.json
"
);}
});
return
JIO
;
})(
wallet
.
userName
,
wallet
.
storageLocation
,
{
"
ID
"
:
"
www.ungproject.com
"
,
"
password
"
:
wallet
.
applicationPassword
});
if
(
wallet
.
provider
)
{
//DAV storage
// load JIO file from a DAV and create the JIO object
initializeFromDav
(
wallet
.
userName
,
wallet
.
storageLocation
,
{
"
ID
"
:
"
www.ungproject.com
"
,
"
password
"
:
wallet
.
applicationPassword
});
}
else
{
Storage
.
create
(
'
{"type":"local","userName":"
'
+
wallet
.
userName
+
'
"}
'
);
}
}
//unhosted functions
function
getStorageLocation
(
provider
)
{
//TODO : uses webFinger
return
"
http://
"
+
provider
;
}
function
getApplicationPasswordFromURL
()
{
return
window
.
location
.
href
.
split
(
"
appPwd:
"
)[
1
]
}
function
setWallet
(
newWallet
)
{
localStorage
.
setItem
(
"
wallet
"
,
JSON
.
stringify
(
newWallet
));
}
function
getWallet
()
{
return
JSON
.
parse
(
localStorage
.
getItem
(
"
wallet
"
))
||
null
;
}
var
Wallet
=
function
()
{
this
.
userName
=
$
(
"
input#name
"
).
attr
(
"
value
"
);
this
.
provider
=
$
(
"
input#storage_location
"
).
attr
(
"
value
"
);
this
.
storageLocation
=
getStorageLocation
(
this
.
provider
);
}
/**
* try to log an user after having logged in their Dav account
* try to log an user just after having logged in their Dav account
* if the user is logged, it means that getApplicationPasswordFromURL has a result
*/
function
tryLog
()
{
var
wallet
=
getWallet
();
...
...
@@ -82,42 +39,92 @@ function tryLog() {
wallet
.
applicationPassword
=
applicationPassword
;
setWallet
(
wallet
);
//to delete for new registration each time
initStorage
(
wallet
);
//go to ung when the storage is ready
waitBeforeSucceed
(
function
()
{
return
getCurrentStorage
().
getUser
();},
function
(){
window
.
location
.
href
=
"
ung.html
"
;});
}
}
/**
* Log an user
with it's
Name and storage provider
* Log an user
after they fill their
Name and storage provider
*/
function
logUser
()
{
var
wallet
=
new
Wallet
();
setWallet
(
wallet
);
if
(
!
wallet
.
userName
)
{
return
;}
if
(
wallet
.
provider
)
{
if
(
!
wallet
.
storageLocation
)
{
alert
(
"
unable to find your storage from your provider
"
);
return
;}
if
(
!
wallet
.
applicationPassword
)
{
logIntoDav
(
wallet
);
return
;}
if
(
!
wallet
.
storageLocation
)
{
alert
(
"
unable to find your storage from your provider
"
);
return
;}
if
(
!
wallet
.
applicationPassword
)
{
logIntoDav
(
wallet
);
return
;}
}
initStorage
(
wallet
);
//go to ung when the storage is ready
waitBeforeSucceed
(
function
()
{
return
getCurrentStorage
().
getUser
();},
function
(){
window
.
location
.
href
=
"
ung.html
"
;});
}
/***************************************************************************
********************** Unhosted functions *****************************
* these function are only required to respect the unhosted architecture */
// load JIO file from a DAV and create the JIO object
function
initializeFromDav
(
userName
,
location
,
applicant
)
{
//get the user personal JIO file
$
.
ajax
({
url
:
location
+
"
/dav/
"
+
userName
+
"
/
"
+
applicant
.
ID
+
"
/
"
+
"
jio.json
"
,
//we could use userAdress instead...
type
:
"
GET
"
,
async
:
false
,
dataType
:
"
text
"
,
headers
:
{
Authorization
:
"
Basic
"
+
Base64
.
encode
(
userName
+
"
:
"
+
applicant
.
password
)},
fields
:
{
withCredentials
:
"
true
"
},
success
:
function
(
jioContent
){
Storage
.
create
(
jioContent
);
},
error
:
function
(
type
)
{
alert
(
"
Error
"
+
type
.
status
+
"
: fail while trying to load jio.json
"
);}
});
return
JIO
;
}
function
getStorageLocation
(
provider
)
{
//TODO : use webFinger
return
"
http://
"
+
provider
;
}
function
getApplicationPasswordFromURL
()
{
return
window
.
location
.
href
.
split
(
"
appPwd:
"
)[
1
]
}
function
setWallet
(
newWallet
)
{
localStorage
.
setItem
(
"
wallet
"
,
JSON
.
stringify
(
newWallet
));
}
function
getWallet
()
{
return
JSON
.
parse
(
localStorage
.
getItem
(
"
wallet
"
))
||
null
;
}
var
Wallet
=
function
()
{
this
.
userName
=
$
(
"
input#name
"
).
attr
(
"
value
"
);
this
.
provider
=
$
(
"
input#storage_location
"
).
attr
(
"
value
"
);
this
.
storageLocation
=
getStorageLocation
(
this
.
provider
);
}
//redirects the application to the storage of the user to log the application in and get the password for the application
function
logIntoDav
(
wallet
)
{
var
recall
=
window
.
location
;
window
.
location
.
href
=
wallet
.
storageLocation
+
"
#
"
+
recall
;
}
/**********************************************************************
* functions from UNG Docs 1.0 and not currently used
*/
/**
* create an account (to use only if UNG is also a storage provider)
*/
function
createNewUser
()
{
var
form
=
$
(
"
form#create-user
"
)[
0
];
/* check that the form is complete */
for
(
var
i
=
0
;
i
<
form
.
length
-
1
;
i
++
)
{
if
(
!
form
[
i
].
value
)
{
formError
(
"
please fill each field
"
);}
...
...
@@ -128,11 +135,11 @@ function createNewUser() {
form
[
5
].
value
=
""
;
}
if
(
!
testEMail
())
{
formError
(
"
please enter a valid email
"
);}
/* create the new user */
//JIO
}
/**
* Report an error when filling the form
*/
...
...
@@ -140,7 +147,7 @@ function formError(message) {
$
(
"
td#form-message
"
).
attr
(
"
value
"
,
message
);
$
(
"
td#form-message
"
).
css
(
"
display
"
,
"
table-cell
"
);
}
/**
* check if an email address is valid
*/
...
...
@@ -149,7 +156,7 @@ function testEMail(email) {
var
regEx
=
new
RegExp
(
patern
);
return
regEx
.
test
(
email
);
}
//TODO
function
setFocus
()
{
login
=
document
.
getElementById
(
'
name
'
);
...
...
@@ -158,4 +165,4 @@ function setFocus() {
password
.
focus
();
else
login
.
focus
();
}
\ No newline at end of file
}
UNGProject/js/theme.js
View file @
4525e4b7
...
...
@@ -287,7 +287,7 @@ Storage.load({
success
:
function
(
list
)
{
delete
list
[
getCurrentUser
().
getName
()
+
"
.profile
"
];
//remove the profile file
getCurrentStorage
().
documentList
=
list
;
fireEvent
(
Storage
.
LIST_READY
);
Storage
.
fireEvent
(
Storage
.
LIST_READY
);
}
}
JIO
.
getDocumentList
(
option
);
...
...
@@ -303,7 +303,7 @@ Storage.load({
setUser
:
function
(
user
)
{
this
.
user
=
user
;
this
.
userName
=
user
.
getName
();
fireEvent
(
Storage
.
USER_READY
);
Storage
.
fireEvent
(
Storage
.
USER_READY
);
this
.
updateDocumentList
();
getCurrentStorage
().
save
();
...
...
@@ -622,4 +622,4 @@ editUserSettings = function() {
}
}
});
}
\ No newline at end of file
}
UNGProject/js/tools.js
View file @
4525e4b7
...
...
@@ -6,7 +6,9 @@
* Class UngObject
* provides useful general methods
*/
UngObject
=
function
()
{}
UngObject
=
function
()
{
this
.
listenerList
=
[];
}
/* return true if this object implements the interface */
UngObject
.
prototype
.
implement
=
function
(
myInterface
)
{
...
...
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