The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

color post

4 posters

Go down

In progress color post

Post by poesia-verses February 3rd 2022, 12:36 pm

I have a post background coloring script on the forum. and the icon stands for this function in the response form. Recently, this icon disappeared in the quick answer, but remained in the full answer. the function works. how to get the icon back?

color post - color post 11111110
color post - color post 22222210

Code:
$(function() {
  $("div.postbody").each(function() {
    var n = this;
    if($(".post-entry", n).length) {
      n = $(".post-entry", n)[0]
    }else {
      if($(".content", n).length) {
        n = $(".content", n)[0]
      }
    }
    while(n.nodeType != 3 && n.hasChildNodes()) {
      n = n.childNodes[0]
    }
    if(n.nodeType != 3) {
      return;
    }
    if(n.nodeValue.substr(0,8)  != "[postbg=") {
      return;
    }
    var m = n.nodeValue.match(/^\[postbg=([^\]]*)\]/);
    if(!m) return;
    $(this).closest("div.post-container,div.post").addClass("postbg").css("background-image", "url(" + m[1] + ")");
    n.nodeValue = n.nodeValue.replace(/^\[postbg=[^\[]*\]\n?/, "");
    if(!n.nodeValue && n.nextSibling && n.nextSibling.nodeType == 1 && n.nextSibling.tagName == "BR") {
      $(n.nextSibling).remove()
    }
  });
  if($("#text_editor_textarea").length && $.sceditor) {
    var bglist = "https://i.servimg.com/u/f10/20/33/56/10/a110.jpg,https://i.imgur.com/20aRJFn.png,https://i.imgur.com/tkC3deY.jpg,https://i.imgur.com/pfTcnqF.png,https://i.imgur.com/dAQtdaR.gif,https://i.imgur.com/48CU2Qx.png,https://i.imgur.com/lRuwoVi.png,https://i.imgur.com/EHp45H1.png,https://i.imgur.com/8bhbqFF.png,https://i.imgur.com/tb80sYG.png,https://i.imgur.com/6LPhzcp.png,https://i.imgur.com/DkRuYf1.png,https://i.imgur.com/57F0z86.jpg,https://i.imgur.com/PZyMuXF.png".split(",");
    var bgnum = -1;
    var val = $("#text_editor_textarea").val();
    if(val.substr(0,8)  == "[postbg=") {
      var m = val.match(/^\[postbg=([^\]]*)\]/);
      if(m) {
        var r = $.inArray(m[1], bglist);
        if(r != -1) {
          bgnum = r
        }else {
          bgnum = bglist.length - 1
        }
        $(function() {
          $(".sceditor-container").css("background-position", "0 " + ($(".sceditor-toolbar").height() + 6) + "px");
          $(".sceditor-container").css("background-image", "url(" + m[1] + ")")
        });
        $("#text_editor_textarea").val(val.replace(/^\[postbg=[^\[]*\]/, ""))
      }
    }
    $(function() {
      if(!$("#text_editor_textarea").sceditor("instance")) {
        return
      }
      $('<a class="sceditor-button" unselectable="on" title="Боковой фон сообщения"><div unselectable="on" style="background:url(https://i.imgur.com/Hrf5w1i.gif);opacity:1">Background of message</div></a>').insertAfter(".sceditor-button-strike").click(function(e) {
        if(e.ctrlKey) {
          $(".sceditor-container").css("background-image", "");
          bgnum = -1
        }else {
          bgnum++;
          if(!bgnum) {
            $(".sceditor-container").css("background-position", "0 " + ($(".sceditor-toolbar").height() + 6) + "px")
          }
          $(".sceditor-container").css("background-image", "url(" + bglist[bgnum % bglist.length] + ")")
        }
      })
    });
    $(function() {
      $('form[name="post"]').submit(function() {
        if(bgnum != -1) {
          $("#text_editor_textarea").val(function(i, val) {
            return"[postbg=" + bglist[bgnum % bglist.length] + "]" + val
          })
        }
      })
    })
  }
});
poesia-verses
poesia-verses
Forumember

Male Posts : 527
Reputation : 21
Language : and small english

https://stihi-podval.forumotion.com/

Back to top Go down

In progress Re: color post

Post by skouliki February 3rd 2022, 12:47 pm

hello

i tested the code in my test forum and its working in the quick reply , did you add anything to your forum recently ?

color post - color post Scre2599
skouliki
skouliki
Manager
Manager

Female Posts : 15161
Reputation : 1696
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Back to top Go down

In progress Re: color post

Post by poesia-verses February 3rd 2022, 1:15 pm

skouliki wrote:hello
did you add anything to your forum recently ?

color post - color post Scre2599
no
thanx
poesia-verses
poesia-verses
Forumember

Male Posts : 527
Reputation : 21
Language : and small english

https://stihi-podval.forumotion.com/

Back to top Go down

In progress Re: color post

Post by skouliki February 3rd 2022, 1:22 pm

can you open the quick reply so guests can view it please
skouliki
skouliki
Manager
Manager

Female Posts : 15161
Reputation : 1696
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Back to top Go down

In progress Re: color post

Post by poesia-verses February 3rd 2022, 1:31 pm

conflict with the function of awards, turn off awards - appears
poesia-verses
poesia-verses
Forumember

Male Posts : 527
Reputation : 21
Language : and small english

https://stihi-podval.forumotion.com/

Back to top Go down

In progress Re: color post

Post by skouliki February 3rd 2022, 2:38 pm

Ok thanks for posting the conflict
I guess the code must be re written
skouliki
skouliki
Manager
Manager

Female Posts : 15161
Reputation : 1696
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Back to top Go down

