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
Klaus Wölfel
renderjs
Commits
5eb28b1c
Commit
5eb28b1c
authored
Jun 04, 2013
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass plumb url to gadget instead of hardcoding
parent
d4345bd9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
34 deletions
+53
-34
gadget/filebrowser.js
gadget/filebrowser.js
+41
-29
gadget/filebrowser_and_preview.js
gadget/filebrowser_and_preview.js
+9
-2
renderjs.js
renderjs.js
+3
-3
No files found.
gadget/filebrowser.js
View file @
5eb28b1c
...
...
@@ -32,37 +32,49 @@
$
(
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
)
{
$
.
ajax
({
// XXX Hardcoded post and url
// Why using postMessage?
method
:
"
POST
"
,
url
:
"
browser://plumb/topwindow/
"
,
context
:
$
(
this
),
data
:
$
(
this
).
text
(),
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
console
.
log
(
"
Plumbing failed:
"
+
errorThrown
);
},
// success: function (value, textStatus, jqXHR) {
// console.log(value);
// },
});
});
}
$
(
this
).
append
(
"
</ul>
"
);
}
else
{
$
(
this
).
text
(
"
Unsupported content type
"
+
content_type
);
};
$
.
ajax
({
method
:
'
GET
'
,
// XXX Hardcoded
url
:
value
.
_links
.
storage
.
href
,
context
:
$
(
'
body
'
),
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
$
(
this
).
text
(
errorThrown
);
},
success
:
function
(
value2
,
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
value2
.
_links
.
contents
){
$
(
this
).
append
(
"
<li><button id='
"
+
i
+
"
'>
"
+
value2
.
_links
.
contents
[
i
].
href
+
"
</button></li>
"
);
$
(
this
).
find
(
"
#
"
+
i
.
toString
()).
on
(
'
click
'
,
function
(
e
,
target
)
{
$
.
ajax
({
// XXX Hardcoded post and url
// Why using postMessage?
method
:
"
POST
"
,
url
:
value
.
_links
.
display
.
href
,
context
:
$
(
this
),
data
:
$
(
this
).
text
(),
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
console
.
log
(
"
Plumbing failed:
"
+
errorThrown
);
},
// success: function (value, textStatus, jqXHR) {
// console.log(value);
// },
});
});
}
$
(
this
).
append
(
"
</ul>
"
);
}
else
{
$
(
this
).
text
(
"
Unsupported content type
"
+
content_type
);
};
},
});
},
});
}
else
{
$
(
"
body
"
).
text
(
"
No parameter found in url
"
);
}
...
...
gadget/filebrowser_and_preview.js
View file @
5eb28b1c
...
...
@@ -50,17 +50,24 @@
var
mapUrl
=
function
(
url
)
{
var
searchString
=
url
.
href
.
split
(
"
?
"
)[
1
],
fileToDisplay
;
fileToDisplay
,
fileToDisplayData
;
if
(
searchString
)
{
fileToDisplay
=
getParameter
(
searchString
,
"
file
"
);
fileToDisplayData
=
"
data://application/hal+json;base64,
"
+
window
.
btoa
(
JSON
.
stringify
({
_links
:
{
self
:
{
href
:
'
browser://browse/ls/
'
},
storage
:
{
href
:
'
browser://browse/ls/
'
},
display
:
{
href
:
'
browser://plumb/parentwindow/
'
},
}}));
if
(
fileToDisplay
)
{
$
(
"
body
"
).
html
(
'
<iframe src="
'
+
// XXX Hardcoded gadget to load
'
filebrowser.html?file=
'
+
fileToDisplay
+
'
filebrowser.html?file=
'
+
fileToDisplay
Data
+
'
">
'
+
'
<p>Your browser does not support iframes.</p>
'
+
'
</iframe">
'
);
...
...
renderjs.js
View file @
5eb28b1c
...
...
@@ -1058,7 +1058,7 @@
dispatch_data
=
function
()
{
// data:[<mediatype>][;base64],<data>
var
regexp
=
/^data:
\/\/([\w\/]
+
)?(
;base64
)?
,
([\w\W]
+
)
/
,
var
regexp
=
/^data:
\/\/([\w\/
+
]
+
)?(
;base64
)?
,
([\w\W]
+
)
/
,
mime_type
,
is_base_64
,
data
;
// window.atob(encodedData);
if
(
regexp
.
test
(
this
.
url
))
{
...
...
@@ -1129,10 +1129,10 @@
}
else
if
(
plumb_regexp
.
test
(
this
.
url
))
{
key
=
plumb_regexp
.
exec
(
this
.
url
)[
1
];
if
(
this
.
method
===
"
POST
"
)
{
if
(
key
===
"
top
window
"
)
{
if
(
key
===
"
parent
window
"
)
{
// XXX hardcoded * necessarity to send in case of file URL
// Fix needed!!!
window
.
top
.
postMessage
(
this
.
requestBody
,
"
*
"
);
window
.
parent
.
postMessage
(
this
.
requestBody
,
"
*
"
);
this
.
respond
(
204
,
{},
""
);
}
else
{
this
.
respond
(
404
,
{},
""
);
...
...
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