Skip to content

Instantly share code, notes, and snippets.

@jptrsn
Last active December 10, 2015 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jptrsn/736d66525e55d1d0da5a to your computer and use it in GitHub Desktop.
Save jptrsn/736d66525e55d1d0da5a to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs
title="List Data Type Example"
scrolling="true"/>
<UserPref name="mylist"
display_name="Add Terms"
datatype="list" />
<Content type="html">
<![CDATA[
<div id=content_div></div>
<script type="text/javascript">
// Get userprefs
var prefs = new gadgets.Prefs();
// Get the array of search terms entered by the user
var terms = prefs.getArray("mylist");
var html = "";
// If the user has not added any terms yet, display message.
if (terms.length == 0)
{
html += "Edit the userprefs to add terms.";
}
else {
html += "Your terms are:<br /><br />";
for (var i = 0; i < terms.length ; i++) {
var term = (terms[i]);
html += term + "<br />";
}
}
document.getElementById("content_div").innerHTML = html;
</script>
]]>
</Content>
</Module>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment