(function() { var loh_load_teste_load = 0; try { if (window['loh']) { loh_load_teste_load = 1;} } catch (e) { } if (loh_load_teste_load == 1) {return;} window['loh'] = new Object(); // alert(1); loh.loh_domain = "http://likeorhate.com";loh.loh_staticdomain = "http://static.likeorhate.com";/* * likeorhate.com * Copyright (c) 2008-2010 likeorhate.com */ // Adds an event listener. Jquery is not loaded yet. loh.addEvent = function(el,ev,fn, capture) { if (el.addEventListener) el.addEventListener(ev, fn, capture); else el.attachEvent('on'+ev, fn); }; /** * Guesses the locale. */ loh.getLocaleFromPageContext = function() { var lng = loh.conf.language; if (lng != null) return loh.conf.language; if (navigator.userLanguage == "string") return navigator.userLanguage.substring(0,2); if (navigator.language == "string") return navigator.language.substring(0,2); return 'en'; } ///// FROM: http://techpatterns.com/downloads/javascript_cookies.php // this fixes an issue with the old method, ambiguous values // with this test document.cookie.indexOf( name + "=" ); loh.getCookie = function(check_name) { // first we'll split this cookie up into name/value pairs // note: document.cookie only returns name=value, not the other components var a_all_cookies = document.cookie.split( ';' ); var a_temp_cookie = ''; var cookie_name = ''; var cookie_value = ''; var b_cookie_found = false; // set boolean t/f default f for (var i = 0; i < a_all_cookies.length; i++) { // now we'll split apart each name=value pair a_temp_cookie = a_all_cookies[i].split( '=' ); // and trim left/right whitespace while we're at it cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, ''); // if the extracted name matches passed check_name if (cookie_name == check_name) { b_cookie_found = true; // we need to handle case where cookie has no value but exists (no = sign, that is): if (a_temp_cookie.length > 1) cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, '')); // note that in cases where cookie is initialized but no value, null is returned return cookie_value; } a_temp_cookie = null; cookie_name = ''; } if (!b_cookie_found) return null; } loh.setCookie = function(cookiename, data) { // TODO } /** * Controls space. */ loh.ctrl = new Object(); /** * Configuration space. */ loh.conf = new Object(); // Defaults { /** * Load or not loh information: */ loh.conf.loadThingOnPages = false; /** * Things popups fadeout behaviour: */ loh.conf.timeoutWindows = true; loh.conf.timeoutWindowPeriod = 200; /** * Allow multiple windows opened. It can be usefull combined no timeout option. * * It does not affect pinned windows. */ loh.conf.multipleWindows = false; /** * Allow drag the windows around */ loh.conf.dragableWindows = true; /** * Appearance of the things delimiters */ loh.conf.showLimiterChar = true; loh.conf.colorLimiterChar = true; // Tipo de indicador de votação: // 0 - nenhum indicador // 1 - cor dos limitadores // 2 - imagens envolvendo a expressão // 3 - imagem a direita /** * Type of likeness/hateness rates hint to use: * 0 - no indicator * 1 - limiter's color * 2 - images around the things * 3 - images on the right of the things */ loh.conf.voteIndicatorType = 1; /** * Indicates the characters taht will surround the thing on the page. */ loh.conf.limiterCharLeft = '#'; loh.conf.limiterCharRight = '#'; /** * When images surround the things, these vars indicates what imagens to display, * and how the will respond to likeness/hateness rates. */ loh.conf.changeSideImagesSize = true; loh.conf.sideImagesSizeMin = 5; loh.conf.sideImagesSizeMax = 15; loh.conf.sideImageLeft = loh.loh_staticdomain + '/images/likeicon.png'; loh.conf.sideImageRight = loh.loh_staticdomain + '/images/hateicon.png'; /** * Base name for the images that will be shown on the right of each marked term. */ loh.conf.onlyRightImageBegin = loh.loh_staticdomain + '/images/arrowicon'; loh.conf.onlyRightImageEnd = '.png'; /** * Indicates how many different images will have to indicate the likeness/hateness rate. * It's assumed that the names of the images are: * loh.conf.onlyRightImageBegin + Math.floor(like*loh.conf.onlyRightSteps/(like + hate)) + loh.conf.onlyRightImageEnd * * Besides those images, is expected an image named: * loh.conf.onlyRightImageBegin + 'load' + loh.conf.onlyRightImageEnd */ loh.conf.onlyRightSteps = 5; /** * Indicates if we should show a hint of the likeness/hateness rate. * It's assumed that the names of the images are: * loh.conf.onlyRightImageBegin + Math.floor(like*loh.conf.onlyRightSteps/(like + hate)) + loh.conf.onlyRightImageEnd */ loh.conf.showStartupHint = false; /** * Sets the page language. This info is sent to the server. Null it if you * want the server to discover it info by itself. */ loh.conf.language = null; /** * Sets the page permalink. This info is sent to the server. Null it if you * want the server to discover it info by itself. */ loh.conf.permalink = null; /** * Sizes and positions that are set directly in js: */ // Thing on text: surrounding images loh.conf.szThingSurrImg = [10, 10]; // Thing on text: sidekick images loh.conf.szThingSideImg = [10, 10]; // Box size loh.conf.szBoxDefault = [310, 290]; loh.conf.szShadowOffset = 6; // Minimum box size loh.conf.szBoxMin = [310, 290]; // Thumbnail box loh.conf.szThumbBox = [102, 108]; // Tab general loh.conf.szTabGeneral = [310, 290]; // Tab comments loh.conf.szTabComments = [520, 460]; // Tab links loh.conf.szTabLinks = [320, 450]; // Tab Trackback loh.conf.szTabTrackback = [430, 420]; // Tab googleit loh.conf.szTabGoogleit = [550, 410]; // Tab wikit loh.conf.szTabWikit = [550, 410]; // LOH Logo loh.conf.szLOHLogo = [219, 40]; // Votebar size loh.conf.heightVotebar = 15; // Tabbox no-auth top loh.conf.topNoauthTabbox = 70; loh.conf.heightpercNoauthTabbox = 70; // Moneymaker boxxy dimensions: left, bottom, right, height (!) loh.conf.mrktingBox = [5, 5, 10, 18]; loh.conf.szVotebarleftcap = [10, 25]; loh.conf.szVotebarcenter = [1, 25]; loh.conf.szVotebarrightcap = [10, 25]; // Tabs that will be shown for the things on the page. Extra to these tabs, // it will be included the main tab and any aditional tab that are specific // for some kind of things. loh.conf.selectedTabs = ['main', 'comments', 'trackback', 'googleit', 'relatedthings', 'wikipedia', 'youtube']; loh.conf.selectedTab = 'main'; // Basic schema for each tab. loh.conf.tabsAvailable = { 'main': { 'size': loh.conf.szBoxDefault, 'lbl_size': 58, 'pane': 'tab_general', 'onShow': loh.tabShowDefault, 'onHide': loh.tabHideDefault }, 'comments': { 'size': loh.conf.szTabComments, 'lbl_size': 91, 'pane': 'tab_iframe', 'onShow': loh.tabShowDefault, 'onHide': loh.tabHideDefault }, 'trackback': { 'size': loh.conf.szTabTrackback, 'lbl_size': 93, 'pane': 'tab_trackback', 'onShow': loh.tabShowDefault, 'onHide': loh.tabHideDefault }, 'googleit': { 'size': loh.conf.szTabGoogleit, 'lbl_size': 62, 'pane': 'tab_iframe', 'onShow': loh.tabShowDefault, 'onHide': loh.tabHideDefault }, 'relatedthings': { 'size': loh.conf.szTabLinks, 'lbl_size': 110, 'pane': 'tab_iframe', 'onShow': loh.tabShowDefault, 'onHide': loh.tabHideDefault }, 'wikipedia': { 'size': loh.conf.szTabWikit, 'lbl_size': 97, 'pane': 'tab_iframe', 'onShow': loh.tabShowDefault, 'onHide': loh.tabHideDefault }, 'youtube': { 'size': loh.conf.szTabWikit, 'lbl_size': 97, 'pane': 'tab_iframe', 'onShow': loh.tabShowDefault, 'onHide': loh.tabHideDefault } }; loh.conf.user = null; } /** * core - Constructor */ loh.core = function() { this.thinglist = new Object(); // map: thinghash -> Thing this.thinglist2request = new Object(); // queue of things to fetch in next request this.thinglistid = new Object(); // map: thingid -> Thing // have we started the code yet? this.started = false; // current language this.language = this.getPageLanguage(); }; loh.core.prototype.getPageLanguage = function() { if (loh.conf.language != null) return loh.conf.language; else return loh.conf.def_language; }; /** * Magic event callback. Used for communication with other javascript * * @param */ loh.core.prototype.divEventCallback = function(ev) { var div = $lhj('#likeorhate-event'); var command = div.attr('data-command'); switch (command) { case 'makeTag': var target = $lhj('#'+div.attr('data-target')); var query = div.attr('data-query'); loh.loh_sngltn.findThing4JElem(target); break; default: } ev.stopPropagation(); } /** * Loads external files. * * @param scripts A list of js files to load. * @param css A list of css files to load. * @param string onloadFnc The function to run after everything is loaded (as a string) */ loh.core.prototype.loadFiles = function(scripts, css, onloadFnc) { var head = document.getElementsByTagName('head').item(0); for (var i = 0; i < css.length; i++) { var cssLink = document.createElement("link"); cssLink.href = css[i]; cssLink.rel = "stylesheet"; cssLink.type = "text/css"; head.appendChild(cssLink); } // TODO: apparently IE doesn't guarantee that scripts are loaded in sequence for (i = 0; i < scripts.length; i++) { var js = document.createElement("script"); js.src = scripts[i]; if (i == scripts.length-1 && onloadFnc) { js.onload = function () { eval(onloadFnc); }; js.onreadystatechange = function () { if (js.readyState == 'loaded' || js.readyState == 'complete') { eval(onloadFnc); } }; } js.type = "text/javascript"; head.appendChild(js); } }; /** * Load all necessary scripts, css, etc, and call start() */ loh.core.prototype.load = function() { try { if (loh_is_mainsite) ; } catch (e) { var css = [ loh.loh_domain + "/css/loh_js.css?version=2" // TODO: automatic versioning ]; var scripts = [ // loh.loh_domain + "/js/internal/loh_main.js" ]; loh.loh_sngltn.loadFiles(scripts, css, 'loh.loh_sngltn.start()'); } // and create a fake div that we use for event triggering var div = document.createElement("div"); div.id = 'likeorhate-event'; div.style.visibility = 'hidden'; div.style.display = 'none'; loh.addEvent(div, 'click', function(ev) { loh.loh_sngltn.divEventCallback(ev); }, true); var body = document.getElementsByTagName('body').item(0); body.appendChild(div); }; /** * Destructor */ loh.core.prototype.destroy = function() { }; // Default page language loh.conf.def_language = loh.getLocaleFromPageContext(); //loh.conf.def_language = ''; // Is user authenticated? // loh.ctrl.isauth = if ($login->isLogged()) echo 'true'; else echo 'false'; var tmp_cookie = loh.getCookie('likeorhate'); if (tmp_cookie == null) tmp_cookie = ''; //alert('tmp_cookie: ' + tmp_cookie); loh.ctrl.isauth = tmp_cookie.length > 0; loh.loh_sngltn = new loh.core(); // Search things on page on load? loh.conf.loadThingOnPages = true; // Event handlers loh.addEvent(window, 'load', loh.loh_sngltn.load); /** * Get translations */ loh.core.prototype.getStrings = function() { // translated strings this.strings = new Object(); this.strings = { 'or': 'or', 'i_like': 'I like', 'i_hate': 'I hate', 'like': 'Like!', 'whatever': 'Whatever...', 'hate': 'Hate!', 'votes_title': 'Votes', 'votes_subtitle': 'Click on the bars to vote!', 'total_votes': 'Votes', 'total_views': 'Views', 'total_comments': 'Comments', 'created': 'Created on ', 'dec_sep': '.', 'thousand': 'thousand', 'million': 'million', 'billion': 'billion', 'thumb_not_ok': 'Image is not ok?', 'thumb_not_ok_tell': 'Tell us!', 'main': 'General', 'comments': 'Comments', 'link': 'Links', 'trackback':'Trackbacks', 'googleit': 'Google it', 'wikipedia': 'Wikipedia', 'relatedthings': 'Related things', 'buyit': 'Buy it!', 'compare': 'Compare Things', 'youtube':'YouTube!', 'compare_btn': 'Compare >>', 'prepare_compare_title': 'Compare Things', 'loading': 'Loading ...', 'thanks_reporting_buggythumb': 'Thank you!', 'data_not_loaded_yet': 'Still loading data!', 'sign_in': 'Sign-in', 'sign_in_tooltip': 'Click to sign-in!', 'register': 'Register now', 'register_tooltip': 'Click to register now (opens a new window)', 'disamb_diag_title': 'Are you looking for a different', 'disamb_diag_title_end': '?', 'mistype_diag_title': 'Are you looking for something different?', 'votelike_tit': 'Do you like it? Click now and vote!', 'votewhtvr_tit': 'Don\'t care? Click now and vote!', 'votehate_tit': 'Do you hate it? Click now and vote!', 'authvotelike_tip': 'Author likes it!', 'authvotewhtvr_tip': 'Author really doesn\'t care...', 'authvotehate_tip': 'Author hates it!', 'commentreplytitle': 'Replying to: ', 'trck_notfound': 'Links found: zero', 'trck_found_tit': 'Links found: ', 'wouldlikelogin': 'Would you like to login (or register) and associate this vote to your account? This dialog will not be shown again.', 'yesplease': 'Yes, please', 'nothanks': 'No, thanks', 'error_on_rate_thing': 'Our servers didn\'t register your vote, sorry. Please try again.', 'error_on_rate_thing_det1': 'If the problem persists, please try again later! We\'ll probably had the problem solved!', 'error_ack_lbl': 'Ok...', 'error_img_notfound': 'Image not found.', 'error_onop': 'An error occured.' }; }; // get translations loh.loh_sngltn.getStrings(); })(); /* * likeorhate.com JS API * Copyright (c) 2008-2010 likeorhate.com * * Released under BSD license. */ if(!window.lohapi){(function(){var window=this; /* * This function comes from http://www.sitepoint.com/blogs/2006/01/17/javascript-inheritance/ */ lohcopyPrototype=function(descendant,parent){var sConstructor=parent.toString();var aMatch=sConstructor.match(/\s*function (.*)\(/);if(aMatch!=null){descendant.prototype[aMatch[1]]=parent}for(var m in parent.prototype){descendant.prototype[m]=parent.prototype[m]}};window.lohapi={init:function(){this.setServer("sandbox")},server:"",auth_user:null,auth_pass:null,cache:{},requestid:0,responseType:"JSON",iframe_form:null,setLanguages:function(languages){},getLanguages:function(){return""},setDefaultResponseType:function(type){if(type=="JSON"||type=="JSONXML"||type=="JSONHTML"){lohapi.responseType=type}},setServer:function(server){switch(server){case"production":lohapi.server="http://likeorhate.com";break;case"sandbox":default:lohapi.server="http://sandbox.likeorhate.com";break}},setAuthentication:function(user,password){lohapi.auth_user=user;lohapi.auth_pass=password},setAJAXPost:function(url,parameters,callback,callbackparams){if(document.getElementById("proxy_frame")){}var proxy_token="token";var cf=document.createElement("iframe");cf.id=cf.name=proxy_token;cf.width=cf.height=0;cf.style.display="none";document.body.appendChild(cf);cf.addEventListener("load",function(event){lohapi.catchAJAXPost(event,callback,callbackparams)},true);var pf=document.createElement("iframe");pf.id="proxyframe";pf.style.display="none";document.body.appendChild(pf);var pp=pf.contentWindow.document;pp.open();pp.write('
');for(var i in parameters){pp.write('')}pp.write("
");pp.write("