Guest User

Untitled

a guest
Oct 5th, 2018
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.14 KB | None | 0 0
  1. <?php
  2. /*** mysql hostname ***/
  3. $hostname = 'localhost';
  4.  
  5. /*** mysql username ***/
  6. $username = 'root';
  7.  
  8. /*** mysql password ***/
  9. $password = 'root';
  10.  
  11. try {
  12. $dbh = new PDO("mysql:host=$hostname;dbname=TestDB", $username, $password);
  13. /*** echo a message saying we have connected ***/
  14. //echo 'Connected to database<p>';
  15.  
  16. /*** The SQL SELECT statement ***/
  17. $sql = "SELECT pressure FROM SensorData";
  18.  
  19. /*** fetch into an PDOStatement object ***/
  20. $stmt = $dbh->query($sql);
  21.  
  22. /*** echo number of columns ***/
  23. $result = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
  24.  
  25. /*** loop over the object directly ***/
  26.  
  27.  
  28. /*** close the database connection ***/
  29. $dbh = null;
  30. }
  31.  
  32. catch(PDOException $e)
  33. {
  34. echo $e->getMessage();
  35. }
  36. ?>
  37.  
  38.  
  39. <!DOCTYPE HTML>
  40. <html>
  41. <head>
  42. <audio id="audOne" preload="auto">
  43. <source src="audio/one.mp3"></source>
  44. <!--<source src="audio/one.ogg"></source>-->
  45. <source src="audio/one.wav"></source>
  46. Sorry, your browser does not support HTML5 audio!
  47. </audio>
  48.  
  49.  
  50. <audio id="audTwo" preload="auto">
  51. <source src="audio/two.mp3"></source>
  52. <!--<source src="audio/two.ogg"></source>-->
  53. <source src="audio/two.wav"></source>
  54. Sorry, your browser does not support HTML5 audio!
  55. </audio>
  56.  
  57. <audio id="audThree" preload="auto">
  58. <source src="audio/three.mp3"></source>
  59. <!--<source src="audio/three.ogg"></source>-->
  60. <source src="audio/three.wav"></source>
  61. Sorry, your browser does not support HTML5 audio!
  62. </audio>
  63.  
  64. <audio id="audFour" preload="auto">
  65. <source src="audio/four.mp3"></source>
  66. <!--<source src="audio/four.ogg"></source>-->
  67. <source src="audio/four.wav"></source>
  68. Sorry, your browser does not support HTML5 audio!
  69. </audio>
  70.  
  71. <audio id="audFive" preload="auto">
  72. <source src="audio/five.mp3"></source>
  73. <!--<source src="audio/five.ogg"></source>-->
  74. <source src="audio/five.wav"></source>
  75. Sorry, your browser does not support HTML5 audio!
  76. </audio>
  77.  
  78. <audio id="audSix" preload="auto">
  79. <source src="audio/six.mp3"></source>
  80. <!--<source src="audio/six.ogg"></source>-->
  81. <source src="audio/six.wav"></source>
  82. Sorry, your browser does not support HTML5 audio!
  83. </audio>
  84.  
  85. <audio id="audSeven" preload="auto">
  86. <source src="audio/seven.mp3"></source>
  87. <!--<source src="audio/seven.ogg"></source>-->
  88. <source src="audio/seven.wav"></source>
  89. Your browser isn't invited for super fun time.
  90. </audio>
  91.  
  92. <audio id="audEight" preload="auto">
  93. <source src="audio/eight.mp3"></source>
  94. <!--<source src="audio/eight.ogg"></source>-->
  95. <source src="audio/eight.wav"></source>
  96. Your browser isn't invited for super fun time.
  97. </audio>
  98.  
  99. <audio id="audNine" preload="auto">
  100. <source src="audio/nine.mp3"></source>
  101. <!--<source src="audio/nine.ogg"></source>-->
  102. <source src="audio/nine.wav"></source>
  103. Your browser isn't invited for super fun time.
  104. </audio>
  105.  
  106. <audio id="audTen" preload="auto">
  107. <source src="audio/ten.mp3"></source>
  108. <!--<source src="audio/ten.ogg"></source>-->
  109. <source src="audio/ten.wav"></source>
  110. Your browser isn't invited for super fun time.
  111. </audio>
  112.  
  113.  
  114. <style>
  115. body {
  116. margin: 0px;
  117. padding: 0px;
  118. }
  119. canvas {
  120. border: 1px solid #9C9898;
  121. background:gray;
  122. background-image:url("backs/grey2.jpeg");
  123. }
  124. </style>
  125.  
  126. </head>
  127. <script src="libraries/kinetic.js"></script>
  128. <script>
  129. var dataArray = new Array();
  130. dataArray = <?php echo json_encode($result);?>;
  131. document.write(" this is data array " + dataArray);
  132.  
  133. var totalValues = ((dataArray[0]*1000)+(dataArray[1]*1000)+(dataArray[3]*1000)+(dataArray[4]*1000)+(dataArray[5]*1000)+(dataArray[6]*1000)+(dataArray[7]*1000)+(dataArray[8]*1000))/1000;
  134. var average = totalValues/9;
  135. document.write("<br /> average : " + average);
  136.  
  137. var audioArray = ['audOne', 'audTwo', 'audThree', 'audFour', 'audFive', 'audSix', 'audSeven', 'audEight', 'audNine', 'audTen'];
  138. var randomAudio = [Math.floor(audioArray.length * Math.random())];
  139. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  140.  
  141.  
  142. function loadImages(sources, callback) {
  143.  
  144. var images = {};
  145. var loadedImages = 0;
  146. var numImages = 0;
  147. // get num of sources
  148. for(var src in sources) {
  149. numImages++;
  150. }
  151. for(var src in sources) {
  152. images[src] = new Image();
  153. images[src].onload = function() {
  154. if(++loadedImages >= numImages) {
  155. callback(images);
  156. }
  157. };
  158. images[src].src = sources[src];
  159. }
  160. }
  161.  
  162.  
  163. function draw(images) {
  164.  
  165. var stage = new Kinetic.Stage({
  166. container: "container",
  167. //width: window.innerWidth,
  168. //height: window.innerHeight,
  169. width: 960,
  170. height: 640,
  171. fill: "blue"
  172. });
  173.  
  174. }
  175.  
  176. var layer = new Kinetic.Layer();
  177.  
  178. var Xposition = new Array();
  179. var Yposition = new Array();
  180.  
  181. Xposition[0]=stage.getWidth()/10;
  182. Xposition[1]=stage.getWidth()/5;
  183. Xposition[2]=stage.getWidth()/10*3;
  184. Xposition[3]=stage.getWidth()/5*2;
  185. Xposition[4]=stage.getWidth()/2;
  186. Xposition[5]=stage.getWidth()/5*3;
  187. Xposition[6]=stage.getWidth()/10*7;
  188. Xposition[7]=stage.getWidth()/5*4;
  189. Xposition[8]=stage.getWidth()/10*9;
  190. Xposition[9]=stage.getWidth();
  191.  
  192. Yposition[0]=stage.getHeight()/10;
  193. Yposition[1]=stage.getHeight()/5;
  194. Yposition[2]=stage.getHeight()/10*3;
  195. Yposition[3]=stage.getHeight()/5*2;
  196. Yposition[4]=stage.getHeight()/2;
  197. Yposition[5]=stage.getHeight()/5*3;
  198. Yposition[6]=stage.getHeight()/10*7;
  199. Yposition[7]=stage.getHeight()/5*4;
  200. Yposition[8]=stage.getHeight()/10*9;
  201. Yposition[9]=stage.getHeight();
  202.  
  203.  
  204.  
  205. function createCloud(x,y,radius){
  206. var circle = new Kinetic.Circle({
  207. x: x,
  208. y: y,
  209. radius: radius,
  210. opacity:0.5,
  211. fill: "#00d2ff",
  212. stroke: "transparent",
  213. strokeWidth: 4,
  214. //draggable: true
  215. });
  216. return circle;
  217. }
  218.  
  219. function createRing(x,y,radius){
  220. var circle = new Kinetic.Circle({
  221. x: x,
  222. y: y,
  223. radius: radius,
  224. opacity:0.5,
  225. fill: "transparent",
  226. stroke: "white",
  227. strokeWidth: 2,
  228. //draggable: true
  229. });
  230. return circle;
  231. }
  232.  
  233. function createAniOut(ring,size){
  234. var periodOut = 1000;
  235. var size = size;
  236. var animOut = new Kinetic.Animation({
  237. func: function(frame) {
  238. var scale=Math.sin(frame.time*2/periodOut)*size;
  239. ring.setScale(scale);
  240.  
  241. },
  242. node: layer
  243. });
  244. return animOut;
  245. }
  246.  
  247. function createAniIn(ring){
  248. var periodIn = 1000;
  249. var animIn = new Kinetic.Animation({
  250. func: function(frame) {
  251. var scale=periodIn/frame.time*2
  252. ring.setScale(scale);
  253. },
  254. node: layer
  255. });
  256. return animIn;
  257. }
  258.  
  259. var cloud = new Array(); //array of dots
  260. var ring = new Array();
  261.  
  262.  
  263. for(i=0; i<11; i++){
  264. var posX=Math.floor(Math.random()*9);
  265. var posY=Math.floor(Math.random()*9);
  266. cloud[i]=createCloud(Xposition[posX], Yposition[posY], 10);
  267. ring[i]=createRing(Xposition[posX], Yposition[posY], 10);
  268. }
  269.  
  270.  
  271. for(i=0; i<ring.length; i++){
  272. layer.add(ring[i]);
  273. }
  274. for(i=0; i<cloud.length; i++){
  275. layer.add(cloud[i]);
  276. }
  277.  
  278. stage.add(layer);
  279.  
  280. var animIn=new Array;
  281. var animOut=new Array;
  282.  
  283. for(k=0; k<cloud.length; k++){
  284. animOut[k]=createAniOut(ring[k], average);
  285. //choose sounds here after putting them into new array
  286. }
  287.  
  288.  
  289.  
  290.  
  291. cloud[0].on("mouseover touchstart touchmove", function() {
  292. animOut[0].start();
  293. layer.draw();
  294. });
  295.  
  296. cloud[0].on("mouseout touchend", function() {
  297. animOut[0].stop();
  298. layer.draw();
  299. });
  300.  
  301.  
  302. cloud[1].on("mouseover touchstart touchmove", function() {
  303. animOut[1].start();
  304. layer.draw();
  305. });
  306.  
  307. cloud[1].on("mouseout touchend", function() {
  308. animOut[1].stop();
  309. layer.draw();
  310. });
  311.  
  312.  
  313. cloud[2].on("mouseover touchstart touchmove", function() {
  314. animOut[2].start();
  315. layer.draw();
  316. });
  317.  
  318. cloud[2].on("mouseout touchend", function() {
  319. animOut[2].stop();
  320. layer.draw();
  321. });
  322.  
  323.  
  324. cloud[3].on("mouseover touchstart touchmove", function() {
  325. animOut[3].start();
  326. layer.draw();
  327. });
  328.  
  329. cloud[3].on("mouseout touchend", function() {
  330. animOut[3].stop();
  331. layer.draw();
  332. });
  333.  
  334.  
  335. cloud[4].on("mouseover touchstart touchmove", function() {
  336. animOut[4].start();
  337. layer.draw();
  338. });
  339.  
  340. cloud[4].on("mouseout touchend", function() {
  341. animOut[4].stop();
  342. layer.draw();
  343. });
  344.  
  345.  
  346. cloud[5].on("mouseover touchstart touchmove", function() {
  347. animOut[5].start();
  348. layer.draw();
  349. });
  350.  
  351. cloud[5].on("mouseout touchend", function() {
  352. animOut[5].stop();
  353. layer.draw();
  354. });
  355.  
  356.  
  357. cloud[6].on("mouseover touchstart touchmove", function() {
  358. animOut[6].start();
  359. layer.draw();
  360. });
  361.  
  362. cloud[6].on("mouseout touchend", function() {
  363. animOut[6].stop();
  364. layer.draw();
  365. });
  366.  
  367.  
  368. cloud[7].on("mouseover touchstart touchmove", function() {
  369. animOut[7].start();
  370. layer.draw();
  371. });
  372.  
  373. cloud[7].on("mouseout touchend", function() {
  374. animOut[7].stop();
  375. layer.draw();
  376. });
  377.  
  378. cloud[8].on("mouseover touchstart touchmove", function() {
  379. animOut[8].start();
  380. layer.draw();
  381. });
  382.  
  383. cloud[8].on("mouseout touchend", function() {
  384. animOut[8].stop();
  385. layer.draw();
  386. });
  387.  
  388. cloud[9].on("mouseover touchstart touchmove", function() {
  389. animOut[9].start();
  390. layer.draw();
  391. });
  392.  
  393. cloud[9].on("mouseout touchend", function() {
  394. animOut[9].stop();
  395. layer.draw();
  396. });
  397.  
  398.  
  399.  
  400.  
  401.  
  402. ring[0].on("mouseover touchstart touchmove", function() {
  403. audOne.play();
  404. });
  405.  
  406. ring[1].on("mouseover touchstart touchmove", function() {
  407. audTwo.play();
  408. });
  409.  
  410. ring[2].on("mouseover touchstart touchmove", function() {
  411. audThree.play();
  412. });
  413.  
  414. ring[3].on("mouseover touchstart touchmove", function() {
  415. audFour.play();
  416. });
  417.  
  418. ring[4].on("mouseover touchstart touchmove", function() {
  419. audFive.play();
  420. });
  421.  
  422. ring[5].on("mouseover touchstart touchmove", function() {
  423. audSix.play();
  424. });
  425.  
  426. ring[6].on("mouseover touchstart touchmove", function() {
  427. audSeven.play();
  428. });
  429.  
  430. ring[7].on("mouseover touchstart touchmove", function() {
  431. audEight.play();
  432. });
  433.  
  434. ring[8].on("mouseover touchstart touchmove", function() {
  435. audNine.play();
  436. });
  437.  
  438. window.onload = function() {
  439.  
  440. var sources = {
  441. one: "backs/1.jpeg",
  442. two: "backs/2.jpeg",
  443. };
  444.  
  445.  
  446. loadImages(sources, function(images) {
  447. draw(images);
  448. });
  449.  
  450. };
  451.  
  452. </script>
  453.  
  454. <body onmousedown="return false;">
  455. <div id="container"></div>
  456. </body>
  457. </html>
Add Comment
Please, Sign In to add comment