~ken-vandine/+junk/hangonman

« back to all changes in this revision

Viewing changes to www/js/license.js

  • Committer: Ken VanDine
  • Date: 2014-03-07 03:22:47 UTC
  • Revision ID: ken.vandine@canonical.com-20140307032247-uk4i0eqyf4l7e4em
initial packaging on hangonman

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2012, Intel Corporation.
 
3
 *
 
4
 * This program is licensed under the terms and conditions of the 
 
5
 * Apache License, version 2.0.  The full text of the Apache License is at
 
6
 * http://www.apache.org/licenses/LICENSE-2.0
 
7
 *
 
8
 */
 
9
 
 
10
function license_init(id, hpageid)
 
11
{
 
12
    var lbtn = document.getElementById(id+"btnl");
 
13
    var qbtn = document.getElementById(id+"btnq");
 
14
    var lpage = document.getElementById(id+"page");
 
15
    var hpage = document.getElementById(hpageid);
 
16
    var ltext = document.getElementById(id+"text");
 
17
    var lscroll = document.getElementById(id+"scroll");
 
18
    var timer;
 
19
    var priorHpageDisplay = hpage.style.display;
 
20
 
 
21
    lbtn.onclick = function() {
 
22
        priorHpageDisplay=hpage.style.display;
 
23
 
 
24
        /* initialize scroll rate */
 
25
        var dY = 2;
 
26
        var t0 = 0;
 
27
        var delay = 1000;
 
28
 
 
29
        /* set the scroller to the top position */
 
30
        lscroll.style.top = "0px";
 
31
 
 
32
        /* display the license page */
 
33
        hpage.style.display="none";
 
34
        lpage.style.display="block";
 
35
 
 
36
        /* calculate the scroll length when the window is shown */
 
37
        var maxY = lscroll.clientHeight - ltext.clientHeight;
 
38
 
 
39
        /* start the autoscroll interval */
 
40
        timer = setInterval(function() {
 
41
            /* get the actual interval, in case performance slows us down */
 
42
            var t1 = (new Date()).getTime();
 
43
            var dT = (t0 == 0)?20:(t1-t0);
 
44
            t0 = t1;
 
45
 
 
46
            /* delay specific number of milliseconds */
 
47
            delay -= dT;
 
48
            if(delay > 0)
 
49
                return;
 
50
 
 
51
            /* calculate the new top position using dY and dT */
 
52
            var newY = Math.abs(parseInt(lscroll.style.top)) + ((dT/40)*dY);
 
53
            if(newY > 0)
 
54
                lscroll.style.top = (-1 * newY) + "px";
 
55
            else
 
56
                lscroll.style.top = "0px";
 
57
 
 
58
            /* if the lscroll has hit the limit, delay and swing */
 
59
            /* the other way */
 
60
            if((newY >= maxY)&&(dY > 0))
 
61
            {
 
62
                delay = 5000;
 
63
                dY = -20;
 
64
            }
 
65
            else if((newY <= 0)&&(dY < 0))
 
66
            {
 
67
                delay = 5000;
 
68
                dY = 2;
 
69
            }
 
70
        }, 40);
 
71
    };
 
72
 
 
73
    qbtn.onclick = function() {
 
74
        hpage.style.display=priorHpageDisplay;
 
75
        lpage.style.display="none";
 
76
        clearInterval(timer);
 
77
    };
 
78
}
 
79