Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
458fd7d7
Commit
458fd7d7
authored
12 years ago
by
cramakri
Browse files
Options
Downloads
Patches
Plain Diff
BIS-111 SP-187 : Refactor login page to avoid code duplication
SVN: 26030
parent
cf43ad62
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
openbis/sourceTest/javascript/simpleapp/openbis-login.js
+69
-0
69 additions, 0 deletions
openbis/sourceTest/javascript/simpleapp/openbis-login.js
openbis/sourceTest/javascript/simpleapp/openbis-simple-app.html
+2
-32
2 additions, 32 deletions
...s/sourceTest/javascript/simpleapp/openbis-simple-app.html
with
71 additions
and
32 deletions
openbis/sourceTest/javascript/simpleapp/openbis-login.js
0 → 100644
+
69
−
0
View file @
458fd7d7
/**
* A module for configuring the login page to openBIS. It hides and shows
* the login form and main content as necessary. It invokes a specified
* function on successful login.
*
* This module assumes that the page follows the structure of our standard
* login page. This means that the Following elements are defined :
*
* div#login-form-div
* form#login-form
* input#username
* input#password
* button#login-button
* div#main
* button#logout-button
*
* Assuming these elements are defined, this module configures their appeareance
* and behavior.The div#main element is initially hidden until the user logs in.
* Once logged in, the div#login-form-div element is hidden and the div#main
* element is made visible.
*
* @module openbis-login
* @requires jquery
*/
/**
* Configure the login page to hide and show the login form and main content
* as appropriate
*
* @param openbis The openbis facade object
* @param onLogin The function to be called when login succeeds.
* @function
*/
function
configureLoginPage
(
openbis
,
onLogin
)
{
$
(
'
#main
'
).
hide
();
var
username
=
$
(
"
#username
"
).
value
;
if
(
username
==
null
||
username
.
length
==
0
)
{
$
(
"
#username
"
).
focus
();
}
else
{
$
(
"
#login-button
"
).
focus
();
}
$
(
'
#logout-button
'
).
click
(
function
()
{
openbis
.
logout
(
function
(
data
)
{
$
(
"
#login-form-div
"
).
show
();
$
(
"
#main
"
).
hide
();
$
(
"
#username
"
).
focus
();
});
});
$
(
'
#login-form
'
).
submit
(
function
()
{
openbis
.
login
(
$
.
trim
(
$
(
'
#username
'
).
val
()),
$
.
trim
(
$
(
'
#password
'
).
val
()),
function
(
data
)
{
onLogin
(
data
)
})
});
openbis
.
ifRestoredSessionActive
(
function
(
data
)
{
onLogin
(
data
)
});
// Make the ENTER key the default button
$
(
"
login-form input
"
).
keypress
(
function
(
e
)
{
if
((
e
.
which
&&
e
.
which
==
13
)
||
(
e
.
keyCode
&&
e
.
keyCode
==
13
))
{
$
(
'
button[type=submit].default
'
).
click
();
return
false
;
}
else
{
return
true
;
}
});
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
openbis/sourceTest/javascript/simpleapp/openbis-simple-app.html
+
2
−
32
View file @
458fd7d7
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
<script
type=
"text/javascript"
src=
"d3.time.js"
></script>
<script
type=
"text/javascript"
src=
"d3.time.js"
></script>
<script
type=
"text/javascript"
src=
"jquery.js"
></script>
<script
type=
"text/javascript"
src=
"jquery.js"
></script>
<script
type=
"text/javascript"
src=
"openbis.js"
></script>
<script
type=
"text/javascript"
src=
"openbis.js"
></script>
<script
type=
"text/javascript"
src=
"openbis-login.js"
></script>
<!-- To speed development, cache the requests -->
<!-- To speed development, cache the requests -->
<!-- <script type="text/javascript" src="openbis-request-cache.js"></script> -->
<!-- <script type="text/javascript" src="openbis-request-cache.js"></script> -->
<script>
<script>
...
@@ -153,38 +154,7 @@ function enterApp(data)
...
@@ -153,38 +154,7 @@ function enterApp(data)
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
$
(
'
#main
'
).
hide
();
configureLoginPage
(
openbisServer
,
enterApp
);
var
username
=
$
(
"
#username
"
).
value
;
if
(
username
==
null
||
username
.
length
==
0
)
{
$
(
"
#username
"
).
focus
();
}
else
{
$
(
"
#login-button
"
).
focus
();
}
$
(
'
#logout-button
'
).
click
(
function
()
{
openbisServer
.
logout
(
function
(
data
)
{
$
(
"
#login-form-div
"
).
show
();
$
(
"
#main
"
).
hide
();
$
(
"
#username
"
).
focus
();
});
});
$
(
'
#login-form
'
).
submit
(
function
()
{
openbisServer
.
login
(
$
.
trim
(
$
(
'
#username
'
).
val
()),
$
.
trim
(
$
(
'
#password
'
).
val
()),
function
(
data
)
{
enterApp
(
data
)
})
});
openbisServer
.
ifRestoredSessionActive
(
function
(
data
)
{
enterApp
(
data
)
});
// Make the ENTER key the default button
$
(
"
login-form input
"
).
keypress
(
function
(
e
)
{
if
((
e
.
which
&&
e
.
which
==
13
)
||
(
e
.
keyCode
&&
e
.
keyCode
==
13
))
{
$
(
'
button[type=submit].default
'
).
click
();
return
false
;
}
else
{
return
true
;
}
});
});
});
</script>
</script>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment