Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
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
Xiaowu Zhang
jio
Commits
598490f5
Commit
598490f5
authored
Jan 10, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jslint pass activityUpdater.js
parent
282d28d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
67 deletions
+68
-67
src/jio/activityUpdater.js
src/jio/activityUpdater.js
+68
-67
No files found.
src/jio/activityUpdater.js
View file @
598490f5
var
activityUpdater
=
(
function
(
spec
,
my
)
{
/*jslint indent: 2, maxlen: 80, sloppy: true */
var
that
=
{};
/*global localstorage: true, setInterval: true, clearInterval: true */
spec
=
spec
||
{};
var
activityUpdater
=
(
function
(
spec
,
my
)
{
my
=
my
||
{};
var
that
=
{},
priv
=
{};
// Attributes //
spec
=
spec
||
{};
var
priv
=
{};
my
=
my
||
{};
priv
.
id
=
spec
.
id
||
0
;
priv
.
interval
=
400
;
priv
.
interval_id
=
null
;
// Methods //
priv
.
id
=
spec
.
id
||
0
;
/**
priv
.
interval
=
400
;
* Update the last activity date in the localStorage.
priv
.
interval_id
=
null
;
* @method touch
*/
priv
.
touch
=
function
()
{
localstorage
.
setItem
(
'
jio/id/
'
+
priv
.
id
,
Date
.
now
());
};
/**
// Methods //
* Sets the jio id into the activity.
/**
* @method setId
* Update the last activity date in the localStorage.
* @param {number} id The jio id.
* @method touch
*/
*/
that
.
setId
=
function
(
id
)
{
priv
.
touch
=
function
(
)
{
priv
.
id
=
id
;
localstorage
.
setItem
(
'
jio/id/
'
+
priv
.
id
,
Date
.
now
())
;
};
};
/**
/**
* Sets the interval delay between two updates
.
* Sets the jio id into the activity
.
* @method setIntervalDelay
* @method setId
* @param {number} ms In milliseconds
* @param {number} id The jio id.
*/
*/
that
.
setIntervalDelay
=
function
(
ms
)
{
that
.
setId
=
function
(
id
)
{
priv
.
interval
=
ms
;
priv
.
id
=
id
;
};
};
/**
/**
* Gets the interval delay
.
* Sets the interval delay between two updates
.
* @method g
etIntervalDelay
* @method s
etIntervalDelay
* @return {number} The interval delay.
* @param {number} ms In milliseconds
*/
*/
that
.
getIntervalDelay
=
function
(
)
{
that
.
setIntervalDelay
=
function
(
ms
)
{
return
priv
.
interval
;
priv
.
interval
=
ms
;
};
};
/**
/**
* Starts the activity updater. It will update regulary the last activity
* Gets the interval delay.
* date in the localStorage to show to other jio instance that this instance
* @method getIntervalDelay
* is active.
* @return {number} The interval delay.
* @method start
*/
*/
that
.
getIntervalDelay
=
function
()
{
that
.
start
=
function
()
{
return
priv
.
interval
;
if
(
!
priv
.
interval_id
)
{
};
priv
.
touch
();
priv
.
interval_id
=
setInterval
(
function
()
{
priv
.
touch
();
},
priv
.
interval
);
}
};
/**
/**
* Stops the activity updater.
* Starts the activity updater. It will update regulary the last activity
* @method stop
* date in the localStorage to show to other jio instance that this instance
*/
* is active.
that
.
stop
=
function
()
{
* @method start
if
(
priv
.
interval_id
!==
null
)
{
*/
clearInterval
(
priv
.
interval_id
);
that
.
start
=
function
()
{
priv
.
interval_id
=
null
;
if
(
!
priv
.
interval_id
)
{
}
priv
.
touch
();
};
priv
.
interval_id
=
setInterval
(
function
()
{
priv
.
touch
();
},
priv
.
interval
);
}
};
return
that
;
/**
}());
* Stops the activity updater.
* @method stop
*/
that
.
stop
=
function
()
{
if
(
priv
.
interval_id
!==
null
)
{
clearInterval
(
priv
.
interval_id
);
priv
.
interval_id
=
null
;
}
};
return
that
;
}());
\ 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