viewing paste Unknown #26480 | Javascript

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
<!DOCTYPE html>
<html>
<body>
 
<div id="id01"></div>
<script>
var botCommands = [
{
"command": "discord",
"userType": "mod",
"description": "You can join the Derpy Gaming Network discord by clicking this link: https://discord.gg/0nCaX7zRQ4pOgcXI"
},
{
"command": "minuette",
"userType": "user",
"description": "I am a Twitch Chat Bot."
},
{
"command": "twitter",
"userType": "caster",
"description": "Follow me on Twitter! | https://twitter.com/TheDerpySupport"
}
];
 
botFunction(botCommands);
 
function botFunction(arr) {
    // new
        // Options
            var caption = 0;   // Use table caption? binary
            var botTHcapt = "Bot Command List";   //shows above table as title
            var header = 1;   // Use table row headers? binary
            var botTHcmd = "!Command";   //shows above command column
            var botTHusr =  "Available to";   //shows above user column
            var botTHdesc = "Output";   //shows above description column
            var altColor = 0;   //alternate background colors for rows
            var exclPref = 0;   // Use exclamation mark prefix in command column? binary
            var userParse = 2;  // 0= use as seen in array; 1=stylize only; 2=use icons only(still needs strings for alt text); 3=icons+stylized text
                        // for these to work, the part of the variable after undescore and before the IMG must match 'userType's
            var usr_user = "Viewer";   // stylized name of viewer/user
            var usr_userIMG = "http://i.imgur.com/tJ0wILN.png";   // URL string of viewer icon. leave 0 if no icon. otherwise, make URL string
        
            var usr_subscriber = "Subscriber";   // stylized "sub"
            var usr_subscriberIMG = 0;   // URL string of sub icon. leave 0 if no icon. otherwise, make URL string
        
            var usr_mod = "Moderator";   // stylized "mod"
            var usr_modIMG = "http://i.imgur.com/eDLZuI9.png";   // URL string of mod sword. leave 0 if no icon. otherwise, make URL string
        
            var usr_caster = "Broadcaster";   // stylized "streamer/broadcaster"
            var usr_casterIMG = "http://i.imgur.com/DabFeOQ.png";   // URL of broadcaster icon. leave 0 if no icon. otherwise, make URL string
        // Options end
 
    // table
    out = "<table class='botFunction' id='botFunction'>\n";
    if(caption) {
        out += "<caption>"+botTHcapt+"</caption>\n";
    }
    if(header) {
        out += "<tr><th>"+botTHcmd+"</th><th>"+botTHusr+"</th><th>"+botTHdesc+"</th></tr>\n";
    }
 
    // list
    for(i=0;i<arr.length;i++) {
        (!altColor)?(out += "<tr>\n"):(out += "<tr class='"+((i%2)?"odd":"even")+"'>\n");
        out += "<td class='cmd'>"+((exclPref)?"!":"")+arr[i].command+"</td>\n";
        switch(userParse) {
            case 1:
                out += "<td class='user' style='padding-left:10px;width:125px;'>"+eval("usr_"+arr[i].userType)+"</td>\n";
                break;
            case 2:
                out += "<td class='user' style='width:25px;'>"+((!usr_userIMG)?(""):("<img class='usericon' src='"+eval("usr_"+arr[i].userType+"IMG")+"' alt='"+eval("usr_"+arr[i].userType))+" />")+"</td>\n";
                break;
            case 3:
                out += "<td class='user' style='padding-left:10px;width:150px;'>"+((!usr_userIMG)?(""):("<img class='usericon' src='"+eval("usr_"+arr[i].userType+"IMG")+"' alt='"+eval("usr_"+arr[i].userType))+" />")+" "+eval("usr_"+arr[i].userType)+"</td>\n";
                break;
            default:
                out += "<td class='user' style='padding-left:10px;width:100px;'>"+arr[i].userType+"</td>\n";
        }
        out += "<td class='desc'>"+arr[i].description+"</td>\n";
        out += "</tr>\n";
    }
    // list end
 
    out += "</table>\n";
    // table end
 
    document.getElementById("id01").innerHTML = out;
    // new end
    
    //old
    // var i;
    // for(i = 0; i < arr.length; i++) {
    //    out += arr[i].command + " | " + arr[i].userType + " | " + arr[i].description +'<br>';
    // }
    // document.getElementById("id01").innerHTML = out;
    //old end
}
</script>
<!-- new -->
<style type="text/css">
table.botFunction {
    border-collapse:collapse;
    border-style:outset;
    border-width:5px;
}
table.botFunction caption {
    
}
table.botFunction tr {
    
}
table.botFunction tr.odd {
    background-color:#DDD;
}
table.botFunction tr.even {
    background-color:inherit;
}
table.botFunction th, table.botFunction td {
    padding:5px;
    border-style:solid;
    border-width:1px;
}
table.botFunction th {
    
}
table.botFunction td {
    
}
table.botFunction td.cmd {
    width:100px;
    padding-left:10px;
}
table.botFunction td.user {
    text-align:center;
}
table.botFunction td.desc {
    
}
img.usericon {
    
}
</style>
<!-- new end -->
 
</body>
</html>
Viewed 753 times, submitted by Guest.