Skip to content
Browse files

Converted license info page to use div instead of iframe.

  • Loading branch information...
1 parent c8a54e8 commit 0d378fd83aa4fcf0e593e00459467a72bbe9d6f5 @cwong1 cwong1 committed
Showing with 69 additions and 19 deletions.
  1. +10 −0 css/license.css
  2. +1 −1 index.html
  3. +58 −18 js/license.js
View
10 css/license.css
@@ -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 {
View
2 index.html
@@ -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>
View
76 js/license.js
@@ -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() {

0 comments on commit 0d378fd

Please sign in to comment.
Something went wrong with that request. Please try again.