summaryrefslogtreecommitdiffstats
path: root/notFinishedCode/pChart2.1.2/examples/delayedLoader
diff options
context:
space:
mode:
authorRefik Hadzialic2011-08-09 18:53:51 +0200
committerRefik Hadzialic2011-08-09 18:53:51 +0200
commit8b8b972fa84f6400326f700bd9434e2f257e16d9 (patch)
treed436ed11821797412b7f6671687cf1113c33b2a9 /notFinishedCode/pChart2.1.2/examples/delayedLoader
parentinsert information for smart test on the help message (diff)
downloadgsm-selftest-8b8b972fa84f6400326f700bd9434e2f257e16d9.tar.gz
gsm-selftest-8b8b972fa84f6400326f700bd9434e2f257e16d9.tar.xz
gsm-selftest-8b8b972fa84f6400326f700bd9434e2f257e16d9.zip
Libraries and start code for the output results image
Diffstat (limited to 'notFinishedCode/pChart2.1.2/examples/delayedLoader')
-rw-r--r--notFinishedCode/pChart2.1.2/examples/delayedLoader/delayedLoading.js228
-rw-r--r--notFinishedCode/pChart2.1.2/examples/delayedLoader/draw.php34
-rw-r--r--notFinishedCode/pChart2.1.2/examples/delayedLoader/index.php91
-rw-r--r--notFinishedCode/pChart2.1.2/examples/delayedLoader/wait.gifbin0 -> 2545 bytes
4 files changed, 353 insertions, 0 deletions
diff --git a/notFinishedCode/pChart2.1.2/examples/delayedLoader/delayedLoading.js b/notFinishedCode/pChart2.1.2/examples/delayedLoader/delayedLoading.js
new file mode 100644
index 0000000..b76bbe3
--- /dev/null
+++ b/notFinishedCode/pChart2.1.2/examples/delayedLoader/delayedLoading.js
@@ -0,0 +1,228 @@
+ /*
+ delayedLoader - JS to delay out of sight pictures rendering
+
+ Version : 2.0.2
+ Made by : Jean-Damien POGOLOTTI
+ Last Update : 10/12/10
+
+ This file can be distributed under the license you can find at :
+
+ http://www.pchart.net/license
+
+ You can find the whole class documentation on the pChart web site.
+ */
+
+ var PictureCache = new Array();
+ var PictureCount = 0;
+ var WaitPicture = "wait.gif";
+ var DivClassName = "pChart";
+ var DefaultWidth = 70;
+ var DefaultHeight = 230;
+ var DefaultAlt = "pChart rendered picture";
+
+
+ /* Do the DOM document processing */
+ function loaderInit()
+ {
+ WindowSize = getWindowSize();
+ WindowHeight = WindowSize[1];
+ Offset = getScrollXY();
+ HeightOffset = Offset[1];
+
+ /* Enumerate the tags */
+ Links = document.getElementsByTagName("a");
+ for (i = 0; i < Links.length; i++)
+ {
+ className = Links[i].className;
+
+ if ( className == DivClassName )
+ {
+ ObjectWidth = Links[i].getAttribute("data-pchart-width");
+ ObjectHeight = Links[i].getAttribute("data-pchart-height");
+ ObjectID = Links[i].id;
+ ObjectTop = Links[i].offsetTop;
+ ObjectURL = Links[i].href;
+ ObjectAlt = Links[i].getAttribute("data-pchart-alt");
+
+ if ( ObjectWidth == null ) { ObjectWidth = DefaultWidth; }
+ if ( ObjectHeight == null ) { ObjectHeight = DefaultHeight; }
+ if ( ObjectAlt == null ) { ObjectAlt = DefaultAlt; }
+
+ if (ObjectID == "") { ObjectID = "pChart-"+i; Links[i].id = ObjectID; }
+
+ PictureCache[PictureCount] = new Array();
+ PictureCache[PictureCount][0] = ObjectID;
+ PictureCache[PictureCount][1] = ObjectTop;
+ PictureCache[PictureCount][2] = ObjectURL;
+ PictureCache[PictureCount][3] = ObjectAlt;
+ PictureCache[PictureCount][4] = ObjectWidth;
+ PictureCache[PictureCount][5] = ObjectHeight;
+
+ PictureCount++;
+ }
+ }
+
+ /* Replace the <A> tags by <DIV> ones and attach the loader */
+ for(i=0;i<PictureCount;i++)
+ {
+ ATag = document.getElementById(PictureCache[i][0]);
+ DivTag = document.createElement("div");
+ DivID = "pChart-Div"+i; PictureCache[i][0] = DivID;
+
+ DivTag.setAttribute("id", DivID);
+ DivTag.style.width = PictureCache[i][4];
+ DivTag.style.height = PictureCache[i][5];
+ DivTag.style.backgroundColor = "#E0E0E0";
+
+ DivTag2 = ATag.parentNode.replaceChild(DivTag, ATag);
+
+ DivTop = DivTag.offsetTop;
+ PictureCache[i][1] = DivTop;
+
+ changeOpac(50, i);
+ changeContent("<img src='"+WaitPicture+"' width=24 height=24 alt=''/>",i);
+
+ if ( HeightOffset + WindowHeight > PictureCache[i][1] ) { triggerVisible(i); }
+ }
+ }
+
+ /* Replace the contents of the delayed loading DIV */
+ function changeContent(html, id)
+ { DivID = PictureCache[id][0]; document.getElementById(DivID).innerHTML = html; }
+
+ /* Trigger the picture rendering when the pChart DIV became visible */
+ function triggerVisible(PictureID)
+ {
+ if ( !PictureCache[PictureID][6] == true )
+ {
+ PictureCache[PictureID][6] = true;
+ ajaxRender(PictureCache[PictureID][2],PictureID);
+ }
+ }
+
+ /* Catch the navigator window scrolling event */
+ function scrollEvent()
+ {
+ WindowSize = getWindowSize();
+ WindowHeight = WindowSize[1];
+ Offset = getScrollXY();
+ HeightOffset = Offset[1];
+
+ for(i=0;i<=PictureCount-1;i++) { if ( HeightOffset + WindowHeight > PictureCache[i][1] ) { triggerVisible(i); } }
+ }
+
+ /* Cross browser X/Y window offset gatherer */
+ function getScrollXY()
+ {
+ var scrOfX = 0, scrOfY = 0;
+
+ if( typeof( window.pageYOffset ) == 'number' )
+ { scrOfY = window.pageYOffset; scrOfX = window.pageXOffset; }
+ else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) )
+ { scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft; }
+ else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )
+ { scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft; }
+
+ return [ scrOfX, scrOfY ];
+ }
+
+ /* Cross browser X/Y window size gatherer */
+ function getWindowSize()
+ {
+ var myWidth = 0, myHeight = 0;
+
+ if( typeof( window.innerWidth ) == 'number' )
+ { myWidth = window.innerWidth; myHeight = window.innerHeight; }
+ else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
+ { myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight; }
+ else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
+ { myWidth = document.body.clientWidth; myHeight = document.body.clientHeight; }
+
+ return [ myWidth, myHeight ];
+ }
+
+ /* Cross browser alpha transparency changer */
+ function changeOpac(opacity, id)
+ {
+ DivID = PictureCache[id][0];
+
+ var object = document.getElementById(DivID).style;
+ object.opacity = (opacity / 100);
+ object.MozOpacity = (opacity / 100);
+ object.KhtmlOpacity = (opacity / 100);
+ object.filter = "alpha(opacity=" + opacity + ")";
+ }
+
+ /* Shade in-out function */
+ function opacity(id, opacStart, opacEnd, millisec)
+ {
+ var speed = Math.round(millisec / 100);
+ var timer = 0;
+
+ if(opacStart > opacEnd)
+ {
+ for(i = opacStart; i >= opacEnd; i--)
+ {
+ setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
+ timer++;
+ }
+ }
+ else if(opacStart < opacEnd)
+ {
+ for(i = opacStart; i <= opacEnd; i++)
+ {
+ setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
+ timer++;
+ }
+ }
+ }
+
+ /* Start the loader */
+ function StartFade(PictureID)
+ {
+ Loader = new Image();
+ URL = PictureCache[PictureID][2];
+ Loader.src = URL;
+ setTimeout("CheckLoadingStatus("+PictureID+")", 200);
+ }
+
+ /* check the picture loading status */
+ function CheckLoadingStatus(PictureID)
+ {
+ DivID = PictureCache[PictureID][0];
+ URL = PictureCache[PictureID][2];
+ Alt = PictureCache[PictureID][3];
+
+ if ( Loader.complete == true )
+ {
+ changeOpac(0, PictureID);
+ HTMLResult = "<center><img src='" + URL + "' alt='"+Alt+"'/></center>";
+ document.getElementById(DivID).innerHTML = HTMLResult;
+
+ opacity(PictureID,0,100,100);
+ }
+ else
+ setTimeout("CheckLoadingStatus("+PictureID+")", 200);
+ }
+
+ /* Compute the pChart picture in background */
+ function ajaxRender(URL,PictureID)
+ {
+ var xmlhttp=false;
+ /*@cc_on @*/
+ /*@if (@_jscript_version >= 5)
+ try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } }
+ @end @*/
+
+ if (!xmlhttp && typeof XMLHttpRequest!='undefined')
+ { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp=false; } }
+
+ if (!xmlhttp && window.createRequest)
+ { try { xmlhttp = window.createRequest(); } catch (e) { xmlhttp=false; } }
+
+ xmlhttp.open("GET", URL,true);
+
+ xmlhttp.onreadystatechange=function()
+ { if (xmlhttp.readyState==4) { StartFade(PictureID); } }
+ xmlhttp.send(null)
+ }
diff --git a/notFinishedCode/pChart2.1.2/examples/delayedLoader/draw.php b/notFinishedCode/pChart2.1.2/examples/delayedLoader/draw.php
new file mode 100644
index 0000000..c5b3c2f
--- /dev/null
+++ b/notFinishedCode/pChart2.1.2/examples/delayedLoader/draw.php
@@ -0,0 +1,34 @@
+<?php
+ if ( !isset($_GET["Seed"]) )
+ { $Seed = "Unknown"; }
+ else
+ { $Seed = $_GET["Seed"]; }
+
+ /* pChart library inclusions */
+ include("../../class/pDraw.class.php");
+ include("../../class/pImage.class.php");
+
+ /* Create the pChart object */
+ $myPicture = new pImage(700,230);
+ $myPicture->drawGradientArea(0,0,700,230,DIRECTION_HORIZONTAL,array("StartR"=>220,"StartG"=>220,"StartB"=>220,"EndR"=>180,"EndG"=>180,"EndB"=>180,"Alpha"=>100));
+ $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,array("StartR"=>220,"StartG"=>220,"StartB"=>220,"EndR"=>180,"EndG"=>180,"EndB"=>180,"Alpha"=>50));
+ $RectangleSettings = array("R"=>180,"G"=>180,"B"=>180,"Alpha"=>100);
+
+ /* Add a border to the picture */
+ $myPicture->drawRectangle(0,0,699,229,array("R"=>150,"G"=>150,"B"=>150));
+
+ /* Write the title */
+ $myPicture->setFontProperties(array("FontName"=>"../../fonts/advent_light.ttf","FontSize"=>40));
+ $myPicture->drawText(130,130,"Delayed loading script",array("R"=>255,"G"=>255,"B"=>255));
+
+ /* Write the seed # */
+ $myPicture->setFontProperties(array("FontName"=>"../../fonts/advent_light.ttf","FontSize"=>10));
+ $myPicture->drawText(130,140,"Seed # : ".$Seed,array("R"=>255,"G"=>255,"B"=>255));
+
+ /* Draw a bezier curve */
+ $BezierSettings = array("R"=>255,"G"=>255,"B"=>255,"Ticks"=>4,"DrawArrow"=>TRUE,"ArrowTwoHeads"=>TRUE);
+ $myPicture->drawBezier(360,170,670,120,430,100,560,190,$BezierSettings);
+
+ /* Render the picture (choose the best way) */
+ $myPicture->autoOutput("draw.png");
+?> \ No newline at end of file
diff --git a/notFinishedCode/pChart2.1.2/examples/delayedLoader/index.php b/notFinishedCode/pChart2.1.2/examples/delayedLoader/index.php
new file mode 100644
index 0000000..10e3db0
--- /dev/null
+++ b/notFinishedCode/pChart2.1.2/examples/delayedLoader/index.php
@@ -0,0 +1,91 @@
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <script src='delayedLoading.js' type="text/javascript"></script>
+ <title>pChart 2.x - Delayed loading</title>
+ <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
+ <style>
+ html { height: 100%; }
+ body { background-color: #F0F0F0; font-family: tahoma; font-size: 14px; height: 100%;}
+ td { font-family: tahoma; font-size: 11px; }
+ div.txt { font-family: tahoma; font-size: 11px; width: 660px; padding: 15px; }
+ a.smallLink:link { text-decoration: none; color: #6A6A6A; }
+ a.smallLink:visited { text-decoration: none; color: #6A6A6A; }
+ a.smallLink:hover { text-decoration: underline; color: #6A6A6A; }
+ a.pChart { text-decoration: none; color: #6A6A6A; }
+ </style>
+</head>
+<body onscroll="scrollEvent();" onload="loaderInit();">
+
+ <table style='border: 2px solid #FFFFFF;'><tr><td>
+ <div style='font-size: 11px; padding: 2px; color: #FFFFFF; background-color: #666666; border-bottom: 3px solid #484848;'>&nbsp;Navigation</div>
+ <table style='padding: 1px; background-color: #E0E0E0; border: 1px solid #D0D0D0; border-top: 1px solid #FFFFFF;'><tr>
+ <td width=16><img src='../resources/application_view_tile.png' width=16 height=16 alt=''/></td>
+ <td width=95>&nbsp;<a class=smallLink href='../'>Examples</a></td>
+ <td width=16><img src='../resources/application_view_list.png' width=16 height=16 alt=''/></td>
+ <td width=95>&nbsp;<a class=smallLink href='../sandbox/'>Sandbox</a></td>
+ <td width=16><img src='../resources/application_view_list.png' width=16 height=16 alt=''/></td>
+ <td width=95>&nbsp;<b>Delayed loader</b></td>
+ <td width=16><img src='../resources/application_view_list.png' width=16 height=16 alt=''/></td>
+ <td width=100>&nbsp;<a class=smallLink href='../imageMap/'>Image Map</a></td>
+ </tr></table>
+ </td></tr></table>
+
+ <br/>
+
+ <div class=txt>
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
+ aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
+ occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+ </div>
+ <a class='pChart' href='draw.php?Seed=1' data-pchart-alt='Picture1' data-pchart-width='700' data-pchart-height='230'>Picture 1</a>
+ <div class=txt>
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
+ aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
+ occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+ </div>
+ <a class='pChart' href='draw.php?Seed=2' data-pchart-alt='Picture2'>Picture 2</a>
+ <div class=txt>
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
+ aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
+ occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+ </div>
+ <a class='pChart' href='draw.php?Seed=3' data-pchart-alt='Picture3'>Picture 3</a>
+ <div class=txt>
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
+ aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
+ occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+ </div>
+ <a class='pChart' href='draw.php?Seed=4' data-pchart-alt='Picture4'>Picture 4</a>
+ <div class=txt>
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
+ aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
+ occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+ </div>
+ <a class='pChart' href='draw.php?Seed=5' data-pchart-alt='Picture5'>Picture 5</a>
+ <div class=txt>
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
+ aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
+ occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+ </div>
+ <a class='pChart' href='draw.php?Seed=6' data-pchart-alt='Picture6'>Picture 6</a>
+ <div class=txt>
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
+ aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
+ occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+ </div>
+ <a class='pChart' href='draw.php?Seed=7' data-pchart-alt='Picture7'>Picture 7</a>
+ <div class=txt>
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
+ aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
+ occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+ </div>
+</body>
+</html> \ No newline at end of file
diff --git a/notFinishedCode/pChart2.1.2/examples/delayedLoader/wait.gif b/notFinishedCode/pChart2.1.2/examples/delayedLoader/wait.gif
new file mode 100644
index 0000000..1c72ebb
--- /dev/null
+++ b/notFinishedCode/pChart2.1.2/examples/delayedLoader/wait.gif
Binary files differ