Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
b457655e
Commit
b457655e
authored
Dec 07, 2006
by
Richard Mansfield
Browse files
Check if file exists (in js) before uploading
parent
802c80a4
Changes
3
Hide whitespace changes
Inline
Side-by-side
htdocs/artefact/file/index.php
View file @
b457655e
...
...
@@ -39,8 +39,7 @@ foreach ($strings as $string) {
$javascript
=
<<<JAVASCRIPT
var browser = new FileBrowser('filelist');
var uploader = new FileUploader('uploader');
uploader.uploadcallback = browser.refresh;
var uploader = new FileUploader('uploader', null, null, browser.refresh, browser.fileexists);
browser.changedircallback = uploader.updatedestination;
JAVASCRIPT;
...
...
htdocs/artefact/file/js/filebrowser.js
View file @
b457655e
...
...
@@ -6,6 +6,7 @@ function FileBrowser(element, changedircallback) {
this
.
pathids
=
{
'
/
'
:
null
};
this
.
cwd
=
'
/
'
;
this
.
changedircallback
=
changedircallback
;
this
.
filenames
=
{};
this
.
init
=
function
()
{
self
.
filelist
=
new
TableRenderer
(
...
...
@@ -106,6 +107,7 @@ function FileBrowser(element, changedircallback) {
}
this
.
formatname
=
function
(
r
)
{
self
.
filenames
[
r
.
title
]
=
true
;
if
(
r
.
artefacttype
==
'
file
'
)
{
return
TD
(
null
,
r
.
title
);
}
...
...
@@ -118,10 +120,15 @@ function FileBrowser(element, changedircallback) {
}
}
this
.
fileexists
=
function
(
filename
)
{
return
self
.
filenames
[
filename
]
==
true
;
}
this
.
changedir
=
function
(
path
)
{
self
.
cwd
=
path
;
self
.
linked_path
();
self
.
changedircallback
(
self
.
pathids
[
path
],
path
);
self
.
filenames
=
{};
var
args
=
path
==
'
/
'
?
null
:
{
'
folder
'
:
self
.
pathids
[
path
]};
self
.
filelist
.
doupdate
(
args
);
return
false
;
...
...
htdocs/js/fileuploader.js
View file @
b457655e
function
FileUploader
(
element
,
foldername
,
folderid
,
uploadcallback
)
{
function
FileUploader
(
element
,
foldername
,
folderid
,
uploadcallback
,
fileexists
)
{
var
self
=
this
;
this
.
element
=
element
;
this
.
foldername
=
foldername
?
foldername
:
get_string
(
'
home
'
);
this
.
folderid
=
folderid
;
this
.
uploadcallback
=
uploadcallback
;
if
(
typeof
(
fileexists
)
==
'
function
'
)
{
this
.
fileexists
=
fileexists
;
}
else
{
this
.
fileexists
=
function
(
filename
)
{
alert
(
filename
);
};
}
this
.
init
=
function
()
{
self
.
nextupload
=
1
;
...
...
@@ -70,10 +77,6 @@ function FileUploader(element, foldername, folderid, uploadcallback) {
}
}
this
.
fileexists
=
function
(
filename
)
{
return
true
;
}
this
.
sendform
=
function
(
replace
)
{
var
localname
=
self
.
form
.
userfile
.
value
;
if
(
isEmpty
(
localname
))
{
...
...
Write
Preview
Supports
Markdown
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