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

let yoho = require('yoho-app');

let tip = require('plugin/tip');
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);
            }

            if (yoho && yoho.isApp) {
                yoho.invokeMethod('go.refreshUserInfomation');
            }
        }
    });
});

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

    if (yoho && yoho.isApp) {

        if (yoho.isMarsApp) {
            yoho.ready(() => {
                yoho.invokeMethod('set.removeTopRightButton');
            });
        }
    }
}());