Commit 2cc58b53 authored by lukas.niegsch's avatar lukas.niegsch

finished dynamic api for methods

parent 67150aa0
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
</head> </head>
<body> <body>
<div <div
data-gadget-url="gadget_browser.html" data-gadget-url="gadget_devtools.html"
data-gadget-scope="browser" data-gadget-scope="devtools"
data-gadget-sandbox="public"> data-gadget-sandbox="public">
</div> </div>
</body> </body>
......
...@@ -31,33 +31,46 @@ ...@@ -31,33 +31,46 @@
rJS(window) rJS(window)
.declareMethod("convert", function(html) { .declareMethod("convert", function(html) {
var gadget = this; var gadget = this;
var browser; var devtools;
var page; var targetId;
var frameId;
var base64data; var base64data;
return gadget.getDeclaredGadget("browser")
/**
* Steps:
*
* // new page setup
* Target.createTarget();
* Target.attachToTarget();
* Target.activateTarget();
*
* // enable events
* Network.enable();
* Page.enable();
*
* // change content
* Page.frameAttached();
* Page.setDocumentContent();
* Page.loadEventFired(); // Is this event fired once loading starts or stops?
*
* // convert html to pdf
* Page.printToPDF();
*
* // cleanup
* Target.detachFromTarget();
* Target.closeTarget();
*/
return gadget.getDeclaredGadget("devtools")
.push(function (subgadget) { .push(function (subgadget) {
browser = subgadget; return subgadget.getDevtools();
return browser.openNewPage("http://www.example.com");
}) })
.push(function (result) { .push(function (result) {
page = result; devtools = result;
return browser.setPageContent(page, html); return devtools.Browser.getVersion();
})
.push(function () {
return browser.getVersion();
})
.push(function () {
return browser.enablePage(page);
})
.push(function () {
return browser.printToPdf(page, optionsForPrintToPdf);
}) })
.push(function (result) { .push(function (result) {
base64data = result; console.log(result);
return browser.closePage(page);
})
.push(function () {
return base64data;
}) })
}) })
}(window, rJS)); }(window, rJS));
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment