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
6b500761
Commit
6b500761
authored
Jul 07, 2014
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add stockage save for alldocs
parent
e7f8a34d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
96 additions
and
51 deletions
+96
-51
src/audioplayer/audioplayer.js
src/audioplayer/audioplayer.js
+28
-12
src/audioplayer/index.html
src/audioplayer/index.html
+5
-2
src/audioplayer_bridge/audiogadget.js
src/audioplayer_bridge/audiogadget.js
+27
-5
src/audioplayer_control/control.js
src/audioplayer_control/control.js
+22
-24
src/audioplayer_playlist/index.html
src/audioplayer_playlist/index.html
+3
-2
src/audioplayer_playlist/playlist.js
src/audioplayer_playlist/playlist.js
+11
-6
No files found.
src/audioplayer/audioplayer.js
View file @
6b500761
...
...
@@ -8,13 +8,16 @@
$
.
mobile
.
pushStateEnabled
=
false
;
var
gadget_list
=
{
"
upload
"
:
{
"
0
"
:
"
../audioplayer_upload/index.html
"
,
"
1
"
:
"
../audioplayer_playlist/index.html
"
},
"
1
"
:
"
../audioplayer_playlist/index.html
"
,
"
2
"
:
"
../audioplayer_playlist/index.html
"
},
"
playlist
"
:
{
"
0
"
:
"
../audioplayer_playlist/index.html
"
,
"
1
"
:
"
../audioplayer_playlist/index.html
"
},
"
1
"
:
"
../audioplayer_playlist/index.html
"
,
"
2
"
:
"
../audioplayer_playlist/index.html
"
},
"
control
"
:
{
"
0
"
:
"
../audioplayer_control/index.html
"
,
"
1
"
:
"
../audioplayer_control/index.html
"
}
"
1
"
:
"
../audioplayer_control/index.html
"
,
"
2
"
:
"
../audioplayer_control/index.html
"
}
},
allStorageType
=
[
"
indexeddbStorage
"
,
"
httpStorag
e
"
];
allStorageType
=
[
"
offline
"
,
"
localhost
"
,
"
onlin
e
"
];
function
storageType
(
type
)
{
return
allStorageType
[
type
];
}
...
...
@@ -40,8 +43,10 @@
.
declareAcquiredMethod
(
"
pleaseRedirectMyHash
"
,
"
pleaseRedirectMyHash
"
)
.
allowPublicAcquisition
(
"
plEnablePage
"
,
function
()
{
var
controlPanel
=
this
.
__element
.
getElementsByClassName
(
'
page
'
)[
0
];
while
(
controlPanel
.
firstChild
)
{
controlPanel
.
removeChild
(
controlPanel
.
firstChild
);
if
(
controlPanel
)
{
while
(
controlPanel
.
firstChild
)
{
controlPanel
.
removeChild
(
controlPanel
.
firstChild
);
}
}
})
.
allowPublicAcquisition
(
"
plDisablePage
"
,
function
()
{
...
...
@@ -99,15 +104,24 @@
rJS
(
window
)
.
ready
(
function
(
g
)
{
return
g
.
getDeclaredGadget
(
"
httpStorage
"
)
return
g
.
getDeclaredGadget
(
"
online
"
)
.
push
(
function
(
gadget
)
{
return
gadget
.
createJio
(
{
"
type
"
:
"
http
"
,
"
database
"
:
"
http://192.168.242.63:8080/
"
}
);
})
.
push
(
function
()
{
return
g
.
getDeclaredGadget
(
"
localhost
"
);
})
.
push
(
function
(
gadget
)
{
return
gadget
.
createJio
(
{
"
type
"
:
"
http
"
,
//indexeddb
"
database
"
:
"
http://localhost:8080/
"
}
//test
{
"
type
"
:
"
http
"
,
"
database
"
:
"
http://localhost:8080/
"
}
);
})
.
push
(
function
()
{
return
g
.
getDeclaredGadget
(
"
indexeddbStorag
e
"
);
return
g
.
getDeclaredGadget
(
"
offlin
e
"
);
})
.
push
(
function
(
gadget
)
{
return
gadget
.
createJio
(
...
...
@@ -130,10 +144,12 @@
}
gadget
.
storageType
=
gadget
.
storageType
||
0
;
if
(
options
.
page
===
"
playlist
"
)
{
if
(
options
.
id
===
"
indexeddbStorag
e
"
)
{
if
(
options
.
id
===
"
offlin
e
"
)
{
gadget
.
storageType
=
0
;
}
else
if
(
options
.
id
===
"
httpStorage
"
)
{
}
else
if
(
options
.
id
===
"
localhost
"
)
{
gadget
.
storageType
=
1
;
}
else
if
(
options
.
id
===
"
online
"
)
{
gadget
.
storageType
=
2
;
}
}
return
gadget
.
declareGadget
(
...
...
src/audioplayer/index.html
View file @
6b500761
...
...
@@ -24,10 +24,13 @@
</div>
<div
class=
"
indexeddbStorage"
data-gadget-url=
"../audioplayer_bridge/index.html"
data-gadget-scope=
"indexeddbStorag
e"
>
<div
class=
"
offline"
data-gadget-url=
"../audioplayer_bridge/index.html"
data-gadget-scope=
"offlin
e"
>
</div>
<div
class=
"httpStorage"
data-gadget-url=
"../audioplayer_bridge/index.html"
data-gadget-scope=
"httpStorage"
>
<div
class=
"localhost"
data-gadget-url=
"../audioplayer_bridge/index.html"
data-gadget-scope=
"localhost"
>
</div>
<div
class=
"online"
data-gadget-url=
"../audioplayer_bridge/index.html"
data-gadget-scope=
"online"
>
</div>
<article
class=
"gadget_container"
></article>
...
...
src/audioplayer_bridge/audiogadget.js
View file @
6b500761
/*global rJS, jIO, console */
/*global rJS, jIO, console, RSVP */
/*jslint nomen: true*/
(
function
(
rJS
,
jIO
)
{
"
use strict
"
;
...
...
@@ -6,17 +7,38 @@
.
ready
(
function
(
gadget
)
{
// Initialize the gadget local parameters
gadget
.
state_parameter_dict
=
{};
gadget
.
save
=
{};
})
.
declareMethod
(
'
createJio
'
,
function
(
jio_options
)
{
this
.
state_parameter_dict
.
jio_storage
=
jIO
.
createJIO
(
jio_options
);
})
.
declareMethod
(
'
allDocs
'
,
function
()
{
var
storage
=
this
.
state_parameter_dict
.
jio_storage
;
return
storage
.
allDocs
.
apply
(
storage
,
arguments
);
var
storage
=
this
.
state_parameter_dict
.
jio_storage
,
that
=
this
;
if
(
that
.
save
.
data
!==
undefined
)
{
return
that
.
save
;
}
return
storage
.
allDocs
.
apply
(
storage
,
arguments
)
.
then
(
function
(
result
)
{
that
.
save
=
result
;
return
result
;
});
})
.
declareMethod
(
'
get
'
,
function
()
{
var
storage
=
this
.
state_parameter_dict
.
jio_storage
;
.
declareMethod
(
'
get
'
,
function
(
param
)
{
var
storage
=
this
.
state_parameter_dict
.
jio_storage
,
result
=
this
.
save
,
length
,
i
;
if
(
result
.
data
!==
undefined
)
{
length
=
result
.
data
.
rows
.
length
;
for
(
i
=
0
;
i
<
length
;
i
+=
1
)
{
if
((
result
.
data
.
rows
[
i
].
doc
.
title
===
param
.
_id
)
||
(
result
.
data
.
rows
[
i
].
id
===
param
.
_id
))
{
//xxx
return
({
"
data
"
:
{
"
title
"
:
result
.
data
.
rows
[
i
].
doc
.
title
}});
}
}
}
return
storage
.
get
.
apply
(
storage
,
arguments
);
})
.
declareMethod
(
'
getAttachment
'
,
function
()
{
...
...
src/audioplayer_control/control.js
View file @
6b500761
/*global window, rJS, RSVP, console, URL, Math, parseInt, document,
Uint8Array,
File,
Audio, loopEventListener, jQuery, promiseEventListener*/
/*global window, rJS, RSVP, console, URL, Math, parseInt, document,
jIO,
Uint8Array, Audio, loopEventListener, jQuery, promiseEventListener*/
/*jslint nomen: true*/
(
function
(
window
,
rJS
,
RSVP
,
loopEventListener
,
$
,
promiseEventListener
)
{
...
...
@@ -122,6 +122,9 @@
gradient
.
addColorStop
(
0
,
'
#f00
'
);
that
.
audio
.
play
();
drawFrame
=
function
()
{
if
(
that
.
audio
.
duration
!==
0
)
{
bar_context
.
max
=
that
.
audio
.
duration
;
}
array
=
getFFTValue
(
that
);
canvasCtx
.
clearRect
(
0
,
0
,
cwidth
,
cheight
);
step
=
Math
.
round
(
array
.
length
/
meterNum
);
...
...
@@ -140,21 +143,7 @@
};
return
promiseRequestAnimation
(
drawFrame
);
}
function
nextToPlay
(
g
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
g
.
allDocs
({
"
include_docs
"
:
true
});
})
.
push
(
function
(
e
)
{
var
list
=
e
.
data
.
rows
,
id
;
do
{
id
=
list
[
Math
.
floor
(
Math
.
random
()
*
list
.
length
)].
id
;
}
while
(
g
.
currentId
===
id
);
return
g
.
displayThisPage
({
page
:
"
control
"
,
id
:
id
});
});
}
gk
.
declareAcquiredMethod
(
"
jio_getAttachment
"
,
"
jio_getAttachment
"
)
.
declareAcquiredMethod
(
"
jio_get
"
,
"
jio_get
"
)
.
declareAcquiredMethod
(
"
plSave
"
,
"
plSave
"
)
...
...
@@ -176,7 +165,10 @@
return
g
.
plGive
(
"
value
"
);
})
.
push
(
function
(
value
)
{
g
.
filter
.
frequency
=
value
;
if
(
value
===
0
)
{
value
=
5000
;
}
g
.
filter
.
frequency
.
value
=
value
;
})
.
push
(
function
()
{
g
.
currentId
=
options
.
id
;
...
...
@@ -190,7 +182,16 @@
return
g
.
displayThisTitle
(
result
.
data
.
title
);
})
.
push
(
function
()
{
return
nextToPlay
(
g
);
return
g
.
allDocs
({
"
include_docs
"
:
true
});
})
.
push
(
function
(
e
)
{
var
list
=
e
.
data
.
rows
,
id
;
do
{
id
=
list
[
Math
.
floor
(
Math
.
random
()
*
list
.
length
)].
id
;
}
while
(
g
.
currentId
===
id
);
return
g
.
displayThisPage
({
page
:
"
control
"
,
id
:
id
});
})
.
push
(
function
(
url
)
{
g
.
__element
.
getElementsByClassName
(
"
next
"
)[
0
].
href
=
url
;
...
...
@@ -224,7 +225,6 @@
return
g
.
plEnablePage
();
})
.
push
(
function
()
{
bar_context
.
max
=
g
.
audio
.
duration
;
time_context
.
style
.
left
=
bar_context
.
style
.
left
;
$
(
time_context
).
offset
().
top
=
$
(
bar_context
).
offset
().
top
+
3
;
time_context
.
innerHTML
=
timeFormat
(
g
.
audio
.
duration
);
...
...
@@ -235,10 +235,8 @@
}),
loopEventListener
(
g
.
audio
,
"
ended
"
,
false
,
function
()
{
return
nextToPlay
(
g
)
.
push
(
function
(
url
)
{
window
.
location
=
url
;
});
window
.
location
=
g
.
__element
.
getElementsByClassName
(
"
next
"
)[
0
].
href
;
}),
loopEventListener
(
command_context
,
"
click
"
,
false
,
function
()
{
...
...
src/audioplayer_playlist/index.html
View file @
6b500761
...
...
@@ -34,8 +34,9 @@
<div
data-role=
"footer"
data-position=
"fixed"
data-theme=
"b"
>
<div
data-role=
"navbar"
>
<ul>
<li><a
data-role=
"button"
class=
"indexeddbStorage"
data-icon=
"arrow-l"
>
indexeddbStorage
</a></li>
<li><a
data-role=
"button"
class=
"httpStorage"
data-icon=
"arrow-r"
>
httpStorage
</a></li>
<li><a
data-role=
"button"
class=
"offline"
data-icon=
"arrow-l"
>
offline
</a></li>
<li><a
data-role=
"button"
class=
"localhost"
data-icon=
"arrow-r"
>
localhost
</a></li>
<li><a
data-role=
"button"
class=
"online"
data-icon=
"arrow-r"
>
online
</a></li>
</ul>
</div>
<!-- /navbar -->
</div>
<!-- /footer -->
...
...
src/audioplayer_playlist/playlist.js
View file @
6b500761
...
...
@@ -24,16 +24,20 @@
.
push
(
function
()
{
return
RSVP
.
all
([
gadget
.
displayThisPage
({
page
:
"
playlist
"
,
id
:
"
indexeddbStorag
e
"
}),
id
:
"
offlin
e
"
}),
gadget
.
displayThisPage
({
page
:
"
playlist
"
,
id
:
"
httpStorage
"
})
id
:
"
localhost
"
}),
gadget
.
displayThisPage
({
page
:
"
playlist
"
,
id
:
"
online
"
})
]);
})
.
push
(
function
(
param_list
)
{
gadget
.
__element
.
getElementsByClassName
(
'
indexeddbStorag
e
'
)[
0
]
gadget
.
__element
.
getElementsByClassName
(
'
offlin
e
'
)[
0
]
.
href
=
param_list
[
0
];
gadget
.
__element
.
getElementsByClassName
(
'
httpStorage
'
)[
0
]
gadget
.
__element
.
getElementsByClassName
(
'
localhost
'
)[
0
]
.
href
=
param_list
[
1
];
gadget
.
__element
.
getElementsByClassName
(
'
online
'
)[
0
]
.
href
=
param_list
[
2
];
})
.
push
(
function
()
{
return
gadget
.
allDocs
({
"
include_docs
"
:
true
});
...
...
@@ -43,8 +47,9 @@
i
,
j
,
exp
;
if
(
options
.
id
!==
undefined
&&
options
.
id
!==
"
indexeddbStorage
"
&&
options
.
id
!==
"
httpStorage
"
)
{
if
(
options
.
id
!==
undefined
&&
options
.
id
!==
"
offline
"
&&
options
.
id
!==
"
localhost
"
&&
options
.
id
!==
"
online
"
)
{
for
(
i
=
0
,
j
=
0
;
i
<
e
.
data
.
rows
.
length
;
i
+=
1
)
{
exp
=
new
RegExp
(
options
.
id
,
"
i
"
);
if
(
e
.
data
.
rows
[
i
].
doc
.
title
.
search
(
exp
)
!==
-
1
)
{
...
...
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