Anonymous Anonymous - 3 months ago
245 0

No description

Javascript

old code

doc = document;
getChatLine = doc.getElementById('chatline');
getChatWrap = doc.getElementById('chatwrap');

var x = CHANNEL.emotes
var smiles = [];

for (i=0; i<x.length; i++)
{
  smiles.push(x[i].name + ' ');
  smiles.push('<img src="' + x[i].image + '" /> ');
  }


function PastSmile(Smile){
  getChatLine.value += Smile;
  hidesmiles();
  getChatLine.focus();
}




if (SmilesUI == null){
  var SmilesUI = doc.createElement('div');
  SmilesUI.id = 'smilesui';
  SmilesUI.style.background = "rgba(0,0,0,0.7)";
  SmilesUI.style.border = "solid 1px #aaaaaa";
  SmilesUI.style.borderRadius = "5px";
  SmilesUI.style.display = "none";
  SmilesUI.style.position = "absolute";
  var chatwidth = $("#chatwrap").width();
  SmilesUI.style.width = chatwidth+'px';
  SmilesUI.style.color = "#fff";
  SmilesUI.style.textAlign = "center";
  SmilesUI.innerHTML = "";
 
  for (var i=0; i<smiles.length; i =i+2)
  {
    SmilesUI.innerHTML += "<span onclick='PastSmile(\" \" + smiles[" + i + "] + \" \")'/>" + smiles[i+1] + "</span>";
  }
  getChatWrap.appendChild(SmilesUI);
}

if (SmilesButton == null){
  var SmilesButton = doc.createElement('div');
  SmilesButton.className = 'btn';
  SmilesButton.setAttribute("onClick",'showsmiles();');
  SmilesButton.innerHTML = "Смайлы";
  getChatWrap.appendChild(SmilesButton);
}

function showsmiles(){
  SmilesUI.style.display = "block";
  SmilesButton.innerHTML = "СмайлыŒ";
  SmilesButton.setAttribute("onClick","hidesmiles();");
}

function hidesmiles(){
  SmilesUI.style.display = "none";
  SmilesButton.innerHTML = "Смайлы‹";
  SmilesButton.setAttribute("onClick","showsmiles();");
}