Adicionar mais categorias no código

3 participantes

Ver o tópico anterior Ver o tópico seguinte Ir para baixo

Tópico resolvido Adicionar mais categorias no código

Mensagem por IsmaelS. 15/08/16, 06:30 am

Detalhes da questão


Endereço do fórum: http://suportedesign.forumeiros.com/
Versão do fórum: PunBB

Descrição


Olá!

Estou a usar um .jS que a funcionalidade é pré-visualizar uma imagem dos tópicos específicos, só que eu queria adicionar mais categorias e não estou a conseguir apenas consegui uma, o código é este:
Código:
var a = "/f57-fontes"; var x = window.location.pathname;
if (x == a) {jQuery(function(){var sCSS='<style>'+'.bim_mainThumb {'+'opacity: 1;'+'visibility: visible;'+'max-width: none;'+'max-height: none;'+'width: 70%;'+'height: 70%;'+'display: block;'+'image-rendering: auto'+'}'+'.bim_thumbPreview {'+'float: right;'+'position: relative;'+'left: -20px;'+'margin-right: 20px;'+'z-index: 0;'+'overflow: hidden;'+'}'+'.bim_img_container {'+'height: 64px;'+'width: 128px;'+'}'+'.bim_thumbPreview span {'+'box-shadow: 0 6px 6px rgba(0, 0, 0, 0.5);'+'margin-left: 84px;'+'margin-top: -68px;'+'position: absolute;'+'visibility: hidden;'+'z-index: 2500;'+'}'+'.bim_thumbPreview:hover span {'+'z-index: 2500;'+'visibility: visible;'+'position: fixed;'+'top: 25%;'+'left: 45%;'+'padding: 25px;'+'box-shadow: inset 0 3px 5px 5px #111, 0 3px 5px 1px #010101;'+'background-color: #090909'+'}'+'.bim_thumbPreview span img {'+'border: none;'+'max-width: 300px;'+'}'+'</style>';document.head.insertAdjacentHTML('beforeEnd',sCSS);var sHtml='<a class="bim_thumbPreview">'+'<div style="padding: 1px; border: 1px solid #d5d5d5;">'+'<div class="thumbIMG">'+'<div class="bim_img_container" style="overflow: hidden; background-image: none;">'+'<img src="http://2img.net/i/fa/empty.gif" class="bim_mainThumb">'+'</div>'+'</div>'+'</div>'+'<span class="previewIMG"><img src="http://s5.postimg.org/tlg9puyjn/no_prev.png"></span>'+'</a>';var oTarget=0,sFound='td:eq(2)',sInsert='',sCommon='a.topictitle',sOverflow='auto',sGetIMG='';var phpBB2=jQuery('.three-col td:eq(1) > table.forumline:last tbody tr:not(":empty")');var phpBB3=jQuery('.topiclist.topics.bg_none li:not(":empty")');var punbb=jQuery('.statused tr:not(":empty")');var invision=jQuery('.borderwrap table.ipbtable tbody tr:not(":empty")');if(phpBB2.length){oTarget=phpBB2;sInsert='div.topictitle';sGetIMG='.postbody:first div:eq(0) img'}else if(phpBB3.length){oTarget=phpBB3;sFound='dd.dterm';sInsert='div.topic-title-container';sOverflow='inherit';sGetIMG='.postbody:first .content img'}else if(punbb.length){oTarget=punbb;sFound='.tcl.tdtopics';sInsert='span.status';sGetIMG='.entry-content:first img'}else if(invision.length){oTarget=invision;sInsert=sCommon;sGetIMG='.post-entry:first img'};oTarget.each(function(index){var oFound=jQuery(this).find(sFound);if(oFound.length){var oInsert=oFound.find(sInsert);var sUrl=oFound.find(sCommon).attr('href');var ID='Udyat_'+index;oFound.attr('id',ID);oFound.css('overflow',sOverflow);jQuery(sHtml).insertAfter(oInsert);var elem=document.getElementById(ID);if(isInViewPort(elem)){jQuery.get(sUrl,function(data){var oImg=jQuery(sGetIMG,data);var sImg='';if(oImg!==undefined){sImg=oImg.attr('src');if(sImg!==undefined){oFound.find('.bim_img_container img').attr('src',sImg);oFound.find('.previewIMG img').attr('src',sImg)}else{oFound.find('.bim_img_container img').attr('src','http://s5.postimg.org/tlg9puyjn/no_prev.png')}}})}else{jQuery(window).on('scroll.'+sUrl,showImage(sUrl,elem,oFound,sGetIMG))}}})});function isInViewPort(elem){var rect=elem.getBoundingClientRect();return(rect.top>=0&&rect.left>=0&&rect.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&rect.right<=(window.innerWidth||document.documentElement.clientWidth))}function showImage(event,elem,oBject,sString){return function(){if(isInViewPort(elem)){jQuery(window).off('scroll.'+event);jQuery.get(event,function(data){var oImg=jQuery(sString,data);var sImg='';if(oImg!==undefined){sImg=oImg.attr('src');if(sImg!==undefined){oBject.find('.bim_img_container img').attr('src',sImg);oBject.find('.previewIMG img').attr('src',sImg)}else{oBject.find('.bim_img_container img').attr('src','http://s5.postimg.org/tlg9puyjn/no_prev.png')}}})}}}
}else {
  console.log('Não foi possível carregar a pré-visualização');
}

