Page 1 of 1

Auto-continue of static webteases

Posted: Sat Dec 13, 2014 11:27 pm
by Czech
Hi,

I am new to this site, and one thing I didn't like with the "non-flash" (or static) versions of webteases was that I had to click "continue" all the time, which can be distracting or even messy (when using lube for example :-D), but definitely annoying.

But I have some background in programming, and so I wrote the following HTML file to auto-continue static webteases:

Code: Select all

<html><head>  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>  <script type="text/javascript" charset="utf-8">    // put the URL here, without the page number:    var URL="http://www.milovana.com/webteases/showtease.php?id=2528&p=";    // page number to start with:    var page = 1;    // time until next page:    var seconds = 10;     $(document).ready(function () {      var $iframe = $("iframe").attr("src",URL+page);      setInterval(function() {        page = page + 1;        var newLoc = URL+page;        $iframe.attr("src",newLoc);      }, seconds*1000);    });  </script>    <style type="text/css" media="screen">    iframe {      height: 100%;      width: 100%;      border: none;    }  </style></head><body>  <iframe></iframe></body></html>
There you see 3 variables, URL, page and seconds, which you have to edit according to your preferences and to the webtease you want to see.

To use it, do the following steps:
  • Open a plain-text editor (for example 'notepad' on Windows or 'gedit' on Linux, but not MS Word or alike)
  • Copy the above code into your text editor. To get rid of the leading spaces, click on "Line numbers On/Off" before.
  • Save the file to your hard disk, and give it a name of your choice ending with ".html"
  • Edit the 3 variables according to your needs. Make sure you remove the page number in the URL field, so that the URL ends with "p=". The page number is added to the URL later and is specified in the "page" variable.
  • Save your changes
  • Open the .html file in your browser, most likely by double-clicking on it.
  • Enjoy!
If you extend or improve this piece of code, please share it in this forum so other people can benefit from it. Otherwise, you may use or share it as you like.

Re: Auto-continue of static webteases

Posted: Sun Dec 14, 2014 1:03 am
by MiloM
That's brilliant, and very impressive! At least to me, because I have you to dabble in the world of HTML. Thank you!

Re: Auto-continue of static webteases

Posted: Sun Dec 14, 2014 4:49 am
by DoxysTurtle
Great idea Czech, I'm sure a lot will love using it

Re: Auto-continue of static webteases

Posted: Sun Dec 14, 2014 9:31 am
by les
                     


                     As an aside

                              You can click anywhere on the picture, or hit the space bar
                     to move on in static teases



                     Hope this helps the non-coders amongst us.


                     

Re: Auto-continue of static webteases

Posted: Mon Dec 15, 2014 1:52 pm
by Czech
Hi boys and girls,

I have, just for fun, extended my original HTML file. I've learned a lot doing it, and I'd like to share the result with you. :-)

New features are:
  • Graphical status line at the top.
  • Original URL handling. No need to edit the URL, just copy it into the URL field.
  • Play/Pause button or SPACE key
  • Previous/Next buttons or Left/Right keys
  • Jump to pages directly
  • Speed adjustment or Up/Down keys
  • Bookmarking support by storing the current settings in the URL
  • Emergency key (just a little joke)
Usage:
  • Save the HTML file to your hard disk as described in the first post. Name it "something.html".
  • Open it in your browser (optionally: bookmark the file)
  • Copy a webtease URL into the "URL" field (right click on link --> Copy link address --> paste) and hit Enter or click "Apply"
Here is the source code:

Code: Select all

