<?php $__env->startSection('content'); ?>

<div class="card send__sms">
    <div class="card-body">

        <form action="<?php echo e(route('general-sms.send')); ?>" method="POST">
            <?php echo csrf_field(); ?>






            <div class="col-12 mt-1">
                <h5 class="mb-4">Send SMS:</h5>
                <label class="font-weight-300">Enter Mobile Numbers <span>(Use Comma for number separation. Don't use speace after/before comma.)</span></label>
                <fieldset class="form-label-group mb-0">
                    <textarea data-length="160" class="form-control char-textarea" id="textarea-counter" rows="3"
                        placeholder="Ex : 01934115336,01870762474" name="mobile_number" required="" style="color: rgb(78, 81, 84);"></textarea>
                    <label for="textarea-counter"></label>
                </fieldset>
            </div>

            <div class="col-12 mt-1 mb-2">
                <label>Enter SMS Content </label>
                <fieldset class="form-label-group mb-0">
                    <textarea class="form-control char-textarea" id="message" name="sms_body" rows="3" placeholder="Write your sms body here..."
                        style="color: rgb(78, 81, 84);"></textarea>
                    <label for="textarea-counter"></label>
                </fieldset>
                <small class="sms-count float-left">
                    <span id="length">0 characters</span> |
                    <span id="remaining">1530 Characters Left | </span>
                    <span id="messages" style="color: #f79622;font-weight: bold;"> 1 SMS </span>
                    <span id="smslen" style="color: #f79622;font-weight: bold;"> ( 160 Char./SMS ) </span>
                </small>
            </div>

            <div class="col-12">
                <button type="submit"
                    class="btn btn-submit float-right">Send</button>
            </div>
        </form>
    </div>
</div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>

<script>
    $(document).ready(function () {
        var $remaining = $('#remaining'),
            $length = $('#length'),
            $smslen = $('#smslen'),
            $messages = $remaining.next();


        var $remainingfile = $('#remainingfile'),
            $lengthfile = $('#lengthfile'),
            $smslenfile = $('#smslenfile'),
            $messagesfile = $remainingfile.next();


        var $remaininggroup = $('#remaininggroup'),
            $lengthgroup = $('#lengthgroup'),
            $smslengroup = $('#smslengroup'),
            $messagesgroup = $remaininggroup.next();

        $('#message').keyup(function () {
            var str = this.value;
            var msgResponse = isDoubleByte(str);
            var chars = this.value.length;

            if (msgResponse == false) {
                $("#customRadio1").prop("checked", true);
                console.log(chars);
                if (chars <= 160) {
                    messages = Math.ceil(chars / 160),
                        $length.text(chars + ' characters');
                    $remaining.text((1530 - chars) + ' characters left | ');
                    $messages.text(messages + ' SMS');
                    $smslen.text('( 160 Char./SMS )');
                } else {
                    messages = Math.ceil(chars / 153),
                        $length.text(chars + ' characters');
                    $remaining.text((1530 - chars) + ' characters left | ');
                    $messages.text(messages + ' SMS');
                    $smslen.text(' ( 153 Char./SMS ) ');
                }
            } else {
                $("#customRadio2").prop("checked", true);
                if (chars <= 70) {
                    messages = Math.ceil(chars / 70),
                        $length.text(chars + ' characters');
                    $remaining.text((670 - chars) + ' characters left | ');
                    $messages.text(messages + ' SMS');
                    $smslen.text('( 70 Char./SMS )');
                } else {
                    messages = Math.ceil(chars / 67),
                        $length.text(chars + ' characters');
                    $remaining.text((670 - chars) + ' characters left | ');
                    $messages.text(messages + ' SMS');
                    $smslen.text('( 67 Char./SMS )');
                }

            }

        });


        $('#messagefile').keyup(function () {
            var str = this.value;
            var msgResponse = isDoubleByte(str);
            var charsfile = this.value.length;

            if (msgResponse == false) {
                $("#customRadio4").prop("checked", true);
                // console.log(chars);
                if (charsfile <= 160) {
                    messagesfile = Math.ceil(charsfile / 160),
                        $lengthfile.text(charsfile + ' characters');
                    $remainingfile.text((1530 - charsfile) + ' characters left | ');
                    $messagesfile.text(messagesfile + ' SMS');
                    $smslenfile.text('( 160 Char./SMS )');
                } else {
                    messagesfile = Math.ceil(charsfile / 153),
                        $lengthfile.text(charsfile + ' characters');
                    $remainingfile.text((1530 - charsfile) + ' characters left | ');
                    $messagesfile.text(messagesfile + ' SMS');
                    $smslenfile.text(' ( 153 Char./SMS ) ');
                }
            } else {
                $("#customRadio6").prop("checked", true);
                if (charsfile <= 70) {
                    messagesfile = Math.ceil(charsfile / 70),
                        $lengthfile.text(charsfile + ' characters');
                    $remainingfile.text((670 - charsfile) + ' characters left | ');
                    $messagesfile.text(messagesfile + ' SMS');
                    $smslenfile.text('( 70 Char./SMS )');
                } else {
                    messagesfile = Math.ceil(charsfile / 68),
                        $lengthfile.text(charsfile + ' characters');
                    $remainingfile.text((670 - charsfile) + ' characters left | ');
                    $messagesfile.text(messagesfile + ' SMS');
                    $smslenfile.text('( 68 Char./SMS )');
                }

            }

        });


        $('#messagegroup').keyup(function () {
            var str = this.value;
            var msgResponse = isDoubleByte(str);
            var charsgroup = this.value.length;

            if (msgResponse == false) {
                $("#customRadio3").prop("checked", true);
                // console.log(chars);
                if (charsgroup <= 160) {
                    messagesgroup = Math.ceil(charsgroup / 160),
                        $lengthgroup.text(charsgroup + ' characters');
                    $remaininggroup.text((1530 - charsgroup) + ' characters left | ');
                    $messagesgroup.text(messagesgroup + ' SMS');
                    $smslengroup.text('( 160 Char./SMS )');
                } else {
                    messagesgroup = Math.ceil(charsgroup / 153),
                        $lengthgroup.text(charsgroup + ' characters');
                    $remaininggroup.text((1530 - charsgroup) + ' characters left | ');
                    $messagesgroup.text(messagesgroup + ' SMS');
                    $smslengroup.text(' ( 153 Char./SMS ) ');
                }
            } else {
                $("#customRadio4").prop("checked", true);
                if (charsgroup <= 70) {
                    messagesgroup = Math.ceil(charsgroup / 70),
                        $lengthgroup.text(charsgroup + ' characters');
                    $remaininggroup.text((670 - charsgroup) + ' characters left | ');
                    $messagesgroup.text(messagesgroup + ' SMS');
                    $smslengroup.text('( 70 Char./SMS )');
                } else {
                    messagesgroup = Math.ceil(charsgroup / 68),
                        $lengthgroup.text(charsgroup + ' characters');
                    $remaininggroup.text((670 - charsgroup) + ' characters left | ');
                    $messagesgroup.text(messagesgroup + ' SMS');
                    $smslengroup.text('( 68 Char./SMS )');
                }

            }

        });


    });


    function isDoubleByte(str) {
        for (var i = 0, n = str.length; i < n; i++) {
            // console.log(i)
            //if (str.charCodeAt( i ) > 255 && str.charCodeAt( i )!== 8364 )
            if (str.charCodeAt(i) > 255 ||
                str.charCodeAt(i) == 91 ||
                str.charCodeAt(i) == 92 ||
                str.charCodeAt(i) == 93 ||
                str.charCodeAt(i) == 94 ||
                str.charCodeAt(i) == 123 ||
                str.charCodeAt(i) == 124 ||
                str.charCodeAt(i) == 125 ||
                str.charCodeAt(i) == 126
            ) {
                return true;
            }
        }
        return false;
    }

</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/EdueasyCollege/resources/views/pages/sms/general_sms/create.blade.php ENDPATH**/ ?>