Merlin's Academy for Excellence
IMPORTANT NOTICE: Due to inactivity, Merlin's Academy is no longer a Harry Potter RP site. It is being used for CASUAL, CLEAN RP of ANY TOPIC among friends. If you wish to join, however, please feel free; we would love to make new friends. Thanks to everyone who made MAE what it was before, and we wish you all lots of love and a great life up ahead. <3

~Lor, Mads, Lyd, and Mel~
Merlin's Academy for Excellence
IMPORTANT NOTICE: Due to inactivity, Merlin's Academy is no longer a Harry Potter RP site. It is being used for CASUAL, CLEAN RP of ANY TOPIC among friends. If you wish to join, however, please feel free; we would love to make new friends. Thanks to everyone who made MAE what it was before, and we wish you all lots of love and a great life up ahead. <3

~Lor, Mads, Lyd, and Mel~
Merlin's Academy for Excellence
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Merlin's Academy for Excellence


 
HomeLatest imagesSearchRegisterLog in
Log in
Username:
Password:
Log in automatically: 
:: I forgot my password
Site Time

~Month: September~

Year: 2017

~Season: Autumn~

Important Info
LINKS

  • MAE Rules
  • Hex Colour Codes
  • Character Applications
  • Claims Center
  • Jobs

  • CHARACTERS NEEDED

    None at the moment


    Share
     

     Word Counter Code

    View previous topic View next topic Go down 
    AuthorMessage
    Teagan Finn
    Teagan Finn
    Professors
    Professors

    Posts : 186

    Word Counter Code Empty
    PostSubject: Word Counter Code   Word Counter Code EmptyTue Feb 21, 2017 8:57 pm

    In case this is ever needed again. It is to go in the Modules area, down in the Java script section. Just copy and paste this:

    $(function(){$(function() {
    var c = Number($('.nav a:eq(1)').attr('href').replace(/\/c(\d+)-.*/,'$1'));

    if (c == 1 || c == 2 || c == 13) {
    var MinNumberOfWords = 100;
    var LetterCountPerWord = 1;
    var ico_compl = "https://i.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
    var ico_incompl = "https://i.servimg.com/u/f73/18/10/89/49/exclam10.png";

    if($("#text_editor_textarea").length != 0){
    $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
    $(".sceditor-container").after("
    Minimum words to send a message: " + MinNumberOfWords + "
    ");

    var sceditor = $("#text_editor_textarea").sceditor("instance");
    var str = sceditor.val();
    var regex = new RegExp('\\w{' + LetterCountPerWord + ',}\\b', 'g');
    var str_arr = str.match(regex);
    var str_len = str_arr == null ? 0 : str_arr.length;

    if(str_len >= MinNumberOfWords) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");

    sceditor.keyUp(function(e) {
    str = sceditor.val();
    str_arr = str.match(regex);
    str_len = str_arr == null ? 0 : str_arr.length;
    if(str_len >= MinNumberOfWords) {
    $("#div_minchars_info").html("You've written " + str_len + " word(s). You can now send the message ");
    $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
    }else{
    $("#div_minchars_info").html("You've written " + str_len + " word(s). You need " + (MinNumberOfWords - str_len) + " word(s) to send this message ");
    $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
    }
    });
    }
    }
    })});
    Back to top Go down
    https://merlinsacademy.rpg-board.net
     

    Word Counter Code

    View previous topic View next topic Back to top 
    Page 1 of 1

    Permissions in this forum:You cannot reply to topics in this forum
    Merlin's Academy for Excellence  :: Welcome! :: Saved Posts-