1function NameWarning(opt) 2{ 3 if(!$("row_name")) return; 4 5 var nameWarning = new Element("div",{"id":"nameWarning","class":"submitWarning"}); 6 $("row_name").parentNode.insertBefore(nameWarning,$("row_name").nextSibling); 7 nameWarning.hide(); 8 9 var timeout = null; 10 $("name").observe("keyup",function(){ 11 if ($("name").value.length > 0) 12 { 13 if (timeout) clearTimeout(timeout); 14 timeout = setTimeout(function(){ 15 new Ajax.Request(opt.ajaxURL,{ 16 "method":"post", 17 "parameters":$H({"search":$("name").value}).toQueryString(), 18 "onSuccess":function(transport){ 19 if (transport.responseJSON.length > 0) 20 { 21 var result = transport.responseJSON[0]; 22 nameWarning.show(); 23 nameWarning.update("Did you mean <a href='"+opt.linkURL+result.id+"'>"+result.name.escapeHTML()+"</a>?"); 24 } 25 else 26 nameWarning.hide(); 27 }, 28 }); 29 timeout = null; 30 }, 1000); 31 } 32 }); 33} 34 35function AddPreviewButton( button ) 36{ 37 var origTextarea = document.body.select("textarea").first(); 38 if (!origTextarea) return; 39 40 var previewButton = new Element("input",{"type":"submit","id":"submitPreview","value":"Preview"}); 41 button.parentNode.insertBefore(previewButton,button); 42 previewButton.observe("click",function(e){ 43 e.stop(); 44 45 var w = 600; 46 var h = 400; 47 var x = (screen.width - w) / 2; 48 var y = (screen.height - h) / 2; 49 var wnd = window.open("","previewWnd","left="+x+",top="+y+",width="+w+",height="+h+",resizable=yes,status=yes,toolbar=no,location=no,menubar=no,scrollbars=yes"); 50 51 var form = new Element("form",{"method":"post","target":"previewWnd","action":"preview.php"}); 52 document.body.insert(form); 53 54 var textarea = new Element("textarea",{"name":"message"}); 55 //textarea.update( origTextarea.value ); 56 textarea.value = origTextarea.value; 57 form.insert(textarea); 58 59 form.submit(); 60 61 form.remove(); 62 }); 63} 64 65function adjustSubmitFormFields() 66{ 67 if($("platform")) $A( $("platform").options ).each(function(item){ 68 if (item.selected) 69 { 70// if (item.text.toLowerCase().indexOf("zx") != -1) 71// $("row_zxdemoID").show(); 72 if (item.text.toLowerCase().indexOf("commodore") != -1) 73 $("row_csdbID").show(); 74 if (item.text.toLowerCase().indexOf("c64") != -1) 75 $("row_csdbID").show(); 76 if (item.text.toLowerCase().indexOf("c16") != -1) 77 $("row_csdbID").show(); 78 } 79 }); 80 if($("type")) $A( $("type").options ).each(function(item){ 81 if (item.selected) 82 { 83 if (item.text.toLowerCase().indexOf("invitation") != -1) 84 { 85 $("row_invitationParty").show(); 86 $("row_invitationYear").show(); 87 } 88 if (item.text.toLowerCase().indexOf("bbstro") != -1) 89 { 90 $("row_boardID").show(); 91 } 92 } 93 }); 94 if ($("invitationParty") && $("invitationParty").value) 95 { 96 $("row_invitationParty").show(); 97 $("row_invitationYear").show(); 98 } 99} 100 101function PrepareSubmitForm() 102{ 103 NameWarning({"ajaxURL":"./ajax_prods.php","linkURL":"prod.php?which="}); 104 105 var fields = $A([ 106 "row_csdbID", 107 //"row_zxdemoID", 108 "row_invitationParty", 109 "row_invitationYear", 110 "row_boardID", 111 ]); 112 if ($("partyID")) 113 { 114 fields.concat([ 115 "row_partyYear", 116 "row_partyCompo", 117 "row_partyRank", 118 ]); 119 } 120 fields.each(function(item){ 121 if ($(item)) $(item).hide(); 122 }); 123 124 var resetCompos = function() 125 { 126 var options = $("partyCompo").select("option"); 127 var v = $("partyCompo").options[$("partyCompo").selectedIndex].value; 128 $("partyCompo").update(""); 129 options.each(function(i){ $("partyCompo").insert(i); }); 130 $("partyCompo").value = v; 131 } 132 var reorganizeCompos = function(){ 133 if (!$("partyID").value) { resetCompos(); return; } 134 if (!$("partyYear").options[$("partyYear").selectedIndex].value) { resetCompos(); return; } 135 new Ajax.Request("ajax_partycompos.php",{ 136 "method":"GET", 137 "parameters":$H({ 138 "party":$("partyID").value, 139 "year":$("partyYear").options[$("partyYear").selectedIndex].value 140 }), 141 "onException": function(r, e) { throw e; }, 142 "onSuccess":function(transport) 143 { 144 if (transport.responseJSON && transport.responseJSON.c
144ompos.length) 145 { 146 var options = $("partyCompo").select("option"); 147 var v = $("partyCompo").options[$("partyCompo").selectedIndex].value; 148 $("partyCompo").update(""); 149 var idx = 0; 150 var og1 = new Element("optgroup",{"label":"known compos at this party"}); 151 $("partyCompo").insert(og1); 152 options.each(function(i){ 153 if (transport.responseJSON.compos.indexOf(parseInt(i.value,10)) != -1) 154 og1.insert( i ); 155 }); 156 157 var og2 = new Element("optgroup",{"label":"other compos"}); 158 $("partyCompo").insert(og2); 159 options.each(function(i){ 160 if (transport.responseJSON.compos.indexOf(parseInt(i.value,10)) == -1) 161 og2.insert( i ); 162 }); 163 164 $("partyCompo").insert( {top:options.find(function(i){ return i.value == 0; })} ); 165 $("partyCompo").value = v; 166 167 } 168 else 169 { 170 resetCompos(); 171 } 172 }, 173 }); 174 }; 175 176 if ($("platform")) $("platform").observe("change",adjustSubmitFormFields); 177 if ($("type")) $("type").observe("change",adjustSubmitFormFields); 178 adjustSubmitFormFields(); 179 if ($("group1")) new Autocompleter($("group1"), {"dataUrl":"./ajax_groups.php","processRow": function(item) { 180 return item.name.escapeHTML() + (item.disambiguation ? " <span class='group-disambig'>" + item.disambiguation.escapeHTML() + "</span>" : ""); 181 }}); 182 if ($("group2")) new Autocompleter($("group2"), {"dataUrl":"./ajax_groups.php","processRow": function(item) { 183 return item.name.escapeHTML() + (item.disambiguation ? " <span class='group-disambig'>" + item.disambiguation.escapeHTML() + "</span>" : ""); 184 }}); 185 if ($("group3")) new Autocompleter($("group3"), {"dataUrl":"./ajax_groups.php","processRow": function(item) { 186 return item.name.escapeHTML() + (item.disambiguation ? " <span class='group-disambig'>" + item.disambiguation.escapeHTML() + "</span>" : ""); 187 }}); 188 if ($("partyID")) new Autocompleter($("partyID"), {"dataUrl":"./ajax_parties.php",onSelectItem:function(){ 189 $("row_partyYear").show(); 190 $("row_partyCompo").show(); 191 $("row_partyRank").show(); 192 reorganizeCompos(); 193 }}); 194 $("partyYear").observe("change",reorganizeCompos); 195 $("partyYear").observe("keyup",reorganizeCompos); 196 if ($("invitationParty")) new Autocompleter($("invitationParty"), {"dataUrl":"./ajax_parties.php",onSelectItem:function(){ 197 //$("row_invitationYear").show(); 198 }}); 199 if ($("boardID")) new Autocompleter($("boardID"), {"dataUrl":"./ajax_boards.php"}); 200} 201 202function PreparePostForm( form ) 203{ 204 form.observe('submit',function(e){ 205 var ta = e.element().down("textarea"); 206 var bbTags = $A(["url", "code", "b", "i", "u", "img", "quote", "list"]); 207 var broken = false; 208 bbTags.each(function(item){ 209 var re1 = new RegExp("\\["+item+"[^a-z]","gi"); 210 var re2 = new RegExp("\\[/"+item+"[^a-z]","gi"); 211 if ((ta.value.match(re1) || []).length != (ta.value.match(re2) || []).length) 212 broken = item; 213 }); 214 if (broken) 215 { 216 if (!confirm("your ["+broken+"] bbcode is broken ! are you sure you want to post it ?")) 217 e.stop(); 218 } 219 }); 220} 221function InstrumentAdminEditorForAjax( parentElement, formAction, _options ) 222{ 223 var options = _options || {}; 224 225 parentElement.select(".edit").each(function(item){ 226 var tr = item.up("tr"); 227 item.observe("click",function(e){ 228 e.stop(); 229 new Ajax.Updater($(tr), item.href, { 230 method: 'get', 231 parameters: { 232 partial: true, 233 }, 234 onComplete: function() { 235 if (options.onRowLoad) 236 options.onRowLoad($(tr)); 237 tr.down("input[type='submit']").observe("click",function(ev){ 238 ev.stop(); 239 var invalidFields = tr.select("input,select").filter(function(item){ return item.validity && !item.validity.valid; }); 240 if (invalidFields.length > 0) 241 { 242 alert("There are invalid values in the following fields: " + invalidFields.collect(function(i){ return i.name}).join(", ") ); 243 return; 244 } 245 var opt = Form.serializeElements( tr.select("input,select"), {hash:true} ); 246 opt["partial"] = true; 247 opt["formProcessorAction"] = tr.up("form").down("input[name='formProcessorAction']").value; 248 new Ajax.Request( tr.up("form").action, { 249 method: "post", 250 parameters: opt, 251 onSuccess: function(transport) { 252 tr.update(transport.responseText); 253 InstrumentAdminEditorForAjax( tr, formAction, options ); 254 fireSuccessOverlay(); 255 } 256 }); 257 }); 258 }, 259 }); 260 }); 261 }); 262 parentElement.select(".delete").each(function(item){ 263 var tr = item.up("tr"); 264 item.observe("click",function(e){ 265 e.stop(); 266 if(!confirm("Are you sure you want to delete this item?")) 267 return; 268 269 //var opt = item.href.toQueryParams(); 270 var opt = Form.serializeElements( tr.select("input,select"), {hash:true} ); 271 opt = $H(opt).merge( item.href.toQueryParams() ).toObject(); 272 opt["partial"] = true; 273 opt["formProcessorAction"] = tr.up("form").down("input[name='formProcessorAction']").value; 274 new Ajax.Request( tr.up("form").action, { 275 method: "post", 276 parameters: opt, 277 onSuccess: function(transport) { 278 tr.remove(); 279 fireSuccessOverlay(); 280 } 281 }); 282 }); 283 }); 284 if (parentElement.down(".new")) 285 { 286 parentElement.down(".new").observe("click",function(e){ 287 var tr = new Element("tr"); 288 parentElement.down("table.boxtable").insert(tr); 289 e.stop(); 290 new Ajax.Updater($(tr), e.element().href, { 291 method: 'get', 292 parameters: { 293 partial: true, 294 }, 295 onComplete: function() { 296 if (options.onRowLoad) 297 options.onRowLoad($(tr)); 298 tr.down("input[type='submit']").observe("click",function(ev){ 299 ev.stop(); 300 var invalidFields = tr.select("input,select").filter(function(item){ return item.validity && !item.validity.valid; }); 301 if (invalidFields.length > 0) 302 { 303 alert("There are invalid values in the following fields: " + invalidFields.
303collect(function(i){ return i.name}).join(", ") ); 304 return; 305 } 306 var opt = Form.serializeElements( tr.select("input,select"), {hash:true} ); 307 opt["partial"] = true; 308 opt["formProcessorAction"] = tr.up("form").down("input[name='formProcessorAction']").value; 309 new Ajax.Request( tr.up("form").action, { 310 method: "post", 311 parameters: opt, 312 onSuccess: function(transport) { 313 tr.update(transport.responseText); 314 InstrumentAdminEditorForAjax( tr, formAction, options ); 315 fireSuccessOverlay(); 316 } 317 }); 318 }); 319 }, 320 }); 321 }); 322 } 323} 324 325 326 327 328 329var timerDensity = 50; 330var timeCrossfade = 500; 331var timeWait = 1000; 332function fadeOverlays() 333{ 334 var step = 1.0 / (timeCrossfade * 1.0 / timerDensity); 335 var elements = ["successOverlay","errorOverlay"]; 336 var success = false; 337 elements.each(function(item){ 338 if (!$(item)) return; 339 item = $(item); 340 341 item.style.opacity = parseFloat(item.style.opacity) - step; 342 //console.log(item.style.opacity); 343 if (item.style.opacity <= step + 0.01) // wahey chrome precision! 344 { 345 item.remove(); 346 return; 347 } 348 success = true; 349 }); 350 if (!success) return; 351 setTimeout(fadeOverlays,timerDensity); 352} 353 354function fireSuccessOverlay( msg ) 355{ 356 if (!$("successOverlay")) 357 document.body.insert(new Element("div",{"id":"successOverlay"}).update( msg ? msg : "Success !")); 358 $("successOverlay").style.opacity = "1.0"; 359 //console.log(timeWait + timerDensity); 360 setTimeout(fadeOverlays,timeWait + timerDensity); 361} 362 363function fireErrorOverlay( errors ) 364{ 365 if (!$("errorOverlay")) 366 document.body.insert(new Element("div",{"id":"errorOverlay"}).update( errors ? errors : "There was an error :(" )); 367 $("errorOverlay").style.opacity = "1.0"; 368 setTimeout(fadeOverlays,timeWait + timerDensity); 369} 370 371function StubLinksToDomainName( parentElement, detailed ) 372{ 373 parentElement.select("a[rel='external']").each(function(item){ 374 var host = item.href.match(/:\/\/(.*?)\//); 375 if (host) 376 { 377 item.update( host[1].escapeHTML() ); 378 return; 379 } 380 }); 381} 382 383/* BBCODE helper script by AMcBain */ 384 385(function () 386{ 387 "use strict"; // See http://daringfireball.net/2010/07/improved_regex_for_matching_urls 388 var textarea, buttons, url = /^\s*((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?\xAB\xBB\u201C\u201D\u2018\u2019]))/i; 389 var protocol = /^\s*[A-Z_a-z]+:\/\//; 390 391 // Replaces the selected text in a textarea with the given text optionally highlighting a subset 392 // of the replacement text based on insets from the start and end of the replacement text. 393 function replaceText (text, sinset, einset) 394 { 395 var start = textarea.selectionStart, end = textarea.selectionEnd; 396 397 textarea.value = textarea.value.substring(0, start) + text + textarea.value.substring(end); 398 399 if (typeof sinset === "number" && typeof einset === "number") { 400 textarea.setSelectionRange(start + sinset, start + text.length - einset); 401 } 402 else 403 { 404 textarea.setSelectionRange(start + text.length, start + text.length); 405 } 406 textarea.focus(); 407 } 408 409 function getText () 410 { 411 return textarea.value.substring(textarea.selectionStart, textarea.selectionEnd); 412 } 413 414 // Puts proper bb-code around selected text and places the cursor after it, 415 // or inserts some bb-code-surrounded dummy text and selects the dummy text. 416 function simpleEdit () 417 { 418 var text = getText(), start = this.code[0], end = this.code[1]; 419 420 if (text) { 421 replaceText(start + text + end); 422 } 423 else { 424 replaceText(start + this.text + end, start.length, end.length); 425 } 426 } 427 428 function linkAltEdit () 429 { 430 var text = getText(), start = "[url=", end = "[/url]"; 431 432 if (text) 433 { 434 if (url.test(text)) 435 { 436 if (!protocol.test(text)) 437 { 438 text = "http://" + text; 439 } 440 text = text.strip();
441 replaceText(start + text + "]" + this.smpl + end, start.length + text.length + 1, end.length); 442 } 443 else 444 { 445 replaceText(start + this.text + "]" + text + end, start.length, end.length + text.length + 1); 446 } 447 } 448 else 449 { 450 text = start + this.text + "]" + this.smpl + end; 451 replaceText(text, start.length, 1 + this.smpl.length + end.length); 452 } 453 } 454 455 function listEdit () 456 { 457 var text = getText(), start = this.code[0], end = this.code[1]; 458 459 if (text) 460 { 461 text = start + text.replace(/(?:^|\n)([^\n]+)/g, "[*]$1\n") + end; 462 replaceText(text, text.length + 1, 0); 463 } 464 else 465 { 466 text = start + this.text + end; 467 replaceText(text, start.length + 3, end.length + 1); 468 } 469 } 470 471 buttons = [ { 472 name: "Bold", 473 code: [ "[b]", "[/b]" ], 474 text: "bold text" 475 }, { 476 name: "Italic", 477 code: [ "[i]", "[/i]" ], 478 text: "italic text" 479 }, { 480 name: "Link", 481 code: [ "[url]", "[/url]" ], 482 text: "http://example.com", 483 click: function () 484 { 485 var text = getText(); 486 487 if (url.test(text) && !protocol.test(text)) 488 { 489 this.smpl = text.strip(); 490 linkAltEdit.call(this); 491 } 492 else 493 { 494 simpleEdit.call(this); 495 } 496 } 497 }, { 498 "class": "link_alt", 499 name: "Link w/ text", 500 text: "http://example.com", 501 smpl: "linky", 502 click: linkAltEdit 503 }/*, { 504 name: "Email", 505 code: [ "[email]", "[/email]" ], 506 text: "[email protected]" 507 }*/, { 508 name: "Image", 509 code: [ "[img]", "[/img]" ], 510 text: "http://example.com/image.png" 511 }, { 512 name: "Quote", 513 code: [ "[quote]", "[/quote]" ], 514 text: "quoted text" 515 }, { 516 name: "Code", 517 code: [ "[code]", "[/code]" ], 518 text: "// code comment" 519 }, { 520 name: "Bullet list", 521 more: true, 522 code: [ "[list]\n", "[/list]" ], 523 text: "[*]list item\n", 524 click: listEdit 525 }, { 526 name: "Alpha list", 527 more: true, 528 code: [ "[list=A]\n", "[/list]" ], 529 text: "[*]A is for alligator\n", 530 click: listEdit 531 }, { 532 name: "Numbered list", 533 more: true, 534 code: [ "[list=1]\n", "[/list]" ], 535 text: "[*]list item\n", 536 click: listEdit 537 } ]; 538 539 document.observe("dom:loaded", function () 540 { 541 textarea = $$("#pouetbox_bbsopen textarea, #pouetbox_bbspost textarea, #pouetbox_prodpost textarea")[0]; 542 543 // Require IE9+ and other supporting browsers. 544 if(!textarea || !("selectionStart" in textarea)) { 545 return; 546 } 547 548 var list = document.createElement("ul"); 549 list.id = "pouet_bb_editor"; 550 551 var sublist = document.createElement("ul"); 552 553 buttons.each(function (button) 554 { 555 var li = document.createElement("li"); 556 li.innerHTML = button.name; 557 li.onclick = function () 558 { 559 (button.click || simpleEdit).call(button); 560 }; 561 562 var parent = (button.more ? sublist : list); 563 parent.appendChild(li); 564 parent.appendChild(document.createTextNode(" ")); 565 }); 566 567 list.insertAdjacentHTML("beforeend", "<li>more...</li>"); 568 list.lastChild.appendChild(sublist); 569 570 textarea.nextSibling.nextSibling.appendChild(list); 571 }); 572}()); 573 574function CollapsibleHeaders( elements ) 575{ 576 elements.each(function(box){ 577 if (!box.down("h2,h3")) 578 return; 579 580 var header = box.down("h2,h3"); 581 var elements = header.nextSiblings(); 582 583 var container = new Element("div",{"class":"collapseContainer"}); 584 585 elements.each(function(i){ container.insert(i); }); 586 587 box.insert(container); 588 589 var toggle = new Element("span",{"class":"collapseToggle"}); 590 header.insert( toggle ); 591 592 if (box.id && Cookie.getData('pouetHeadersShown-'+box.id)) 593 { 594 toggle.update("hide"); 595 container.show(); 596 } 597 else 598 { 599 toggle.update("show"); 600 container.hide(); 601 } 602 603 var _box = box; 604 header.observe("click",function(){ 605 if (toggle.innerHTML == "show") 606 { 607 toggle.update("hide"); 608 container.show(); 609 if (_box && _box.id) Cookie.setData('pouetHeadersShown-'+_box.id,true); 610 } 611 else 612 { 613 toggle.update("show"); 614 container.hide(); 615 if (_box && _box.id) Cookie.setData('pouetHeadersShown-'+_box.id,false); 616 } 617 }); 618 }); 619} 620 621function checkForNewsTickers() 622{ 623 if (!newsTickers) 624 { 625 return; 626 } 627 628 var container = null; 629 $H(newsTickers).each(function(kvp){ 630 if(Date.now() > kvp.value.expires*1000) 631 { 632 return; 633 } 634 if (Cookie.getData("newsTickerSupress-"+kvp.key)) 635 { 636 return; 637 } 638 if (!container) 639 { 640 container = new Element("ul",{"class":"newsTickers"}); 641 document.body.insert(container); 642 } 643 var li = new Element("li",{"class":kvp.value.class}).update("<p>"+kvp.value.html+"</p>"); 644 var close = new Element("button",{"class":"close","title":"Close"}).update("❌"); 645 close.observe("click",function(){ 646 li.remove(); 647 Cookie.setData("newsTickerSupress-"+kvp.key, true); 648 }); 649 li.insert(close); 650 container.insert(li); 651 }); 652} 653 654// on load scripts - keep this to minimum 655document.observe("dom:loaded",function(){ 656 Cookie.init({name: 'pouetSettings', expires: 365}); 657 if (location.hash=="#success") 658 { 659 if (history && "pushState" in history) 660 { 661 history.pushState("", document.title, window.location.pathname + window.location.search); 662 } 663 else 664 { 665 location.hash = ""; 666 } 667 fireSuccessOverlay(); 668 } 669 checkForNewsTickers(); 670});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.