Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
PUBLIC
/
surfer-okd
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 04bc2989
authored
9 years ago
by
Johannes Zellner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work off of the location hash to make browser history work
1 parent
95c627bf
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
6 deletions
app/js/app.js
app/js/app.js
View file @
04bc298
...
@@ -21,7 +21,7 @@ function login(username, password) {
...
@@ -21,7 +21,7 @@ function login(username, password) {
localStorage
.
username
=
username
;
localStorage
.
username
=
username
;
localStorage
.
password
=
password
;
localStorage
.
password
=
password
;
loadDirectory
(
app
.
path
);
loadDirectory
(
window
.
location
.
hash
.
slice
(
1
)
);
});
});
}
}
...
@@ -43,6 +43,10 @@ function encode(filePath) {
...
@@ -43,6 +43,10 @@ function encode(filePath) {
return
filePath
.
split
(
'/'
).
map
(
encodeURIComponent
).
join
(
'/'
);
return
filePath
.
split
(
'/'
).
map
(
encodeURIComponent
).
join
(
'/'
);
}
}
function
decode
(
filePath
)
{
return
filePath
.
split
(
'/'
).
map
(
decodeURIComponent
).
join
(
'/'
);
}
var
mimeTypes
=
{
var
mimeTypes
=
{
images
:
[
'.png'
,
'.jpg'
,
'.jpeg'
,
'.tiff'
,
'.gif'
],
images
:
[
'.png'
,
'.jpg'
,
'.jpeg'
,
'.tiff'
,
'.gif'
],
text
:
[
'.txt'
,
'.md'
],
text
:
[
'.txt'
,
'.md'
],
...
@@ -81,13 +85,16 @@ function loadDirectory(filePath) {
...
@@ -81,13 +85,16 @@ function loadDirectory(filePath) {
if
(
error
)
return
console
.
error
(
error
);
if
(
error
)
return
console
.
error
(
error
);
if
(
result
.
statusCode
===
401
)
return
logout
();
if
(
result
.
statusCode
===
401
)
return
logout
();
result
.
body
.
entries
.
sort
(
function
(
a
,
b
)
{
return
a
.
isDirectory
&&
b
.
isFile
?
-
1
:
1
});
result
.
body
.
entries
.
sort
(
function
(
a
,
b
)
{
return
a
.
isDirectory
&&
b
.
isFile
?
-
1
:
1
;
});
app
.
entries
=
result
.
body
.
entries
.
map
(
function
(
entry
)
{
app
.
entries
=
result
.
body
.
entries
.
map
(
function
(
entry
)
{
entry
.
previewUrl
=
getPreviewUrl
(
entry
,
filePath
);
entry
.
previewUrl
=
getPreviewUrl
(
entry
,
filePath
);
return
entry
;
return
entry
;
});
});
app
.
path
=
filePath
;
app
.
path
=
filePath
;
app
.
pathParts
=
filePath
.
split
(
'/'
).
filter
(
function
(
e
)
{
return
!!
e
;
});
app
.
pathParts
=
decode
(
filePath
).
split
(
'/'
).
filter
(
function
(
e
)
{
return
!!
e
;
});
// update in case this was triggered from code
window
.
location
.
hash
=
app
.
path
;
Vue
.
nextTick
(
function
()
{
Vue
.
nextTick
(
function
()
{
$
(
function
()
{
$
(
function
()
{
...
@@ -98,15 +105,18 @@ function loadDirectory(filePath) {
...
@@ -98,15 +105,18 @@ function loadDirectory(filePath) {
}
}
function
open
(
entry
)
{
function
open
(
entry
)
{
var
path
=
sanitize
(
app
.
path
+
'/'
+
entry
.
filePath
);
var
path
=
encode
(
sanitize
(
app
.
path
+
'/'
+
entry
.
filePath
)
);
if
(
entry
.
isDirectory
)
return
loadDirectory
(
path
);
if
(
entry
.
isDirectory
)
{
window
.
location
.
hash
=
path
;
return
;
}
window
.
open
(
path
);
window
.
open
(
path
);
}
}
function
up
()
{
function
up
()
{
loadDirectory
(
app
.
path
.
split
(
'/'
).
slice
(
0
,
-
1
).
filter
(
function
(
p
)
{
return
!!
p
;
}).
join
(
'/'
));
window
.
location
.
hash
=
encode
(
sanitize
(
app
.
path
.
split
(
'/'
).
slice
(
0
,
-
1
).
filter
(
function
(
p
)
{
return
!!
p
;
}).
join
(
'/'
)
));
}
}
function
upload
()
{
function
upload
()
{
...
@@ -219,4 +229,8 @@ var app = new Vue({
...
@@ -219,4 +229,8 @@ var app = new Vue({
login
(
localStorage
.
username
,
localStorage
.
password
);
login
(
localStorage
.
username
,
localStorage
.
password
);
$
(
window
).
on
(
'hashchange'
,
function
()
{
loadDirectory
(
window
.
location
.
hash
.
slice
(
1
));
});
})();
})();
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
Attach a file
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 post a comment