Skip to content

Instantly share code, notes, and snippets.

@marti1125
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marti1125/9c3ea92a23ef10899eb4 to your computer and use it in GitHub Desktop.
Save marti1125/9c3ea92a23ef10899eb4 to your computer and use it in GitHub Desktop.
ceci-channel-menu
changeChannel : function(handlerType, handler ,color){
//alert(handler)
var visEl = this.component.querySelector("ceci-"+this.channelType+"["+handlerType+"=\""+handler+"\"]");
if (color == "false"){
if (visEl){
visEl.parentNode.removeChild(visEl);
}
} else {
// If it exists
if (visEl){
visEl.setAttribute("on",color);
} else {
var newEl = document.createElement("ceci-" + this.channelType);
newEl.setAttribute("on",color);
newEl.setAttribute(handlerType,handler);
this.component.appendChild(newEl);
var visLines = document.getElementById("visLines");
var sub = visLines.querySelector('[for="sendMessage"]');
sub.setAttribute("data-val","1");
if(handler == 'clear'){
sub.setAttribute("data-val","1");
console.log("hereeeeeeee")
var visLines2 = document.getElementById("visLines");
var clear = visLines2.querySelector('[for="clear"]');
clear.setAttribute("data-val","2");
}
if(handler == 'set_room'){
var set_room = visLines.querySelector('[for="set_room"]');
set_room.setAttribute("data-val","3");
}
if(handler == 'set_username'){
var set_username = visLines.querySelector('[for="set_username"]');
set_username.setAttribute("data-val","4");
}
}
}
this.dispatchEvent(new CustomEvent('channelUpdated', {name: name, bubbles: true, detail: this}));
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment