Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
renderjs
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
renderjs
Commits
0ff0e9c2
Commit
0ff0e9c2
authored
Jun 04, 2013
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fetch parameter from url
parent
b82bce7b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
24 deletions
+57
-24
gadget/filebrowser.js
gadget/filebrowser.js
+57
-24
No files found.
gadget/filebrowser.js
View file @
0ff0e9c2
/*global document, jQuery */
// filebrowser.html?file=browser%3A%2F%2Fbrowse%2Fls%2F
"
use strict
"
;
(
function
(
document
,
$
)
{
$
(
document
).
ready
(
function
()
{
$
.
ajax
({
method
:
'
GET
'
,
// XXX Hardcoded
url
:
"
browser://browse/ls/
"
,
context
:
$
(
'
body
'
),
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
$
(
this
).
text
(
errorThrown
);
},
success
:
function
(
value
,
textStatus
,
jqXHR
)
{
var
content_type
=
jqXHR
.
getResponseHeader
(
"
Content-Type
"
)
||
""
;
// XXX Hardcoded mime type
if
(
content_type
.
split
(
'
;
'
)[
0
]
===
"
application/hal+json
"
)
{
// XXX Will fail if response does not send expected links...
$
(
this
).
html
(
"
<ul>
"
);
for
(
var
i
in
value
.
_links
.
contents
){
$
(
this
).
append
(
"
<li>
"
+
value
.
_links
.
contents
[
i
].
href
+
"
</li>
"
);
}
$
(
this
).
append
(
"
</ul>
"
);
}
else
{
$
(
this
).
text
(
"
Unsupported content type
"
+
content_type
);
};
},
});
var
getParameter
=
function
(
searchString
,
paramName
)
{
var
i
,
val
,
params
=
searchString
.
split
(
"
&
"
);
for
(
i
=
0
;
i
<
params
.
length
;
i
++
)
{
val
=
params
[
i
].
split
(
"
=
"
);
if
(
val
[
0
]
==
paramName
)
{
return
decodeURIComponent
(
val
[
1
]);
}
}
return
null
;
};
var
mapUrl
=
function
(
url
)
{
var
searchString
=
url
.
href
.
split
(
"
?
"
)[
1
],
fileToDisplay
;
if
(
searchString
)
{
fileToDisplay
=
getParameter
(
searchString
,
"
file
"
);
if
(
fileToDisplay
)
{
$
.
ajax
({
method
:
'
GET
'
,
// XXX Hardcoded
url
:
fileToDisplay
,
context
:
$
(
'
body
'
),
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
$
(
this
).
text
(
errorThrown
);
},
success
:
function
(
value
,
textStatus
,
jqXHR
)
{
var
content_type
=
jqXHR
.
getResponseHeader
(
"
Content-Type
"
)
||
""
;
// XXX Hardcoded mime type
if
(
content_type
.
split
(
'
;
'
)[
0
]
===
"
application/hal+json
"
)
{
// XXX Will fail if response does not send expected links...
$
(
this
).
html
(
"
<ul>
"
);
for
(
var
i
in
value
.
_links
.
contents
){
$
(
this
).
append
(
"
<li><button id='
"
+
i
+
"
'>
"
+
value
.
_links
.
contents
[
i
].
href
+
"
</button></li>
"
);
$
(
this
).
find
(
"
#
"
+
i
.
toString
()).
on
(
'
click
'
,
function
(
e
,
target
)
{
// XXX What to do with the url info?
console
.
log
(
$
(
this
).
text
());
});
}
$
(
this
).
append
(
"
</ul>
"
);
}
else
{
$
(
this
).
text
(
"
Unsupported content type
"
+
content_type
);
};
},
});
}
else
{
$
(
this
).
text
(
"
No parameter found in url
"
);
}
}
};
$
(
document
).
ready
(
function
()
{
mapUrl
(
window
.
location
);
});
}(
document
,
jQuery
));
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