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
84aa663f
Commit
84aa663f
authored
Jun 04, 2013
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Plug fake xhr into renderjs
parent
21b266de
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
0 deletions
+74
-0
gadget/filebrowser.html
gadget/filebrowser.html
+18
-0
renderjs.js
renderjs.js
+56
-0
No files found.
gadget/filebrowser.html
View file @
84aa663f
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta
name=
"viewport"
content=
"width=device-width, height=device-height, initial-scale=1"
/>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=UTF-8"
/>
<script
type=
"text/javascript"
src=
"http://code.jquery.com/jquery-1.9.1.min.js"
></script>
<script
type=
"text/javascript"
src=
"../hyperbrowser.js"
></script>
<script
type=
"text/javascript"
src=
"../renderjs.js"
></script>
<script
type=
"text/javascript"
src=
"filebrowser.js"
></script>
</head>
<body>
<noscript>
Please enable Javascript
</noscript>
</body>
</html>
renderjs.js
View file @
84aa663f
...
...
@@ -1042,4 +1042,60 @@
priv
.
initialize
();
}
});
//////////////////////////////////////////////
// Fake xhr to access local resource
//////////////////////////////////////////////
var
default_xhr
=
$
.
ajaxSettings
.
xhr
,
dispatch
;
dispatch
=
function
()
{
// XXX Local hack
var
ls_regexp
=
/browser:
\/\/
localstorage
\/([\w\W]
+
)
/
,
browse_regexp
=
/browser:
\/\/
browse
\/
ls
\/([\w\W]
+
)
/
,
key
;
if
(
ls_regexp
.
test
(
this
.
url
))
{
key
=
ls_regexp
.
exec
(
this
.
url
)[
1
];
if
(
this
.
method
===
"
POST
"
)
{
localStorage
[
key
]
=
this
.
requestBody
;
this
.
respond
(
200
,
{},
""
);
}
else
if
(
this
.
method
===
"
GET
"
)
{
this
.
respond
(
200
,
{
"
Content-Type
"
:
"
text/plain
"
},
localStorage
[
key
]);
}
else
if
(
this
.
method
===
"
DELETE
"
)
{
localStorage
.
removeItem
(
key
);
this
.
respond
(
200
,
{},
""
);
}
else
{
this
.
respond
(
405
,
{},
""
);
}
}
else
if
(
browse_regexp
.
test
(
this
.
url
))
{
key
=
browse_regexp
.
exec
(
this
.
url
)[
1
];
this
.
respond
(
200
,
{
'
Content-Type
'
:
'
application/hal+json
'
},
JSON
.
stringify
({
_links
:
{
self
:
{
href
:
'
browser://browse/ls/
'
+
key
},
enclosure
:
{
href
:
'
browser://localstorage/
'
+
key
},
}
}));
}
else
{
this
.
respond
(
404
,
{},
""
);
}
};
$
.
ajaxSetup
({
xhr
:
function
()
{
var
result
;
if
(
/^browser:
\/\/
/
.
test
(
this
.
url
))
{
result
=
new
BrowserHttpRequest
();
result
.
dispatch
=
dispatch
;
}
else
{
result
=
default_xhr
();
}
return
result
;
}
});
}(
jQuery
,
window
));
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