1require(['gitbook', 'jquery'], function(gitbook, $) { 2 function site(label, icon, link) { 3 return { 4 label: label, 5 icon: 'fa fa-' + icon, 6 onClick: function (e) { 7 e.preventDefault(); 8 window.open(link); 9 } 10 }; 11 } 12 13 var url = encodeURIComponent(location.href); 14 var title = encodeURIComponent(document.title); 15 16 var SITES = { 17 douban: site('è±ç£', 'share', 'http://shuo.douban.com/!service/share?href=' + url + '&name=' + title), 18 facebook: site('Facebook', 'facebook', 'http://www.facebook.com/sharer/sharer.php?s=100&p[url]=' + url), 19 google: site('Google+', 'google-plus', 'https://plus.google.com/share?url=' + url), 20 hatenaBookmark: site('ã¯ã¦ãªããã¯ãã¼ã¯', 'bold', 'http://b.hatena.ne.jp/entry/' + url), 21 instapaper: site('instapaper', 'instapaper', 'http://www.instapaper.com/text?u=' + url), 22 line: site('LINE', 'comment', 'http://line.me/R/msg/text/?' + title + ' ' + url), 23 linkedin: site('Linkedin', 'linkedin', 'https://www.linkedin.com/shareArticle?mini=true&url=' + url), 24 messenger: site('Facebook Messenger', 'commenting', 'fb-messenger://share?link=' + url), 25 pocket: site('Pocket', 'get-pocket', 'https://getpocket.com/save?url=' + url + '&title=' + title), 26 qq: site('QQ', 'qq', 'http://connect.qq.com/widget/shareqq/index.html?url=' + url + '&title=' + title), 27 qzone: site('QQ空é´', 'star', 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + url + '&title=' + title), 28 stumbleupon: site('StumbleUpon', 'stumbleupon', 'http://www.stumbleupon.com/submit?url=' + url + '&title=' + title), 29 twitter: site('Twitter', 'twitter', 'https://twitter.com/intent/tweet?url=' + title + '&text=' + title), 30 viber: site('Viber', 'volume-control-phone', 'viber://forward?text='+ url + ' ' + title), 31 vk: site('VK', 'vk', 'http://vkontakte.ru/share.php?url=' + url), 32 weibo: site('æ°æµªå¾®å', 'weibo', 'http://service.weibo.com/share/share.php?content=utf-8&url=' + url + '&title=' + title), 33 whatsapp: site('WhatsApp', 'whatsapp', 'whatsapp://send?text='+ url + ' ' + title), 34 }; 35 36 gitbook.events.bind('start', function(e, config) { 37 var opts = config.sharing; 38 39 // Create dropdown menu 40 var menu = $.map(opts.all, function(id) { 41 var site = SITES[id]; 42 43 return { 44 text: site.label, 45 onClick: site.onClick 46 }; 47 }); 48 49 // Create main button with dropdown 50 if (menu.length > 0) { 51 gitbook.toolbar.createButton({ 52 icon: 'fa fa-share-alt', 53 label: 'Share', 54 position: 'right', 55 dropdown: [menu] 56 }); 57 } 58 59 // Direct actions to share 60 $.each(SITES, function(sideId, site) { 61 if (!opts[sideId]) return; 62 63 gitbook.toolbar.createButton({ 64 icon: site.icon, 65 label: site.text, 66 position: 'right', 67 onClick: site.onClick 68 }); 69 }); 70 }); 71});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.