No ínicio do código está "/f57-fontes"; e queria adicionar mais categorias é possível? As categorias são estas: http://suportedesign.forumeiros.com/f45-recursos-graficos


Última edição por IsmaelS. em 15/08/16, 07:04 am, editado 1 vez(es)
avatar

IsmaelS.
Hiper Membro

Membro desde : 24/11/2012
Mensagens : 2994
Pontos : 4142

http://suporte-design.forumeiros.com/

Ir para o topo Ir para baixo

  • 0

Tópico resolvido Re: Adicionar mais categorias no código

Mensagem por while 15/08/16, 06:56 am

Olá, vamos por passos ok?
vamos ter que criar uma nova variável, ela se chamará Y , está vendo essa linha?
if (x == a)
Deixaremos assim:
if (x === a || x === y )

E em cima aqui:
var a = "/f57-fontes"; var x = window.location.pathname;
Trocaremos por isto:
var a = "/f71-renders-stocks";
var y = "/f45-recursos-graficos";
var x = window.location.pathname;

Simples não?
Ficaria assim o código já pronto:

Código:
var a = "/f71-renders-stocks";
var y = "/f45-recursos-graficos";
var x = window.location.pathname;
if (x === a || x === y ) {jQuery(function(){var sCSS='<style>'+'.bim_mainThumb {'+'opacity: 1;'+'visibility: visible;'+'max-width: none;'+'max-height: none;'+'width: 70%;'+'height: 70%;'+'display: block;'+'image-rendering: auto'+'}'+'.bim_thumbPreview {'+'float: right;'+'position: relative;'+'left: -20px;'+'margin-right: 20px;'+'z-index: 0;'+'overflow: hidden;'+'}'+'.bim_img_container {'+'height: 64px;'+'width: 128px;'+'}'+'.bim_thumbPreview span {'+'box-shadow: 0 6px 6px rgba(0, 0, 0, 0.5);'+'margin-left: 84px;'+'margin-top: -68px;'+'position: absolute;'+'visibility: hidden;'+'z-index: 2500;'+'}'+'.bim_thumbPreview:hover span {'+'z-index: 2500;'+'visibility: visible;'+'position: fixed;'+'top: 25%;'+'left: 45%;'+'padding: 25px;'+'box-shadow: inset 0 3px 5px 5px #111, 0 3px 5px 1px #010101;'+'background-color: #090909'+'}'+'.bim_thumbPreview span img {'+'border: none;'+'max-width: 300px;'+'}'+'</style>';document.head.insertAdjacentHTML('beforeEnd',sCSS);var sHtml='<a class="bim_thumbPreview">'+'<div style="padding: 1px; border: 1px solid #d5d5d5;">'+'<div class="thumbIMG">'+'<div class="bim_img_container" style="overflow: hidden; background-image: none;">'+'<img src="http://2img.net/i/fa/empty.gif" class="bim_mainThumb">'+'</div>'+'</div>'+'</div>'+'<span class="previewIMG"><img src="http://s5.postimg.org/tlg9puyjn/no_prev.png"></span>'+'</a>';var oTarget=0,sFound='td:eq(2)',sInsert='',sCommon='a.topictitle',sOverflow='auto',sGetIMG='';var phpBB2=jQuery('.three-col td:eq(1) > table.forumline:last tbody tr:not(":empty")');var phpBB3=jQuery('.topiclist.topics.bg_none li:not(":empty")');var punbb=jQuery('.statused tr:not(":empty")');var invision=jQuery('.borderwrap table.ipbtable tbody tr:not(":empty")');if(phpBB2.length){oTarget=phpBB2;sInsert='div.topictitle';sGetIMG='.postbody:first div:eq(0) img'}else if(phpBB3.length){oTarget=phpBB3;sFound='dd.dterm';sInsert='div.topic-title-container';sOverflow='inherit';sGetIMG='.postbody:first .content img'}else if(punbb.length){oTarget=punbb;sFound='.tcl.tdtopics';sInsert='span.status';sGetIMG='.entry-content:first img'}else if(invision.length){oTarget=invision;sInsert=sCommon;sGetIMG='.post-entry:first img'};oTarget.each(function(index){var oFound=jQuery(this).find(sFound);if(oFound.length){var oInsert=oFound.find(sInsert);var sUrl=oFound.find(sCommon).attr('href');var ID='Udyat_'+index;oFound.attr('id',ID);oFound.css('overflow',sOverflow);jQuery(sHtml).insertAfter(oInsert);var elem=document.getElementById(ID);if(isInViewPort(elem)){jQuery.get(sUrl,function(data){var oImg=jQuery(sGetIMG,data);var sImg='';if(oImg!==undefined){sImg=oImg.attr('src');if(sImg!==undefined){oFound.find('.bim_img_container img').attr('src',sImg);oFound.find('.previewIMG img').attr('src',sImg)}else{oFound.find('.bim_img_container img').attr('src','http://s5.postimg.org/tlg9puyjn/no_prev.png')}}})}else{jQuery(window).on('scroll.'+sUrl,showImage(sUrl,elem,oFound,sGetIMG))}}})});function isInViewPort(elem){var rect=elem.getBoundingClientRect();return(rect.top>=0&&rect.left>=0&&rect.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&rect.right<=(window.innerWidth||document.documentElement.clientWidth))}function showImage(event,elem,oBject,sString){return function(){if(isInViewPort(elem)){jQuery(window).off('scroll.'+event);jQuery.get(event,function(data){var oImg=jQuery(sString,data);var sImg='';if(oImg!==undefined){sImg=oImg.attr('src');if(sImg!==undefined){oBject.find('.bim_img_container img').attr('src',sImg);oBject.find('.previewIMG img').attr('src',sImg)}else{oBject.find('.bim_img_container img').attr('src','http://s5.postimg.org/tlg9puyjn/no_prev.png')}}})}}}
}else {
  console.log('Não foi possível carregar a pré-visualização');
}

