| 1 | <html> |
|---|
| 2 | <head> |
|---|
| 3 | <title>Auto Copy: Options</title> |
|---|
| 4 | |
|---|
| 5 | <script type="text/javascript" src="date.js"></script> |
|---|
| 6 | |
|---|
| 7 | <script type="text/javascript"> |
|---|
| 8 | function saveOptions() { |
|---|
| 9 | if (!window.localStorage) { |
|---|
| 10 | alert("Error local storage is unavailable."); |
|---|
| 11 | window.close(); |
|---|
| 12 | } |
|---|
| 13 | |
|---|
| 14 | window.localStorage.enableForTextBoxes = |
|---|
| 15 | document.getElementById("eitb").checked ? true : false; |
|---|
| 16 | window.localStorage.pasteOnMiddleClick = |
|---|
| 17 | document.getElementById("pomc").checked ? true : false; |
|---|
| 18 | //--------------------------------------------------------------------- |
|---|
| 19 | // Working around an issue in Chrome 6 |
|---|
| 20 | //--------------------------------------------------------------------- |
|---|
| 21 | //window.localStorage.copyAsPlainText = |
|---|
| 22 | // document.getElementById("capt").checked ? true : false; |
|---|
| 23 | window.localStorage.copyAsPlainText = true; |
|---|
| 24 | //--------------------------------------------------------------------- |
|---|
| 25 | window.localStorage.includeUrl = |
|---|
| 26 | document.getElementById("iurl").checked ? true : false; |
|---|
| 27 | window.localStorage.prependUrl = |
|---|
| 28 | document.getElementById("iurlp").checked ? true : false; |
|---|
| 29 | //--------------------------------------------------------------------- |
|---|
| 30 | // Setting a localStorage var to empty causes it to get set to |
|---|
| 31 | // undefined so there is no way to tell if a user has set an empty |
|---|
| 32 | // string. Therefore, a placeholder is needed, so a single space is |
|---|
| 33 | // used. |
|---|
| 34 | //--------------------------------------------------------------------- |
|---|
| 35 | var text = document.getElementById("iurltext").value; |
|---|
| 36 | window.localStorage.includeUrlText = |
|---|
| 37 | (text.length <= 0 || text === " ") ? " " : text; |
|---|
| 38 | //(text.length <= 0 || text === " ") ? " " : text + " "; |
|---|
| 39 | //--------------------------------------------------------------------- |
|---|
| 40 | window.localStorage.includeUrlCommentCountEnabled = |
|---|
| 41 | document.getElementById("iurlewc").checked ? true : false; |
|---|
| 42 | window.localStorage.includeUrlCommentCount = |
|---|
| 43 | parseInt(document.getElementById("iurlcount").value,10); |
|---|
| 44 | |
|---|
| 45 | window.close(); |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | function restoreOptions() { |
|---|
| 49 | if (!window.localStorage) { |
|---|
| 50 | alert("Error local storage is unavailable."); |
|---|
| 51 | window.close(); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | document.getElementById("eitb").checked = |
|---|
| 55 | (window.localStorage.enableForTextBoxes === "true") ? true : false; |
|---|
| 56 | document.getElementById("pomc").checked = |
|---|
| 57 | (window.localStorage.pasteOnMiddleClick === "true") ? true : false; |
|---|
| 58 | //--------------------------------------------------------------------- |
|---|
| 59 | // Working around an issue in Chrome 6 |
|---|
| 60 | //--------------------------------------------------------------------- |
|---|
| 61 | //document.getElementById("capt").checked = |
|---|
| 62 | // (window.localStorage.copyAsPlainText === "true") ? true : false; |
|---|
| 63 | document.getElementById("capt").checked = true; |
|---|
| 64 | //--------------------------------------------------------------------- |
|---|
| 65 | document.getElementById("iurl").checked = |
|---|
| 66 | (window.localStorage.includeUrl === "true") ? true : false; |
|---|
| 67 | document.getElementById("iurltext").value = |
|---|
| 68 | window.localStorage.includeUrlText || |
|---|
| 69 | "$crlfCopied from: $title - <$url>"; |
|---|
| 70 | document.getElementById("iurlewc").checked = |
|---|
| 71 | (window.localStorage.includeUrlCommentCountEnabled === "true") ? |
|---|
| 72 | true : false; |
|---|
| 73 | document.getElementById("iurlcount").value = |
|---|
| 74 | window.localStorage.includeUrlCommentCount || 5; |
|---|
| 75 | |
|---|
| 76 | var v = window.localStorage.prependUrl; |
|---|
| 77 | if (v === undefined || v === "false") { |
|---|
| 78 | document.getElementById("iurlp").checked = false; |
|---|
| 79 | document.getElementById("iurla").checked = true; |
|---|
| 80 | } else { |
|---|
| 81 | document.getElementById("iurlp").checked = true; |
|---|
| 82 | document.getElementById("iurla").checked = false; |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | if ( |
|---|
| 86 | window.localStorage.includeUrl && |
|---|
| 87 | window.localStorage.includeUrl === "true" |
|---|
| 88 | ) { |
|---|
| 89 | toggleDiv("diviurlap"); |
|---|
| 90 | } |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | function validateCountValue() { |
|---|
| 94 | var enabled = document.getElementById('iurlewc'); |
|---|
| 95 | var count = parseInt(document.getElementById('iurlcount').value,10); |
|---|
| 96 | var saveBtn = document.getElementById('saveButton'); |
|---|
| 97 | var text = document.getElementById('commentCount'); |
|---|
| 98 | |
|---|
| 99 | if (enabled.checked) { |
|---|
| 100 | if (count < 1 || count > 99 || isNaN(count)) { |
|---|
| 101 | saveBtn.disabled = true; |
|---|
| 102 | text.className = "error"; |
|---|
| 103 | } else { |
|---|
| 104 | saveBtn.disabled = false; |
|---|
| 105 | text.className = ""; |
|---|
| 106 | } |
|---|
| 107 | } else { |
|---|
| 108 | saveBtn.disabled = false; |
|---|
| 109 | text.className = ""; |
|---|
| 110 | } |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | function toggleCapt() { |
|---|
| 114 | var capt = document.getElementById('capt'); |
|---|
| 115 | var iurl = document.getElementById('iurl').checked; |
|---|
| 116 | |
|---|
| 117 | //--------------------------------------------------------------------- |
|---|
| 118 | // Working around an issue in Chrome 6 |
|---|
| 119 | //--------------------------------------------------------------------- |
|---|
| 120 | capt.checked = true; |
|---|
| 121 | return; |
|---|
| 122 | //--------------------------------------------------------------------- |
|---|
| 123 | |
|---|
| 124 | if (iurl) { |
|---|
| 125 | capt.checked = true; |
|---|
| 126 | } else { |
|---|
| 127 | capt.checked = |
|---|
| 128 | (window.localStorage.copyAsPlainText === "true") ? true : false; |
|---|
| 129 | } |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | function fixUpIncludeUrl() { |
|---|
| 133 | var capt = document.getElementById('capt').checked; |
|---|
| 134 | var iurl = document.getElementById('iurl'); |
|---|
| 135 | var iurldiv = document.getElementById('diviurlap'); |
|---|
| 136 | |
|---|
| 137 | if (capt) { |
|---|
| 138 | iurl.checked = |
|---|
| 139 | (window.localStorage.includeUrl === "true") ? true : false; |
|---|
| 140 | if (iurl.checked) { |
|---|
| 141 | iurldiv.style.display = 'block'; |
|---|
| 142 | } |
|---|
| 143 | } else { |
|---|
| 144 | iurl.checked = false; |
|---|
| 145 | iurldiv.style.display = 'none'; |
|---|
| 146 | } |
|---|
| 147 | } |
|---|
| 148 | |
|---|
| 149 | function toggleDiv(id) { |
|---|
| 150 | var el = document.getElementById(id); |
|---|
| 151 | |
|---|
| 152 | if (!el) { |
|---|
| 153 | return |
|---|
| 154 | } |
|---|
| 155 | |
|---|
| 156 | el.style.display = (el.style.display === "block") ? "none" : "block"; |
|---|
| 157 | } |
|---|
| 158 | </script> |
|---|
| 159 | <style> |
|---|
| 160 | div#diviurlap { |
|---|
| 161 | display: none; |
|---|
| 162 | } |
|---|
| 163 | .error { |
|---|
| 164 | color: #FF0000; |
|---|
| 165 | } |
|---|
| 166 | .note { |
|---|
| 167 | font-size: smaller; |
|---|
| 168 | color: #426DC9; |
|---|
| 169 | text-shadow: #fff 0 1px 1px; |
|---|
| 170 | } |
|---|
| 171 | .larger { |
|---|
| 172 | font-size: 1.1em; |
|---|
| 173 | } |
|---|
| 174 | .indent { |
|---|
| 175 | margin-left: 20px; |
|---|
| 176 | margin-bottom: -20px; |
|---|
| 177 | } |
|---|
| 178 | h1 { |
|---|
| 179 | -webkit-border-radius: 8px; |
|---|
| 180 | -webkit-box-shadow: 0px 1px 0px #f7f7f7; |
|---|
| 181 | -webkit-box-shadow: 0 0 20px #d0d0d0; |
|---|
| 182 | background: -webkit-linear-gradient(left, #BBCEE9, #BBCEE9 50%, #AABEDC); |
|---|
| 183 | border-bottom: 1px solid #8faad9; |
|---|
| 184 | border-top: 1px solid #8faad9; |
|---|
| 185 | text-shadow: #bbcee9 0 1px 1px; |
|---|
| 186 | padding: 20px; |
|---|
| 187 | font-size: 3em; |
|---|
| 188 | color: #000; |
|---|
| 189 | text-shadow: #bbcee9 0 1px 1px; |
|---|
| 190 | margin: 20px; |
|---|
| 191 | } |
|---|
| 192 | .options { |
|---|
| 193 | -webkit-border-radius: 8px; |
|---|
| 194 | -webkit-border-end: 1px solid #c6c9ce; |
|---|
| 195 | -webkit-box-shadow: 0 0 20px #d0d0d0; |
|---|
| 196 | background: -webkit-linear-gradient(rgba(234, 238, 243, 0.2), #eaeef3), |
|---|
| 197 | -webkit-linear-gradient(left, #eaeef3, #eaeef3 50%, #d3d7db); |
|---|
| 198 | padding: 20px; |
|---|
| 199 | margin: 20px; |
|---|
| 200 | font-size: 1.1em; |
|---|
| 201 | line-height: 1.6em; |
|---|
| 202 | color: #000; |
|---|
| 203 | text-shadow: #fff 0 1px 1px; |
|---|
| 204 | } |
|---|
| 205 | #logo { |
|---|
| 206 | float: left; |
|---|
| 207 | padding-right: 20px; |
|---|
| 208 | } |
|---|
| 209 | button { |
|---|
| 210 | margin-top: 12px; |
|---|
| 211 | padding: 6px; |
|---|
| 212 | } |
|---|
| 213 | </style> |
|---|
| 214 | </head> |
|---|
| 215 | |
|---|
| 216 | <body onload="restoreOptions()"> |
|---|
| 217 | <h1> |
|---|
| 218 | <img id="logo" src="autoCopy-64.png" width="64" height="64" alt="logo"> |
|---|
| 219 | Auto Copy - Options |
|---|
| 220 | </h1> |
|---|
| 221 | <div class="options"> |
|---|
| 222 | <input type="checkbox" id="eitb"> Enable in text boxes |
|---|
| 223 | <br> |
|---|
| 224 | <!----> |
|---|
| 225 | <input type="checkbox" id="pomc"> Paste on middle click |
|---|
| 226 | <br> |
|---|
| 227 | <!----> |
|---|
| 228 | <!-- Working around an issue in Chrome 6 --> |
|---|
| 229 | <!-- |
|---|
| 230 | <input type="checkbox" id="capt" onclick="fixUpIncludeUrl();"> Copy without formatting |
|---|
| 231 | --> |
|---|
| 232 | <input type="checkbox" disabled="disabled" checked="checked" id="capt" onclick="fixUpIncludeUrl();"> Copy without formatting <span class="note">(Note: Due to a change in Chrome permissions since version 6 this option must be enabled.)</span> |
|---|
| 233 | |
|---|
| 234 | <br> |
|---|
| 235 | <input type="checkbox" id="iurl" onclick="toggleDiv('diviurlap'); toggleCapt();"> Include an informational comment <span class="note">(Note: this option requires copy without formatting.)</span> |
|---|
| 236 | <div id="diviurlap" class="indent"> |
|---|
| 237 | <input type="checkbox" name="iurlewc" id="iurlewc" onclick="validateCountValue();"> <span id="commentCount" >Only include the comment if more than <input title="Valid values are 1 to 99" type="text" maxlength="2" size="1" id="iurlcount" value="5" onclick="this.select();" onblur="validateCountValue();" onkeyup="validateCountValue();"> words are selected</span> |
|---|
| 238 | <br> |
|---|
| 239 | <input type="radio" name="iurlap" id="iurlp"> Add the comment to the beginning of the copied text |
|---|
| 240 | <br> |
|---|
| 241 | <input type="radio" name="iurlap" id="iurla" checked="checked"> Add the comment to the end of the copied text |
|---|
| 242 | <br> |
|---|
| 243 | Format: <input type="text" size="64" id="iurltext" value="$crlfCopied from: $title - <$url>" onclick="this.select();"> <span class="note">(Default: $crlfCopied from: $title - <$url>)</span> |
|---|
| 244 | <div class="indent note larger"> |
|---|
| 245 | The comment can contain the following variables: |
|---|
| 246 | <br> |
|---|
| 247 | <div class="indent"> |
|---|
| 248 | <b>$title</b> - Document title |
|---|
| 249 | <div class="indent">Example: <b>stratus nine: auto copy</b></div> |
|---|
| 250 | <br> |
|---|
| 251 | <b>$url</b> - Document URL |
|---|
| 252 | <div class="indent">Example: <b>http://www.stratusnine.com/trac/Auto-Copy/</b></div> |
|---|
| 253 | <br> |
|---|
| 254 | <b>$crlf</b> - Inserts a blank line |
|---|
| 255 | </div> |
|---|
| 256 | </div> |
|---|
| 257 | |
|---|
| 258 | </div> |
|---|
| 259 | <br> |
|---|
| 260 | <button id="saveButton" onclick="saveOptions()">Save & Close</button> |
|---|
| 261 | </div> |
|---|
| 262 | </body> |
|---|
| 263 | </html> |
|---|