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
bd4038b0
Commit
bd4038b0
authored
Aug 14, 2014
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add download functionality in local mode
parent
3339d9f8
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
125 additions
and
11 deletions
+125
-11
dev/audioplayer/audioplayer.js
dev/audioplayer/audioplayer.js
+7
-1
dev/audioplayer_playlist_local/index.html
dev/audioplayer_playlist_local/index.html
+7
-2
dev/audioplayer_playlist_local/playlist.js
dev/audioplayer_playlist_local/playlist.js
+46
-3
src/audioplayer/audioplayer.js
src/audioplayer/audioplayer.js
+7
-1
src/audioplayer_playlist_local/index.html
src/audioplayer_playlist_local/index.html
+7
-2
src/audioplayer_playlist_local/playlist.js
src/audioplayer_playlist_local/playlist.js
+51
-2
No files found.
dev/audioplayer/audioplayer.js
View file @
bd4038b0
...
@@ -115,7 +115,13 @@
...
@@ -115,7 +115,13 @@
return
jio_gadget
.
get
.
apply
(
jio_gadget
,
param_list
);
return
jio_gadget
.
get
.
apply
(
jio_gadget
,
param_list
);
});
});
}).
allowPublicAcquisition
(
"
jio_remove
"
,
function
(
param_list
)
{
}).
allowPublicAcquisition
(
"
jio_remove
"
,
function
(
param_list
)
{
return
this
.
getDeclaredGadget
(
storageType
(
this
.
storageType
)).
push
(
function
(
jio_gadget
)
{
var
type
;
if
(
param_list
[
1
]
===
0
||
param_list
[
1
]
===
1
)
{
type
=
param_list
[
1
];
}
else
{
type
=
this
.
storageType
;
}
return
this
.
getDeclaredGadget
(
storageType
(
type
)).
push
(
function
(
jio_gadget
)
{
return
jio_gadget
.
remove
.
apply
(
jio_gadget
,
param_list
);
return
jio_gadget
.
remove
.
apply
(
jio_gadget
,
param_list
);
});
});
}).
allowPublicAcquisition
(
"
jio_put
"
,
function
(
param_list
)
{
}).
allowPublicAcquisition
(
"
jio_put
"
,
function
(
param_list
)
{
...
...
dev/audioplayer_playlist_local/index.html
View file @
bd4038b0
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
<script
src=
"../lib/handlebars.min.js"
></script>
<script
src=
"../lib/handlebars.min.js"
></script>
<script
src=
"../mixin_promise/mixin_promise.js"
type=
"text/javascript"
></script>
<script
src=
"../mixin_promise/mixin_promise.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/id3-minimized.js"
type=
"text/javascript"
></script>
<script
id=
"network"
type=
"text/x-handlebars-template"
>
<script
id=
"network"
type=
"text/x-handlebars-template"
>
{{
#
each
rows
}}
{{
#
each
rows
}}
...
@@ -22,6 +23,10 @@
...
@@ -22,6 +23,10 @@
{{
this
.
doc
.
title
}}
{{
this
.
doc
.
title
}}
<
/a
>
<
/a
>
{{
/
compare
}}
{{
/
compare
}}
<
a
href
=
#
page
=
playlist
&
id
=
{{
this
.
id
}}
&
action
=
download
>
data
-
rel
=
popup
data
-
position
-
to
=
window
<
/a
>
<
/li>
<
/li>
{{
/
each
}}
{{
/
each
}}
</script>
</script>
...
@@ -34,7 +39,7 @@
...
@@ -34,7 +39,7 @@
<input
type=
"search"
class=
"research"
placeholder=
"research..."
/>
<input
type=
"search"
class=
"research"
placeholder=
"research..."
/>
<div
data-role=
"content"
>
<div
data-role=
"content"
>
<ul
data-role=
"listview"
data-split-icon=
"
delete
"
data-split-theme=
"d"
>
<ul
data-role=
"listview"
data-split-icon=
"
arrow-d
"
data-split-theme=
"d"
>
</ul>
</ul>
</div>
</div>
...
...
dev/audioplayer_playlist_local/playlist.js
View file @
bd4038b0
/*global window, rJS, RSVP, console, jQuery, $, JSON, Handlebars,
/*global window, rJS, RSVP, console, jQuery, $, JSON, Handlebars,
loopEventListener, RegExp */
loopEventListener, RegExp
, ID3, FileAPIReader, Date
*/
/*jslint maxlen:80, nomen: true */
/*jslint maxlen:80, nomen: true */
(
function
(
window
,
rJS
,
$
,
Handlebars
,
loopEventListener
)
{
(
function
(
window
,
rJS
,
$
,
Handlebars
,
loopEventListener
)
{
"
use strict
"
;
"
use strict
"
;
var
gk
=
rJS
(
window
),
network_source
=
gk
.
__template_element
.
getElementById
(
"
network
"
).
innerHTML
,
network
=
Handlebars
.
compile
(
network_source
);
var
gk
=
rJS
(
window
),
network_source
=
gk
.
__template_element
.
getElementById
(
"
network
"
).
innerHTML
,
network
=
Handlebars
.
compile
(
network_source
);
gk
.
declareAcquiredMethod
(
"
allDocs
"
,
"
allDocs
"
).
declareAcquiredMethod
(
"
displayThisPage
"
,
"
displayThisPage
"
).
declareAcquiredMethod
(
"
displayThisTitle
"
,
"
displayThisTitle
"
).
declareAcquiredMethod
(
"
plEnablePage
"
,
"
plEnablePage
"
).
declareAcquiredMethod
(
"
pleaseRedirectMyHash
"
,
"
pleaseRedirectMyHash
"
).
declareMethod
(
"
render
"
,
function
(
options
)
{
gk
.
declareAcquiredMethod
(
"
allDocs
"
,
"
allDocs
"
).
declareAcquiredMethod
(
"
jio_putAttachment
"
,
"
jio_putAttachment
"
).
declareAcquiredMethod
(
"
jio_post
"
,
"
jio_post
"
).
declareAcquiredMethod
(
"
jio_remove
"
,
"
jio_remove
"
).
declareAcquiredMethod
(
"
jio_getAttachment
"
,
"
jio_getAttachment
"
).
declareAcquiredMethod
(
"
displayThisPage
"
,
"
displayThisPage
"
).
declareAcquiredMethod
(
"
displayThisTitle
"
,
"
displayThisTitle
"
).
declareAcquiredMethod
(
"
plEnablePage
"
,
"
plEnablePage
"
).
declareAcquiredMethod
(
"
pleaseRedirectMyHash
"
,
"
pleaseRedirectMyHash
"
).
declareMethod
(
"
render
"
,
function
(
options
)
{
var
gadget
=
this
,
list
=
gadget
.
__element
.
getElementsByTagName
(
"
ul
"
)[
0
];
var
gadget
=
this
,
list
=
gadget
.
__element
.
getElementsByTagName
(
"
ul
"
)[
0
];
return
new
RSVP
.
Queue
().
push
(
function
()
{
return
new
RSVP
.
Queue
().
push
(
function
()
{
return
RSVP
.
all
([
gadget
.
displayThisPage
({
return
RSVP
.
all
([
gadget
.
displayThisPage
({
...
@@ -15,8 +15,42 @@
...
@@ -15,8 +15,42 @@
id
:
"
online
"
id
:
"
online
"
})
]);
})
]);
}).
push
(
function
(
param_list
)
{
}).
push
(
function
(
param_list
)
{
var
blob
;
gadget
.
__element
.
getElementsByClassName
(
"
offline
"
)[
0
].
href
=
param_list
[
0
];
gadget
.
__element
.
getElementsByClassName
(
"
offline
"
)[
0
].
href
=
param_list
[
0
];
gadget
.
__element
.
getElementsByClassName
(
"
online
"
)[
0
].
href
=
param_list
[
1
];
gadget
.
__element
.
getElementsByClassName
(
"
online
"
)[
0
].
href
=
param_list
[
1
];
if
(
options
.
action
===
"
download
"
)
{
return
gadget
.
jio_getAttachment
({
_id
:
options
.
id
,
_attachment
:
"
enclosure
"
}).
then
(
function
(
file
)
{
var
now
=
new
Date
(),
type
;
if
(
options
.
id
.
indexOf
(
"
.mp3
"
)
===
-
1
)
{
type
=
"
video/webm
"
;
}
else
{
type
=
"
audio/mp3
"
;
}
blob
=
file
;
return
gadget
.
jio_post
({
title
:
options
.
id
,
type
:
type
,
format
:
type
,
size
:
blob
.
size
,
artist
:
"
unknown
"
,
album
:
"
unknown
"
,
year
:
"
unknown
"
,
picture
:
"
./unknown.jpg
"
,
modified
:
now
.
toUTCString
(),
date
:
now
.
getFullYear
()
+
"
-
"
+
(
now
.
getMonth
()
+
1
)
+
"
-
"
+
now
.
getDate
()
},
0
);
}).
then
(
function
(
res
)
{
gadget
.
putId
=
res
.
id
;
return
gadget
.
jio_putAttachment
({
_id
:
res
.
id
,
_attachment
:
"
enclosure
"
,
_blob
:
blob
},
0
);
});
}
}).
push
(
function
()
{
}).
push
(
function
()
{
return
gadget
.
allDocs
({
return
gadget
.
allDocs
({
include_docs
:
true
include_docs
:
true
...
@@ -29,7 +63,7 @@
...
@@ -29,7 +63,7 @@
}
}
return
options
.
inverse
(
this
);
return
options
.
inverse
(
this
);
});
});
if
(
options
.
id
!==
undefined
&&
options
.
id
!==
"
localhost
"
)
{
if
(
options
.
id
!==
undefined
&&
options
.
id
!==
"
localhost
"
&&
options
.
action
!==
"
download
"
)
{
tmp
=
[];
tmp
=
[];
for
(
i
=
0
,
j
=
0
;
i
<
e
.
data
.
rows
.
length
;
i
+=
1
)
{
for
(
i
=
0
,
j
=
0
;
i
<
e
.
data
.
rows
.
length
;
i
+=
1
)
{
exp
=
new
RegExp
(
options
.
id
,
"
i
"
);
exp
=
new
RegExp
(
options
.
id
,
"
i
"
);
...
@@ -47,6 +81,15 @@
...
@@ -47,6 +81,15 @@
return
gadget
.
displayThisTitle
(
"
localhost playlist:
"
+
tmp
.
length
+
"
media
"
);
return
gadget
.
displayThisTitle
(
"
localhost playlist:
"
+
tmp
.
length
+
"
media
"
);
}).
fail
(
function
(
error
)
{
}).
fail
(
function
(
error
)
{
if
(
!
(
error
instanceof
RSVP
.
CancellationError
))
{
if
(
!
(
error
instanceof
RSVP
.
CancellationError
))
{
if
(
error
.
target
.
error
.
name
===
"
QuotaExceededError
"
)
{
gadget
.
__element
.
getElementsByClassName
(
"
info
"
)[
0
].
innerHTML
=
"
QuotaError
"
;
if
(
gadget
.
putId
)
{
return
gadget
.
jio_remove
({
_id
:
gadget
.
putId
},
0
);
}
return
;
}
gadget
.
__element
.
getElementsByClassName
(
"
info
"
)[
0
].
innerHTML
=
"
please enable local server
"
;
gadget
.
__element
.
getElementsByClassName
(
"
info
"
)[
0
].
innerHTML
=
"
please enable local server
"
;
}
}
});
});
...
...
src/audioplayer/audioplayer.js
View file @
bd4038b0
...
@@ -133,7 +133,13 @@
...
@@ -133,7 +133,13 @@
});
});
})
})
.
allowPublicAcquisition
(
"
jio_remove
"
,
function
(
param_list
)
{
.
allowPublicAcquisition
(
"
jio_remove
"
,
function
(
param_list
)
{
return
this
.
getDeclaredGadget
(
storageType
(
this
.
storageType
))
var
type
;
if
(
param_list
[
1
]
===
0
||
param_list
[
1
]
===
1
)
{
type
=
param_list
[
1
];
}
else
{
type
=
this
.
storageType
;
}
return
this
.
getDeclaredGadget
(
storageType
(
type
))
.
push
(
function
(
jio_gadget
)
{
.
push
(
function
(
jio_gadget
)
{
return
jio_gadget
.
remove
.
apply
(
jio_gadget
,
param_list
);
return
jio_gadget
.
remove
.
apply
(
jio_gadget
,
param_list
);
});
});
...
...
src/audioplayer_playlist_local/index.html
View file @
bd4038b0
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
<script
src=
"../<%= copy.handlebars.relative_dest%>"
></script>
<script
src=
"../<%= copy.handlebars.relative_dest%>"
></script>
<script
src=
"../mixin_promise/mixin_promise.js"
type=
"text/javascript"
></script>
<script
src=
"../mixin_promise/mixin_promise.js"
type=
"text/javascript"
></script>
<script
src=
"../<%= copy.id3.relative_dest %>"
type=
"text/javascript"
></script>
<script
id=
"network"
type=
"text/x-handlebars-template"
>
<script
id=
"network"
type=
"text/x-handlebars-template"
>
{{
#
each
rows
}}
{{
#
each
rows
}}
...
@@ -22,6 +23,10 @@
...
@@ -22,6 +23,10 @@
{{
this
.
doc
.
title
}}
{{
this
.
doc
.
title
}}
<
/a
>
<
/a
>
{{
/
compare
}}
{{
/
compare
}}
<
a
href
=
#
page
=
playlist
&
id
=
{{
this
.
id
}}
&
action
=
download
>
data
-
rel
=
popup
data
-
position
-
to
=
window
<
/a
>
<
/li>
<
/li>
{{
/
each
}}
{{
/
each
}}
</script>
</script>
...
@@ -34,7 +39,7 @@
...
@@ -34,7 +39,7 @@
<input
type=
"search"
class=
"research"
placeholder=
"research..."
/>
<input
type=
"search"
class=
"research"
placeholder=
"research..."
/>
<div
data-role=
"content"
>
<div
data-role=
"content"
>
<ul
data-role=
"listview"
data-split-icon=
"
delete
"
data-split-theme=
"d"
>
<ul
data-role=
"listview"
data-split-icon=
"
arrow-d
"
data-split-theme=
"d"
>
</ul>
</ul>
</div>
</div>
...
...
src/audioplayer_playlist_local/playlist.js
View file @
bd4038b0
/*global window, rJS, RSVP, console, jQuery, $, JSON, Handlebars,
/*global window, rJS, RSVP, console, jQuery, $, JSON, Handlebars,
loopEventListener, RegExp */
loopEventListener, RegExp
, ID3, FileAPIReader, Date
*/
/*jslint maxlen:80, nomen: true */
/*jslint maxlen:80, nomen: true */
...
@@ -10,6 +10,10 @@
...
@@ -10,6 +10,10 @@
.
getElementById
(
'
network
'
).
innerHTML
,
.
getElementById
(
'
network
'
).
innerHTML
,
network
=
Handlebars
.
compile
(
network_source
);
network
=
Handlebars
.
compile
(
network_source
);
gk
.
declareAcquiredMethod
(
"
allDocs
"
,
"
allDocs
"
)
gk
.
declareAcquiredMethod
(
"
allDocs
"
,
"
allDocs
"
)
.
declareAcquiredMethod
(
"
jio_putAttachment
"
,
"
jio_putAttachment
"
)
.
declareAcquiredMethod
(
"
jio_post
"
,
"
jio_post
"
)
.
declareAcquiredMethod
(
"
jio_remove
"
,
"
jio_remove
"
)
.
declareAcquiredMethod
(
"
jio_getAttachment
"
,
"
jio_getAttachment
"
)
.
declareAcquiredMethod
(
"
displayThisPage
"
,
"
displayThisPage
"
)
.
declareAcquiredMethod
(
"
displayThisPage
"
,
"
displayThisPage
"
)
.
declareAcquiredMethod
(
"
displayThisTitle
"
,
"
displayThisTitle
"
)
.
declareAcquiredMethod
(
"
displayThisTitle
"
,
"
displayThisTitle
"
)
.
declareAcquiredMethod
(
"
plEnablePage
"
,
"
plEnablePage
"
)
.
declareAcquiredMethod
(
"
plEnablePage
"
,
"
plEnablePage
"
)
...
@@ -27,10 +31,46 @@
...
@@ -27,10 +31,46 @@
]);
]);
})
})
.
push
(
function
(
param_list
)
{
.
push
(
function
(
param_list
)
{
var
blob
;
gadget
.
__element
.
getElementsByClassName
(
'
offline
'
)[
0
]
gadget
.
__element
.
getElementsByClassName
(
'
offline
'
)[
0
]
.
href
=
param_list
[
0
];
.
href
=
param_list
[
0
];
gadget
.
__element
.
getElementsByClassName
(
'
online
'
)[
0
]
gadget
.
__element
.
getElementsByClassName
(
'
online
'
)[
0
]
.
href
=
param_list
[
1
];
.
href
=
param_list
[
1
];
if
(
options
.
action
===
"
download
"
)
{
return
gadget
.
jio_getAttachment
({
"
_id
"
:
options
.
id
,
"
_attachment
"
:
"
enclosure
"
})
.
then
(
function
(
file
)
{
var
now
=
new
Date
(),
type
;
if
(
options
.
id
.
indexOf
(
"
.mp3
"
)
===
-
1
)
{
type
=
"
video/webm
"
;
}
else
{
type
=
"
audio/mp3
"
;
}
blob
=
file
;
return
gadget
.
jio_post
({
"
title
"
:
options
.
id
,
"
type
"
:
type
,
"
format
"
:
type
,
"
size
"
:
blob
.
size
,
"
artist
"
:
"
unknown
"
,
"
album
"
:
"
unknown
"
,
"
year
"
:
"
unknown
"
,
"
picture
"
:
"
./unknown.jpg
"
,
"
modified
"
:
now
.
toUTCString
(),
"
date
"
:
now
.
getFullYear
()
+
"
-
"
+
(
now
.
getMonth
()
+
1
)
+
"
-
"
+
now
.
getDate
()
},
0
);
})
.
then
(
function
(
res
)
{
gadget
.
putId
=
res
.
id
;
return
gadget
.
jio_putAttachment
({
"
_id
"
:
res
.
id
,
"
_attachment
"
:
"
enclosure
"
,
"
_blob
"
:
blob
},
0
);
});
}
})
})
.
push
(
function
()
{
.
push
(
function
()
{
return
gadget
.
allDocs
({
"
include_docs
"
:
true
});
return
gadget
.
allDocs
({
"
include_docs
"
:
true
});
...
@@ -46,7 +86,8 @@
...
@@ -46,7 +86,8 @@
}
}
return
options
.
inverse
(
this
);
return
options
.
inverse
(
this
);
});
});
if
(
options
.
id
!==
undefined
&&
options
.
id
!==
"
localhost
"
)
{
if
(
options
.
id
!==
undefined
&&
options
.
id
!==
"
localhost
"
&&
options
.
action
!==
"
download
"
)
{
tmp
=
[];
tmp
=
[];
for
(
i
=
0
,
j
=
0
;
i
<
e
.
data
.
rows
.
length
;
i
+=
1
)
{
for
(
i
=
0
,
j
=
0
;
i
<
e
.
data
.
rows
.
length
;
i
+=
1
)
{
exp
=
new
RegExp
(
options
.
id
,
"
i
"
);
exp
=
new
RegExp
(
options
.
id
,
"
i
"
);
...
@@ -66,6 +107,14 @@
...
@@ -66,6 +107,14 @@
})
})
.
fail
(
function
(
error
)
{
.
fail
(
function
(
error
)
{
if
(
!
(
error
instanceof
RSVP
.
CancellationError
))
{
if
(
!
(
error
instanceof
RSVP
.
CancellationError
))
{
if
(
error
.
target
.
error
.
name
===
"
QuotaExceededError
"
)
{
gadget
.
__element
.
getElementsByClassName
(
'
info
'
)[
0
].
innerHTML
=
"
QuotaError
"
;
if
(
gadget
.
putId
)
{
return
gadget
.
jio_remove
({
"
_id
"
:
gadget
.
putId
},
0
);
}
return
;
}
gadget
.
__element
.
getElementsByClassName
(
'
info
'
)[
0
].
innerHTML
=
gadget
.
__element
.
getElementsByClassName
(
'
info
'
)[
0
].
innerHTML
=
"
please enable local server
"
;
"
please enable local server
"
;
}
}
...
...
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