if (top.location.href.indexOf('preview') >= 0) {
    scope.token = 'dev-token';
    next('success', args);
}
else {
    if (window['getPxToken']) {
        window['getPxToken'](function (e, token) {
            switch (e) {
                case 'net error':
                    next('error', { type: 'error' });
                    break;
                case 'need login':
                    next('failed', { type: 'failed' });
                    break;
                case 'state invalid':
                    next('invalid', { type: 'invalid' });
                    break;
                default:
                    if (token) {
                        scope.token = token;
                        next('success', args);
                    }
                    else {
                        next('invalid', { type: 'invalid key' });
                    }
            }
        });
    }
    else {
        next('error', { type: 'no ready' });
    }
}
