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
48b8c894
Commit
48b8c894
authored
Jun 04, 2013
by
Romain Courteaud
🐸
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrap postmessage inside ajax call.
parent
04733133
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
6 deletions
+32
-6
gadget/filebrowser.js
gadget/filebrowser.js
+14
-3
gadget/filebrowser_and_preview.js
gadget/filebrowser_and_preview.js
+1
-0
renderjs.js
renderjs.js
+17
-3
No files found.
gadget/filebrowser.js
View file @
48b8c894
...
...
@@ -41,8 +41,20 @@
$
(
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
());
$
.
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>
"
);
...
...
@@ -61,7 +73,6 @@
$
(
document
).
ready
(
function
()
{
mapUrl
(
window
.
location
);
window
.
top
.
postMessage
({
"
type
"
:
"
foo
"
,
"
bar
"
:
"
hello
"
},
window
.
location
);
});
}(
document
,
jQuery
));
gadget/filebrowser_and_preview.js
View file @
48b8c894
...
...
@@ -16,6 +16,7 @@
};
var
handler
=
function
(
event
)
{
console
.
log
(
event
.
origin
);
console
.
log
(
"
hello inside handler
"
);
console
.
log
(
event
);
};
...
...
renderjs.js
View file @
48b8c894
...
...
@@ -1057,9 +1057,10 @@
dispatch
=
function
()
{
// XXX Local hack
var
ls_regexp
=
/browser:
\/\/
localstorage
\/([\w\W]
+
)
/
,
browse_file_regexp
=
/browser:
\/\/
browse
\/
ls
\/([\w\W]
+
)
/
,
browse_directory_regexp
=
/browser:
\/\/
browse
\/
ls
\/
/
,
var
ls_regexp
=
/^browser:
\/\/
localstorage
\/([\w\W]
+
)
/
,
browse_file_regexp
=
/^browser:
\/\/
browse
\/
ls
\/([\w\W]
+
)
/
,
browse_directory_regexp
=
/^browser:
\/\/
browse
\/
ls
\/
/
,
plumb_regexp
=
/^browser:
\/\/
plumb
\/([\w\W]
+
)\/
/
,
key
;
if
(
ls_regexp
.
test
(
this
.
url
))
{
key
=
ls_regexp
.
exec
(
this
.
url
)[
1
];
...
...
@@ -1101,6 +1102,19 @@
this
.
respond
(
200
,
{
'
Content-Type
'
:
'
application/hal+json
'
},
JSON
.
stringify
(
response
));
}
else
if
(
plumb_regexp
.
test
(
this
.
url
))
{
key
=
plumb_regexp
.
exec
(
this
.
url
)[
1
];
if
(
this
.
method
===
"
POST
"
)
{
if
(
key
===
"
topwindow
"
)
{
// XXX hardcoded * necessarity to send in case of file URL
// Fix needed!!!
window
.
top
.
postMessage
(
this
.
body
,
"
*
"
);
}
else
{
this
.
respond
(
404
,
{},
""
);
}
}
else
{
this
.
respond
(
405
,
{},
""
);
}
}
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