var subnav; var last_log; var reg_logid = new RegExp(' id=\"log([0-9]*)\"'); var spy_bins = ""; var light; var loginwin; var regwin; var fbreqwin; var tweetreqwin; var extras = []; var isIE6 = /msie|MSIE 6/.test(navigator.userAgent); var topicalUsers; var comment; var minispy; var minicache=false; var instance_prefix=""; var fbSharePush=false; var fbSharePushAsked=false; var fbSharePostAsked=false; var fbLoginUrl="#"; var tweetPostAsked=false; var tweetPushAsked=false; var tweetCommentAsked=false; var tweetPush=false; var tweetPost=false; var tweetComment=false; var frameLinks = false; var useHotkeys = true; var userTabComplete; var default_adlink = 193912; var drops = []; var descriptionMaxLength = 170; var robotSentence = ""; var domain = ""; Array.prototype.indexOf=function(o,i){for(var j=this.length,i=i<0?i+j<0?0:i+j:i||0;i'+textlinks[i].title+''; } if(textlinks.length<4){ var fillers = [{"url":"http://qvaq.com","title":"Qvaq - chatta i grupp om det som intresserar dig"}, {"url":"http://iqs.me","title":"Internets enklaste bilduppladdning - gratis"}, {"url":"http://www.smidigt.se","title":"Smidigt - prylar och teknik"}, {"url":"http://begagnadeprogram.se","title":"Köp och sälj begagnade programvaror"} ]; //shuffle(fillers); for(var i=0; i<4-textlinks.length; i++){ textlinklist.innerHTML += '
  • '+fillers[i].title+'
  • '; } } } },"text/html"); } } function utf8_encode(argString){ var string = (argString + ''); var utftext = "", start, end, stringl = 0; start = end = 0; stringl = string.length; for (var n = 0; n < stringl; n++){ var c1 = string.charCodeAt(n); var enc = null; if (c1 < 128){ end++; }else if(c1 > 127 && c1 < 2048){ enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128); }else{ enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128); } if(enc !== null){ if(end > start){ utftext += string.slice(start, end); } utftext += enc; start = end = n + 1; } } if(end > start){ utftext += string.slice(start, stringl); } return utftext; } function initSponsoredLink(){ var placeHolder = document.getElementById("sponsoredLink"); if(placeHolder){ ajaxCall("/get_sponsoredlink.php",'',function(http_request){ if (http_request.responseText!=""){ var sponsoredLink = eval('(' + http_request.responseText + ')'); var online = document.getElementById("logout"); placeHolder.innerHTML = '

    '+sponsoredLink.title+'

    Denna länk är en annons

    '+(sponsoredLink.description.lengthLäs mer »')+'

    '+(sponsoredLink.pushed?''+sponsoredLink.nrOfPushes+' pushad':''+sponsoredLink.nrOfPushes+' Pusha')+'

    '; initLinks(placeHolder); if(online && sponsoredLink.id!=default_adlink){ document.getElementById("blockLink"+sponsoredLink.id).onclick = function(){ ajaxCall("/block_link.php",'link='+this.rel,function(){ initSponsoredLink(); }); return false; } } }else{ placeHolder.innerHTML = ""; } },"text/html"); } } function initMiniSpy(){ minispy = document.getElementById('minispy'); if (minispy){ var dls = minispy.getElementsByTagName('DL'); var id = dls[0].getAttribute('id'); id = id.substr(3); last_log = id; if(minicache){ setInterval(getMiniSpyCached,15000); }else{ setInterval(getMiniSpy,20000); } } } function initSpy(){ var spy = document.getElementById("spy"); if (spy){ var inputs = document.getElementsByTagName("INPUT"); var cbs = []; //new Array(); var bonus = ""; var oc = function(){ bonus= "" ; spy_bins = ""; for(var i=0; i=0){ e.style.display="block"; el.className="drop up"; el.innerHTML="Dölj mer ▲"; }else{ e.style.display="none"; el.className="drop down"; el.innerHTML="Visa mer ▼"; } return false; } function getCaretPos(obj){ if(obj.selectionStart){ return obj.selectionStart; }else if(document.selection && document.selection.createRange){ obj.focus(); var sel = document.selection.createRange(); var dup = sel.duplicate(); var c = "\001"; sel.text=c; dup.moveToElementText(obj); var pos = dup.text.indexOf(c); sel.moveStart('character',-1); sel.text=""; return pos; }else{ return -1; } } function setSelRange(inputEl, selStart, selEnd){ if (inputEl.setSelectionRange){ inputEl.focus(); inputEl.setSelectionRange(selStart, selEnd); }else if(inputEl.createTextRange){ var range = inputEl.createTextRange(); range.collapse(true); range.moveEnd('character', selEnd); range.moveStart('character', selStart); range.select(); } } function getKey(str,keys){ keys=arr_uniq(keys);//keys.unique(); var matches=[]; //new Array(); for(var i=0; i1){ var common = 0; var tryAnother=true; while(tryAnother){ var chr = matches[0].charAt(common); for(var i=1; i pushad"; if(fbSharePush){ spreadFacebook(response[0],'pushat'); } if(tweetPush){ spreadTwitter(response[0],'pushat'); } } } },"text/html") return false; } function wikiVote(wiki,selected){ if(document.getElementById('wikiItem'+selected).className!='selected'){ ajaxCall("/wikiVote.php",'wiki='+wiki+'&selected='+selected,function(http_request){ if(http_request.responseText!=""){ alreadySelected = getElementsByClass('selected',null,'LI'); if(alreadySelected && alreadySelected.length>0){ alreadySelected[0].className=''; wikiChangeVoteCount(document.getElementById("votes"+alreadySelected[0].id.replace('wikiItem','')),-1); } document.getElementById('wikiItem'+selected).className='selected'; wikiChangeVoteCount(document.getElementById('votes'+selected),1); } },"text/html") } return false; } function wikiChangeVoteCount(votesEl,voteChange){ nrOfVotes = parseInt(votesEl.getAttribute('rel')); nrOfVotes += voteChange; votesEl.setAttribute('rel',nrOfVotes); votesEl.innerHTML = nrOfVotes + ' ' + pluralis(nrOfVotes,'röst','röster'); } function pluralis(count,singular,pluralis){ if(count==1) return singular; return pluralis; } function logout(){ ajaxCall("/loggaut","ajax=true",function(http_request){},"text/html"); } var drop = function(){ this.blur(); var el = document.getElementById(this.getAttribute('rel')); if(el.style.display=="inline"){ el.style.display="none"; }else{ el.style.display="inline"; } drops.push(el); //var old_body_click = document.body.onclick; /*document.body.onclick=function(){ //old_body_click(); document.body.onclick = function(){ closeDrops(); e.style.display="none"; //document.body.onclick=old_body_click; } }*/ document.onclick = function(){ document.onclick=closeDrops; } //stopBubble(el); return false; } function closeDrops(){ for(var i=0; iDölj video'; var hide = function(){ viddiv.style.display = "none"; showvideo.innerHTML = 'Visa video'; showvideo.getElementsByTagName('A')[0].onclick=function(){ viddiv.style.display = "block"; showvideo.innerHTML = 'Dölj video'; showvideo.getElementsByTagName('A')[0].onclick=hide; return false; }; return false; }; showvideo.getElementsByTagName('A')[0].onclick=hide; } },"text/xml"); return false; } function showImage(){ var id = this.getAttribute('rel'); ajaxCall("/getimage.php","id="+id,function(http_request){ if(http_request.responseText!="" && http_request.responseText!="notimage"){ var imgdiv = document.getElementById("image"+id); imgdiv.style.display = "block"; imgdiv.innerHTML = http_request.responseText; var showimage = document.getElementById("show_image"+id); showimage.innerHTML = 'Dölj bild'; var hide = function(){ imgdiv.style.display = "none"; showimage.innerHTML = 'Visa bild'; showimage.getElementsByTagName('A')[0].onclick=function(){ imgdiv.style.display = "block"; showimage.innerHTML = 'Dölj bild'; showimage.getElementsByTagName('A')[0].onclick=hide; return false; }; return false; }; showimage.getElementsByTagName('A')[0].onclick=hide; } },"text/xml"); return false; } function showPoll(){ var id = this.getAttribute('rel'); ajaxCall("/getvideo.php","id="+id,function(http_request){ if(http_request.responseText!="" && http_request.responseText!="notvideo"){ var viddiv = document.getElementById("video"+id); viddiv.style.display = "block"; viddiv.innerHTML = http_request.responseText; var showvideo = document.getElementById("show_video"+id); showvideo.innerHTML = 'Dölj omröstning'; var hide = function(){ viddiv.style.display = "none"; showvideo.innerHTML = 'Visa omröstning'; showvideo.getElementsByTagName('A')[0].onclick=function(){ viddiv.style.display = "block"; showvideo.innerHTML = 'Dölj omröstning'; showvideo.getElementsByTagName('A')[0].onclick=hide; return false; }; return false; }; showvideo.getElementsByTagName('A')[0].onclick=hide; } },"text/xml"); return false; } function showList(){ var id = this.getAttribute('rel'); ajaxCall("/getvideo.php","id="+id,function(http_request){ if(http_request.responseText!="" && http_request.responseText!="notvideo"){ var viddiv = document.getElementById("video"+id); viddiv.style.display = "block"; viddiv.innerHTML = http_request.responseText; var showvideo = document.getElementById("show_video"+id); showvideo.innerHTML = 'Dölj lista'; var hide = function(){ viddiv.style.display = "none"; showvideo.innerHTML = 'Visa lista'; showvideo.getElementsByTagName('A')[0].onclick=function(){ viddiv.style.display = "block"; showvideo.innerHTML = 'Dölj lista'; showvideo.getElementsByTagName('A')[0].onclick=hide; return false; }; return false; }; showvideo.getElementsByTagName('A')[0].onclick=hide; } },"text/xml"); return false; } function showAlbum(){ var id = this.getAttribute('rel'); ajaxCall("/getvideo.php","id="+id,function(http_request){ if(http_request.responseText!="" && http_request.responseText!="notvideo"){ var viddiv = document.getElementById("video"+id); viddiv.style.display = "block"; viddiv.innerHTML = http_request.responseText; var showvideo = document.getElementById("show_video"+id); showvideo.innerHTML = 'Dölj album'; var hide = function(){ viddiv.style.display = "none"; showvideo.innerHTML = 'Visa album'; showvideo.getElementsByTagName('A')[0].onclick=function(){ viddiv.style.display = "block"; showvideo.innerHTML = 'Dölj album'; showvideo.getElementsByTagName('A')[0].onclick=hide; return false; }; return false; }; showvideo.getElementsByTagName('A')[0].onclick=hide; } },"text/xml"); return false; } function report(){ var id = this.getAttribute('rel'); ajaxCall("/report.php","link="+id,function(http_request){ if(http_request.responseText!=""){ var response = http_request.responseText; if (response=="offline"){ login("Logga in för att rapportera!"); }else{ document.getElementById('link'+response).className += " reported"; //document.getElementById('report'+response).className = "report"; document.getElementById('report'+response).innerHTML = ""; document.getElementById('dupereport'+response).innerHTML = ""; } } },"text/html"); return false; } function dupereport(){ var id = this.getAttribute('rel'); ajaxCall("/dupereport.php","link="+id,function(http_request){ if(http_request.responseText!=""){ var response = http_request.responseText; if (response=="offline"){ login("Logga in för att rapportera!"); }else{ document.getElementById('link'+response).className += " reported"; //document.getElementById('report'+response).className = "dupereport"; document.getElementById('report'+response).innerHTML = ""; document.getElementById('dupereport'+response).innerHTML = ""; } } },"text/html"); return false; } function deleteLink(){ var id = this.getAttribute('rel'); ajaxCall("/delete.php","link="+id,function(http_request){ if(http_request.responseText!=""){ var response = http_request.responseText; if (response=="offline"){ login("Logga in för att radera!"); }else{ //document.getElementById('delete'+response).className = "delete"; document.getElementById('link'+response).className += " deleted"; document.getElementById('delete'+response).innerHTML = ""; } } },"text/html"); return false; } function reportComment(){ var q = this.getAttribute('rel'); var id=q.match(/comment=([0-9]+)(.*)?/)[1]; var parent = this.parentNode; ajaxCall("/report_comment.php",q,function(http_request){ if(http_request.responseText!=""){ var response = http_request.responseText; if (response=="offline"){ login("Logga in för att rapportera!"); }else{ document.getElementById('comment-'+id).className += " reported"; parent.innerHTML='Rapporterad'; } } },"text/html"); return false; } function addLinkToTopic(){ var what = this.getAttribute('rel'); var link = what.split(":")[0]; var topic = what.split(":")[1]; var displayName = what.split(":")[2]; ajaxCall("/addLinkToTopic.php","link="+link+"&topic="+topic,function(http_request){ if(http_request.responseText!=""){ var response = http_request.responseText; if (response=="offline"){ login("Logga in för att rapportera!"); }else{ var linkDiv = document.getElementById('link'+link); var linkHtml = linkDiv.innerHTML; var splitHtml = linkHtml.split(" i "); var host = window.location.host.replace(/^([a-z0-9]){1,20}./, ''); linkDiv.innerHTML = splitHtml[0] + ' i ' + displayName + ', ' + splitHtml[1]; initLinks(); } } },"text/html"); this.parentNode.removeChild(this); return false; } function click(id){ ajaxCall("/click.php","link="+id,function(http_request){},"text/html") } function initLinks(holder){ if(typeof holder==undefined) holder = document.getElementById("main"); var pushbuttons = getElementsByClass("push",holder,"p"); for(var i=0; i'; } } shares[i].onmouseover = loadShare; shares[i].onfocus = loadShare; } var trashs = getElementsByClass("trash",holder,"a"); for(var i=0; i'+infoText+'

    '; document.getElementsByTagName('BODY')[0].appendChild(fbreqwin); extras.push(fbreqwin); document.getElementById("fbPostTrue").onclick = function(){ closeExtras(); true_function(); } document.getElementById("fbPostFalse").onclick = function(){ closeExtras(); false_function(); } }else{ fbreqwin.style.display = "block"; } } function showTweetRequest(true_function,false_function,type){ closeExtras(); modularWin(); if(!tweetreqwin){ haveAsked = function(){ if(type=="pushat") tweetPushAsked=true; if(type=="postat") tweetPostAsked=true; if(type=="kommenterat") tweetCommentAsked=true; ajaxCall("/twitter_askedspread.php","verb="+type,function(http_request){},"text/xml"); } tweetreqwin = document.createElement('div'); tweetreqwin.id = "tweetreqwin"; var heading = ""; var infoText = ""; if(type=="postat"){ heading = "Sprid dina länkar på Twitter"; infoText = "

    Vi kan se till att länkarna du postar på Pusha automatiskt postas på Twitter. På så sätt kan du enkelt öka chanserna för att dina länkar ska få fler pushar.

    I dina inställningar här på Pusha kan du ändra ditt val senare om du vill.

    "; }else if(type=="pushat"){ heading = "Sprid dina pushar på Twitter"; infoText = "

    Vi kan se till att länkarna du pushar på Pusha automatiskt postas på Twitter. På så sätt kan du visa dina followers vilka bilder, videor och nyheter du gillar.

    I dina inställningar här på Pusha kan du ändra ditt val senare om du vill.

    "; }else if(type=="kommenterat"){ heading = "Sprid dina kommentarer på Twitter"; infoText = "

    Vi kan se till att länkarna du kommenterar på Pusha automatiskt postas på Twitter. På så sätt kan du tipsa dina followers om diskussionen.

    I dina inställningar här på Pusha kan du ändra ditt val senare om du vill.

    "; } tweetreqwin.innerHTML = '

    Stäng

    '+heading+'

    '+infoText+'

    '; document.getElementsByTagName('BODY')[0].appendChild(tweetreqwin); extras.push(tweetreqwin); document.getElementById("tweetTrue").onclick = function(){ haveAsked(); closeExtras(); true_function(); } document.getElementById("tweetFalse").onclick = function(){ haveAsked(); closeExtras(); false_function(); } }else{ tweetreqwin.style.display = "block"; } } function spreadFacebook(linkid,verb){ var fbSpreadCall = function(){ ajaxCall("/spreadfacebook.php","linkid="+linkid+"&verb="+verb,function(http_request){},"text/xml"); } FB.api("/me/permissions",function(response){ var asked = false; if(verb=="postat") asked = fbSharePostAsked; if(verb=="pushat") asked = fbSharePushAsked; //have we asked and do we have the publish_stream permission? if(asked && response["data"] && response["data"][0] && response["data"][0]["publish_stream"]){ //yes we have publish_stream and we have asked fbSpreadCall(); }else{ //no we don't have publish_stream or we havn't asked showFbPostRequest( function(){ FB.login(function(response) { if (response.authResponse) { // we got a positive response fbSpreadCall(); } }, {scope: 'publish_stream'}); }, function(){ ajaxCall("/fb_turnoffspread.php","verb="+verb,function(http_request){},"text/xml"); fbSharePush=false; }, verb ); } }); } function spreadTwitter(linkid,verb,anchor){ if(typeof anchor==='undefined') anchor=""; var spreadCall = function(){ ajaxCall("/spreadtwitter.php","linkid="+linkid+"&verb="+verb+"&anchor="+anchor,function(http_request){},"text/xml"); } var asked = false; var doit = false; if(verb=="postat"){ asked = tweetPostAsked; doit = tweetPost; }else if(verb=="pushat"){ asked = tweetPushAsked; doit = tweetPush; }else if(verb=="kommenterat"){ asked = tweetCommentAsked; doit = tweetComment; } if(asked){ if(doit){ spreadCall(); } }else{ showTweetRequest( spreadCall, function(){ ajaxCall("/twitter_turnoffspread.php","verb="+verb,function(http_request){},"text/xml"); if(verb=="postat") tweetPost=false; if(verb=="pushat") tweetPush=false; if(verb=="kommenterat") tweetComment=false; }, verb ); } } function showRegister(){ if(isIE6) return true; closeExtras(); modularWin(); if(!regwin){ regwin = document.createElement('div'); regwin.id = "regwin"; extra_message = '
    Om du har ett konto på Facebook kan du enkelt logga in via det utan att skapa ett konto på Pusha, klicka bara på knappen nedan.

    '; regwin.innerHTML = '

    Stäng

    Bli medlem

    '+extra_message+'

    Acceptera vårt användaravtal.

    '; document.getElementsByTagName('BODY')[0].appendChild(regwin); extras.push(regwin); //parseFbml(); }else{ regwin.style.display = "block"; } document.register.username.focus(); //document.getElementById("username").focus(); return false; } /* function showLogin(){ showLogin("",""); } function showLogin(message){ showLogin(message,""); } */ function showLogin(message,ref){ if(typeof message === 'undefined') message=""; if(typeof ref === 'undefined') ref=""; if(isIE6) return true; closeExtras(); modularWin(); if(!loginwin){ loginwin = document.createElement('div'); loginwin.id = "loginwin"; var whole=""; if(typeof message!="string") message=""; var extra_title = ""; var extra_message = ""; if(message!=""){ extra_title = " för att pusha"; extra_message = '

    Ny på Pusha? Bli medlem gratis eller logga in med ditt Facebook- eller Twitter-konto.

    '; } if(typeof ref!="string") ref=""; if(ref==""){ whole = ''; }else{ ref = ''; } var fullhtml = '

    Stäng

    Logga in'+extra_title+'

    '+extra_message+''+ref+whole+'

    Kom ihåg mig | Glömt ditt lösenord?

    '; loginwin.innerHTML = fullhtml; document.getElementsByTagName('BODY')[0].appendChild(loginwin); extras.push(loginwin); //parseFbml(); }else{ loginwin.style.display = "block"; } if(document.login.username) document.login.username.focus(); //document.getElementById("username").focus(); return false; } function initModular(){ var login = document.getElementById("login"); if(login) login.onclick = showLogin; var register = document.getElementById("signup"); if(register) register.onclick = showRegister; var submit = document.getElementById("post"); var online = document.getElementById("logout"); if(submit && !online) submit.onclick=function(){return showLogin('

    Logga in för posta länkar!

    Eller bli medlem gratis om du inte redan är det.

    ','/posta');}; } function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } function getElementsByClass(className,node,tag) { var classElements = new Array(); if (node == null) node = document; if (tag == null) tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; for(var i=0, j=0; i-1){ classElements[j] = els[i]; j++; } } return classElements; } function getMiniSpyCached(){ sc = document.getElementById("getminiscript"); if(sc){ document.body.removeChild(sc) } var script = document.createElement("script"); script.setAttribute("src","http://cache.pusha.se/"+instance_prefix+"minispy?nocache="+Math.random()); script.setAttribute("type","text/javascript"); script.setAttribute("id","getminiscript"); document.body.appendChild(script); } function gotMiniSpy(logs){ newlogs = []; for(var i=0; ilast_log){ newlogs.push(logs.logs[i]); } } addMini(newlogs); } function addMini(logs){ if(logs.length>0){ var log = logs.pop(); loghtml = '
    '; loghtml += '
    '+log.avatar+''; loghtml += '
    '+log.title+'
    '; loghtml += '
    '+log.action+' av '+log.username+'
    '; loghtml += '
    '; minispy.innerHTML = loghtml + minispy.innerHTML; var dls = minispy.getElementsByTagName("DL"); minispy.removeChild(dls[dls.length-1]); //parseFbml(); last_log=log.id; setTimeout(function(){addMini(logs)},500); } } function NewTips(){} NewTips.init = function(){ NewTips.layer = document.getElementById("newtips"); if(NewTips.layer){ NewTips.container = document.getElementById("newtipcontainer"); document.getElementById("yeslink").onclick=NewTips.yes; document.getElementById("nolink").onclick=NewTips.no; //NewTips.test(); NewTips.dupes = new Array(); NewTips.dupes[0] = parseInt(document.getElementById("newtiplink").rel); ajaxCall("/get_newtips.php","",function(http_request){ if(http_request.responseText!=""){ NewTips.links = eval('(' + http_request.responseText + ')'); //alert(NewTips.links[0].title); } },"text/html"); } } NewTips.scrollTo = function(target,callback){ if(parseInt(NewTips.layer.style.top)!=target){ var curr = (NewTips.layer.style.top=="")? 0 : parseInt(NewTips.layer.style.top); var dist = curr-target; NewTips.layer.style.top = (curr-Math.ceil(dist/5.0))+"px"; setTimeout('NewTips.scrollTo('+target+','+callback+')',10); }else{ if(target!=0){ NewTips.layer.style.top = "50px"; callback(); NewTips.scrollTo(0,callback); } } } NewTips.next = function(){ NewTips.scrollTo(-50,function(){ NewTips.dupes.push(parseInt(document.getElementById("newtiplink").rel)); var newLink = NewTips.links.shift(); while (newLink!=null && NewTips.dupes.indexOf(newLink.id)>=0){ newLink = NewTips.links.shift(); } if(newLink==null){ //no more links NewTips.layer.innerHTML = '
    Inga fler nya länkar'; setTimeout('NewTips.close()',1000); }else{ //switch link document.getElementById("newtiplink").innerHTML = newLink.title; document.getElementById("newtiplink").href = (frameLinks)? newLink.frameUrl : newLink.url; document.getElementById("newtiplink").rel = newLink.id; document.getElementById("newtiplink").title = newLink.url; //alert("old: "+document.getElementById("yeslink").rel); document.getElementById("yeslink").rel = "h="+newLink.h+"&link="+newLink.id; document.getElementById("nolink").rel = "h="+newLink.h+"&link="+newLink.id; document.getElementById("newtipcomment").href = newLink.permaUrl; document.getElementById("newtipcomment").innerHTML = "("+((newLink.nrOfComments==0)? "Kommentera)" : newLink.nrOfComments+" kommentar"+((newLink.nrOfComments==1)? ")" : "er)")); //alert("new: "+document.getElementById("yeslink").rel); } }); } NewTips.test = function(){ setInterval('NewTips.next()',4000); } NewTips.close = function(){ if(NewTips.container.style.display!="none"){ if(parseInt(NewTips.container.style.height)>0||NewTips.container.style.height==""){ if(NewTips.container.style.height==""){ NewTips.container.style.display="block"; NewTips.container.style.height="30px"; }else{ NewTips.container.style.height=(parseInt(NewTips.container.style.height)-2)+"px"; } setTimeout('NewTips.close()',10); }else{ NewTips.container.style.height="0"; NewTips.container.style.display="none"; } } } NewTips.yes = function(){ //alert(this.rel); ajaxCall("/save.php",this.rel,function(http_request){ if(http_request.responseText!=""){ if (http_request.responseText=="offline"){ login("pusha"); }else if(http_request.responseText=="notallowed"){ //alert("Något gick fel, prova att ladda om sidan"); }else{ var response = http_request.responseText.split(" "); if(fbSharePush){ spreadFacebook(response[0],'pushat'); } } } },"text/html"); NewTips.next(); return false; } NewTips.no = function(){ //alert("no"); ajaxCall("/no.php",this.rel,function(http_request){ if(http_request.responseText!=""){ if (http_request.responseText=="offline"){ login("pusha"); }else if(http_request.responseText=="notallowed"){ alert("fel: "+http_request.responseText); }else{ //noed } } },"text/html"); NewTips.next(); return false; } function TabComplete(trigger,triggerMatch,words,textbox){ this.trigger = trigger; this.triggerMatch = triggerMatch; this.words = words; this.textbox = textbox; this.active = false; this.lastPos = 0; this.last = 0; this.currArr = null; this.complete = function(){ var end = getCaretPos(textbox); var startStr = textbox.value.substr(0,end); var userMatch = startStr.match(this.triggerMatch); // /(.*?)@([a-zA-Z0-9_]{0,15})$/ if(userMatch){ if(this.active && end==this.lastPos){ var oldm = new RegExp((this.trigger+this.currArr[this.last]+"$").replace(/\+/g,"\\+"),"i"); startStr = startStr.replace(oldm,""); this.last++; if(this.last>=this.currArr.length) this.last=0; startStr += this.trigger+this.currArr[this.last]; textbox.value = startStr + textbox.value.substring(end); var pos = startStr.length; this.lastPos = pos; setSelRange(textbox,pos,pos); TabComplete.fixFirefoxCarretPos(); }else{ var matchingUsers = TabComplete.getMatching(userMatch[2],this.words); if(matchingUsers.length>0){ var oldm = new RegExp(this.trigger+userMatch[2]+"$","i"); startStr = startStr.replace(oldm,""); startStr += this.trigger+matchingUsers[0]; this.active = true; this.last = 0; this.currArr = matchingUsers; textbox.value = startStr + textbox.value.substring(end); var pos = startStr.length; this.lastPos = pos; setSelRange(textbox,pos,pos); TabComplete.fixFirefoxCarretPos(); } } } } this.deactivate = function(){ this.active = false; } TabComplete.getMatching = function(str,arr){ if(str.length==0) return arr; var matches=[]; //new Array(); for(var i=0; i1; this.currLink = -1; this.inited=true; } PushKeys.next = function(){ if(PushKeys.inited!=true) PushKeys.init(); if(PushKeys.enableJumping){ if(PushKeys.currLink=PushKeys.links.length){ PushKeys.nextPage(); }else{ PushKeys.highlight(); scrollToElement(PushKeys.links[PushKeys.currLink]); } } } } PushKeys.prev = function(){ if(PushKeys.inited!=true) PushKeys.init(); if(PushKeys.enableJumping){ if(PushKeys.currLink>-1){ PushKeys.clear(); PushKeys.currLink--; if(PushKeys.currLink<0){ PushKeys.prevPage(); }else{ PushKeys.highlight(); scrollToElement(PushKeys.links[PushKeys.currLink]); } } } } PushKeys.nextPage = function(){ var paging = document.getElementById("paging"); if(paging){ var pages = paging.getElementsByTagName("A"); for(var i=0; i=0){ if(i+1=0){ if(i>0){ window.location=pages[i-1].href; } } } } } PushKeys.clear = function(){ if(PushKeys.currLink>-1&&PushKeys.currLink0) pushLinks[0].onclick(); } } PushKeys.visit = function(){ if(PushKeys.inited!=true) PushKeys.init(); if(PushKeys.currLink!=-1){ var visitLinks = PushKeys.links[PushKeys.currLink].getElementsByTagName('A'); if(visitLinks.length>0){ visitLinks[0].onclick(); if(visitLinks[0].target=="_blank"){ newwindow=window.open(visitLinks[0].href); }else{ window.location = visitLinks[0].href; } } } } PushKeys.view = function(){ if(PushKeys.inited!=true) PushKeys.init(); if(PushKeys.currLink!=-1){ var viewLinks = document.getElementById(PushKeys.links[PushKeys.currLink].id.replace("link","comments")).getElementsByTagName('A'); if(viewLinks.length>0){ window.location = viewLinks[0].href; } } } PushKeys.expand = function(){ if(PushKeys.inited!=true) PushKeys.init(); if(PushKeys.currLink!=-1){ var expandLi = document.getElementById(PushKeys.links[PushKeys.currLink].id.replace("link","show_video")); if(!expandLi) expandLi = document.getElementById(PushKeys.links[PushKeys.currLink].id.replace("link","show_image")); if(expandLi){ var expandLinks = expandLi.getElementsByTagName('A'); if(expandLinks.length>0){ expandLinks[0].onclick(); } } } } PushKeys.info = function(){ if(!PushKeys.infoActive){ PushKeys.infoActive=true; if(isIE6) return true; closeExtras(); modularWin(); if(!PushKeys.infoWin){ PushKeys.infoWin = document.createElement('div'); PushKeys.infoWin.id = "hotkeywin"; var fullhtml = '

    Stäng

    Kortkommandon

    Du kan använda tangentbordet för att navigera på Pusha snabbare.

    • ? - visa/dölj kortkommandon (denna ruta)
    • j - nästa länk
    • k - föregående länk
    • p - pusha länk
    • b - besök länk
    • v - visa inbäddat innehåll
    • Enter - gör till permalänk (kommentarer)
    '; PushKeys.infoWin.innerHTML = fullhtml; document.getElementsByTagName('BODY')[0].appendChild(PushKeys.infoWin); extras.push(PushKeys.infoWin); //parseFbml(); }else{ PushKeys.infoWin.style.display = "block"; } }else{ closeExtras(); PushKeys.infoActive=false; } return false; } function initPushaKeys(){ if(useHotkeys){ HotKey.addChar("?",PushKeys.info); HotKey.addChar("K",PushKeys.prev); HotKey.addChar("J",PushKeys.next); HotKey.addChar("P",PushKeys.push); HotKey.addKey(13,PushKeys.view); HotKey.addChar("B",PushKeys.visit); HotKey.addChar("V",PushKeys.expand); } } addLoadEvent(initSearch); addLoadEvent(initLinks); addLoadEvent(initSubNav); addLoadEvent(initMiniSpy); addLoadEvent(initSpy); addLoadEvent(initModular); addLoadEvent(initAds); addLoadEvent(initSponsoredLink); addLoadEvent(NewTips.init); addLoadEvent(HotKey.init); addLoadEvent(initPushaKeys); jQuery(document).ready(function($) { var online = document.getElementById("logout"); if(online){ var getNewNotifications = function(){ var last = $('ul.notifications li.notification').length>0? $('ul.notifications li.notification').first().attr('id').replace('notification','') : 0; $.ajax({ url:"/get_new_notifications.php?last="+last }).done(function(msg){ if(msg!=null && msg!=''){ $('ul.notifications li.empty').slideUp(); $(msg).hide().prependTo('ul.notifications').slideDown(); $('a.notifications').removeClass('on').addClass('on'); } }).fail(function(){ }); }; var notificationsPoller = setInterval(getNewNotifications,30000); } $('a.notifications').click(function(){ $('ul.notifications').fadeToggle('fast', function(){ if($('ul.notifications').is(':visible')){ $('a.notifications').removeClass('on').addClass('on'); }else{ $('a.notifications').removeClass('on'); //$('ul.notifications li.new').removeClass('new'); } }); if($('ul.notifications li.notification').length>0){ $.ajax({ url:"/seen_notifications.php?last="+$('ul.notifications li.notification').first().attr('id').replace('notification','') }); } return false; }); $(document).mouseup(function (e){ var container = $('.notifications'); if (!$('.notifications').is(e.target) && $('.notifications').has(e.target).length === 0){ if($('ul.notifications').is(':visible')){ $('ul.notifications').fadeOut('fast'); $('a.notifications').removeClass('on'); //$('ul.notifications li.new').removeClass('new'); } } }); var initFollow = function(elements){ elements.click(function(){ var userToFollow = this.id.replace("follow",""); $.ajax({ url:"/user_follow.php?userToFollow="+userToFollow }).done(function(msg){ var matches = msg.match(/following ([0-9]+)/); if(matches){ $('#follow'+matches[1]).removeClass("startFollowing").addClass("following"); $('#follow'+matches[1]).html("Följer"); $('#follow'+matches[1]).unbind('mouseover mouseout click'); $('#followerCount'+matches[1]).html(parseInt($('#followerCount'+matches[1]).html())+1); initUnfollow($('#follow'+matches[1])); }else{ alert(msg); } }).fail(function(){ }); return false; }); } var initUnfollow = function(elements){ elements.mouseover(function(){ $(this).html("Sluta följa"); }); elements.mouseout(function(){ $(this).html("Följer"); }); elements.click(function(){ var userToFollow = this.id.replace("follow",""); $.ajax({ url:"/user_unfollow.php?userToUnfollow="+userToFollow }).done(function(msg){ var matches = msg.match(/unfollowed ([0-9]+)/); if(matches){ $('#follow'+matches[1]).removeClass("following").addClass("startFollowing"); $('#follow'+matches[1]).html("Börja följa"); $('#follow'+matches[1]).unbind('mouseover mouseout click'); $('#followerCount'+matches[1]).html(parseInt($('#followerCount'+matches[1]).html())-1); initFollow($('#follow'+matches[1])); }else{ alert('unexpected: '+msg); } }).fail(function(){ }); return false; }); } initFollow($('.startFollowing')); initUnfollow($('.following')); $('button.close').click(function(el){ console.log(el); $(this).parent().fadeOut(); console.log($(this).parent().attr('data-tag')); if($(this).parent().attr('data-tag')!=undefined){ $.ajax({ url:"/close_alert.php?tag="+$(this).parent().attr('data-tag') }).done(function(msg){ }); } }); });