Skip to content
This repository has been archived by the owner on Apr 18, 2019. It is now read-only.

Commit

Permalink
Converted license info page to use div instead of iframe.
Browse files Browse the repository at this point in the history
  • Loading branch information
cwong1 committed Jan 4, 2013
1 parent c8a54e8 commit 0d378fd
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 19 deletions.
10 changes: 10 additions & 0 deletions css/license.css
Expand Up @@ -39,6 +39,16 @@
border-radius: 12px;
box-shadow: inset 1px 1px 2px 1px black;
margin-bottom: 2px;
padding-left: 10px;
padding-bottom: 10px;
overflow: hidden;
cursor: move;
}

#licensescroll {
position: relative;
font: 25px/100% Arial, Helvetica, sans-serif;
text-align: center;
}

.licensebtn {
Expand Down
2 changes: 1 addition & 1 deletion index.html
Expand Up @@ -151,7 +151,7 @@
<div id="licensebtnl" style="top: 560px; left: 984px;"> i </div>
</div>
<div id="licensepage" style="display: none">
<iframe id="licensetext" src="README.txt"></iframe>
<div id="licensetext"><div id="licensescroll"></div></div>
<div id="licensebtnq" class="licensebtn">Back</div>
</div>

Expand Down
76 changes: 58 additions & 18 deletions js/license.js
Expand Up @@ -13,41 +13,81 @@ function license_init(id, hpageid)
var qbtn = document.getElementById(id+"btnq");
var lpage = document.getElementById(id+"page");
var hpage = document.getElementById(hpageid);
var frame = window.frames[id+"text"];
var dY = 1;
var t0 = 0;
var ltext = document.getElementById(id+"text");
var lscroll = document.getElementById(id+"scroll");
var timer;

var request = new XMLHttpRequest();
request.open("GET", "README.txt", false);
request.onload = function(e) {
var text = this.responseText;
text = text.replace(/</g,"&lt;");
text = text.replace(/>/g,"&gt;");
var lines = text.split("\n");
lines[0] = "<br><br>"+lines[0];
for(var i in lines)
{
if(lines[i].match(/--------------------/))
{
lines[i] = "";
}
else
{
lines[i] += "<br>";
}
}
lscroll.innerHTML = lines.join("\n");
}
request.send();

lbtn.onclick = function() {
var delay = 0;
/* initialize scroll rate */
var dY = 2;
var t0 = 0;
var delay = 1000;

/* set the scroller to the top position */
lscroll.style.top = "0px";

/* display the license page, hide its parent */
hpage.style.display="none";
lpage.style.display="block";

/* calculate the scroll length when the window is shown */
var maxY = lscroll.clientHeight - ltext.clientHeight;

/* start the autoscroll interval */
timer = setInterval(function() {
/* get the actual interval, in case performance slows us down */
var t1 = (new Date()).getTime();
var dT = (t0 == 0)?20:(t1-t0);
t0 = t1;
var old = frame.scrollY;
frame.scrollTo(0, frame.scrollY + ((dT/20)*dY));

/* if the frame has hit the limit, delay and swing */
/* delay specific number of milliseconds */
delay -= dT;
if(delay > 0)
return;

/* calculate the new top position using dY and dT */
var newY = Math.abs(parseInt(lscroll.style.top)) + ((dT/40)*dY);
if(newY > 0)
lscroll.style.top = (-1 * newY) + "px";
else
lscroll.style.top = "0px";

/* if the lscroll has hit the limit, delay and swing */
/* the other way */
if((frame.scrollY == old)&&(delay++ > ((100*dT)/20)))
if(newY >= maxY)
{
delay = 5000;
dY = -20;
}
else if(newY <= 0)
{
delay = 0;
if(frame.scrollY > 0)
{
dY = -20;
}
else
{
dY = 1;
}
delay = 5000;
dY = 2;
}
}, 20);
}, 40);
};

qbtn.onclick = function() {
Expand Down

0 comments on commit 0d378fd

Please sign in to comment.