Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var $debilove = "SAS1939"; // prispevky se zobrazi az po kliknuti na nick
- var $poleBanAdres = [];
- /*
- var podbarvit = `[
- {"nick":"bloodrat", "background_color":"beige"},
- {"nick":"Losssssss", "background_color":"#c3f9ff"}
- ]`;
- */
- if (location.protocol == 'http:') {
- window.location.assign("https://www.okoun.cz");
- }
- var ultradebilove_cas = localStorage.getItem("ultradebilove_cas");
- var $ultradebilove = localStorage.getItem("ultradebilove");
- var b_ud_stahnout = false;
- if (typeof $ultradebilove === 'undefined') {
- b_ud_stahnout = true;
- }
- if (ultradebilove_cas) {
- var newDate = new Date();
- var difference = newDate.getTime() - ultradebilove_cas;
- if (difference > 600000) {
- b_ud_stahnout = true;
- }
- } else {
- b_ud_stahnout = true;
- }
- if (b_ud_stahnout) {
- $ultradebilove = $(getUD()).find('div.xdata').html();
- var newDate = new Date();
- localStorage.setItem("ultradebilove_cas", newDate.getTime());
- }
- // var podbarvit2 = JSON.parse(podbarvit);
- var $defaultFormat = "plain"; /* plain | html | radeox */
- var mods = $(".yui-u").first().html();
- mods = mods.split("<br><br>");
- mods = mods[0];
- var $el = $(".main > .yui-g > .yui-u").first();
- if ($el.length === 0) {
- $el = $(".main > .yui-gc > .yui-u").first();
- }
- $el.html("<p title='Naposledy načteno' id='xtime'></p><p><input placeholder='Hledej' id='srchinput'></p>");
- $el.append("<h3>S novými <span id='pocetsnovymi'></span></h3><div id='novydiv'></div>");
- // Opravene mizeni .pager a mazaciho tlacitka pokud se jedna o vzkaznik - BR 12.9.22 - ZACATEK
- $el_pager = $("div.pager").first();
- var $jeToMujVzkaznik = $(".expbutton").find("a.expcol").text();
- if ($jeToMujVzkaznik !== 'Nový vzkaz') {
- $el_pager.detach().prependTo( ".list-and-pagers-wrapper");
- }
- var $jeToMujKlub = $('div.settings a').filter(function(index) { return $(this).text() === "Nastavení klubu"; }).attr("href") ;
- // Opravene mizeni .pager a mazaciho tlacitka pokud se jedna o vzkaznik - BR 12.9.22 - KONEC
- $( "<div id='welcome2'></div>" ).insertAfter( $(".welcome"));
- $("[name='markWelcomeMsgBoardForm']").hide();
- $("h2").append("<span id='rozbal2' title='Rozbal popis klubu'> </span>");
- $( "#welcome2").html("<div id='rozbal3'>"+$( ".welcome" ).html()+"</div>");
- $("h2").append("<span id='mods_expand' title='Moderátoři'>M</span>");
- $("#welcome2").append("<div id='rozbal4'>"+mods+"</div>");
- var $prispevky = $("div.item");
- var $neprecteny;
- var $debilove_arr = $debilove.split(",");
- $ultradebilove = $ultradebilove.split(' ,').join(',');
- $ultradebilove = $ultradebilove.split(', ').join(',');
- localStorage.setItem("ultradebilove", $ultradebilove);
- var $ultradebilove_arr = $ultradebilove.split(",");
- var ultradebilove_counter = 0;
- var $showAutocheckedForDel = false; //mechanismus schovávání del buttonu na radce 428
- $ultradebilove_arr.push('Cindy');
- $ultradebilove_arr.push('Karma');
- $prispevky.each(function() {
- var prispevek = $(this);
- embedVideos (prispevek.find(".content"));
- if (jQuery.inArray(prispevek.find("span.user").html(), $debilove_arr )!== -1) {
- $(this).addClass( "hiddenart" );
- }
- var username = prispevek.find( "span.user").html();
- if (jQuery.inArray(username, $ultradebilove_arr )!== -1) {
- ultradebilove_counter++;
- // zde je začátek přidaného kódu - BR
- var titleId = prispevek.find("div.content").html();
- var $debilProBan = prispevek.find("span.user").html();
- if (titleId.search("img") !== -1) {
- var id = $(this).attr('id');
- $(`#${id} .title`).text('měl bych se raději zabít');
- $(`#${id} .yui-base`).find("img").attr('src', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==');
- /*
- var pathname = window.location.pathname;
- if (pathname == 'https://www.okoun.cz/msgbox.jsp'||'http://www.okoun.cz/msgbox.jsp') {
- $(`#${id} .content`).find("img").attr('src', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==');
- }*/
- }
- // a zde je konec, jinak beze změn - BR
- // umlceni ultradebila - BR 12.9.22 - ZACATEK
- var id = $(this).attr('id');
- $(`#${id} .yui-base`).html("Měl bych se zabít a chcípnout v libovolném pořadí.");
- if ($jeToMujVzkaznik === 'Nový vzkaz') {
- $(`#${id} .content`).html("Měl bych se zabít a chcípnout v libovolném pořadí.");
- }
- // umlceni ultradebila - BR 12.9.22 - KONEC
- if ($jeToMujKlub !== undefined){
- $(this).find("span.delete input").prop( "checked", true );
- $showAutocheckedForDel = true;
- var item = $(this);
- // item.before( '<span class="yui-button" id="banButtonID"><a href="' + $jeToMujKlub + '&uuName=' + $debilProBan +'&uuAction=banishHim" target="_blank">Ban!</a></span>' );
- // https://www.okoun.cz/updateBoard.jsp?boardId=10303&uuName=Cindy&uuAction=banishHim
- $poleBanAdres.push($jeToMujKlub +'&uuName=' + $debilProBan +'&uuAction=banishHim');
- }
- // <input type="checkbox" name="defReadPerm" value="on" checked="checked" id="bcform-defReadPerm">
- $(this).addClass( "hiddenart2" );
- }
- if (prispevek.hasClass('new')) {
- $neprecteny = prispevek;
- }
- /*
- $.each(podbarvit2, function(key,value) {
- if (username == value.nick) {
- prispevek.css("background-color", value.background_color);
- }
- });
- */
- $(this).find("span.user").after(" <a title='Filtruj' class='userfilter' href='"+window.location.pathname+"?searchedUsers="+username+"'>•</a>");
- $(this).find(".actions").append( "<span class='oblibit' data-xid="+$(this).attr("id")+">Oblíbit</span>");
- });
- if (ultradebilove_counter> 0 ) {
- $('.settings').append("<span class='skrytoprispevku' style='float:left;padding-right:10px'>UD: "+ultradebilove_counter+' ' + "</span>");
- }
- $(document).on("click", ".skrytoprispevku", function (e) {
- $(".hiddenart2").addClass("hiddenart2_show");
- $(".hiddenart2").removeClass("hiddenart2");
- $(".skrytoprispevku").hide();
- });
- if ($neprecteny) {
- if (NotInViewport($neprecteny)) {
- const julie = $neprecteny[0];
- julie.scrollIntoView(false);
- window.scrollBy(0,100);
- }
- }
- var mesice = "ledna,února,března,dubna,května,června,července,srpna,září,října,listopadu,prosince";
- var mesice_arr = mesice.split(",");
- var $novy = $("#novydiv");
- xload();
- setInterval( function(){
- xload();
- }, 60000);
- function xload() {
- var $pocetsnovymi = 0;
- $novy.load( "https://www.okoun.cz/favourites.jsp?new=1&k="+Math.random()+" .item", function() {
- $novy.find(".item").each(function() {
- var str_dt = $(this).find("span.date").html();
- var arr = str_dt.split(" ");
- var arr2 = arr[0].split(".");
- var out = arr[1];
- out += twoplaces(mesice_arr.indexOf(arr2[1]));
- out += twoplaces(arr2[0]);
- if (arr[2].length<8) {out += "0";}
- out += arr[2];
- var nazev = $(this).find("a.name").html();
- var href = $(this).find("a.name").attr('href');
- var novych = $(this).find("b").html();
- novych = novych.replace(' nových', '');
- novych = novych.replace(' nový', '');
- novych = novych.replace(' nové', '');
- $(this).html("<a class='klub' data-tm='" + out + "' title='"+ str_dt + "' href='" + href + "'>" + nazev + "</a> - " + novych);
- $pocetsnovymi = $pocetsnovymi +1;
- });
- $("#novydiv .item").sort(descending_sort).appendTo('#novydiv');
- $("#pocetsnovymi").html("(" + $pocetsnovymi + ")");
- });
- var dt = new Date();
- $("#xtime").html(dt.getHours() + ":" + twoplaces(dt.getMinutes()) + ":" + twoplaces(dt.getSeconds()));
- }
- function descending_sort(a, b) {
- return ($(b).html()) > ($(a).html()) ? 1 : -1;
- }
- function twoplaces(n) {
- return (n<10) ? "0"+n: n;
- }
- $("[name='searchBoardsForm']").submit(function() {
- if ($("[name='searchBoardsForm'] [name='keyword']").val()=="") {
- alert ("Hledáš prázdný text");
- return false;
- }
- });
- $(".hiddenart .user").on( "click", function() {
- $(this).parent().parent().removeClass("hiddenart");
- });
- $('select[name ="bodyType"]').val($defaultFormat);
- function NotInViewport(e) {
- var elementTop = e.offset().top;
- var elementBottom = elementTop + e.outerHeight();
- var viewportTop = $(window).scrollTop();
- var viewportBottom = viewportTop + $(window).height();
- return !(elementBottom > viewportTop && elementTop < viewportBottom);
- }
- $('div.menu').append(' <span><a id="loadarchiv" href="#">Archiv</a></span>');
- $(document).on("click", ".smazatzaznam", function (e) {
- if (confirm("Určitě odstranit z archivu?")) {
- var bookmarks = jQuery.parseJSON(localStorage.getItem("zalozky"));
- var idx = 0;
- var k = $(this).data("xid");
- $("#"+k).remove();
- $.each(bookmarks, function(key,value) {
- if (k == value.id) {
- bookmarks.splice(idx, 1);
- };
- idx = idx +1;
- });
- localStorage.setItem("zalozky", JSON.stringify(bookmarks));
- }
- });
- $(".oblibit").on( "click", function() {
- var prispevek = $(this).parent().parent();
- var user2 = prispevek.find(".ico-wrapper > a").attr('href');
- if (user2) {
- user2 = user2.replace('/msgbox.do?rcpt=', '');
- }
- var savearticle = {
- "id": $(this).data("xid"),
- "icosrc": prispevek.find(".ico-wrapper > a > img").attr('src'),
- "user": prispevek.find("span.user").text(),
- "user2": user2,
- "descr": prispevek.find("span.user > span.descr").text(),
- "permalink": prispevek.find("div.permalink > a").attr('href'),
- "content": prispevek.find("div.content").html(),
- "replyto": prispevek.find("div.actions a.prev").html(),
- "replytolink": prispevek.find("div.actions a.prev").attr('href')
- };
- const bookmarks0 = localStorage.getItem('zalozky');
- if (bookmarks0) {
- var bookmarks = JSON.parse(bookmarks0);
- bookmarks.push (savearticle);
- } else {
- bookmarks = [];
- bookmarks.push (savearticle);
- }
- localStorage.setItem("zalozky",JSON.stringify(bookmarks));
- alert ("Přidáno.");
- })
- $("#loadarchiv").on( "click", function() {
- var $el2 = $(".yui-g").first();
- if ($el2.length === 0) {
- $el2 = $(".yui-u.yui-ge.first.main").first();
- }
- $el2.html(``);
- var bookmarks = jQuery.parseJSON(localStorage.getItem("zalozky"));
- $.each(bookmarks, function(key,value) {
- if (!value.deleted) {
- var xout =`
- <div id="` + value.id + `" class="item">
- <div class="ico user" style="clear:left">
- <div class="ico-wrapper">
- <a href="/msgbox.do?rcpt=` + value.user2 + `"><img src="` + value.icosrc + ` " alt=""></a>
- </div>
- </div>
- <div class="meta">
- <span class="user">` + value.user + ` </span>
- <span class="descr"> </span>
- <div class="permalink">
- <a href="` + value.permalink + ` " class="date link">Přejít na příspěvek</a>
- </div>
- </div>
- <div class="content yui-base">` + value.content + ` </div>
- <div class="actions">
- <span class="smazatzaznam" data-xid="` + value.id + `">Smazat záznam</span>
- `;
- if (value.replyto) {
- xout += ' Reakce na <a class="prev" href="' + value.replytolink + '">' + value.replyto + '</a>';
- }
- xout += "</div></div>";
- $el2.prepend (xout);
- }
- });
- $el2.prepend (`
- <div class="yui-u first">
- <h2><a href="#">Archiv</a></h2>
- </div>
- `);
- $el2.css("background-color", "#F0F8FF");
- $el2.css("border-radius", "5px");
- $el2.css("padding", "10px");
- var $yuigc = $(document).find(".yui-gc");
- if ($yuigc) {
- $yuigc.removeClass("news");
- }
- });
- $(document).on("click", "#rozbal2", function (e) {
- $("#rozbal3").slideToggle( "300", function() {
- });
- });
- $(document).on("click", "#mods_expand", function (e) {
- $("#rozbal4").slideToggle( "300", function() {
- });
- });
- $(document).on("keyup", "#srchinput", function (e) {
- var inputValue = $(this).val().toLowerCase();
- $("#novydiv a.klub").each(function() {
- if ($(this).text().toLowerCase().indexOf(inputValue) > -1) {
- $(this).parent().removeClass("notfound");
- } else {
- $(this).parent().addClass("notfound");
- }
- });
- });
- // mechanismus mazacího tlačítka
- var btn = $('button:contains("Smazat")').first();
- btn.appendTo($('.pager').first());
- btn.css("float", "right");
- btn.html("Smazat vybrané");
- btn.attr('id', "smazatvybrane");
- if (!$showAutocheckedForDel) {btn.hide()};
- var btn = $('button.submit:contains("Hledat")').eq(1);
- var frm = $('div.search form').first();
- btn.appendTo(frm);
- $(document).on("click", "span.delete input", function (e) {
- var nekterynahozeny = false;
- var checkboxy = $(document).find("span.delete input");
- $.each(checkboxy, function() {
- if ($(this).is(':checked')) {
- nekterynahozeny = true;
- };
- });
- if (nekterynahozeny) {
- $("#smazatvybrane").show();
- } else {
- $("#smazatvybrane").hide();
- }
- });
- // Stažení Seznam_parazitu
- function getUD(){
- console.log ("stahuju UD");
- return $.ajax({
- type: "GET",
- url: '/boards/Seznam_parazitu',
- cache: false,
- async: false
- }).responseText;
- }
- // banovací tlačítko a mechanismus - ZAČÁTEK
- $( document ).ready(function() {
- var okounUsSetLink = $('div.settings a').filter(function(index) { return $(this).text() === "Nastavení klubu"; }).attr("href");
- if (okounUsSetLink == undefined) {
- console.log('klub bez moderátorských práv');
- }
- if (window.location.href.indexOf('https://www.okoun.cz/updateBoard.jsp?boardId=') == 0) {
- var urlParams = new URLSearchParams(window.location.search);
- if (urlParams.get('uuAction') == 'banishHim') {
- $('input[name="newPermUserLogin[0]"]').val(urlParams.get('uuName'));
- $('input[name="newPermRead[0]"]').prop('checked', false);
- $('input[name="newPermWrite[0]"]').prop('checked', false);
- $('input[name="newPermDeleteOwn[0]"]').prop('checked', false)
- $('html, body').animate({scrollTop: $(document).height()},500);
- $(document).ready(function(){
- $("#owners .submit").click();
- });
- }
- }
- });
- // banovací tlačítko a mechanismus - KONEC
- // Ban All button - ZAČÁTEK
- if (ultradebilove_counter >0) {
- $('.settings').append('<button class="submit" type="submit" id="banUD" style="float: left;">Ban UD </button>'+ ' ');
- }
- $('#banUD').click(function(){
- $.each($poleBanAdres, function(index, value){
- window.open(`${value}`);
- var urlParams = new URLSearchParams(window.location.search);
- // alert(value);
- // alert(urlParams);
- checkFlag();
- function checkFlag() {
- if (window.location.href.indexOf(value) > -1) {
- window.setTimeout(checkFlag, 1000); /* this checks the flag every 100 milliseconds*/
- } else {
- }
- }
- });
- });
- // Ban All button - KONEC
- $(document).on("change", 'select[name="bodyType"]', function (e) {
- localStorage.setItem("post_format", $(this).val());
- });
- if ($(document).find('form[name="boardUpdateForm"]').length > 0) { // jsem na obrazovce nastavení klubu
- $("#perms, #owners").hide();
- var nazevklubu = $(".yui-u.yui-g.first .settings a").first().text();
- $(".yui-u.yui-g.first").first().remove();
- $(".legend").hide();
- $("<h1>Nastavení klubu "+nazevklubu+"</h1>").insertBefore("form[name='boardUpdateForm']");
- $("<h1 class='h1nahled'>Náhled Uvítací zprávy</h1><div id='nahled'></div>").insertAfter("textarea[name='welcomeMsg']");
- $(`<div class="boardsettings"><a href="#gen2">Základní nastavení</a>
- | <a href="#perms2">Přístupová práva</a>
- | <a href="#owners2">Správci klubu</a></div>
- `).insertBefore("form[name='boardUpdateForm']");
- $("form[name='boardUpdateForm'] .legend").css("background", "red");
- $(".yui-gf .yui-u").css("float", "left");
- $(".yui-gf .yui-u").css("min-height", "30px");
- $("form[name='boardUpdateForm'] textarea").css("margin-left", "0");
- $("form[name='boardUpdateForm'] textarea").css("width", "99%");
- $('label[for="uf-postLimit"]').html("Max. délka příspěvku pro registrované uživatele<br>(počet znaků, 0 = bez omezeni)");
- $('label[for="uf-anonPostLimit"]').html("Max. délka příspěvku pro anonymní uživatele<br>(počet znaků, 0 = bez omezeni)");
- $( "i:contains('zadejte maximální počet znaků')" ).parent().remove();
- $("#gen").append($("#uf-welcome").parent());
- $("#uf-welcome").parent().addClass("yui-gf");
- if ($("#uf-format").val()=="html") {
- $("#nahled").html($("#uf-welcome").val());
- }
- var submits = $("button.submit");
- $(submits[4]).hide();
- $("h4:contains('Tito uživatelé mají nastavena specifická')").after("<table id='usersList'></table>");
- $("h4:contains('Tito uživatelé mají nastavena specifická')").before("<table id='hornitabulka'><tr></tr></table>");
- var xrow=$("#hornitabulka").find('tr:first');
- var prvni = $('#perms .yui-u.first .detail').parent();
- xrow.append("<td>"+prvni.html()+"</td>");
- prvni.remove();
- var druhy = $('#perms .yui-u:first .detail').parent();
- xrow.append("<td>"+druhy.html()+"</td>");
- druhy.remove();
- var treti = $('h4:contains("Přidělit specifická přístupová práva")').first().parent();
- xrow.append("<td>"+treti.html()+"</td>");
- var users = $("#perms .user.ico");
- $("#perms").css("background-color", "#F0F8FF");
- var row = "";
- var counter = 0;
- $.each(users, function() {
- row += '<td>' + $(this).parent().html() + '</td>';
- $(this).parent().remove();
- if (counter++ > 3) {
- $('#usersList').append('<tr>' + row + '</tr>');
- counter = 0;
- row = "";
- }
- });
- if (counter > 0) {
- $('#usersList').append('<tr>' + row + '</tr>');
- }
- }
- $(document).on("click", "a[href='#gen2'], a[href='#perms2'], a[href='#owners2']", function (e) {
- if ($(this).attr("href")=='#gen2') {
- $("#gen").show();
- $("#perms, #owners").hide();
- }
- if ($(this).attr("href")=='#perms2') {
- $("#perms").show();
- $("#gen, #owners").hide();
- }
- if ($(this).attr("href")=='#owners2') {
- $("#owners").show();
- $("#gen, #perms").hide();
- }
- e.stopPropagation();
- return false;
- });
- $(document).on("change keyup paste", "textarea[name='welcomeMsg']", function (e) {
- $("#nahled").html($(this).val());
- });
- $(document).on("change keyup paste", "#uf-format", function (e) {
- if ($("#uf-format").val()=="html") {
- $("#nahled").html($("#uf-welcome").val());
- $("h1.h1nahled").show();
- $("#nahled").show();
- } else {
- $("h1.h1nahled").hide();
- $("#nahled").hide();
- }
- });
- function embedVideos(e) {
- $(e).find("a").each(function () {
- // Exit quickly if this is the wrong type of URL
- if (this.protocol !== 'http:' && this.protocol !== 'https:') {
- return;
- }
- // Find the ID of the YouTube video
- var id, matches;
- if (this.hostname === 'youtube.com' || this.hostname === 'www.youtube.com') {
- // For URLs like https://www.youtube.com/watch?v=xLrLlu6KDss
- matches = this.search.match(/[?&]v=([^&]*)/);
- id = matches && matches[1];
- } else if (this.hostname === 'youtu.be') {
- // For URLs like https://youtu.be/xLrLlu6KDss
- id = this.pathname.substr(1);
- }
- // Check that the ID only has alphanumeric characters, to make sure that
- // we don't introduce any XSS vulnerabilities.
- var validatedID;
- if (id && id.match(/^[a-zA-Z0-9]*$/)) {
- validatedID = id;
- }
- // Add the embedded YouTube video, and remove the link.
- if (validatedID) {
- $(this)
- .before('<div><iframe width="500" height="350" src="https://www.youtube.com/embed/' + validatedID + '" frameborder="0" allowfullscreen></iframe></div>')
- .remove();
- }
- });
- }
- // Měnič HTML/text v příspěvku
- function text_change() {
- var value = $(this).val();
- var switcher = $(this).parent().parent().parent().find('select[name=bodyType]');
- if (value.indexOf('<') >= 0) {
- switcher.val('html');
- } else {
- switcher.val('plain');
- }
- }
- try {
- $("textarea").keyup(text_change);
- var config = { childList: true, subtree: true };
- (new MutationObserver(function (records, observer) {
- records.forEach(function (record) {
- for (var node of record.addedNodes) {
- if (node.className == 'post content') {
- $(node).find("textarea").keyup(text_change);
- }
- }
- });
- })).observe(document, config);
- }
- catch(exception) {
- alert(exception.message);
- }
- // Tlačítka v panelu
- function addButtons(parent, textarea)
- {
- parent.insertBefore(create_button('B', bold), textarea);
- parent.insertBefore(create_button('I', italic), textarea);
- parent.insertBefore(create_button('U', underline), textarea);
- parent.insertBefore(create_button('S', strike), textarea);
- parent.insertBefore(create_button('BR', br), textarea);
- parent.insertBefore(document.createTextNode('\xA0\xA0\xA0'), textarea);
- parent.insertBefore(create_button('URL', link), textarea);
- parent.insertBefore(create_button('IMG', img), textarea);
- parent.insertBefore(create_button('FONT', font), textarea);
- parent.insertBefore(create_button('SPOIL', spoil), textarea);
- parent.insertBefore(document.createTextNode('\xA0\xA0\xA0'), textarea);
- parent.insertBefore(create_button('CODE', code), textarea);
- parent.insertBefore(document.createElement('br'), textarea);
- }
- function link(event)
- {
- try {
- var textarea = event.target.parentNode.querySelector('textarea');
- var url = prompt('Zadejte adresu odkazu: ', '');
- if (url) {
- if (textarea.selectionStart < textarea.selectionEnd) {
- var pretext = textarea.value.substring(0, textarea.selectionStart);
- var posttext = textarea.value.substring(textarea.selectionEnd, textarea.value.length);
- var selection = textarea.value.substring(textarea.selectionStart, textarea.selectionEnd);
- textarea.value = pretext + '<a href="' + url + '">' + selection + '</a>' + posttext;
- } else {
- var str = prompt('Zadejte text odkazu: ', '');
- textarea.value = textarea.value + '<a href="' + url + '">' + str + '</a>';
- }
- }
- textarea.focus();
- event.preventDefault();
- } catch (exception) {
- alert(exception.message);
- }
- }
- function img(event) {
- try {
- var textarea = event.target.parentNode.querySelector('textarea');
- if (textarea.selectionStart < textarea.selectionEnd) {
- var pretext = textarea.value.substring(0, textarea.selectionStart);
- var posttext = textarea.value.substring(textarea.selectionEnd, textarea.value.length);
- var selection = textarea.value.substring(textarea.selectionStart, textarea.selectionEnd);
- textarea.value = pretext + '<img src="' + selection + '" />' + posttext;
- } else {
- var str = prompt('Zadejte cestu k obrazku: ', '');
- if (str) textarea.value = textarea.value + '<img src="' + str + '" />';
- }
- textarea.focus();
- event.preventDefault();
- } catch (exception) {
- alert(exception.message);
- }
- }
- function font(event) {
- try {
- var textarea = event.target.parentNode.querySelector('textarea');
- var color = prompt('Zadejte barvu textu: ', '');
- var size = prompt('Zadejte velikost fontu: ', '');
- if (color || size) {
- var string_to_write;
- if (textarea.selectionStart < textarea.selectionEnd) {
- var pretext = textarea.value.substring(0, textarea.selectionStart);
- var posttext = textarea.value.substring(textarea.selectionEnd, textarea.value.length);
- var selection = textarea.value.substring(textarea.selectionStart, textarea.selectionEnd);
- string_to_write = '<font';
- if (color) { string_to_write = string_to_write +' color="' + color + '"'; }
- if (size) { string_to_write = string_to_write +' size="' + size +'"'; }
- string_to_write = string_to_write +'>' + selection + '</font>';
- textarea.value = pretext + string_to_write + posttext;
- } else {
- var str = prompt('Zadejte text: ', '');
- string_to_write = '<font';
- if (color) { string_to_write = string_to_write +' color="' + color + '"'; }
- if (size) { string_to_write = string_to_write +' size="' + size +'"'; }
- string_to_write = string_to_write +'>' + str + '</font>';
- textarea.value = textarea.value + string_to_write;
- }
- }
- textarea.focus();
- event.preventDefault();
- } catch (exception) {
- alert(exception.message);
- }
- }
- function surroundText(event, opening, closing) {
- try {
- var textarea = event.target.parentNode.querySelector('textarea');
- var pretext = textarea.value.substring(0, textarea.selectionStart);
- var posttext = textarea.value.substring(textarea.selectionEnd, textarea.value.length);
- var selection = textarea.value.substring(textarea.selectionStart, textarea.selectionEnd);
- textarea.value = pretext + opening + selection + closing + posttext;
- textarea.focus();
- event.preventDefault();
- } catch (exception) {
- alert(exception.message);
- }
- }
- function spoil(event) {
- surroundText(event, '<table><tr><td bgcolor="#fff"><font color="#fff">', '</font></td></tr></table>');
- }
- function bold(event) {
- surroundText(event, '<b>', '</b>');
- }
- function italic(event) {
- surroundText(event, '<i>', '</i>');
- }
- function underline(event) {
- surroundText(event, '<u>', '</u>');
- }
- function strike(event) {
- surroundText(event, '<s>', '</s>');
- }
- function br(event) {
- try {
- var textarea = event.target.parentNode.querySelector('textarea');
- const selectionStart = textarea.selectionStart;
- const selectionEnd = textarea.selectionEnd;
- const value = textarea.value;
- const pretext = value.substring(0, selectionStart);
- const posttext = value.substring(selectionEnd, value.length);
- const selection = value.substring(selectionStart, selectionEnd);
- textarea.value = pretext + selection + '<br>' + posttext;
- textarea.focus();
- textarea.selectionStart = selectionEnd + 4;
- textarea.selectionEnd = selectionEnd + 4;
- event.preventDefault();
- } catch (exception) {
- alert(exception.message);
- }
- }
- function code(event) {
- surroundText(event, '<div class="code">', '</div>');
- }
- function mouseover(event)
- {
- this.style.border = "1px solid #808080";
- this.style.backgroundColor = "#E0E0E0";
- event.preventDefault();
- }
- function mouseout(event)
- {
- this.style.border = "1px solid #A7A6AA";
- this.style.backgroundColor = "white";
- event.preventDefault();
- }
- function create_button(text, listener)
- {
- var button = document.createElement('button');
- var txt = document.createTextNode(text);
- button.style.font = "10pt Arial";
- button.style.border = "1px solid #A7A6AA";
- button.style.backgroundColor = "white";
- button.style.cursor = "pointer";
- button.style.marginBottom = "2px";
- button.style.marginRight = "2px";
- switch (text) {
- case 'B': button.style.fontWeight = "bold";
- break;
- case 'I': button.style.fontStyle = "italic";
- break;
- case 'U': button.style.textDecoration = "underline";
- break;
- case 'S': button.style.textDecoration = "line-through";
- break;
- }
- button.insertBefore(txt, null);
- button.addEventListener("mouseover", mouseover, false);
- button.addEventListener("mouseout", mouseout, false);
- button.addEventListener("click", listener, false);
- return button;
- }
- try {
- var textarea = document.querySelector("textarea");
- if (textarea) {
- var parent = textarea.parentNode;
- addButtons(parent, textarea);
- }
- (new MutationObserver(function (records, observer) {
- records.forEach(function (record) {
- for (var node of record.addedNodes) {
- if (node.className == 'post content') {
- node.querySelectorAll('textarea').forEach(function (textarea) {
- var parent = textarea.parentNode;
- addButtons(parent, textarea);
- });
- }
- }
- });
- })).observe(document, { childList: true, subtree: true });
- } catch (exception) {
- alert(exception.message);
- }
Add Comment
Please, Sign In to add comment