1var googObj = googObj || {}; 2 3(function(jQuery) { 4 googObj.translator = { 5 langCode: { 6 'en': 'English', 7 'fr': 'French', 8 'es': 'Spanish', 9 'zh-CN': 'Chinese' 10 }, 11 12 initDropdown: function() { 13 jQuery('.languages li').click(function() { 14 jQuery('.languages li').removeClass('active'); 15 jQuery(this).addClass('active'); 16 var lang = jQuery(this).data('lang'); 17 var jQueryframe = jQuery('iframe.goog-te-menu-frame:first'); 18 if (!jQueryframe.size()) { 19 console.log('no google translate iframe'); 20 return false; 21 } 22 23 jQuery( jQueryframe.contents().find('.goog-te-menu2-item span.text') ).each(function( index ) { 24 console.log('found lang'); 25 if (jQuery(this).text() == lang) { 26 if (lang == 'English') { 27 googObj.translator.showOriginalText(); 28 return false; 29 } 30 31 jQuery(this).click(); 32 33 return false; 34 } 35 }); 36 return false; 37 }); 38 }, 39 40 showOriginalText: function() { 41 var googBar = jQuery('iframe.goog-te-banner-frame:first'); 42 jQuery( googBar.contents().find('.goog-te-button button') ).each(function( index ) { 43 if ( jQuery(this).text() == 'Show original' ) { 44 jQuery(this).trigger('click'); 45 46 if (jQuery('.languages .active').data('value') != 'en') { 47 jQuery('.languages ul').find( 'en' ).addClass('active'); 48 } 49 return false; 50 } 51 }); 52 }, 53 54 setLangDropdown: function() { 55 var cookieVal = this.getCookieValue(); 56 if (cookieVal) { 57 jQuery('.languages ul .active').removeClass('active'); 58 jQuery('.languages ul').find( this.langCode[cookieVal] ).addClass('active'); 59 } 60 }, 61 62 getCookieValue: function() { 63 var transCookie = getCookie('googtrans'); 64 if ( transCookie ) { 65 transCookie = transCookie.split('/'); 66 transCookie = transCookie[2]; 67 return transCookie; 68 } 69 70 return false; 71 }, 72 73 init: function() { 74 this.initDropdown(); 75 this.setLangDropdown(); 76 } 77 } 78})(jQuery); 79 80function getCookie(name) { 81 var nameEQ = name + "="; 82 var ca = document.cookie.split(';'); 83 for (var i=0; i < ca.length; i++) { 84 var c = ca[i]; 85 while (c.charAt(0) == ' ') c = c.substring(1, c.length); 86 if ( c.indexOf(nameEQ) == 0 ) { 87 return c.substring(nameEQ.length,c.length); 88 } 89 } 90 return null; 91} 92
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.