Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
renderjs
Commits
734051d3
Commit
734051d3
authored
Jun 10, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
started relocating functionality to renderjs
parent
8ab4b629
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
58 deletions
+25
-58
gadget/filebrowser.js
gadget/filebrowser.js
+2
-2
gadget/filebrowser_and_preview.js
gadget/filebrowser_and_preview.js
+6
-52
gadget/filecontent.js
gadget/filecontent.js
+9
-2
gadget/preview_by_hash_change.js
gadget/preview_by_hash_change.js
+1
-1
gadget/preview_by_postmessage.js
gadget/preview_by_postmessage.js
+7
-1
No files found.
gadget/filebrowser.js
View file @
734051d3
...
...
@@ -36,7 +36,7 @@
.
replace
(
"
{scope}
"
,
scope
)
.
replace
(
"
{interaction}
"
,
""
);
service
=
{
"
type
"
:
"
service/test
"
,
"
type
"
:
"
register/any
"
,
"
src
"
:
encodeURIComponent
(
window
.
location
.
href
),
"
rel
"
:
"
browse
"
,
"
self
"
:
window
.
frameElement
.
id
...
...
@@ -69,7 +69,7 @@
success
:
function
(
value2
,
textStatus
,
jqXHR
)
{
var
content_type
=
jqXHR
.
getResponseHeader
(
"
Content-Type
"
)
||
""
,
request
=
value
.
_links
.
call
.
href
.
replace
(
"
{method}
"
,
"
service
"
)
.
replace
(
"
{method}
"
,
"
request
"
)
.
replace
(
"
{scope}
"
,
scope
)
.
replace
(
"
{interaction}
"
,
"
preview
"
);
...
...
gadget/filebrowser_and_preview.js
View file @
734051d3
/*global document, jQuery */
"
use strict
"
;
(
function
(
document
,
$
)
{
"
use strict
"
;
var
getParameter
=
function
(
searchString
,
paramName
)
{
var
i
,
val
,
params
=
searchString
.
split
(
"
&
"
);
...
...
@@ -14,52 +14,6 @@
return
null
;
};
var
handler
=
function
(
event
)
{
// prevent registrations to renderJs from triggering here
var
type
=
event
.
data
.
type
,
service
,
scope
,
request
;
if
(
type
===
undefined
)
{
$
.
ajax
({
method
:
"
GET
"
,
url
:
event
.
data
,
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
console
.
log
(
"
request failed:
"
+
errorThrown
);
},
success
:
function
(
value
,
textStatus
,
jqXHR
)
{
// we now have the URL to handle and the method
// to request. We need to POST this, because
// we can't access renderJS.gadgetService from here...
// when optimizing all the secondary ajax calls should be removed
// question also is, whether we need POST at all, if we could
// pass everything through the URL?
scope
=
value
.
_links
.
self
.
href
.
split
(
"
/
"
).
slice
(
0
,
-
1
).
pop
();
service
=
{
"
service
"
:
value
.
_links
.
self
.
href
.
split
(
/
[/]
+/
).
pop
(),
"
parameters
"
:
[
value
.
_links
.
request
.
href
],
"
scope
"
:
scope
}
request
=
'
browser://request/
'
+
scope
+
'
/
'
;
$
.
ajax
({
method
:
"
POST
"
,
url
:
request
,
context
:
$
(
this
),
data
:
JSON
.
stringify
(
service
),
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
console
.
log
(
"
request for service failed
"
);
},
// success: function () {
// console.log("service requested from renderJS");
// }
});
}
});
}
};
var
mapUrl
=
function
(
searchString
)
{
var
fileToDisplay
=
getParameter
(
searchString
,
"
file
"
),
browserAPI
,
...
...
@@ -117,11 +71,11 @@
$
(
"
body
"
).
text
(
"
No parameter found in url
"
);
}
if
(
window
.
addEventListener
){
window
.
addEventListener
(
"
message
"
,
handler
,
false
)
}
else
{
window
.
attachEvent
(
"
onmessage
"
,
handler
)
}
//
if (window.addEventListener){
//
window.addEventListener("message", handler, false)
//
} else {
//
window.attachEvent("onmessage", handler)
//
}
});
}(
document
,
jQuery
));
gadget/filecontent.js
View file @
734051d3
/*global document, jQuery */
"
use strict
"
;
(
function
(
document
,
$
)
{
"
use strict
"
;
// sample contents
localStorage
.
setItem
(
"
foo
"
,
"
bar
"
);
...
...
@@ -10,7 +10,14 @@
var
setup
=
function
()
{
// not an easy API...
// can this be done automatically?
// can this be done internally?
// TODO:
// "call" default API need not be passed,
// "self" can be added automatically
// "scope" (previous "storage") don't like... too gadget-specific?
// "target" (previous "display") don't like, as above
var
instance1
=
"
data://application/hal+json;base64,
"
+
window
.
btoa
(
JSON
.
stringify
({
_links
:
{
...
...
gadget/preview_by_hash_change.js
View file @
734051d3
...
...
@@ -67,7 +67,7 @@
.
replace
(
"
{scope}
"
,
scope
)
.
replace
(
"
{interaction}
"
,
""
);
service
=
{
"
type
"
:
"
service/test
"
,
"
type
"
:
"
register/any
"
,
"
src
"
:
encodeURIComponent
(
window
.
location
.
href
),
"
rel
"
:
"
preview
"
,
"
self
"
:
window
.
frameElement
.
id
...
...
gadget/preview_by_postmessage.js
View file @
734051d3
...
...
@@ -67,7 +67,7 @@
.
replace
(
"
{scope}
"
,
scope
)
.
replace
(
"
{interaction}
"
,
""
);
service
=
{
"
type
"
:
"
service/test
"
,
"
type
"
:
"
register/any
"
,
"
src
"
:
encodeURIComponent
(
window
.
location
.
href
),
"
rel
"
:
"
preview
"
,
"
self
"
:
window
.
frameElement
.
id
...
...
@@ -85,6 +85,12 @@
// console.log("registration successful");
}
});
// renderJs.addService(service, function (response, error) {
// console.log("registration happened");
// console.log(error);
// console.log(response);
// });
}
});
}
...
...
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