| | 1 | // TODO: I'd like to have an extra "js" directory for all JavaScripts |
| | 2 | // a theme needs. |
| | 3 | |
| | 4 | /* |
| | 5 | * Jlogs not minified version of JavaScript |
| | 6 | */ |
| | 7 | |
| | 8 | function jlog_bbcode(insText, aTag, eTag) { |
| | 9 | if (!insText) { return ''; } |
| | 10 | return aTag + insText + eTag; |
| | 11 | } |
| | 12 | |
| | 13 | function jlog_bbcode_link(insText, aTag, eTag) { |
| | 14 | var url = new RegExp('^(http://|https://|www.|ftp://|news:|mailto:).'); |
| | 15 | var www = new RegExp('^(www.).'); |
| | 16 | var mail = new RegExp('^[^@]+@[^@]+\.[a-zA-Z]+$'); |
| | 17 | var http = new RegExp('^(http://)$'); |
| | 18 | var node, href; |
| | 19 | if((url.test(insText)) || (mail.test(insText))) { |
| | 20 | href = insText; |
| | 21 | if (mail.test(href)) { href = 'mailto:' + insText; } |
| | 22 | if (www.test(href)) { href = 'http://' + href; } |
| | 23 | node = prompt(jlog_l_comments_url_node); |
| | 24 | if((node !== null) && (node !== '')) { insText = '[url=' + href + ']' + node + eTag; } |
| | 25 | else if(node === '') { insText = aTag + href + eTag; } |
| | 26 | } |
| | 27 | else { |
| | 28 | node = insText; |
| | 29 | if(node === '') { node = prompt(jlog_l_comments_url_node, insText); } |
| | 30 | href = prompt(jlog_l_comments_url_href, 'http://'); |
| | 31 | if (http.test(href)) { return insText; } |
| | 32 | if (www.test(href)) { href = 'http://' + href; } |
| | 33 | if(((node !== null) && (node !== '')) && ((href !== null) && (href !== ''))) { |
| | 34 | insText = '[url=' + href + ']' + node + eTag; |
| | 35 | } |
| | 36 | else if((href !== null) && (href !== '')) { insText = aTag + href + eTag; } |
| | 37 | } |
| | 38 | return insText; |
| | 39 | } |
| | 40 | |
| | 41 | |
| | 42 | function jlog_bbcode_list(o_insText, aTag, eTag) { |
| | 43 | var insText = o_insText.replace(/(\n|\r|\r\n)(?=(.+))/g, '$1[*]'); |
| | 44 | return '[list]\n[*]' + insText + eTag + '\n'; |
| | 45 | } |
| | 46 | |
| 8 | | var insText = range.text; |
| 9 | | if (aTag == '[url]') range.text = jlog_bbcode_link(insText, aTag, eTag); |
| 10 | | else if(eTag == '[/list]') range.text = jlog_bbcode_list(insText, aTag, eTag); |
| 11 | | else range.text = jlog_bbcode(insText, aTag, eTag); |
| | 55 | insText = range.text; |
| | 56 | if (aTag === '[url]') { range.text = jlog_bbcode_link(insText, aTag, eTag); } |
| | 57 | else if(eTag === '[/list]') { range.text = jlog_bbcode_list(insText, aTag, eTag); } |
| | 58 | else { range.text = jlog_bbcode(insText, aTag, eTag); } |
| 28 | | var insText = input.value.substring(start, end); |
| 29 | | if(aTag == '[url]') insText = jlog_bbcode_link(insText, aTag, eTag); |
| 30 | | else if(eTag == '[/list]') insText = jlog_bbcode_list(insText, aTag, eTag); |
| 31 | | else insText = jlog_bbcode(insText, aTag, eTag); |
| | 75 | insText = input.value.substring(start, end); |
| | 76 | if(aTag === '[url]') { insText = jlog_bbcode_link(insText, aTag, eTag); } |
| | 77 | else if(eTag === '[/list]') { insText = jlog_bbcode_list(insText, aTag, eTag); } |
| | 78 | else { insText = jlog_bbcode(insText, aTag, eTag); } |
| 49 | | if(aTag == '[url]') insText = jlog_bbcode_link('', aTag, eTag); |
| 50 | | else if(eTag == '[/list]') insText = jlog_bbcode_list('', aTag, eTag); |
| 51 | | else insText = jlog_bbcode(prompt(jlog_l_comments_plz_format_txt), aTag, eTag); |
| | 96 | if(aTag === '[url]') { insText = jlog_bbcode_link('', aTag, eTag); } |
| | 97 | else if(eTag === '[/list]') { insText = jlog_bbcode_list('', aTag, eTag); } |
| | 98 | else { insText = jlog_bbcode(prompt(jlog_l_comments_plz_format_txt), aTag, eTag); } |
| 54 | | } |
| 55 | | |
| 56 | | function jlog_bbcode(insText, aTag, eTag) { |
| 57 | | if (!insText) return ''; |
| 58 | | return aTag + insText + eTag; |
| 59 | | } |
| 60 | | |
| 61 | | function jlog_bbcode_link(insText, aTag, eTag) { |
| 62 | | var url = new RegExp('^(http://|https://|www.|ftp://|news:|mailto:).'); |
| 63 | | var www = new RegExp('^(www.).'); |
| 64 | | var mail= new RegExp('^[^@]+@[^@]+\.[a-zA-Z]+$'); |
| 65 | | var http= new RegExp('^(http://)$'); |
| 66 | | if((url.test(insText)) || (mail.test(insText))) { |
| 67 | | var href = insText; |
| 68 | | if (mail.test(href)) href = 'mailto:' + insText; |
| 69 | | if (www.test(href)) href = 'http://' + href; |
| 70 | | var node = prompt(jlog_l_comments_url_node); |
| 71 | | if((node != null) && (node != '')) insText = '[url=' + href + ']' + node + eTag; |
| 72 | | else if(node == '') insText = aTag + href + eTag; |
| 73 | | } |
| 74 | | else { |
| 75 | | var node = insText; |
| 76 | | if(node == '') node = prompt(jlog_l_comments_url_node, insText); |
| 77 | | var href = prompt(jlog_l_comments_url_href, 'http://'); |
| 78 | | if (http.test(href)) return insText; |
| 79 | | if (www.test(href)) href = 'http://' + href; |
| 80 | | if(((node != null) && (node != '')) && ((href != null) && (href != ''))) |
| 81 | | insText = '[url=' + href + ']' + node + eTag; |
| 82 | | else if((href != null) && (href != '')) insText = aTag + href + eTag; |
| 83 | | } |
| 84 | | return insText; |
| 85 | | } |
| 86 | | |
| 87 | | function jlog_bbcode_list(o_insText, aTag, eTag) { |
| 88 | | insText = o_insText.replace(/(\n|\r|\r\n)(?=(.+))/g, '$1[*]'); |
| 89 | | return '[list]\n[*]' + insText + eTag + '\n'; |
| 160 | | } |
| 161 | | |
| 162 | | var jlog_bbcode_br; |
| 163 | | |
| 164 | | function jlog_init() { |
| 165 | | if(document.getElementById("pingbacks")) var jlog_comments = document.getElementById("pingbacks"); |
| 166 | | else var jlog_comments = document.getElementById("comments"); |
| 167 | | if (jlog_comments) { |
| 168 | | show = true; |
| 169 | | if (!document.getElementById || !document.createElement || !document.createTextNode) return; |
| 170 | | var p = document.createElement("p"); |
| 171 | | p.className = "hidecomments"; |
| 172 | | var a = document.createElement("a"); |
| 173 | | a.id = "hidecomments"; |
| 174 | | a.href = "javascript:jlog_killcomments()"; |
| 175 | | var text = document.createTextNode(jlog_l_comments_hide); |
| 176 | | a.appendChild(text); |
| 177 | | p.appendChild(a); |
| 178 | | if (jlog_comments.insertBefore) { |
| 179 | | jlog_comments.parentNode.insertBefore(p, jlog_comments); |
| 180 | | } |
| 181 | | } |
| 182 | | |
| 183 | | jlog_bbcode_br = document.getElementById("bbcode"); |
| 184 | | if(jlog_bbcode_br || (typeof(jlog_admin) != "undefined")) { |
| 185 | | |
| 186 | | if (jlog_bbcode_br.insertBefore) { |
| 187 | | jlog_bbcode_do_button(jlog_l_comments_url, '[url]', '[/url]'); |
| 188 | | jlog_bbcode_do_button(jlog_l_comments_bold, '[b]', '[/b]'); |
| 189 | | jlog_bbcode_do_button(jlog_l_comments_italic, '[i]', '[/i]'); |
| 190 | | jlog_bbcode_do_button(jlog_l_comments_quote, '[quote]', '[/quote]'); |
| 191 | | if (jlog_comments) jlog_bbcode_br.parentNode.getElementsByTagName("span")[0].style.display = "none"; |
| 192 | | } |
| 193 | | |
| 194 | | if (typeof(jlog_admin) != "undefined") { |
| 195 | | document.getElementById("jlogteaserpic").style.display = "block"; |
| 196 | | if (jlog_bbcode_br.insertBefore) { |
| 197 | | jlog_bbcode_do_button(jlog_l_headline, '[headline]', '[/headline]'); |
| 198 | | jlog_bbcode_do_button(jlog_l_list, '[list][*]', '[/list]'); |
| 199 | | } |
| 200 | | } |
| 201 | | } |
| 202 | | |
| 203 | | if(typeof(jlog_searchpage) === "undefined") jlog_searchengineSearchHighlight(); |
| 204 | | } |
| 205 | | |
| 206 | | function addLoadEvent(func) { |
| 207 | | var oldonload = window.onload; |
| 208 | | if (typeof window.onload != 'function') { |
| 209 | | window.onload = func; |
| 210 | | } else { |
| 211 | | window.onload = function() { |
| 212 | | oldonload(); |
| 213 | | func(); |
| 214 | | } |
| 215 | | } |
| 216 | | } |
| 217 | | |
| 218 | | addLoadEvent(jlog_init); |
| 219 | | addLoadEvent( function() { |
| 220 | | if(document.getElementById("password")) |
| 221 | | document.getElementById("password").focus() |
| 222 | | }); |
| 223 | | |
| 224 | | var winpops; |
| 225 | | |
| 226 | | /* Open popup to learn BBCode for comments */ |
| 227 | | function jlog_learnbb(path) { |
| 228 | | var popurl = path + '/learn_bb.php?v=small'; |
| 229 | | winpops=window.open(popurl,'','width=400,height=300,scrollbars=yes'); |
| 230 | | } |
| 231 | | |
| 232 | | /* Open popup to upload pictures in admincenter */ |
| 233 | | function jlog_wopen(popurl) { |
| 234 | | winpops=window.open(popurl,'','width=350,height=350,scrollbars=yes'); |
| | 229 | function jlog_init() { |
| | 230 | var jlog_comments; |
| | 231 | if(document.getElementById("pingbacks")) { jlog_comments = document.getElementById("pingbacks"); } |
| | 232 | else { jlog_comments = document.getElementById("comments"); } |
| | 233 | if (jlog_comments) { |
| | 234 | if (!document.getElementById || !document.createElement || !document.createTextNode) { return; } |
| | 235 | var p = document.createElement("p"); |
| | 236 | p.className = "hidecomments"; |
| | 237 | var a = document.createElement("a"); |
| | 238 | a.id = "hidecomments"; |
| | 239 | a.href = "#"; |
| | 240 | a.onclick = function() {jlog_killcomments(); return false; }; |
| | 241 | var text = document.createTextNode(jlog_l_comments_hide); |
| | 242 | a.appendChild(text); |
| | 243 | p.appendChild(a); |
| | 244 | if (jlog_comments.insertBefore) { |
| | 245 | jlog_comments.parentNode.insertBefore(p, jlog_comments); |
| | 246 | } |
| | 247 | } |
| | 248 | |
| | 249 | jlog_bbcode_br = document.getElementById("bbcode"); |
| | 250 | if(jlog_bbcode_br || (typeof(jlog_admin) !== "undefined")) { |
| | 251 | |
| | 252 | if (jlog_bbcode_br.insertBefore) { |
| | 253 | jlog_bbcode_do_button(jlog_l_comments_url, '[url]', '[/url]'); |
| | 254 | jlog_bbcode_do_button(jlog_l_comments_bold, '[b]', '[/b]'); |
| | 255 | jlog_bbcode_do_button(jlog_l_comments_italic, '[i]', '[/i]'); |
| | 256 | jlog_bbcode_do_button(jlog_l_comments_quote, '[quote]', '[/quote]'); |
| | 257 | if (jlog_comments) { jlog_bbcode_br.parentNode.getElementsByTagName("span")[0].style.display = "none"; } |
| | 258 | } |
| | 259 | |
| | 260 | if (typeof(jlog_admin) !== "undefined") { |
| | 261 | document.getElementById("jlogteaserpic").style.display = "block"; |
| | 262 | if (jlog_bbcode_br.insertBefore) { |
| | 263 | jlog_bbcode_do_button(jlog_l_headline, '[headline]', '[/headline]'); |
| | 264 | jlog_bbcode_do_button(jlog_l_list, '[list][*]', '[/list]'); |
| | 265 | } |
| | 266 | } |
| | 267 | } |
| | 268 | |
| | 269 | if(typeof(jlog_searchpage) === "undefined") { jlog_searchengineSearchHighlight(); } |
| | 270 | } |
| | 271 | |
| | 272 | function addLoadEvent(func) { |
| | 273 | var oldonload = window.onload; |
| | 274 | if (typeof window.onload !== 'function') { |
| | 275 | window.onload = func; |
| | 276 | } else { |
| | 277 | window.onload = function() { |
| | 278 | oldonload(); |
| | 279 | func(); |
| | 280 | }; |
| | 281 | } |
| | 282 | } |
| | 283 | |
| | 284 | addLoadEvent(jlog_init); |
| | 285 | addLoadEvent( function() { |
| | 286 | if(document.getElementById("password")) { |
| | 287 | document.getElementById("password").focus(); |
| | 288 | } |
| | 289 | }); |
| | 290 | |
| | 291 | var winpops; |
| | 292 | |
| | 293 | /* Open popup to learn BBCode for comments */ |
| | 294 | function jlog_learnbb(path) { |
| | 295 | var popurl = path + '/learn_bb.php?v=small'; |
| | 296 | winpops=window.open(popurl,'','width=400,height=300,scrollbars=yes'); |
| | 297 | } |
| | 298 | |
| | 299 | /* Open popup to upload pictures in admincenter */ |
| | 300 | function jlog_wopen(popurl) { |
| | 301 | winpops=window.open(popurl,'','width=350,height=350,scrollbars=yes'); |
| | 302 | } |
| | 303 | |