Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>emote</title>
- </head>
- <body>
- <div id="emotes">
- <h1>EMOTES:</h1>
- </div>
- <div id="chosen">
- <h1>CHOSEN:</h1>
- </div>
- <div id="testMote">
- </div>
- <button id="d1">Drop 1</button>
- <button id="d5">Drop 5</button>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
- <script src="http://cdn.tmijs.org/js/1.1.2/tmi.min.js"></script>
- <script>
- var options = {
- options: {
- debug: false
- },
- connection: {
- cluster: "aws",
- reconnect: true
- },
- identity: {
- username: <username>,
- password: <oauth including oauth:>
- },
- channels: ["channel1", "channel2", "channel3", etc]
- };
- var client = new tmi.client(options);
- client.connect();
- var chosen = [];
- var queue = [];
- $.getJSON('https://api.twitch.tv/kraken/chat/summit1g/emoticons?client_id=jucl44orsw1z6t0io4yhkrm84lra4n', function(data) {
- for(i = 0; i < data.emoticons.length; i++){
- if(data.emoticons[i].subscriber_only){
- //console.log(data.emoticons[i].url);
- var id = data.emoticons[i].url.split("-")[2];
- if(! isNaN(id)){
- link = "https://static-cdn.jtvnw.net/emoticons/v1/"+id+"/2.0"
- $("#emotes").append("<image id='"+id+"' class='emote' src='"+link+"'></image>");
- }
- }
- }
- fixRows();
- $(".emote").click(function(){
- if($(this).parents('#emotes').length > 0) {
- $(this).appendTo("#chosen");
- chosen.push($(this)[0].id);
- console.log(chosen);
- }else{
- $(this).appendTo("#emotes");
- chosen.splice(chosen.indexOf($(this)[0].id), 1);
- }
- fixRows();
- })
- function fixRows(){
- $('#emotes br').remove();
- for(i = 0; i < $("#emotes").children('.emote').length; i++){
- if((i+1) % 5 == 0){
- $( "<br>" ).insertAfter( $("#emotes").children('.emote')[i] );
- }
- }
- $('#chosen br').remove();
- for(i = 0; i < $("#chosen").children('.emote').length; i++){
- if((i+1) % 5 == 0){
- $( "<br>" ).insertAfter( $("#chosen").children('.emote')[i] );
- }
- }
- }
- client.on("resub", function (channel, username, months, message) {
- queue.push(months);
- //dropEmotes(months);
- });
- $("#d5").click(function(){
- queue.push(22);
- // dropEmotes(22);
- })
- setInterval(function(){
- if(queue.length > 0){
- dropEmotes(queue[0]);
- queue.splice(0,1);
- }
- },7000)
- function dropEmotes(months){
- $("#testMote").html("");
- for(i = 0; i< months; i++){
- var randomEmote = chosen[Math.floor(Math.random() * chosen.length)];
- console.log(randomEmote);
- var randomLink = "https://static-cdn.jtvnw.net/emoticons/v1/"+randomEmote+"/3.0"
- $("#testMote").append("<image class='falling' src='"+randomLink+"'></image>");
- }
- $(".falling").each(function(){
- var posx = (Math.random() * ($(document).width() - 112)).toFixed();
- var posy = (Math.random() * (-200 - 10)).toFixed();
- $( this ).css({
- 'position':'absolute',
- 'left':posx+'px',
- 'top': posy+'px',
- })
- })
- $(".falling").css({
- "-webkit-animation-name":"rotatebox",
- "-webkit-animation-duration":"7s",
- "-webkit-animation-iteration-count":"1",
- });
- $(".falling")
- .on("animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd",
- function(e){
- $("#testMote").html("");
- $(this).off(e);
- });
- }
- });
- </script>
- <style>
- @-webkit-keyframes rotatebox /*--for webkit--*/{
- to{
- -webkit-transform:translate(0%,125vh) rotate(0deg);
- }
- from{
- -webkit-transform:translate(0%,-112px) rotate(720deg);
- }
- }
- html{
- overflow-y:hidden;
- overflow-x:hidden;
- }
- .falling{
- max-width: 112px;
- max-height: 112px;
- height: 100%;
- position: absolute;
- }
- .emote{
- margin-right: 5px;
- margin-bottom: 5px;
- }
- #emotes{
- float: left;
- width: 320px;
- padding: 20px;
- padding-top: 0px;
- border-style: solid;
- border-radius: 15px;
- }
- #chosen{
- width: 10%;
- margin-left: 5%;
- float: left;
- width: 320px;
- padding: 20px;
- padding-top: 0px;
- border-style: solid;
- border-radius: 15px;
- }
- </style>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement