Skip to content

Instantly share code, notes, and snippets.

@yssharma
Created October 17, 2013 07:10
Show Gist options
  • Select an option

  • Save yssharma/7020381 to your computer and use it in GitHub Desktop.

Select an option

Save yssharma/7020381 to your computer and use it in GitHub Desktop.
xml test
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Hello World"
description="Matches and echoes 'Hello World' string in emails">
<!-- Declare feature dependencies. -->
<!-- This one is not specific to Gmail contextual gadgets. -->
<Require feature="dynamic-height"/>
<!-- The next feature, Caja, is optional, and is supported for
use only within test domains. Uncomment the tag only for
non-production gadgets. -->
<!-- <Require feature="caja"/> -->
<!-- The next feature, google.contentmatch, is required for all
Gmail contextual gadgets.
<Param> - specify one or more comma-separated extractor IDs in
a param named "extractors". This line is overridden by the extractor ID
in the manifest, but is still expected to be present. -->
<Require feature="google.contentmatch">
<Param name="extractors">
google.com:HelloWorld
</Param>
</Require>
</ModulePrefs>
<!-- Define the content type and display location. The settings
"html" and "card" are required for all Gmail contextual gadgets. -->
<Content type="html" view="card">
<![CDATA[
<!-- Start with Single Sign-On -->
<script type="text/javascript" src="https://example.com/gadgets/sso.js"></script>
<script type="text/javascript">
<!-- Fetch the array of content matches. -->
matches = google.contentmatch.getContentMatches();
var matchList = document.createElement('UL');
var listItem;
var extractedText;
<!-- Iterate through the array and display output for each match. -->
for (var match in matches) {
for (var key in matches[match]) {
listItem = document.createElement('LI');
extractedText = document.createTextNode(key + ": " + matches[match][key]);
listItem.appendChild(extractedText);
matchList.appendChild(listItem);
}
}
document.body.appendChild(matchList);
gadgets.window.adjustHeight(100);
</script>
]]>
</Content>
</Module>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment