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

finished dynamic api for methods

parent 67150aa0
......@@ -9,8 +9,8 @@
</head>
<body>
<div
data-gadget-url="gadget_browser.html"
data-gadget-scope="browser"
data-gadget-url="gadget_devtools.html"
data-gadget-scope="devtools"
data-gadget-sandbox="public">
</div>
</body>
......
......@@ -31,33 +31,46 @@
rJS(window)
.declareMethod("convert", function(html) {
var gadget = this;
var browser;
var page;
var devtools;
var targetId;
var frameId;
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) {
browser = subgadget;
return browser.openNewPage("http://www.example.com");
return subgadget.getDevtools();
})
.push(function (result) {
page = result;
return browser.setPageContent(page, html);
})
.push(function () {
return browser.getVersion();
})
.push(function () {
return browser.enablePage(page);
})
.push(function () {
return browser.printToPdf(page, optionsForPrintToPdf);
devtools = result;
return devtools.Browser.getVersion();
})
.push(function (result) {
base64data = result;
return browser.closePage(page);
})
.push(function () {
return base64data;
console.log(result);
})
})
}(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