Guest User

Untitled

a guest
Apr 25th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <Module>
  3. <ModulePrefs title="Dynamic Height"
  4. height="100">
  5. <Require feature="dynamic-height"/>
  6. </ModulePrefs>
  7. <Content type="html">
  8. <![CDATA[
  9. <script type="text/javascript">
  10. // This example lets users add items to a grocery list and then clear the list.
  11. // When items are added or cleared, the gadget resizes itself.
  12. var mylist = "";
  13. var flag = 0;
  14.  
  15. // Function that is invoked whenever user clicks the Add button to add an
  16. // item to the list.
  17. function addToList (form) {
  18. var input = _trim(form.inputbox.value);
  19. if (input == "") {
  20. return;
  21. }
  22.  
  23. // Make alternating lines green/white, depending on value of flag variable.
  24. if(flag == 0){
  25. mylist += "<div style='padding-left: 5px;background-color: #E6FFE6; font-family:Arial, Helvetica;'>" +input + "</div>";
  26. flag = 1;
  27. }
  28. else {
  29. mylist += "<div style='padding-left: 5px;font-family:Arial, Helvetica;'>" +input + "</div>";
  30. flag = 0;
  31. }
  32.  
  33. // Call setContent to output HTML to div and resize gadget
  34. setContent(mylist);
  35. }
  36.  
  37. // Clear the list
  38. function clearList(form) {
  39. // Call setContent to remove all items from the list and resize the gadget
  40. setContent("");
  41. }
  42.  
  43. // Outputs content to the div and resizes the gadget
  44. function setContent(html) {
  45. document.getElementById('content_div').innerHTML = html;
  46.  
  47. // Tells gadget to resize itself
  48. gadgets.window.adjustHeight();
  49. }
  50. </script>
  51. <FORM NAME="myform" ACTION="" METHOD="GET"><BR>
  52. <INPUT TYPE="text" NAME="inputbox" VALUE="">
  53. <INPUT TYPE="button" NAME="button" Value="Add" onClick="addToList(this.form)">
  54. <INPUT TYPE="button" NAME="button2" Value="Clear" onClick="clearList(this.form)">
  55. </FORM>
  56. <div id="content_div"></div>
  57. ]]>
  58. </Content>
  59. </Module>
Add Comment
Please, Sign In to add comment