Skip to content

Instantly share code, notes, and snippets.

@gastonsoto
Created February 20, 2020 13:11
Show Gist options
  • Save gastonsoto/1e51f4715b9f5419a83e31819956772c to your computer and use it in GitHub Desktop.
Save gastonsoto/1e51f4715b9f5419a83e31819956772c to your computer and use it in GitHub Desktop.
function leptonOptiShow(targetIframe="leptonIframeContainer",targetComponent="") {
var optiContainer = document.getElementById(targetIframe);
optiContainer.classList.add("opti-on");
var newURL = "https://optionline-dev.herokuapp.com/empresa/mariano/opti?access_token=anGteR_zuBLkJDQMHwyk&refresh=true&id_msg=" + targetComponent;
document.getElementById("myIframe").src = newURL
@gastonsoto
Copy link
Author

gastonsoto commented Feb 20, 2020

El código completo de lo que se incrustaría dentro del cliente podría ser (basado en el código de arriba):

<style>.opti-on {display:show} .opti-off {display:none}</style>

function init(i,ic,co,re,s){
    var optiFrame = document.getElementById(i);
    var optiContainer = document.getElementById(ic);
    var optiURL = "https://optionline-dev.herokuapp.com/empresa/mariano/opti?access_token=anGteR_zuBLkJDQMHwyk"
    
    optiFrame.src =  optiURL + "?refresh=" + re + "&id_msg=" + co;
    
    if(s){
        optiContainer.classList.add("opti-on");
    } else {
       optiContainer.classList.remove("opti-on");       
    }
}

init("myIframe","myIframeComponent","INDEX",false,false)

Y el código de cada botón:

<a onClick="init("myIframe","myIframeComponent","VER_PROYECTOS",true,true)">Ver Proyectos</a>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment