/** * QR码解码 */ var qrDecode = (function () { "use strict"; var _show = function(text){ var el = $('#__fehelper_qr_decode__'); if(!el[0]){ el = $('
').appendTo('body'); el.find('a#__fehelper_qr_copy_').click(function(e){ e.preventDefault(); el.find('textarea').select(); document.execCommand('Copy'); el.find('#__fehelper_qr_msg_').show().delay(2000).hide('slow'); }); el.find('a#__fehelper_qr_close_').click(function(e){ e.preventDefault(); el.hide('slow'); }); } if(text == 'error decoding QR Code') { text = '抱歉,二维码识别失败!'; } el.show('slow').find('textarea').val(text); }; var _init = function () { // 在tab创建或者更新时候,监听事件,看看是否有参数传递过来 chrome.runtime.onMessage.addListener(function (request, sender, callback) { if (request.type == MSG_TYPE.QR_DECODE) { _show(request.result); } }); }; return { init: _init }; })(); qrDecode.init();