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
a333157f
Commit
a333157f
authored
May 30, 2014
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add history gestion in audioplayer
parent
c198f439
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
7 deletions
+31
-7
src/audioplayer/audioplayer.js
src/audioplayer/audioplayer.js
+28
-7
src/audioplayer_control/control.js
src/audioplayer_control/control.js
+3
-0
No files found.
src/audioplayer/audioplayer.js
View file @
a333157f
/*global window, rJS, RSVP, console, $, jQuery, URL */
/*global window, rJS, RSVP, console, $, jQuery, URL
, location
*/
/*jslint nomen: true*/
(
function
(
window
,
rJS
,
$
)
{
"
use strict
"
;
...
...
@@ -7,7 +7,8 @@
time
,
volume
,
title
,
totalId
=
0
;
totalId
=
0
,
initialUrl
;
function
nextId
()
{
return
Math
.
floor
(
Math
.
random
()
*
totalId
);
}
...
...
@@ -41,6 +42,7 @@
control
.
getTitle
().
then
(
function
(
value
)
{
title
.
setMessage
(
value
);
});
animation
.
showAnimation
();
})
.
allowPublicAcquisition
(
"
showAnimation
"
,
function
()
{
animation
.
showAnimation
();
...
...
@@ -51,6 +53,7 @@
.
ready
(
function
(
g
)
{
var
next_context
=
g
.
__element
.
getElementsByTagName
(
'
button
'
)[
0
],
command_context
=
g
.
__element
.
getElementsByTagName
(
'
button
'
)[
1
];
initialUrl
=
location
.
href
;
RSVP
.
all
([
g
.
getDeclaredGadget
(
"
control
"
...
...
@@ -81,13 +84,12 @@
});
},
1000
);
volume
.
setMax
(
3
);
next_context
.
onclick
=
function
()
{
control
.
setSong
(
nextId
()).
then
(
function
()
{
var
id
=
nextId
();
control
.
setSong
(
id
).
then
(
function
()
{
control
.
playSong
();
animation
.
showAnimation
();
control
.
getTotalTime
().
then
(
function
(
value
)
{
time
.
setMax
(
value
);
control
.
getTitle
().
then
(
function
(
value
)
{
window
.
history
.
pushState
(
null
,
null
,
initialUrl
+
value
);
});
});
};
...
...
@@ -111,6 +113,25 @@
title
.
getSize
().
then
(
function
(
size
)
{
title
.
setPosition
(
size
*
2
);
});
window
.
addEventListener
(
"
popstate
"
,
function
(
e
)
{
var
href
=
location
.
href
,
name
,
lastIndex
=
href
.
lastIndexOf
(
'
/
'
)
+
1
;
if
(
lastIndex
!==
href
.
length
)
{
name
=
href
.
slice
(
lastIndex
);
control
.
setSong
(
name
).
then
(
function
()
{
control
.
playSong
();
animation
.
showAnimation
();
control
.
getTotalTime
().
then
(
function
(
value
)
{
time
.
setMax
(
value
);
});
});
}
else
{
control
.
stopSong
();
animation
.
stopAnimation
();
title
.
setMessage
(
"
audio player
"
);
}
},
false
);
})
.
fail
(
function
(
e
)
{
console
.
log
(
"
[ERROR]:
"
+
e
);
...
...
src/audioplayer_control/control.js
View file @
a333157f
...
...
@@ -7,6 +7,9 @@
var
gk
=
rJS
(
window
);
gk
.
declareMethod
(
'
setSong
'
,
function
(
id
)
{
//configure a song
var
gadget
=
this
;
if
(
typeof
id
===
"
string
"
)
{
id
=
gadget
.
playlist
.
indexOf
(
id
);
}
if
((
id
>=
gadget
.
lenght
)
||
(
id
<
0
))
{
console
.
log
(
"
invalide play id
"
);
return
;
...
...
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