Claudiu898

Joined on Jun 1st 2017
Karma

130

  • john.indexOf('teacher') looks for the string 'teacher' in the array john
    If it finds it, it returns the index. In this case it doesn't find it(because john is not a teacher, or better said because the string 'teacher' is not present in the array john) and therefore returns -1.
    More info here:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf

  • <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
    var accros = ["AFK", "LOL"];
    var tags = ["Away from the kboard", "Laugh..."];
    var element = "textarea";
    var button = "button";
    document.addEventListener("DOMContentLoaded", function () {
    var len = accros.length;
    var el = document.querySelector(element);
    button = document.querySelector(button);
    button.addEventListener("click", function () {
    var html = el.value;
    for (var i = 0; i < len; i++) {
    html = html.split(accros[i]).join("<abbr title=\"" + tags[i] + "\">" + accros[i] + "</abbr>");
    }
    el.value = html;
    })
    })
    </script>
    </head>
    <body>
    <textarea cols="30" rows="10"></textarea>
    <button>Click</button>
    </body>
    </html>

    Your code had a few problems:the button didn't need an onclick attribute and it had no value. Also my script had a bug(DomContentLoaded instead of DOMContentLoaded). It works now.

  • var accros=["AFK", "LOL"];
    var tags=["Away from the kboard", "Laugh..."];
    var element="textarea";
    var button="button";
    document.addEventListener("DomContentLoaded", function(){
    var len=accros.length;
    var el=document.querySelector(element);
    var button=document.querySelector(button);
    button.addEventListener("click", function(){
    var html=el.value;
    for(var i=0;i<len;i++){
    html=html.split(accros[i]).join("<abbr title=\""+tags[i]+"\">"+accros[i]+"</abbr>");
    }
    el.value=html;
    })
    })

    This should work for you. If you have more than one textarea or more than one button on your page, you have to modify the 3rd and 4th lines in the code with an id/class for the specific textarea and button you use.
    Note:I haven't the tested.

  • I use Atom. The interface looks awesome and you can have 2 files open at the same time. I tried brackets but I prefer Atom. For me any editor is good as long as it has basic syntax highlightning and a dark theme.

  • I can tell you have no idea what you're talking about just my reading your question. Making a real cool game takes at least a few months, a lot of people working at it and more than one programming language. I doubt you'll ever make such a thing. Unless you're 10 years old right now.

  • Linux or Windows. I wouldn't use mac unless I had no choice

  • Why use jquery when plain javascript is much faster?

  • var accros=["AFK", "LOL"];
    var tags=["Away from the kboard", "Laugh..."];
    var element=".privacy";
    document.addEventListener("DomContentLoaded", function(){
    var len=accros.length;
    var el=document.querySelector(element);
    var html=el.innerHTML;
    for(var i=0;i<len;i++){
    html=html.split(accros[i]).join("<abbr title=\""+tags[i]+"\">"+accros[i]+"</abbr>");
    }
    el.innerHTML=html;
    }

    This should do the trick. You have to modify the first 3 lines:
    var accros=["AFK", "LOL"];=>here you can add more accronymes

    var tags=["Away from the kboard", "Laugh..."];=>These are the descriptions. You have to have as many accronymes as
    descriptions otherwise it wont work.

    var element=".privacy";=>This is the html element that contains your accronymes. If you have no idea what a html element is, just replace this line with var element="body".

  • I'd say first learn php and sql, because wordpress is written in them. I personally wouldn't advise you to "learn" wordpress unless you want to use it yourself. It's pretty old scholl software if you ask me.

  • Mostly Windows 10, but also Linux from time to time(Kali being my favourite distro).

  • Nope, you can't. You'll need to know at least HTML.