SlimTimer Static Sidebar Note

Adds static sidebar notes to SlimTimer pages.

  1. // vim: et ai nu tw=80 sw=4 ts=4 sts=4
  2. //
  3. // ==UserScript==
  4. // @name SlimTimer Static Sidebar Note
  5. // @namespace http://www.arthaey.com
  6. // @description Adds static sidebar notes to SlimTimer pages.
  7. // @include http://www.slimtimer.com/tasks*
  8. // @include http://www.slimtimer.com/edit*
  9. // @include http://www.slimtimer.com/report*
  10. // @version 1.0
  11. //
  12. // Backed up from http://userscripts.org/scripts/review/14273
  13. // Last updated on 2007-11-20
  14. // ==/UserScript==
  15.  
  16. /* HOW TO USE:
  17. * Edit the createContent() method to return the HTML you want displayed
  18. * in the sidebar.
  19. */
  20.  
  21. window.addEventListener("load", function () {
  22.  
  23. /* EDIT ME to return the HTML you want in the sidebar */
  24. function createContent() {
  25. var bCSS = "font: bolder 12px Arial";
  26. return '<b style="' + bCSS + '">Tag Legend</b>' +
  27. '<ul style="margin-left: 10px">' +
  28. '<li>@location</li>' +
  29. '<li>+project</li>' +
  30. '<li>general category</li>' +
  31. '</ul>'
  32. ;
  33. }
  34.  
  35. // same method of rounder corners as used by SlimTimer
  36. function createBorder(loc) {
  37. var border = document.createElement("div");
  38. border.style.backgroundColor = "rgb(255,255,255)";
  39.  
  40. css = [
  41. ["2px", "1px", "3px", "3px"],
  42. ["1px", "1px", "2px", "2px"],
  43. ["1px", "1px", "1px", "1px"],
  44. ["1px", "2px", "0px", "0px"]
  45. ];
  46.  
  47. // reverse array if location is bottom
  48. if (loc == "bot") {
  49. var tmp, j;
  50. for (var i = 0; i * 2 <= css.length; i++) {
  51. j = css.length - 1 - i;
  52. tmp = css[i];
  53. css[i] = css[j];
  54. css[j] = tmp;
  55. }
  56. }
  57.  
  58. innerHTML = '';
  59. for (var i = 0; i < css.length; i++) {
  60. innerHTML += '<span style="border-style: solid; ' +
  61. 'border-color: rgb(246,246,246); ' +
  62. 'border-width: 0px ' + css[i][0] + '; ' +
  63. 'overflow: hidden; ' +
  64. 'background-color: rgb(238,238,238); ' +
  65. 'display: block; ' +
  66. 'height: ' + css[i][1] + '; ' +
  67. 'font-size: 1px; ' +
  68. 'margin-left: ' + css[i][2] + '; ' +
  69. 'margin-right: ' + css[i][3] + ';"></span>'
  70. ;
  71. }
  72. border.innerHTML = innerHTML;
  73.  
  74. return border;
  75. }
  76.  
  77. function addSidebarNote(contentsHTML) {
  78. var sidebar = document.getElementById("secondary-sidebar");
  79. if (!sidebar) return;
  80.  
  81. var spacing = document.createElement("div");
  82. spacing.style.height = "10px";
  83. spacing.style.backgroundColor = "white";
  84.  
  85. var topBorder = createBorder("top");
  86. var botBorder = createBorder("bot");
  87.  
  88. var content = document.createElement("div");
  89. content.className = "content";
  90. content.innerHTML = contentsHTML;
  91.  
  92. sidebar.appendChild(spacing);
  93. sidebar.appendChild(topBorder);
  94. sidebar.appendChild(content);
  95. sidebar.appendChild(botBorder);
  96. }
  97.  
  98. addSidebarNote(createContent());
  99.  
  100. }, true);