Javascript  Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

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.
4 posters

    Javascript

    alexz152
    alexz152
    New Member


    Posts : 8
    Reputation : 1
    Language : polish

    Solved Javascript

    Post by alexz152 December 28th 2019, 7:05 pm

    Hi, I've got a problem with JAVASCRIPT, which used to work, but now it doesn't.
    Mainly it was scripts of navigation bar and chatbox. I've tried to restart them on the forum but that doesn't help. Settings to delete and upload again also doesn't work. What's the problem? I'd be glad for any help.


    Last edited by alexz152 on January 1st 2020, 2:35 pm; edited 1 time in total
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    Solved Re: Javascript

    Post by TheCrow December 28th 2019, 7:11 pm

    alexz152 wrote:Hi, I've got a problem with JAVASCRIPT, which used to work, but now it doesn't.
    Mainly it was scripts of navigation bar and chatbox. I've tried to restart them on the forum but that doesn't help. Settings to delete and upload again also doesn't work. What's the problem? I'd be glad for any help.
    Hello and welcome to the official English Support Forum of Forumotion,

    Please answer the following questions so your problem is more clear.
    - When did this problem occur?
    - Did you add/change/remove any other code when this happened?
    - What is your forum link?

    Regards,
    TC.



    Javascript  Thecro10
    Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    alexz152
    alexz152
    New Member


    Posts : 8
    Reputation : 1
    Language : polish

    Solved Re: Javascript

    Post by alexz152 December 28th 2019, 7:35 pm

    Today.
    Yes, problem appeared after upload the code:
    Code:
    window.localStorage && $(window).load(function() {
     var chatbox_script = function() {
     var sounds = {
     'future': 'https://illiweb.com/fa/fdf/future.mp3',
     'hal': 'https://illiweb.com/fa/fdf/hal.mp3',
     'secret': 'https://illiweb.com/fa/fdf/secret.mp3',
     'zelda': 'https://illiweb.com/fa/fdf/zelda.mono.mp3'
     };
     var default_sound = sounds['zelda'];
     var default_freq = 'new';
     var default_when = 'once';
     var default_volume = 100;
     
     
     if(localStorage.cb_sound && !localStorage.cb_sound.indexOf('https://dl.dropboxusercontent.com/u/181621985/')) localStorage.removeItem('cb_sound');
     var a = document.createElement('audio');
     if(!a.canPlayType) return;
     a.volume = Math.min(1, Math.max(0, localStorage.cb_volume||(default_volume/100)));
     
     var origin_send = Chatbox.prototype.send;
     Chatbox.prototype.send = function(params) {
     var m = $.trim($("#message").val());
     if(m.indexOf('/sound')&&m.indexOf('/soudn'))
     return origin_send.call(this, params);
     m = $.trim(m.substr(6)).split(/\s+/,3);
     var bad_apple = false;
     switch(m[0].toLowerCase()) {
     case "":
     if(!a.src) {
     a.src = localStorage.cb_sound||default_sound;
     a.load();
     }
     a.play();
     break;
     case "all":
     case "new":
     localStorage.cb_freq = m[0]; break;
     case "always":
     case "off":
     case "on":
     case "once":
     case "never":
     localStorage.cb_when = m[0]; break;
     case "stop":
     if(!a.paused) a.pause();
     if(!a.ended && a.readyState > 0) a.currentTime = 0;
     break;
     case "pause":
     if(!a.paused) a.pause();
     break;
     case "volume":
     if(m.length>1) {
     localStorage.cb_volume = Math.min(1, Math.max(0, parseFloat(m[1].replace(',','.'))/100));
     a.volume = localStorage.cb_volume;
     break
     }
     default:
     bad_apple = true;
     };
     if(bad_apple) {
     if(m[0] in sounds) {
     m[0]= sounds[m[0]];
     }
     if(m[0]=="default") {
     m[0]=default_sound;
     localStorage.removeItem('cb_sound');
     localStorage.removeItem('cb_freq');
     localStorage.removeItem('cb_volume');
     localStorage.removeItem('cb_when');
     a.volume = Math.min(1, Math.max(0, default_volume/100));
     }
     if(/^https?:\/\/.+/.test(m[0])) {
     localStorage.cb_sound = m[0];
     a.pause();
     a.src = m[0];
     a.load();
     a.play();
     } else {
     var message = $('#message').val();
     alert('/sound [all | new]\n/sound [always | off | on | once | never]\n/sound [stop | pause]\n/sound default\n/sound volume 0-100\n/sound ['+$.map(sounds,function(_,k){return k}).join(' | ')+']\n/sound [http://* | https://*]');
     setTimeout(function(){ $("#message").val(message).select().focus(); }, 100);
     return;
     }
     }
     return $("#message").val('').focus();
     };
     
     $(window).on("focus", function(){ localStorage.removeItem('cb_once'); localStorage.removeItem('cb_blurred') }).on("blur", function(){ localStorage.cb_blurred=1; });
     
     var play_sound = function(){
     if(a.paused || a.ended) {
     if(a.readyState > 0) a.currentTime=0;
     if(!a.src) {
     a.src = localStorage.cb_sound||default_sound;
     a.load()
     }
     a.play()
     }
     };
     var overrided = Chatbox.prototype.refresh;
     Chatbox.prototype.refresh = function(data) {
     if (data.messages && data.messages.length) {
     var lm = data.messages.slice(-1)[0];
     var last_message = lm.time+','+lm.action+','+lm.msg;
     if(this.last_message_sound != last_message) {
     var user = $.grep(data.users, function(v){return v.id==chatbox.userId});
     user = user.length ? user[0] : [{}];
     if(this.last_message_sound!==undefined) {
     var freq = (localStorage.cb_freq||default_freq);
     var when = (localStorage.cb_when||default_when);
     if(when != "never" && (when != "off" || localStorage.cb_blurred) && (when != "on" || !localStorage.cb_blurred) && (when != "once" || (localStorage.cb_blurred && !localStorage.cb_once))) {
     if(freq =="all" || (lm.userId!=chatbox.userId && user.username!=lm.username)) {
     if(when!="once" || !localStorage.cb_once) {
     play_sound();
     localStorage.cb_once = 1;
     }
     }
     }
     }
     this.last_message_sound = lm;
     }
     }
     overrided.call(this, data);
     };
     };
     var s=document.createElement('script');s.text="("+chatbox_script.toString()+")();";$('object[data^="/chatbox"],iframe[src^="/chatbox"]').each(function(){try{$(this.contentDocument||this.contentWindow.document).find("#chatbox").closest("html").find("head").first().each(function(){this.appendChild(s.cloneNode(true))})}catch(a){}})
     });
    Codes has beeen taken from here: https://help.forumotion.com/t139284-codes-to-personalize-your-chatbox#cb-logmsg
    And code worked except that attached above. That code have been also removed. After that, and after uploading the rest of them it still doesn't worked, although it've been work before.

    website: http://bloody-ritual.forumpolish.com/
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    Solved Re: Javascript

    Post by TheCrow December 28th 2019, 7:49 pm

    Hello,

    Have you tried clearing you browser's cookies and cashe?

    Regards,
    TC.



    Javascript  Thecro10
    Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    alexz152
    alexz152
    New Member


    Posts : 8
    Reputation : 1
    Language : polish

    Solved Re: Javascript

    Post by alexz152 December 28th 2019, 8:03 pm

    Yes, even several times.
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51554
    Reputation : 3523
    Language : English
    Location : United States

    Solved Re: Javascript

    Post by SLGray December 28th 2019, 8:15 pm

    What option did you check for placement?



    Javascript  Slgray10

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


    Solved Re: Javascript

    Post by Guest December 28th 2019, 8:23 pm

    Hello,

    One of the scripts on your forum has multiple occurences of
    Code:
    &
    in it.
    That's the unicode for &. Post the code here and I can fix it.
    alexz152
    alexz152
    New Member


    Posts : 8
    Reputation : 1
    Language : polish

    Solved Re: Javascript

    Post by alexz152 January 1st 2020, 2:16 pm

    Searching after & I found it

    Code:
    window.localStorage&&$(function(){
    $(function(){
    if($("#text_editor_textarea").length&&typeof $.sceditor!="undefined"){
    var a=$(document.post.mode).val(),
    d=$("#text_editor_textarea").sceditor("instance"),
    e,f,g=function(){
    localStorage.setItem(a,d.val());
    f=0},
    b=JSON.parse(localStorage.getItem("br-data"))||[],c;
    switch(a){
    case"editpost":return;
    case"reply":a+=$(document.post.t).val();
    break;
    case"newtopic":a+=$(document.post.f).val()
    }
    a=parseInt((my_getcookie("fa_"+location.hostname.replace(/\./g,"_")+"_data")||"0").replace(/.*s:6:"userid";(i:([0-9]+)|s:[0-9]+:"([0-9]+)");.*/,"$2$3"))+a;
    -1!=(c=$.inArray(a,b))&&b.splice(c,1);
    if(20<b.length){ for(c="b.length-1;0<=c;c--)/^\s*$/.test(localStorage.getItem(b[c])||&quot;&quot;)&amp;&amp;(localStorage.removeItem(b[c])," b.splice(c,1));="" 20<b.length&amp;&amp;(localstorage.removeitem(b[0]),="" b.splice(0,1))}b.push(a);="" localstorage.setitem("br-data",json.stringify(b));="" $(document.post).submit(function(){="" localstorage.setitem("br-target",a)="" });="" !d.val()&amp;&amp;((e="localStorage.getItem(a))&amp;&amp;d.val(e));" d.keyup(function(){="" f||(f="setTimeout(g,3E3))" })}})});="" window.localstorage&amp;&amp;(localstorage.getitem("br-target")&amp;&amp;function(){="" $("meta[http-equiv="refresh" ][content]:first").length&amp;&amp;function(){="" var="" a="JSON.parse(localStorage.getItem(&quot;br-data&quot;))," b="localStorage.getItem(&quot;br-target&quot;),c;" if(-1!="(c=$.inArray(b,a)))a.splice(c,1)," localstorage.setitem("br-data",json.stringify(a));="" localstorage.removeitem(b)}();="" localstorage.removeitem("br-target")}());<="" code=""></b.length){>


    Code:
    $(function() {
      var toolbar_alias = {
     
        Share : 'Szukaj',
        Login : 'Zaloguj',
        Register : 'Rejestracja',
        Welcome : 'Witaj w Salem',
        Notifications : 'Powiadomienia',
     
        See_my_profile : 'Zobacz profil',
        Edit_profile : 'Edytuj profil',
        All_Topics : 'Moje tematy',
        All_Messages : 'Moje posty',
        js_topics_followed : 'Obserwowane',
        Admin_panel : 'Panel Admina',
        Logout : 'Wyloguj się',
     
        Notif_see_all : 'Zobacz wszystkie powiadomienia',
        Notif_priv_msg : 'Masz nową wiadomość <a href="/privmsg?folder=inbox&amp;nid=%(nid)s">private message</a> od <a href="/u%(id)d">%(name)s</a>',
        Notif_report : '<a href="/u%(id)d">%(name)s</a> utworzył <a href="/report?nid=%(nid)s">raport wiadomości</a>',
        Notif_friend_req : 'Otrzymałeś/aś <a href="/profile?mode=editprofile&amp;nid=%(nid)s&amp;page_profil=friendsfoes">zaproszenie do znajomych</a> from <a href="/u%(id)d">%(name)s</a>',
        Notif_group_req : '<a href="/u%(id)d">%(name)s</a> zostałeś/aś przyjęta do grupy <a href="/g%(group_id)d-%(group_url_name)s?nid=%(nid)s">%(group_name)s</a>',
        Notif_friend_con : '<a href="/u%(id)d">%(name)s</a> połączył się',
        Notif_wall_msg : '<a href="/u%(id)d">%(name)s</a> właśnie napisał wiadomość na temat <a href="/u%(self)dwall?nid=%(nid)s">w twoim temacie</a>',
        Notif_abuse : '<a href="/admin/index.forum?mode=active&amp;nid=%(nid)s&amp;part=misc&amp;sub=support">Nadużycie</a> zgłoszone',
        Notif_topic_watch : '<a href="/u%(id)d">%(name)s</a> napisał/a wiadomość <a href="/t%(topic_id)d-%(topic_name)s?nid=%(nid)s#%(post_id)d">w obserwowanym temacie</a>',
        Notif_topic_watch_p : '<a href="/u%(id)d">%(name)s</a> napisał/a wiadomość <a href="/t%(topic_id)dp%(start)d-%(topic_name)s?nid=%(nid)s#%(post_id)d">w obserwowanym temacie</a>',
        Notif_topic_watch_guest : 'Gość napisał wiadomość w <a href="/t%(topic_id)d-%(topic_name)s?nid=%(nid)s#%(post_id)d">w obserwowanym temacie</a>',
        Notif_topic_watch_p_guest : Gość napisał wiadomość w <a href="/t%(topic_id)dp%(start)d-%(topic_name)s?nid=%(nid)s#%(post_id)d">w obserwowanym temacie</a>',
        Notif_mention : '<a href="/u%(id)d">%(name)s</a>zostałeś/aś oznaczona <a href="/t%(topic_id)dp%(start)d-%(topic_name)s?nid=%(nid)s#%(post_id)d">w temacie</a>',
        Notif_hashtag : 'The keyword <a href="/tags/%(tag)s">#%(tag)s</a> zostałeś/aś oznaczona <a href="/t%(topic_id)dp%(start)d-%(topic_name)s?nid=%(nid)s#%(post_id)d">w temacie</a>.',
     
        All_PMs : 'Wiadomości prywatne',
        No_assigned_rank : 'No special rank assigned',
        Posts : 'Posty',
        PMs : 'PMs',
        Reputation : 'Reputation'
     
      },i;
     
      if (window._lang) for (i in toolbar_alias) window._lang[i] = toolbar_alias[i];
    });

    I hope that's it.
    avatar
    Guest
    Guest


    Solved Re: Javascript

    Post by Guest January 1st 2020, 2:25 pm

    The first code seems heavily messed. Do you know what it was supposed to do? For now, you should deactivate it.

    The second one was missing a
    Code:
    '
    . Replace it with:
    Code:
    $(function() {
        var toolbar_alias = {

                Share: 'Szukaj',
                Login: 'Zaloguj',
                Register: 'Rejestracja',
                Welcome: 'Witaj w Salem',
                Notifications: 'Powiadomienia',

                See_my_profile: 'Zobacz profil',
                Edit_profile: 'Edytuj profil',
                All_Topics: 'Moje tematy',
                All_Messages: 'Moje posty',
                js_topics_followed: 'Obserwowane',
                Admin_panel: 'Panel Admina',
                Logout: 'Wyloguj się',

                Notif_see_all: 'Zobacz wszystkie powiadomienia',
                Notif_priv_msg: 'Masz nową wiadomość <a href="/privmsg?folder=inbox&amp;nid=%(nid)s">private message</a> od <a href="/u%(id)d">%(name)s</a>',
                Notif_report: '<a href="/u%(id)d">%(name)s</a> utworzył <a href="/report?nid=%(nid)s">raport wiadomości</a>',
                Notif_friend_req: 'Otrzymałeś/aś <a href="/profile?mode=editprofile&amp;nid=%(nid)s&amp;page_profil=friendsfoes">zaproszenie do znajomych</a> from <a href="/u%(id)d">%(name)s</a>',
                Notif_group_req: '<a href="/u%(id)d">%(name)s</a> zostałeś/aś przyjęta do grupy <a href="/g%(group_id)d-%(group_url_name)s?nid=%(nid)s">%(group_name)s</a>',
                Notif_friend_con: '<a href="/u%(id)d">%(name)s</a> połączył się',
                Notif_wall_msg: '<a href="/u%(id)d">%(name)s</a> właśnie napisał wiadomość na temat <a href="/u%(self)dwall?nid=%(nid)s">w twoim temacie</a>',
                Notif_abuse: '<a href="/admin/index.forum?mode=active&amp;nid=%(nid)s&amp;part=misc&amp;sub=support">Nadużycie</a> zgłoszone',
                Notif_topic_watch: '<a href="/u%(id)d">%(name)s</a> napisał/a wiadomość <a href="/t%(topic_id)d-%(topic_name)s?nid=%(nid)s#%(post_id)d">w obserwowanym temacie</a>',
                Notif_topic_watch_p: '<a href="/u%(id)d">%(name)s</a> napisał/a wiadomość <a href="/t%(topic_id)dp%(start)d-%(topic_name)s?nid=%(nid)s#%(post_id)d">w obserwowanym temacie</a>',
                Notif_topic_watch_guest: 'Gość napisał wiadomość w <a href="/t%(topic_id)d-%(topic_name)s?nid=%(nid)s#%(post_id)d">w obserwowanym temacie</a>',
                Notif_topic_watch_p_guest: 'Gość napisał wiadomość w <a href="/t%(topic_id)dp%(start)d-%(topic_name)s?nid=%(nid)s#%(post_id)d">w obserwowanym temacie</a>',
                Notif_mention: '<a href="/u%(id)d">%(name)s</a>zostałeś/aś oznaczona <a href="/t%(topic_id)dp%(start)d-%(topic_name)s?nid=%(nid)s#%(post_id)d">w temacie</a>',
                Notif_hashtag: 'The keyword <a href="/tags/%(tag)s">#%(tag)s</a> zostałeś/aś oznaczona <a href="/t%(topic_id)dp%(start)d-%(topic_name)s?nid=%(nid)s#%(post_id)d">w temacie</a>.',

                All_PMs: 'Wiadomości prywatne',
                No_assigned_rank: 'No special rank assigned',
                Posts: 'Posty',
                PMs: 'PMs',
                Reputation: 'Reputation'

            },
            i;

        if (window._lang)
            for (i in toolbar_alias) window._lang[i] = toolbar_alias[i];
    });
    alexz152
    alexz152
    New Member


    Posts : 8
    Reputation : 1
    Language : polish

    Solved Re: Javascript

    Post by alexz152 January 1st 2020, 2:34 pm

    It actually works. Thank you for your help.
    avatar
    Guest
    Guest


    Solved Re: Javascript

    Post by Guest January 1st 2020, 2:44 pm

    Glad I could help Smile
    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15391
    Reputation : 1709
    Language : English,Greek
    Location : Greece

    Solved Re: Javascript

    Post by skouliki January 1st 2020, 3:49 pm

    Problem solved & topic archived.
    Please read our forum rules: ESF General Rules