<html>  <head>    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>    <script type="text/javascript" charset="utf-8">      // user-defined fields (default values). You can edit these safely.      var baseUrl="http://www.milovana.com/webteases/showtease.php";      var fallBackUrl="http://www.milovana.com/webteases/";      var emergencyURL="http://www.google.com";       // interval object      var interval;      // default values, do not change      var id = 0;      var p = 0;      var play = 0; // 0: pause, 1: play, 2: browse      var time = 0;      var URL = "";            // main function : document ready      $(function() {        readValuesFromURL();        if (id == 0) {            fallback();        } else {            // set default values if not specified            if (p == 0) p = 1;            if (time == 0) time = 10;            URL = baseUrl + "?id=" + id + "&p=" + p;            refreshStatus();            document.getElementById("myframe").src = URL;            if (play == 1) start();        }      });            // use arrow keys to navigate and space for play/pause      // and up/down to adjust speed      document.onkeydown = function(e) {        e = e || window.event;        switch(e.which || e.keyCode) {          case 32: // space          playPause(); break;           case 37: // left          previous(); break;                    case 38: // up          increaseTime(); break;           case 39: // right          next(); break;                    case 40: // down          decreaseTime(); break;           default: return;        }        e.preventDefault();       };       function readValuesFromURL() {        var newID = getNumField("id");        if (valid(newID)) id = newID;                var newPage = getNumField("p");        if (valid(newPage)) p = newPage;                var newTime = getNumField("time");        if (valid(newTime)) time = newTime;                var newPlay = getNumField("play");        if (0 <= newPlay <= 2) play = newPlay;      }            function valid(value) {        return (!isNaN(value) && value >= 1);      }            function reset() {        play = 2; // browser mode        id = 0;        p = 0;        time = 0;        refreshStatus();      }            function refreshStatus() {        updatePlay();        if (play == 2) {            document.title="Milovana Webteases";            document.getElementById("url").value = "";            document.getElementById("page").value = "";            document.getElementById("time").value = "";        } else {            document.title="Milovana auto-webtease #" + id;            document.getElementById("url").value = URL;            document.getElementById("page").value = p;            document.getElementById("time").value = time;        }      }            function updatePlay() {        var status = ["Paused", "Playing", "Browser"];        var color = ["red", "green", "black"];        document.getElementById("status").innerHTML = status[play];        document.getElementById("status").style.color = color[play];      }            // read user-submitted values      function submit() {          var newID = 0;        var pageFromUrl = 0;        var pageFromForm = 0;                    var urlFromForm = document.getElementById("url").value;        if (urlFromForm != "") {          newID = getNumFieldFromURL(urlFromForm, "id");          pageFromUrl = getNumFieldFromURL(urlFromForm, "p");        }        pageFromForm = getNumElement("page");                if (valid(newID)) {          if (newID == id) {            // prefer page from form            if (valid(pageFromUrl)) p = pageFromUrl;            if (valid(pageFromForm)) p = pageFromForm; // overwrite p          } else { // got a new ID            id = newID;            // prefer page from URL            if (valid(pageFromForm)) p = pageFromForm;             if (valid(pageFromUrl)) p = pageFromUrl; // overwrite p          }          // use page=1 if no page is given          if (!valid(pageFromForm) && !valid(pageFromUrl)) p = 1;        } else { // got no ID          if (valid(pageFromForm)) p = pageFromForm;         }                // set the time if we can.        newTime = getNumElement("time");        if (valid(newTime)) time = newTime;                // reload page to apply the new values        play = 1;        nextPage();      }            // reload page. this will create a new URL from current values      function nextPage() {        location.href = window.location.pathname          + "?id=" + id + "&p=" + p + "&time=" + time + "&play=" + play;      }       function next() {        if (play == 2) return;        p = p + 1;        nextPage();      }            function previous() {        if (play == 2 || p == 1) return;        p = p - 1;        nextPage();      }            function start() {        play = 1;        // call next() after N seconds        interval = setInterval(next, time*1000);      }            function stop() {        play = 0;        clearInterval(interval);      }            function increaseTime() {        time++;        updateTime();        if (play == 1) start();      }            function decreaseTime() {        if (time == 1) return;        time--;        updateTime();        if (play == 1) start();      }            function updateTime() {        document.getElementById("time").value = time;      }            function playPause() {        if (play == 2) return;        play == 0 ? start() : stop();        updatePlay();      }            function fallback() {        reset();        document.getElementById("myframe").src = fallBackUrl;      }            // --- BACKEND METHODS            // FROM: http://jquery-howto.blogspot.de/2009/09 ... query.html      // Read a page's GET URL variables and return them as an associative array.      function getUrlVars(doc)      {          var vars = [], hash;          var hashes = doc.href.slice(doc.href.indexOf('?') + 1).split('&');          for(var i = 0; i < hashes.length; i++)          {              hash = hashes[i].split('=');              vars.push(hash[0]);              vars[hash[0]] = hash[1];          }          return vars;      }            function getNumElement(elem) {        return parseInt(document.getElementById(elem).value);      }            function getNumFieldFromLocation(myLoc, field) {        return parseInt(getUrlVars(myLoc)[field]);      }            function getNumFieldFromURL(myString, field) {        return getNumFieldFromLocation(getLocation(myString), field);      }            function getNumField(field) {        return getNumFieldFromLocation(window.location, field);      }            var getLocation = function(href) {          var l = document.createElement("a");          l.href = href;          return l;        };            // --- END </script>        <style type="text/css" media="screen">      iframe {        height: calc(100% - 30px);        width: 100%;        border: none;      }      body {        margin: 0;      }      form {        display: inline;      }          </style>      </head>  <body>    <div id="statusline">      <span id="status" style="font-weight:bold">Browser</span>              <button onclick="playPause()">Play/Pause</button>      <button onclick="previous()">Previous</button>      <button onclick="next()">Next</button>      <form action="javascript&#058;submit()">        URL:        <input type="text" id="url" size="30" value="" />        page:        <input type="text" id="page" size="2" value="" />        time:        <input type="text" id="time" size="2" value="" />        <input type="submit" value="Apply">      </form>      <button onclick="reset()">Reset</button>      <div style="float: right">        <button onclick="location.href = emergencyURL">Emergency</button>      </div>    </div>    <iframe id="myframe"></iframe>  </body></html>
Have fun! :love: