Jetpackã§Firefoxæ¡å¼µãæ¸ãã¦ã¿ãã®ã§å ¬é
Firefox 拡張を jQuery で書く! Jetpack を使ってみた。ãè¦ã¦é¢ç½ããã ã£ãã®ã§ä½ã£ã¦ã¿ã¾ãããã¤ã³ã¹ãã¼ã«ããã¨ç¾å¨è¦ã¦ãããµã¤ãã®QRã³ã¼ãã表示ã§ãã¾ãã
QR code Manager
http://webtech.s262.xrea.com/blog/jetpack/qrm/
ã³ã¼ãã¯ãã¡ã
// Google Chart APIã§QRã³ã¼ããçæ function getChartURL(url){ var encode_url = encodeURIComponent(url); return 'http://chart.apis.google.com/chart?chs=120x120&cht=qr&chl='+encode_url; } // ã¹ãã¼ã¿ã¹ãã¼ã«è¿½å jetpack.statusBar.append({ html: '<img src="http://webtech.s262.xrea.com/blog/jetpack/qrm/icon.jpg" style="width:20px;">', onReady: function(widget){ // å±¥æ´ä¿åç¨ if(!jetpack.sessionStorage.qrm){ jetpack.sessionStorage.qrm = {}; jetpack.sessionStorage.qrm.history = new Array(); } $(widget).click(function(){ var doc = jetpack.tabs.focused.contentDocument; var url = jetpack.tabs.focused.url; var history = jetpack.sessionStorage.qrm.history; var a_style = 'font-size:12px; color:black; padding2px;'; // ã¦ã£ã¸ã§ããã®ééç¨ if($('#qrm_box', doc).length > 0){ $('#qrm_box', doc).remove(); return; } if($.inArray(url, history) == -1){ history.push(url); } var box = $('<div id="qrm_box">') .css({ width: '600px', height: '200px', background: '#ffffff', border: '1px solid #000000', position: 'fixed', bottom: '10', right: '10', zIndex: '10000' }); var history_list = $('<div id="qrm_history">') .css({ width: '430px', height: '150px', overflow: 'auto', textAlign: 'left', margin: '10px 10px 10px 150px' }); $.each(history, function(k, v){ $(history_list).append('<a href="#" style="'+a_style+'">'+v+'</a><br>'); }); var qr_img = $('<div>') .css({ width: '150px', float: 'left' }) .append('<img id="qrm_qr" src="'+getChartURL(url)+'">'); var footer = $('<div>') .css({ textAlign: 'right', margin: '10px' }) .append('[ <a href="#" id="qrm_clear" style="'+a_style+'">clear</a> ] ') .append('[ <a href="#" id="qrm_close" style="'+a_style+'">close</a> ]'); $(doc) .find("body") .append(box .append(footer) .append(qr_img) .append(history_list) ); $('#qrm_history > a', doc).click(function(){ $('#qrm_qr', doc).attr('src', getChartURL($(this).text())); return false; }); $('#qrm_clear', doc).click(function(){ jetpack.sessionStorage.qrm.history = new Array(); $('#qrm_history', doc).empty(); return false; }); $('#qrm_close', doc).click(function(){ $('#qrm_box', doc).remove(); return false; }); }); }, width: 20 });
Jetpackã®ãµã¤ãã«ç¨æããã¦ãããã¥ã¼ããªã¢ã«ã§å¤§æ ã¯ç解ã§ããã®ã§åé¡ãªãã£ãã®ã§ãããjQueryã®ã¤ãã³ãå¦çã®ã¨ããã§ã¯ã¾ãã¾ããããã¤ãã®æè¦ã§
$('#qrm_history > a').click(function(){...});
ã¨æ¸ãã¦ãã®ã§ãããã¿ããåãæ¿ããã¨ã¤ãã³ããåä½ããªããã§ã
$('#qrm_history > a', jetpack.tabs.focused.contentDocument).click(function(){...});
ã¨ããã¨åã¿ãã§åé¡ãªãã¤ãã³ããåå¾ã§ãã¾ããã
ExtJSã¨çµã¿åãããã¨ãªãããªæ¡å¼µãç°¡åã«æ¸ããããªæãã§ãã