Advertisement
Guest User

SmuTTY Dec 19 event

a guest
Dec 11th, 2019
692
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 12.42 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.  
  4. <head>
  5.   <meta charset="utf-8">
  6.   <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  7.   <meta name="description" content="SmuTTY: Download and view all cards available in Smutstone!">
  8.   <meta name="author" content="">
  9.  
  10.   <title>SmuTTY - Download all Smutstone cards</title>
  11.  
  12.   <!-- Bootstrap core CSS -->
  13.   <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  14.   <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
  15.   <style>
  16.     header {
  17.       padding: 154px 0 100px;
  18.     }
  19.     @media (min-width: 992px) {
  20.       header {
  21.         padding: 156px 0 100px;
  22.       }
  23.     }
  24.     section {
  25.       padding: 150px 0;
  26.     }
  27.     .image-card {
  28.       width: 19% !important;
  29.     }
  30.   </style>
  31. </head>
  32.  
  33. <body id="page-top" onload="createGallery()">
  34. <!-- Navigation -->
  35. <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top" id="mainNav">
  36.   <div class="container">
  37.     <a class="navbar-brand js-scroll-trigger" href="#page-top">SmuTTY</a>
  38.     <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
  39.       <span class="navbar-toggler-icon"></span>
  40.     </button>
  41.     <div class="collapse navbar-collapse" id="navbarResponsive">
  42.       <ul class="navbar-nav ml-auto">
  43.         <li class="nav-item">
  44.           <a class="nav-link js-scroll-trigger" href="#about">About</a>
  45.         </li>
  46.         <li class="nav-item">
  47.           <a class="nav-link js-scroll-trigger" href="#cards-section">Cards</a>
  48.         </li>
  49.         <li class="nav-item">
  50.           <a class="nav-link" href="#" data-toggle="modal" data-target="#downloadModal">Download</a>
  51.         </li>
  52.       </ul>
  53.     </div>
  54.   </div>
  55. </nav>
  56.  
  57. <header class="bg-info text-white" id="head">
  58.   <div class="container text-center">
  59.     <h1>Welcome to SmuTTY</h1>
  60.     <p class="lead">View and download every existing Smutstone card :)</p>
  61.   </div>
  62. </header>
  63.  
  64. <section id="about">
  65.   <div class="container">
  66.     <div class="row">
  67.       <div class="col-lg-8 mx-auto">
  68.         <h2>About SmuTTY</h2>
  69.         <p class="lead">
  70.           SmuTTY is a little tool I wrote for viewing <a href="https://smutstone.com" target="_blank">Smutstone</a> cards.
  71.           I even implemented a downloader to download a zip file containing all those cards.
  72.           It doesn't matter how far you are or if you are even playing the game, here you can view and download every card in every seduction stage.<br><br>
  73.           Have fun guys ;)
  74.         </p>
  75.       </div>
  76.     </div>
  77.   </div>
  78. </section>
  79.  
  80. <section id="cards-section" class="bg-light">
  81.   <div class="container">
  82.     <div class="row">
  83.       <div class="col-lg-12 text-center">
  84.         <div id="cards">
  85.           <!-- Content filled up by js -->
  86.         </div>
  87.       </div>
  88.     </div>
  89.   </div>
  90. </section>
  91.  
  92. <!-- Download Modal-->
  93. <div class="modal fade" id="downloadModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true">
  94.   <div class="modal-dialog" role="document">
  95.     <div class="modal-content">
  96.       <div class="modal-header">
  97.         <h5 class="modal-title text-secondary" id="modalLabel">Download all images?</h5>
  98.         <button class="close" type="button" data-dismiss="modal" aria-label="Close">
  99.           <span aria-hidden="true">×</span>
  100.         </button>
  101.       </div>
  102.       <div class="modal-body text-secondary" id="modalBody">Click "Download" below to obtain a zip containing all images shown on this page.</div>
  103.       <div class="modal-footer">
  104.         <button class="btn btn-secondary" id="modalCancel" type="button" data-dismiss="modal">Cancel</button>
  105.         <a class="btn btn-danger" href="#" onclick="createZip()">Download</a>
  106.       </div>
  107.     </div>
  108.   </div>
  109. </div>
  110.  
  111. <footer class="py-3 bg-dark">
  112.   <div class="container">
  113.     <p class="m-0 text-center text-white">©opyright: None ;)</p>
  114.   </div>
  115. </footer>
  116. </body>
  117.  
  118. <script src="https://code.jquery.com/jquery-3.4.0.min.js" integrity="sha256-BJeo0qm959uMBGb65z40ejJYGSgR7REI4+CW1fNKwOg=" crossorigin="anonymous"></script>
  119. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.min.js" integrity="sha384-leGYpHE9Tc4N9OwRd98xg6YFpB9shlc/RkilpFi0ljr3QD4tFoFptZvgnnzzwG4Q" crossorigin="anonymous"></script>
  120. <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
  121. <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
  122.  
  123. <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.2.0/jszip.min.js" integrity="sha384-ggk621VQWvSvcW2M45vjOS2b4wU7zpEamUx5sNdziv/RNEbmGNsAUHPemMHEicXv" crossorigin="anonymous"></script>
  124. <script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.min.js" integrity="sha384-VgWGwiEJnh9P379lbU8DxPcfRuFkfLl0uPuL9tolOHtm2tx8Qy8d/KtvovfM0Udh" crossorigin="anonymous"></script>
  125. <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip-utils/0.0.2/jszip-utils.min.js" integrity="sha384-ZbOxlAjQZ5+AoE3plRuEC6mpbZCVvqvG6E8GNxtPR3SDZYQTGThUf2AFe7Eh+yLl" crossorigin="anonymous"></script>
  126.  
  127. <script>
  128. var BASE_URL = 'https://cdn.smutstone.com/s2/';
  129. var FILE_NAME = "smutty.zip";
  130.  
  131. var zip = new JSZip();
  132. var zipContent = null;
  133. var imageData = [];
  134. var downloadCount = 0;
  135. var createdZip = false;
  136. var workingOnZip = false;
  137. var modalModified = false;
  138.  
  139. //Creates function used in conf.js
  140. //Modified to extract an array containing the image data
  141. function webpackJsonp(x0, data, x1)
  142. {
  143.     var e = {};
  144.     data[117](e, null, function(x) { return {_tr:function (x) { return x }}; });
  145.     e.exports.forEach(function (item, index) {
  146.         //Check if card with this name already exists (duplicate)
  147.         for(var i = 0; i<imageData.length; i++) {
  148.            if(imageData[i].name === item.name)
  149.                return;
  150.        }
  151.        var dict = {};
  152.        dict.cardId = item.cardId;
  153.        dict.name = item.name;
  154.        //Check if element exists
  155.        var exists = true;
  156.        if(typeof item === 'undefined' || typeof item.big === 'undefined' || typeof item .big._2x === 'undefined') {
  157.            exists = false;
  158.            return;
  159.        }
  160.        dict.pictureURLs = [BASE_URL + item.big._2x];
  161.        item.evolution.stages.forEach(function (subitem, subindex)
  162.        {        
  163.            if(typeof subitem === 'undefined' || typeof subitem.changes === 'undefined' || typeof subitem.changes.big === 'undefined' || typeof subitem.changes.big._2x === 'undefined') {
  164.                exists = false;
  165.                return;
  166.            }
  167.            dict.pictureURLs.push(BASE_URL + subitem.changes.big._2x);
  168.        });
  169.        
  170.        if(!exists)
  171.            return;
  172.        imageData.push(dict)
  173.    })
  174. }
  175.  
  176. function addImageToZip(url, filename, zip)
  177. {
  178.    var dlProgress = document.getElementById('dlProgress');
  179.    JSZipUtils.getBinaryContent(url, function (err, data) {
  180.        if(err) {
  181.            alert("Problem happened when download img: " + url);
  182.            console.error("Problem happened when download img: "+ url);
  183.        } else {
  184.            zip.file(filename, data, {binary:true});
  185.            console.log(url + " downloaded!");
  186.            downloadCount += 1;
  187.            //1/5 * 100 = 25
  188.            dlProgress.style.cssText = "width: "+downloadCount / imageData.length * 25+"%";
  189.            if(downloadCount === imageData.length * 5)
  190.                downloadZip();
  191.        }
  192.    });
  193. }
  194.  
  195. function resetModal() {
  196.    $("#downloadModal").modal("hide");
  197.    document.getElementById("modalLabel").innerText = "Download all images?";
  198.    document.getElementById("modalBody").innerHTML = "Click \"Download\" below to obtain a zip containing all images shown on this page.";
  199.    document.getElementById("modalCancel").removeAttribute("disabled");
  200.    modalModified = false;
  201. }
  202.  
  203. function downloadZip()
  204. {
  205.    if(downloadCount < imageData.length * 5)
  206.        alert("Download not finished yet!");
  207.    else {
  208.        if (zipContent == null) {
  209.            if (!workingOnZip) {
  210.                workingOnZip = true;
  211.                zip.generateAsync({type: "blob"}).then(function (content) {
  212.                    zipContent = content;
  213.                    saveAs(zipContent, FILE_NAME);
  214.                    resetModal();
  215.                });
  216.            }
  217.        }
  218.        else {
  219.            saveAs(zipContent, FILE_NAME);
  220.            resetModal();
  221.        }
  222.    }
  223. }
  224.  
  225. function createZip()
  226. {
  227.    if(!modalModified) {
  228.        document.getElementById("modalLabel").innerText = "Downloading...";
  229.        document.getElementById("modalBody").innerHTML = "<div class=\"progress mb-1\">" +
  230.             "<div class=\"progress-bar progress-bar-striped progress-bar-animated bg-danger\" id='dlProgress' role=\"progressbar\" " +
  231.            "aria-valuenow=\"0\" aria-valuemin=\"0\" aria-valuemax=\"100\"></div></div>" +
  232.             "This may take some time. Please be patient...";
  233.         document.getElementById("modalCancel").setAttribute("disabled", "true");
  234.         modalModified = true;
  235.     }
  236.     if(createdZip)
  237.         downloadZip();
  238.     else {
  239.         createdZip = true;
  240.         imageData.forEach(function (item, index) {
  241.             var card = zip.folder(item.cardId + " - " + item.name);
  242.             console.log("Downloading " + item.name + " (" + item.cardId + ")...");
  243.  
  244.             item.pictureURLs.forEach(function (item, index) {
  245.                 addImageToZip(item, index + 1 + ".jpg", card);
  246.             });
  247.         });
  248.     }
  249. }
  250.  
  251. function createGallery()
  252. {
  253.     var c = document.getElementById("cards");
  254.     imageData.forEach(function (item, index) {
  255.         var div = document.createElement("div");
  256.         var head = document.createElement("h3");
  257.         var text = document.createTextNode(item.name + ": ");
  258.         head.classList.add("text-left", "text-secondary", "mt-4");
  259.         head.appendChild(text);
  260.         div.append(head);
  261.         item.pictureURLs.forEach(function (subitem, subindex) {
  262.             var img = document.createElement("img");
  263.             var a = document.createElement("a");
  264.             a.href = subitem;
  265.             a.target="_blank";
  266.             img.src=subitem;
  267.             img.alt=subindex + 1 + "★";
  268.             img.classList.add("border", "border-dark", "rounded", "image-card", "mx-1");
  269.             a.append(img);
  270.             div.append(a);
  271.         });
  272.         c.appendChild(div);
  273.     });
  274. }
  275.  
  276. //Template Javascript (for the animations...)
  277. (function($) {
  278.     "use strict"; // Start of use strict
  279.     // Smooth scrolling using jQuery easing
  280.     $('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function() {
  281.         if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
  282.            var target = $(this.hash);
  283.             target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
  284.             if (target.length) {
  285.                 $('html, body').animate({
  286.                     scrollTop: (target.offset().top - 70)
  287.                 }, 1000, "easeInOutExpo");
  288.                 return false;
  289.             }
  290.         }
  291.     });
  292.     // Closes responsive menu when a scroll trigger link is clicked
  293.     $('.js-scroll-trigger').click(function() {
  294.         $('.navbar-collapse').collapse('hide');
  295.     });
  296.     // Activate scrollspy to add active class to navbar items on scroll
  297.     $('body').scrollspy({
  298.         target: '#mainNav',
  299.         offset: 80
  300.     });
  301.     // Collapse Navbar
  302.     var navbarCollapse = function() {
  303.         if ($("#mainNav").offset().top > 100) {
  304.             $("#mainNav").addClass("navbar-shrink");
  305.         } else {
  306.             $("#mainNav").removeClass("navbar-shrink");
  307.         }
  308.     };
  309.     // Collapse now if page is not at top
  310.     navbarCollapse();
  311.     // Collapse the navbar when page is scrolled
  312.     $(window).scroll(navbarCollapse);
  313. })(jQuery);
  314. </script>
  315. <script src="https://cdn.smutstone.com/s_nut/328439c1.conf.js"></script>
  316. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement