public/liff-starter.js
/**
* Register event handlers for the buttons displayed in the app
*/
Register event handlers for the buttons displayed in the app
Register event handlers for the buttons displayed in the app
function registerButtonHandlers(type) {
    var close_e = document.getElementById('closeWindowButton');
    document.getElementById('closeWindowButton').addEventListener('click', function() {
        if (!liff.isInClient()) {
            sendAlertIfNotInClient();
        } else {
            liff.closeWindow();
        }
    });
    document.getElementById('sendMessageButton').addEventListener('click', function() {
        if (!liff.isInClient()) {
            sendAlertIfNotInClient();
        } else {
            q_type = ''
            if (type === 'type=one-side') {
                q_type = '單戀';
            } else if (type === 'type=divorce') {
                q_type = '離婚';
            } else if (type === 'type=single') {
                q_type = '單身';
            } else if (type === 'type=cheat') {
                q_type = '劈腿';
            } else if (type === 'type=ambiguous') {
                q_type = '曖昧';
            } else if (type === 'type=marry') {
                q_type = '結婚';
            } else if (type === 'type=make-up') {
                q_type = '復合';
            }
            liff.sendMessages([{
                'type': 'text',
                'text': '我想問關於'+q_type+' 過去抽到愚人 現在抽到寶劍皇后 未來抽到聖杯國王'
            }]).then(function() {
                if (close_e.style.display === 'none') {
                    close_e.style.display = 'block';
                }
            }).catch(function(error) {
                window.alert('Error sending message: ' + error);
            });
        }
    });
}
function registerButtonHandlers ( type ) { var close_e = document . getElementById ( 'closeWindowButton' ) ; document . getElementById ( 'closeWindowButton' ) . addEventListener ( 'click' , function ( ) { if ( ! liff . isInClient ( ) ) { sendAlertIfNotInClient ( ) ; } else { liff . closeWindow ( ) ; } } ) ; document . getElementById ( 'sendMessageButton' ) . addEventListener ( 'click' , function ( ) { if ( ! liff . isInClient ( ) ) { sendAlertIfNotInClient ( ) ; } else { q_type = '' if ( type === 'type=one-side' ) { q_type = '單戀'; } else if ( type === 'type=divorce' ) { q_type = '離婚'; } else if ( type === 'type=single' ) { q_type = '單身'; } else if ( type === 'type=cheat' ) { q_type = '劈腿'; } else if ( type === 'type=ambiguous' ) { q_type = '曖昧'; } else if ( type === 'type=marry' ) { q_type = '結婚'; } else if ( type === 'type=make-up' ) { q_type = '復合'; } liff . sendMessages ( [ { 'type' : 'text' , 'text' : '我想問關於'+q_type+'  過 去抽到愚人  現 在抽到寶劍皇后 未來抽到聖杯國王' } ] ) . then ( function ( ) { if ( close_e . style . display === 'none' ) { close_e . style . display = 'block' ; } } ) . catch ( function ( error ) { window . alert ( 'Error sending message: ' + error ) ; } ) ; } } ) ; }
Register event handlers for the buttons displayed in the app
Register event handlers for the buttons displayed in the app
// closeWindow call // sendMessages call