Skip to content

Instantly share code, notes, and snippets.

@marsch
Last active August 29, 2015 14:11
Show Gist options
  • Save marsch/038954c9435291136350 to your computer and use it in GitHub Desktop.
Save marsch/038954c9435291136350 to your computer and use it in GitHub Desktop.
<script>
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event) {
data = JSON.parse(event.data);
if (data && data.action == 'addNoteCard') {
console.log('message received');
console.log(event);
google.script.run
.withSuccessHandler(function () {})
.addNodeCardJSON(JSON.stringify(data.data));
}
}
</script>
<iframe src="https://localhost:4443/" frameborder="0" style="overflow:hidden;height:100%;width:100%" height="100%" width="100%"></iframe>
Hi from localhost
<button onclick="hitthedoc();">hello gdoc</button>
click the f***ing button, dude!
<script language="javascript">
card = {
"id": "b136be9e-8e3f-4bcf-98e4-44de87b1ef7c",
"name": "Students Visit Pentagon for IT Job Shadow Day",
"color": "#704eb",
"content": {
"directquote": "Dolore aute elit aute occaecat non nisi nulla culpa reprehenderit cillum enim ut mollit.",
"paraphrased": "Labore exercitation aute non aliquip in in elit Lorem Lorem. Occaecat laborum culpa laboris quis velit aliqua ea pariatur et cillum. Et tempor est reprehenderit proident ullamco reprehenderit culpa ipsum ullamco voluptate consectetur. Eu id veniam aliquip aliqua adipisicing dolor nisi nostrud cillum nisi nisi."
}
};
function hitthedoc() {
console.log('hit the doc');
if (window.parent != window) {
msg = {
action: 'addNoteCard',
data: card
};
window.parent.postMessage(JSON.stringify(msg), '*');
} else {
console.log('sorry no parent window');
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment