dcsimg
Results 1 to 1 of 1

Thread: <script> $(function () { var d = new Date() var h12

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2018
    Posts
    58

    <script> $(function () { var d = new Date() var h12

    What is wrong with this code?
    Code:
      <script>
             $(function () { 
               var d = new Date()
               var h12 = d.getHours();
               var h24 = d.getHours();
               var m = d.getMinutes();
               var s = d.getSeconds();
               if (s < 10) {
                   s = "0" + s
               }
               if (m < 10) {
                   m = "0" + m
               }
               if (h12 > 12) {
                   h12 = h12 - 12
               }
               if (h12 == 00) {
                       h12  = 12
                   }
    
               var timeStamp = h12 + ":" + m + ":" + s + " ";
               if (h24 > 11) {
                   timeStamp += "PM";
               } else {
                   timeStamp += "AM";
               }
    
               var userName = document.getElementById("myUserName").value;
               var img = $('<img width="100px;" height=" 100px">');
              $("div.dropdown-menu a").click(function () {
              $('#conDivID').append("<span style='color: red'>" + userName + ': </span>');
              $('#conDivID').append('</br>');
              $("#conDivID").append($(this).find("img").clone(true)); 
              $('#conDivID').append('</br>');
              $('#conDivID').append("<span class='timeSpan'>" + timeStamp + '</span>');
              $('#conDivID').append('</br>');
                   
             });
             })
         </script>
    It's not working it used to sent image(emoji) from dropdown menu to conversation box as in the whole code below
    [CODE]<!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8" />
    <title></title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

    <script
    src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
    </script>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

    </head>
    <body>
    <div class=" bannerDiv">
    <img style="width:40px"height:40px"
    src="https://imgur.com/57AweD4.png" alt="LOGO" />
    <span style="font-family: Times New Roman ;font-size: 30px; color: red">
    RedAppleChat</span>
    </div>

    <form>
    <div class=" UsernameLabelDiv">
    <input style="width: 300px" type="text" placeholder="Username" id="myUserName"maxlength="10"onkeyup="saveValue(this)" onkeypress="return AvoidSpace(event)">
    </div>
    <div class="conDiv" id="conDivID"></div>

    <div class=" myInputtextDiv">
    <input style="color:black;" type="text" id="myInput" maxlength="10000" >

    <input type="text" id="baseimage" onkeyup=" sendImage()" hidden >

    </br>

    <a id="myBtn" class="btn btn-primary btn-sm"onclick="sendFunction();">
    <span class="glyphicon glyphicon-send"></span> Send
    </a>
    <input id="fileInput" type="file" style="display: none;" />
    <a id="fileInput" class="btn btn-success btn-sm" type="file"onclick="document.getElementById ('fileInput').click();">
    <span class="glyphicon glyphicon-camera"></span> Image!
    </a>
    <a id="myBtn" class="btn btn-danger btn-sm" onclick="clearChat();">
    <span class="glyphicon glyphicon-trash"></span> Clear
    </a>
    <!--To record voice -->
    <input id="fileInput" type="file" style="display: none;" />
    <a type="file"onclick="document.getElementById ('fileInput').click();">
    <img src="https://imgur.com/Go9vKSd.png" width=" =20px;" height=" 20px" alt=".."/>
    </a>
    <!--To add stickers-->
    <div class="btn-group" style="display:inline;position: absolute; direction:ltr">
    <button type="button"
    class="btn btn-outline-light btn-sm dropdown-toggle dropdown-toggle-split" data-toggle="dropdown">
    <img src="https://imgur.com/PVBYWRJ.png
    "width=" =20px;"height=" 20px"alt=".."></button>

    <div class="dropdown-menu" >

    <a class="dropup-item"
    <button ><img src="https://imgur.com/zLXQ7Ua.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/u82MtgI.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/5DJF0bU.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/Go9vKSd.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/JGIGROu.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/7ECo6jN.png "
    width=" =20px;" height="20px"alt=".."> </button></a>


    <br/>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/PVBYWRJ.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/bgOYEUb.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/UCi89or.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/Bj4xOS9.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/7QNYfSh.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/6sqrgNK.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/Dt3VM26.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/yBUGgCQ.png "
    width=" =20px;" height="20px"alt=".."> </button></a>


    <a class="dropdown-item"
    <button ><img src="https://imgur.com/XNXYKlC.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/IZh9H8B.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/bYTUGeR.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/bYTUGeR.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <br/>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/GZC0Mga.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/HE2E2sL.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/D9DshnJ.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/rKS2mLu.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/wgmmMJM.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/00zu1KL.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/2DoStHY.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/1x3bgVM.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/IBA9mXh.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/98EIMUt.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/yuLJrdH.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/AqWbP2a.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/mCjBjMP.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/ZLVruHF.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/5IqJpdY.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/wkjgd5T.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/qbeRdCr.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/aFCkpNZ.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/RV84irI.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/OWGw5bW.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/XFGjDSL.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/G2lMKBM.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/bxtFpmf.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/zX9o3nM.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/kFp9RpM.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/IjZSn44.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/YlsSaRf.png "
    width=" =20px;" height="20px"alt=".."> </button></a>

    <a class="dropdown-item"
    <button ><img src="https://imgur.com/0Z8aJ75.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/LFCpFRE.png "
    width=" =20px;" height="20px"alt=".."> </button></a>
    <a class="dropdown-item"
    <button ><img src="https://imgur.com/YP5l3HU.png "
    width=" =20px;" height="20px"alt=".."> </button></a>


    </div>
    </div>
    </div>
    <br>

    <script>
    $(function () {
    var d = new Date()
    var h12 = d.getHours();
    var h24 = d.getHours();
    var m = d.getMinutes();
    var s = d.getSeconds();
    if (s < 10) {
    s = "0" + s
    }
    if (m < 10) {
    m = "0" + m
    }
    if (h12 > 12) {
    h12 = h12 - 12
    }
    if (h12 == 00) {
    h12 = 12
    }

    var timeStamp = h12 + ":" + m + ":" + s + " ";
    if (h24 > 11) {
    timeStamp += "PM";
    } else {
    timeStamp += "AM";
    }

    var userName = document.getElementById("myUserName").value;
    var img = $('<img class="img" width=" =100px;" height=" 100px">')
    .attr('src', imagesrc.value);
    $("div.dropdown-menu a").click(function () {
    $('#conDivID').append("<span style='color: red'>" + userName + ': </span>');
    $('#conDivID').append('</br>');
    $("#conDivID").append($(this).find("img").clone(true));
    $('#conDivID').append('</br>');
    $('#conDivID').append("<span class='timeSpan'>" + timeStamp + '</span>');
    $('#conDivID').append('</br>');

    });
    })
    </script>
    <script>
    function sendFunction() {
    var d = new Date()
    var h12 = d.getHours();
    var h24 = d.getHours();
    var m = d.getMinutes();
    var s = d.getSeconds();
    if (s < 10) {
    s = "0" + s
    }
    if (m < 10) {
    m = "0" + m
    }
    if (h12 > 12) {
    h12 = h12 - 12
    }
    if (h12 == 00) {
    h12 = 12
    }

    var timeStamp = h12 + ":" + m + ":" + s + " ";
    if (h24 > 11) {
    timeStamp += "PM";
    } else {
    timeStamp += "AM";
    }

    var userName = document.getElementById("myUserName").value;
    var userinput = document.getElementById("myInput").value;
    var imagesrc = document.getElementById("baseimage");
    var img = $('<img class="img" width=" =100px;" height=" 100px">')
    .attr('src', imagesrc.value);
    var regex = new RegExp("^[A-Za-z0-9]+$");
    if (regex.test(userName)& imagesrc.value =="") {
    $('#conDivID').append("<span style='color: red'>" + userName + ': </span>');
    $('#conDivID').append( embedUrls(userinput));
    $('#conDivID').append('</br>');
    $('#conDivID').append("<span class='timeSpan'>" + timeStamp + '</span>');
    $('#conDivID').append('</br>');

    document.getElementById('baseimage').value = "";
    document.getElementById('myInput').value = "";
    document.getElementById("myInput").focus();

    } else if (regex.test(userName)& imagesrc.value !="") {
    $('#conDivID').append("<span style='color: red'>" + userName + ': </span>');
    $('#conDivID').append( embedUrls(userinput));
    $('#conDivID').append(%
    Last edited by Max45; Jan 9th, 2019 at 09:24 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width