1var socializeit = function(options) { 2 if (!options || !options.domain) { 3 throw new Error('Error: must pass socializeit a domain (e.g. socializeit({domain:"www.example.com"})).') 4 } 5 6 if (!options.pack) options.pack = 1; //set a default value for whoever is using old version 7 8 var d = document, 9 l = d.location, 10 e = encodeURIComponent, 11 u = e(l.href), 12 t = e(d.title), 13 domain = options.domain, 14 urlroot = 'http://www.'+domain+'/objects/'; 15 16 17 var sitesConfig = { 18 'google': {name: 'Google', 19 img: {1: urlroot+'google.gif'}, 20 url: 'http://www.google.com/bookmarks/mark?op=edit&bkmk='+ u +'&title=' +t}, 21 'buzz': {name: 'Buzz', 22 img: {1: urlroot+'yahoobuzz1.gif'}, 23 url: 'http://buzz.yahoo.com/submit?submitUrl='+ u +'&t=' + t}, 24 'facebook': {name: 'Facebook', 25 img: {1: urlroot+'Facebook.jpg', 26 2: urlroot+'share-on-facebook.gif'}, 27 url: 'http://www.facebook.com/sharer.php?u='+ u +'&t=' + t}, 28 'myspace': {name: 'Myspace', 29 img: {1: urlroot+'myspace.gif'}, 30 url: 'http://www.myspace.com/Modules/PostTo/Pages/?u='+ u +'&t=' + t}, 31 'stumbleupon': {name: 'StumbleUpon', 32 img: {1: urlroot+'StumbleUpon.jpg'}, 33 url: 'http://www.stumbleupon.com/submit?url=' + u + '&title=' + t}, 34 'technorati': {name: 'Technorati', 35 img: {1: urlroot+'Technorati.jpg'}, 36 url: 'http://technorati.com/faves/?add=' + u}, 37 'delicious': {name: 'del.icio.us', 38 img: {1: urlroot+'del.jpg'}, 39 url: 'http://del.icio.us/post?v=4&noui&jump=close&url=' + u + '&title=' + t}, 40 'twitter': {name: 'Twitter', 41 img: {1: urlroot+'twitter.gif', 42 2: urlroot+'tweet-this.gif'}, 43 url: 'http://twitter.com/home?status=Reading%20about%20this:%20'+t+'%20-%20' + u} 44 }; 45 46 var sites = []; 47 if (options.pack == 1) { 48 sites = [sitesConfig.google, sitesConfig.buzz, sitesConfig.facebook, sitesConfig.myspace, 49 sitesConfig.stumbleupon, sitesConfig.technorati, sitesConfig.delicious, sitesConfig.twitter]; 50 } 51 else 52 { 53 sites = [sitesConfig.facebook,sitesConfig.twitter]; 54 55 } 56 57 arguments.callee.getURL = function(which) { 58 59 for (var i=0, ilen=sites.length; i<ilen; i++) { 60 var site = sites[i]; 61 if (site.name == which) { 62 return site.url; 63 } 64 } 65 }; 66 67 68 var html = ''; 69 var midpoint = Math.floor((sites.length-1)/2); 70 var pack = options.pack; 71 var colspan = (pack == 1) ? (midpoint+3) : 5; 72 var rowspan = (pack == 1) ? 'rowspan="2"' : ''; 73 74 75 html = '<table class="socializeIt" align="center" style="border: 1px solid #ccc;border-collapse:separate; padding:2px;width:480px;"><tbody><tr><td '+rowspan+' style="white-space:nowrap;"><strong>Share this page: </strong>'; 76 if (options.whatIsThisUrl) { 77 html += '<br><div id="whatsthis" style="font-size:11px;"><a href="#" onclick="window.open\(\''+options.whatIsThisUrl+'\',\'sharer\',\'toolbar=0,status=0,width=700,height=500,resizable=yes,scrollbars=yes\'\); return false;">What\'s This?</a></div'; 78 } 79 html += '</td>'; 80 // visually want two rows of links 81 82 var iCols= ((2 + midpoint) <ilen) ? 2 + midpoint : ilen; 83 for (var i=0, ilen=sites.length; i<ilen; i++) { 84 var site = sites[i].name; 85 var imgURL = sites[i].img[pack]; 86 var url = sites[i].url; 87 html += '<td><a href="#share_on_'+site+'" onclick="window.open(socializeit.getURL(\''+site+'\'), \'sharer\', \'toolbar=0,status=0,width=700,height=500,resizable=yes,scrollbars=yes\');return false;"><img src="'+imgURL+'" alt="'+site+'" style="border:0"></a></td>'; 88 if ((i == midpoint) && (i+1)<ilen && pack == 1) { 89 html += '</tr><tr>'; 90 } 91 } 92 html += '</tr>'; 93 94 // pay it forward 95 if (options.payItText) { 96 var id = 'socializeit' + (new Date()).getTime() + Math.floor(Math.random() * 1e7) 97 html += '<tr><td colspan="'+colspan+'" style="background:'+options.szColor+';padding:1em;"><p style="text-align:center;margin-top:0;margin-bottom:0;"><a href="#pay_it_forward" onclick="document.getElementById(\''+id+'\').style.display=(document.getElementById(\''+id+'\').style.display == \'block\') ? \'none\' : \'block\';return false;">' + 98 options.payItText + '</a></p><div style="display:none;" id="'+id+'"><p>Would you prefer to share this page with others by linking to it?</p>'+ 99 '<ol><li>Click on the HTML link code below.</li><li>Copy and paste it, adding a note of your own, into your blog, a Web page, forums, a blog comment, your Facebook account, or anywhere that someone would find this page valuable.</li></ol><form action="#"><div style="text-align:center"><textarea cols="50" rows="2" onclick="this.select();"><a href="'+l+'">'+d.title+'</a></textarea></div></form></div></td></tr>'; 100 } 101 html += '</tbody></table>'; 102 103 document.writeln(html); 104}; 105
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.