Guest User

Untitled

a guest
Jul 13th, 2014
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 13.09 KB | None | 0 0
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2.       "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head>
  5. <title>Reddit Tag Generator</title>
  6. <noscript><style> .jsonly { display: none } </style></noscript>
  7. </head>
  8. <style type="text/css">
  9. tr { width: 100% }
  10. table { width: 100% }
  11. input, textarea { box-sizing: border-box; display:inline-block }
  12. input { margin:0;
  13.     padding:0;
  14. }
  15. body {
  16.     background-color: gray;
  17.     font-family:Verdana,Arial,sans-serif;
  18. }
  19.  
  20. h1 {
  21.     width:80%;
  22.     border:3px;
  23.     border-style:solid;
  24.     padding:20px;
  25.     background-color: #08465b;
  26.     color:#eee;
  27.     border-color:black;
  28.     border-radius:10px;
  29. }
  30.  
  31. h3 {
  32.     background-color: #18566b;
  33.     color:#eee;
  34.     padding-left:30px;
  35.     padding-top:5px;
  36.     padding-bottom:5px;
  37.     border-radius:6px;
  38.     border:1px;
  39.     border-style:solid;
  40.     border-color:#00364b;
  41. }
  42.  
  43. .text {
  44.     text-align:left;
  45.     margin-left:2%
  46. }
  47.  
  48. .group {
  49.     margin-top:5px;
  50.     margin-bottom:5px;
  51.     height:170px;
  52. }
  53.  
  54. .cell {
  55.     display: inline-block;
  56.     width: 19.6%;
  57.     margin:0.2%;
  58.     height:300px;
  59.     overflow:hidden;
  60. }
  61.  
  62. .code {
  63.     padding-left:8px;
  64.     padding-right:8px;
  65.     border:1px;
  66.     border-style:solid;
  67.     border-color:gray;
  68.     color:gray;
  69.     background-color:#333;
  70.     font-family:monospace;
  71. }
  72.  
  73. .exampletag_tag {
  74.     padding-left:8px;
  75.     padding-right:8px;
  76.     border:1px;
  77.     border-style:solid;
  78.     border-color:gray;
  79.     color:gray;
  80.     background-color:yellow;
  81.     font-family:monospace;
  82.     border-radius:3px;
  83. }  
  84.  
  85. .box {
  86.     width: 80%;
  87.     padding: 20px;
  88.     background-color: #444;
  89.     border-width: 3px;
  90.     border-style: solid;
  91.     border-color: black;
  92.     color: white;
  93.     margin-left:auto;
  94.     margin-right:auto;
  95.     border-radius:10px;
  96. }
  97.  
  98. select, input, textarea {
  99.     background-color:#5896ab;
  100.     border:1px;
  101.     border-style:solid;
  102.     border-color:black;
  103.     border-radius:4px;
  104.     width:100%;
  105.     color:black;
  106.     padding-left:5px;
  107. }
  108.  
  109. *::-webkit-input-placeholder { color:#444; }
  110. *:-ms-input-placeholder{ color:#444; }
  111. *::-moz-placeholder { color:#444; opacity:1; }
  112. *:-moz-placeholder { color:#444; opacity:1; }
  113.  
  114. </style>
  115. <script language="JavaScript" src="json2.js"></script>
  116. <script>
  117. function change_color(what) {
  118.     what.style.backgroundColor = what.options[what.selectedIndex].value;
  119.     if ( { "aqua": true, "lime": true, "silver": true, "white": true, "yellow": true }[what.style.backgroundColor] ) { var fgcolor="black"; } else { var fgcolor="white"; }
  120.     what.style.color = fgcolor;
  121. }
  122. function show_exampletag() {
  123.     document.getElementById('exampletag').style.display='block';
  124. }
  125. function make_exampletag() {
  126.     var exampletag = "";
  127.     var checks_in = document.getElementsByClassName("check_in");
  128.     var checks_se = document.getElementsByClassName("check_se");
  129.     var count = checks_in.length;
  130.     var highest_count = 0
  131.     var highest = 1;
  132.     for (var i = 0; i < count; i++) {
  133.         var currentcell = document.getElementById("cell"+(i+1));
  134.         if ( checks_in[i].value && checks_se[i].value ) {
  135.             currentcell.style.opacity=1;
  136.             var random_count = Math.floor((Math.random() * 100) + 1)
  137.             exampletag += checks_in[i].value+":"+random_count+" ";
  138.             if ( random_count > highest_count ) {
  139.                 highest_count = random_count;
  140.                 highest = i+1;
  141.             }
  142.         } else {
  143.             currentcell.style.opacity=0.5;
  144.         }
  145.     }
  146.     if ( exampletag ) {
  147.         var bgcolor = document.getElementById("col"+highest).value;
  148.         if ( bgcolor ) {
  149.             document.getElementById('exampletag_tag').style.background = bgcolor;
  150.         } else {
  151.             document.getElementById('exampletag_tag').style.background = '#444';
  152.         }
  153.         if ( { "aqua": true, "lime": true, "silver": true, "white": true, "yellow": true }[bgcolor] ) { var fgcolor="black"; } else { var fgcolor="white"; }
  154.         document.getElementById('exampletag_tag').style.color = fgcolor;
  155.         document.getElementById('exampletag_fromscript').innerHTML=' {'+exampletag.slice(0,-1)+'}';
  156.     }
  157. }
  158. function add_element() {
  159.     document.activeElement.blur()
  160.     var stdelement = document.getElementsByClassName("cell")[0].innerHTML;
  161.     var count = document.querySelectorAll(".cell").length;
  162.     stdelement = stdelement.replace("group1","group"+count);
  163.     stdelement = stdelement.replace("col1","col"+count);
  164.     stdelement = stdelement.replace("name1","name"+count);
  165.     stdelement = stdelement.replace("Group 1","Group "+count);
  166.     stdelement = stdelement.replace("group 1","group "+count);
  167.     document.getElementById('variable_space').innerHTML+="<div class='cell' id='cell"+count+"'>"+stdelement+"</div>";
  168.     make_exampletag()
  169. }
  170. function update_oldusers() {
  171.     var oldtags = document.getElementById('oldtags').value;
  172.     var oldusers = document.getElementById('oldusers');
  173.     if ( oldtags ) {
  174.         oldtags = JSON.parse(oldtags);
  175.         var oldcount = Object.keys(oldtags).length;
  176.         oldusers.innerHTML='<br>You currently have '+oldcount+' users tagged.';
  177.         if ( oldcount > 1000 ) {
  178.             oldusers.innerHTML+=' This is a large amount of data whose processing may lead to problems.<br>If you experience difficulties, upload a file below instead.<br><br>'
  179.         }
  180.     } else {
  181.         oldusers.innerHTML='<br><i>-- OR --</i><br><br>';
  182.     }
  183. }
  184. function afterload() {
  185.     show_exampletag();
  186.     make_exampletag();
  187.     update_oldusers();
  188. }
  189. document.addEventListener("load", afterload, false);
  190. document.addEventListener("DOMContentLoaded", afterload, false);
  191. </script>
  192. <body>
  193. <?php
  194. $metas = json_decode(file_get_contents('subreddits'), true);
  195. $subcount = 0;
  196. foreach ( $metas as $meta ) { $subcount += count($meta); }
  197. $usercount = file_get_contents('usercount');
  198. ?>
  199. <div class='box' style='background-color:#08465b'><div style='margin-left:2%'><span style='font-size:xx-large'>Reddit Enhancement Suite Tag Generator</span><br>
  200. <?php
  201. print "Currently tracking ".number_format($usercount)." users on ".number_format($subcount)." subreddits - and growing!";
  202. ?>
  203. </div></div>
  204. <br>
  205. <div class='box'>
  206. <div class='text' style='color:red'>In RES 4.5.0.2, the settings console is nonfunctional due to a bug. If your
  207. page just reloads instead of opening the tag window, you'll have to wait for the fix to get into a stable version or downgrade RES.</div>
  208. <h3>Intro</h3>
  209. <div class='text'>
  210. Please select which subreddits should be in which group and enter a short name and color for each of them.<br>
  211. You can select multiple subreddits in per group by holding Ctrl.<br>
  212. If no name is entered or if no subreddits are selected, a group is ignored.<br>
  213. The color will be determined by the group in which the user has the highest number of postings.<br>
  214. You can copy and paste your old tags below. They will be added to the generated tags.<br>
  215. Note: Anything between { and } in the old tags will be removed as to prevent duplicate auto-tagging.
  216. </div>
  217. <form action="generate.php" enctype="multipart/form-data" method="post">
  218.  
  219. <h3>Group definitions</h3>
  220.  
  221. <?php
  222.  
  223. $group_select = '';
  224. $color_options = '';
  225.  
  226. $meta_keys = array_keys($metas);
  227. foreach ($meta_keys as $meta) {
  228.     $dummy = array();
  229.     if ( preg_match_all("/.*?(\d+)$/", $meta, $dummy) ) {
  230.         $basename = trim(str_replace(range(0,9),'',$meta));
  231.         if ( $metas[$basename] ) {
  232.             $metas[$basename] = array_merge($metas[$basename],$metas[$meta]);
  233.             unset($metas[$meta]);
  234.         }
  235.     }
  236. }
  237.  
  238. $meta_keys = array_keys($metas);
  239. natcasesort($meta_keys);
  240. $new_key = array_search('New',$meta_keys);
  241. if ( $new_key ) {
  242.     array_splice($meta_keys,$new_key-1,1);
  243.     array_push($meta_keys,'New');
  244. }
  245.  
  246. foreach ($meta_keys as $meta) {
  247.     if ( $meta == 'New' ) {
  248.         if ( !empty($metas['New']) ) { $style='color:darkred'; } else { continue; }
  249.     } else { $style=''; }
  250.     $group_select .= "<optgroup label='$meta' style='$style'>";
  251.     natcasesort($metas[$meta]);
  252.     foreach ($metas[$meta] as $sub) { $group_select .= "<option style='$style'>$sub</option>"; }
  253.     $group_select .= "</optgroup>";
  254. }
  255.  
  256. if ( $new_key and $metas['New'] ) {
  257.     $new = '';
  258.     foreach ( $metas['New'] as $sub ) { $new .= $sub.', '; }
  259.     echo "<div class='text' style='color:red;font-size:small'><b>NEW subreddits: </b>".substr($new,0,strlen($new)-2)."<br></div>";
  260. }
  261.  
  262. $tag_colors = array( "aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow" );
  263. $tag_colors_black_fg = array( "aqua", "lime", "silver", "white", "yellow" );
  264. foreach ($tag_colors as $tag_color) {
  265.     if ( in_array( $tag_color, $tag_colors_black_fg ) ) { $fg_color='black'; } else { $fg_color='white'; }
  266.     $color_options .= "<option value='$tag_color' style='background-color:$tag_color;color: $fg_color'>$tag_color</option>";
  267. }
  268.  
  269. foreach ( range(1,4) as $i ) {
  270.     echo "<div class='cell' id='cell$i'>
  271.         <h3>Group $i</h3>
  272.         <input name='name$i' placeholder='Enter group $i token' style='padding:10' id='name$i' onKeyUp='make_exampletag()' class='check_in'><br>
  273.         <select class='group check_se' name='group".$i."[]' multiple id='group$i' onChange='make_exampletag()'>
  274.         $group_select
  275.         </select><br>
  276.         <select onChange='change_color(this);make_exampletag()' name='col$i' id='col$i'>
  277.         <option value='' selected disabled>Select color...</option>
  278.         $color_options
  279.         </select>
  280.         </div>";
  281. }
  282. ?><noscript><span class='cell' style='vertical-align:top'><h3 style='height:263px;opacity:0.5;'><br>Please enable JavaScript to add more groups.</h3></span></noscript><span class="jsonly"><span id='variable_space'></span><span class='cell'>
  283. <h3>New Group</h3>
  284.  
  285. <input onClick='add_element()' style='background-color:#444;color:#444'><br>
  286. <textarea onClick='add_element()' style='background-color:#444;resize:none;color:#444' id='dummybox' multiple class='group'></textarea><br>
  287. <input onClick='add_element()' style='background-color:#444;color:#444;vertical-align:top;display:block'></select>
  288. </span></span>
  289. <div class='text'><span id='exampletag' style='display:none'><br>Example tag: <span class='exampletag_tag' id='exampletag_tag'>The Tag You Had Before<span id='exampletag_fromscript'></span></span></span></div>
  290. <h3>Old tags</h3>
  291. <div class='text'>
  292. To retrieve your old tags, go on reddit and press ".", which will open the RES console.<br>
  293. In the console, paste <span class='code'>RESStorage update RESmodules.userTagger.tags</span> and press Enter.<br>
  294. Note that depending on your number of tags, this step may take quite a while.<br>
  295. Click into the resulting field, press Ctrl+a and then Ctrl+c to copy all your old tags.<br>
  296. Now click in the entry field below and press Ctrl+v to paste your tags.<br><br>
  297. <textarea id='oldtags' onChange='update_oldusers()' name="oldtags" style="height:100px; width:90%;padding-top:5px;" placeholder='Paste your tags here...'></textarea>
  298. <div id='oldusers'></div>
  299. <input name="tagfile" type="file" style='width:90%' accept="text/*"><br><br>
  300. To upload a file with tags, paste them into a text file on your computer and locate it by clicking 'Browse'.<br>
  301. This is necessary in browsers which limit the maximum length of the entry field above.<br>
  302. If you upload a file, its contents will take precedence over the contents of the entry field.
  303. </div>
  304. <h3>Done?</h3>
  305. <div class='text'>
  306. <input type="checkbox" name="return_tagfile" value="true" style='width:30px;padding:0;margin:0'> Return tags as a text file - use this if you expect the output to be very large<br>
  307. <input type="checkbox" name="override" value="true" style='width:30px;padding:0;margin:0'> Override colors - use this when changing your color selection<br>
  308. <input style='width:30px' name="mincomments" placeholder='2'> comments minimum to count a group<br><br>
  309. Now go on reddit in a new tab and press ".", which will open the RES console.<br>
  310. In the console, paste <span class='code'>RESStorage update RESmodules.userTagger.tags</span> and press Enter.<br>
  311. Once your current tags are displayed, delete them with Ctrl+a and Del.<br>
  312. Now click "Generate" below. Note that depending on the output, this may take a lot of time.<br>
  313. <span style='color:red'>If you get timeout errors, reset errors or similar:</span><br>
  314. <div style='margin-left:30px'>- Upload your old tags as a file<br>
  315. - Select the option to return tas as a text file<br>
  316. - Retry, possibly at a later time<br></div>
  317. Copy all resulting tags with Ctrl+a and Ctrl+c.<br>
  318. Go back to the RES console and paste the tags there with Ctrl+v and click confirm.<br>
  319. Reload the page and you're done!<br><br>
  320. </div>
  321. <input type="submit" value="Generate" style='height:40px;font-size:large;background-color:#08465b;color:white'>
  322. </form>
  323. </div>
  324. <div style='color:#ccc;font-size:small' align='center'><br>Made in July 2014 by <a href='http://www.reddit.com/message/compose/?to=genitaliban' style='color:#ccc'>/u/genitaliban</a> - message me for bug reports, tracking requests and other suggestions!<br>
  325. This website, the script that builds the databases and a local version of this tag generator are available under the GPL upon request.<br>
  326. This website comes without ANY warranty, use at your own risk and keep a backup of your old tags!
  327. <!-- START OF HIT COUNTER CODE -->
  328. <span style='opacity:0.001'><br><script language="JavaScript" src="http://www.counter160.com/js.js?img=11"></script><br><a href="http://www.000webhost.com"><img src="http://www.counter160.com/images/11/left.png" alt="Free web hosting" border="0" align="texttop"></a><a href="http://www.hosting24.com"><img alt="Web hosting" src="http://www.counter160.com/images/11/right.png" border="0" align="texttop"></a></span>
  329. <!-- END OF HIT COUNTER CODE -->
  330. </div>
  331. </body>
  332. </html>
Add Comment
Please, Sign In to add comment