Até mais.
while

while
Hiper Membro

Membro desde : 24/04/2016
Mensagens : 3263
Pontos : 4761

http://www.ajuda.forumeiros.com https://www.facebook.com/profile.php?id=100012157981279

Ir para o topo Ir para baixo

Tópico resolvido Re: Adicionar mais categorias no código

Mensagem por IsmaelS. 15/08/16, 07:07 am

Resultou amigo e obrigado por explicar o processo! Piscada
avatar

IsmaelS.
Hiper Membro

Membro desde : 24/11/2012
Mensagens : 2994
Pontos : 4142

http://suporte-design.forumeiros.com/

Ir para o topo Ir para baixo

Ajudeiro

Tópico resolvido Re: Adicionar mais categorias no código

Mensagem por Fraise 15/08/16, 07:46 am

Questão marcada como Resolvida ou o Autor solicitou que ela fosse arquivada.
Tópico marcado como Resolvido e movido para Questões resolvidas.
Fraise

Fraise
Ajudeiro
Ajudeiro

Membro desde : 26/06/2015
Mensagens : 6558
Pontos : 8045

https://ajuda.forumeiros.com/ https://twitter.com/@FraiseFdF

Ir para o topo Ir para baixo

Ver o tópico anterior Ver o tópico seguinte Ir para o topo


Permissões neste sub-fórum
Não podes responder a tópicos