tide-command.page.js 1.3 KB
require('home/tide-command.page.css');

let tip = require('plugin/tip');
let qs = require('yoho-qs');
let trendWord;

$('.tide-command-page').css('min-height', function() {
    return $(window).height();
});

$('.close').click(function() {
    $('.command-textarea').val('');
});

$('.command-textarea').bind('input propertychange', function() {
    $('.world-number').html(15 - $('.command-textarea').val().length);

    if ($('.command-textarea').val().length >= 15) {
        $(this).val($(this).val().substring(0, 14));
    }
});

$('.save').click(function() {
    trendWord = $('.command-textarea').val();

    $.ajax({
        type: 'GET',
        url: '/activity/set-trend-world',
        data: {
            trendWord: trendWord
        },
        success: function(result) {
            tip.show(result.message);

            if (window._yas && window._yas.sendCustomInfo) {
                window._yas.sendCustomInfo({
                    op: 'YB_MYTREND_TREND_SET_C',
                    param: JSON.stringify({
                        TREND: trendWord
                    })
                }, true);
            }
        }
    });
});

(function() {
    $('.world-number').html(15 - $('.command-textarea').val().length);

    if (qs.hideTips && qs.hideTips === 'true') {
        $('.introduce').hide();
    }
}());