In progress Re: color post

Post by poesia-verses February 4th 2022, 3:37 pm

skouliki wrote:can you open the quick reply so guests can view it please

how to do it please tell me
poesia-verses
poesia-verses
Forumember

Male Posts : 527
Reputation : 21
Language : and small english

https://stihi-podval.forumotion.com/

Back to top Go down

In progress Re: color post

Post by skouliki February 4th 2022, 4:52 pm

if it is a conflict with the awards then the code must be rewritten 
no need to inspect anything
contact the person who wrote that code
skouliki
skouliki
Manager
Manager

Female Posts : 15161
Reputation : 1696
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Back to top Go down

In progress Re: color post

Post by poesia-verses February 4th 2022, 5:40 pm

quick reply so guests
??
poesia-verses
poesia-verses
Forumember

Male Posts : 527
Reputation : 21
Language : and small english

https://stihi-podval.forumotion.com/

Back to top Go down

In progress Re: color post

Post by كونان2000 February 6th 2022, 4:20 pm

hi Razz
Put the code into a template viewtopic_body

Code:
<script type="text/javascript">
          $(function() {
  $("div.postbody").each(function() {
    var n = this;
    if($(".post-entry", n).length) {
      n = $(".post-entry", n)[0]
    }else {
      if($(".content", n).length) {
        n = $(".content", n)[0]
      }
    }
    while(n.nodeType != 3 && n.hasChildNodes()) {
      n = n.childNodes[0]
    }
    if(n.nodeType != 3) {
      return;
    }
    if(n.nodeValue.substr(0,8)  != "[postbg=") {
      return;
    }
    var m = n.nodeValue.match(/^\[postbg=([^\]]*)\]/);
    if(!m) return;
    $(this).closest("div.post-container,div.post").addClass("postbg").css("background-image", "url(" + m[1] + ")");
    n.nodeValue = n.nodeValue.replace(/^\[postbg=[^\[]*\]\n?/, "");
    if(!n.nodeValue && n.nextSibling && n.nextSibling.nodeType == 1 && n.nextSibling.tagName == "BR") {
      $(n.nextSibling).remove()
    }
  });
  if($("#text_editor_textarea").length && $.sceditor) {
    var bglist = "https://i.servimg.com/u/f10/20/33/56/10/a110.jpg,https://i.imgur.com/20aRJFn.png,https://i.imgur.com/tkC3deY.jpg,https://i.imgur.com/pfTcnqF.png,https://i.imgur.com/dAQtdaR.gif,https://i.imgur.com/48CU2Qx.png,https://i.imgur.com/lRuwoVi.png,https://i.imgur.com/EHp45H1.png,https://i.imgur.com/8bhbqFF.png,https://i.imgur.com/tb80sYG.png,https://i.imgur.com/6LPhzcp.png,https://i.imgur.com/DkRuYf1.png,https://i.imgur.com/57F0z86.jpg,https://i.imgur.com/PZyMuXF.png".split(",");
    var bgnum = -1;
    var val = $("#text_editor_textarea").val();
    if(val.substr(0,8)  == "[postbg=") {
      var m = val.match(/^\[postbg=([^\]]*)\]/);
      if(m) {
        var r = $.inArray(m[1], bglist);
        if(r != -1) {
          bgnum = r
        }else {
          bgnum = bglist.length - 1
        }
        $(function() {
          $(".sceditor-container").css("background-position", "0 " + ($(".sceditor-toolbar").height() + 6) + "px");
          $(".sceditor-container").css("background-image", "url(" + m[1] + ")")
        });
        $("#text_editor_textarea").val(val.replace(/^\[postbg=[^\[]*\]/, ""))
      }
    }
    $(function() {
      if(!$("#text_editor_textarea").sceditor("instance")) {
        return
      }
      $('<a class="sceditor-button" unselectable="on" title="Боковой фон сообщения"><div unselectable="on" style="background:url(https://i.imgur.com/Hrf5w1i.gif);opacity:1">Background of message</div></a>').insertAfter(".sceditor-button-strike").click(function(e) {
        if(e.ctrlKey) {
          $(".sceditor-container").css("background-image", "");
          bgnum = -1
        }else {
          bgnum++;
          if(!bgnum) {
            $(".sceditor-container").css("background-position", "0 " + ($(".sceditor-toolbar").height() + 6) + "px")
          }
          $(".sceditor-container").css("background-image", "url(" + bglist[bgnum % bglist.length] + ")")
        }
      })
    });
    $(function() {
      $('form[name="post"]').submit(function() {
        if(bgnum != -1) {
          $("#text_editor_textarea").val(function(i, val) {
            return"[postbg=" + bglist[bgnum % bglist.length] + "]" + val
          })
        }
      })
    })
  }
});
   </script>
   
كونان2000
كونان2000
Forumember

Male Posts : 205
Reputation : 93
Language : Arabic

https://anime.forumperso.com/

Back to top Go down

In progress Re: color post

Post by poesia-verses February 6th 2022, 6:35 pm

no work
poesia-verses
poesia-verses
Forumember

Male Posts : 527
Reputation : 21
Language : and small english

https://stihi-podval.forumotion.com/

Back to top Go down

In progress Re: color post

Post by SLGray February 6th 2022, 9:56 pm

Did you save the change and publish the modified template?


color post - color post Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51503
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

In progress Re: color post

Post by poesia-verses February 7th 2022, 3:49 pm

SLGray wrote:Did you save the change and publish the modified template?
yes
poesia-verses
poesia-verses
Forumember

Male Posts : 527
Reputation : 21
Language : and small english

https://stihi-podval.forumotion.com/

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum