animations.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  1. function currXYSlide(slide) {
  2. var slideWidth = gv.sw;
  3. var slideLength = gv.sh;
  4. var left=0;
  5. var top = 0;
  6. if (typeof(slide.sV.left)!='undefined'){
  7. var left = parseInt(slide.sV.left.style.left);
  8. var top = parseInt(slide.sV.left.style.top);
  9. }
  10. var tranWidth = slide.sV.w;
  11. var tranHeight = slide.sV.h;
  12. switch (slide.c.additionalData) {
  13. case 1:
  14. slide.dX = left;
  15. slide.dY = tranHeight * -1;
  16. break;
  17. case 2:
  18. slide.dX = slideWidth;
  19. slide.dY = top;
  20. break;
  21. case 3:
  22. slide.dX = left;
  23. slide.dY = slideLength;
  24. break;
  25. case 4:
  26. slide.dX = tranWidth * -1;
  27. slide.dY = top;
  28. break;
  29. case 6:
  30. slide.dX = tranWidth * -1;
  31. slide.dY = tranHeight * -1;
  32. break;
  33. case 7:
  34. slide.dX = slideWidth;
  35. slide.dY = tranHeight * -1;
  36. break;
  37. case 8:
  38. slide.dX = slideWidth;
  39. slide.dY = slideLength;
  40. break;
  41. case 9:
  42. slide.dX = tranWidth * -1;
  43. slide.dY = slideLength;
  44. break
  45. }
  46. slide.fX = left;
  47. slide.fY = top;
  48. /*alert("slide is:"+slide);
  49. alert("slide fX is:" + slide.fX);
  50. alert("slide fY is:" + slide.fY);
  51. alert("slide dX is:" + slide.dX);
  52. alert("slide dY is:" + slide.dY);
  53. alert("slide state is:" + slide.state);
  54. alert("The slide length is:" + slide.slideLength);*/
  55. //Add check here,because we have slide.slideLengt is equal to undefined.
  56. if (slide.slideLength != null)
  57. {
  58. if (slide.slideLength.state == 2) {
  59. var h = slide.fY;
  60. slide.fY = slide.dY;
  61. slide.dY = h;
  62. h = slide.fX;
  63. slide.fX = slide.dX;
  64. slide.dX = h
  65. }
  66. }
  67. }
  68. function colorDecimal(val) {
  69. return Math.min(255, Math.round(val * 256))
  70. }
  71. function hsv2color(hue, satur, val) {
  72. var red;
  73. var green;
  74. var blue;
  75. var g;
  76. var h = Math.floor(hue / 60 % 6);
  77. var i = hue / 60 - h;
  78. var j = val * (1 - satur);
  79. var k = val * (1 - i * satur);
  80. var l = val * (1 - (1 - i) * satur);
  81. switch (h) {
  82. case 0: {
  83. red = val;
  84. green = l;
  85. blue = j;
  86. break
  87. };
  88. case 1: {
  89. red = k;
  90. green = val;
  91. blue = j;
  92. break
  93. };
  94. case 2: {
  95. red = j;
  96. green = val;
  97. blue = l;
  98. break
  99. };
  100. case 3: {
  101. red = j;
  102. green = k;
  103. blue = val;
  104. break
  105. };
  106. case 4: {
  107. red = l;
  108. green = j;
  109. blue = val;
  110. break
  111. };
  112. case 5: {
  113. red = val;
  114. green = j;
  115. blue = k;
  116. break
  117. }
  118. }
  119. red = colorDecimal(red);
  120. green = colorDecimal(green);
  121. blue = colorDecimal(blue);
  122. return [red, green, blue]
  123. }
  124. //REF
  125. function rgb2hsv(color) {
  126. red = color[0] / 255;
  127. green = color[1] / 255;
  128. blue = color[2] / 255;
  129. var diffColors;
  130. var hue;
  131. var satur;
  132. var minColor = Math.min(Math.min(red, green), blue);
  133. var maxColor = Math.max(Math.max(red, green), blue);
  134. diffColors = maxColor - minColor;
  135. switch (maxColor) {
  136. case h: {
  137. hue = 0;
  138. break
  139. };
  140. case r: {
  141. hue = 60 * (g - b) / diffColors;
  142. if (g < b) {
  143. hue = hue + 360
  144. }
  145. break
  146. };
  147. case g: {
  148. hue = 60 * (b - r) / diffColors + 120;
  149. break
  150. };
  151. case b: {
  152. hue = 60 * (r - g) / diffColors + 240;
  153. break
  154. }
  155. }
  156. satur = maxColor === 0 ? 0 : 1 - minColor / maxColor;
  157. var hsv = [Math.round(hue), satur, maxColor];
  158. return hsv
  159. }
  160. function tranend(a) {
  161. pause();
  162. if (a != 1) {
  163. gStartTime = gStartTime - (gslength[gc - 1] + animations["s" + gc].t.i - gt);
  164. play();
  165. return
  166. }
  167. gx = 0;
  168. if (gpc != gc)
  169. gco("s" + gpc + "s0").style.display = "none";
  170. if (gpc > gc) {
  171. gco("s" + gpc + "s0").style.zIndex = "0"
  172. }
  173. gpc = 0;
  174. var b = gt - (gslength[gc - 1] + animations["s" + gc].t.i);
  175. gtct = gtct - b;
  176. if (animations["s" + gc].f == gslength[gc - 1]) {
  177. animations["s" + gc].f = gslength[gc - 1] + animations["s" + gc].t.i;
  178. gt = animations["s" + gc].f
  179. } else {
  180. gStartTime = gStartTime - (animations["s" + gc].f - (gslength[gc - 1] + animations["s" + gc].t.i));
  181. gt = animations["s" + gc].f
  182. }
  183. setProgress();
  184. if (animations["s" + gc].f == gslength[gc - 1] + animations["s" + gc].t.i) {
  185. if (animations["s" + gc].t.n == 1 && animations["s" + gc].g == 0) {
  186. playCurrentAniamtion();
  187. play()
  188. }
  189. } else if (galength.indexOf(animations["s" + gc].f) == -1 && animations["s" + gc].f != gslength[gc]) {
  190. playCurrentAniamtion();
  191. play()
  192. }
  193. }
  194. function video(a, b, c) {
  195. if (gv.v == 0)
  196. return;
  197. var d = a.getElementsByTagName("video")[0];
  198. if (d.paused) {
  199. d.play();
  200. checkForAudioVideoObject(d, 1)
  201. } else {
  202. d.currentTime = 0;
  203. d.pause()
  204. }
  205. }
  206. function audio(a) {
  207. var b = a.getElementsByTagName("audio")[0];
  208. if (gv.v == 0 || typeof b.play == "undefined")
  209. return;
  210. if (b.paused) {
  211. b.play();
  212. checkForAudioVideoObject(b, 1)
  213. } else {
  214. b.pause();
  215. b.currentTime = 0
  216. }
  217. }
  218. var audioEl = document.createElement("audio");
  219. StylePpty = function () {};
  220. StylePpty.Transform = function () {
  221. if (typeof this.transform == "undefined") {
  222. this.transform = "transform";
  223. var a = ["transform", "WebkitTransform", "msTransform", "MozTransform", "OTransform"];
  224. var b;
  225. var c = document.getElementsByTagName("div");
  226. while (b = a.shift()) {
  227. if (typeof c[0].style[b] != "undefined") {
  228. this.transform = b;
  229. return this.transform
  230. }
  231. }
  232. }
  233. return this.transform
  234. };
  235. var DOPStyle = new function () {
  236. if (typeof window.getComputedStyle == "undefined") {
  237. this.s = function (a, b) {
  238. if (typeof a.tagName != "undefined")
  239. return a.currentStyle[b]
  240. }
  241. } else {
  242. this.s = function (a, b) {
  243. if (typeof a.tagName != "undefined")
  244. return document.defaultView.getComputedStyle(a, null)[b]
  245. }
  246. }
  247. };
  248. CalculateDimensions = function (a) {
  249. var childNodes = a.childNodes;
  250. var styletop = -1;
  251. var styleleft = -1;
  252. var dimensions = {
  253. height: 0,
  254. width: 0
  255. };
  256. for (var f = 0; f < childNodes.length; f++) {
  257. var g = childNodes[f];
  258. if (g.nodeType == 1 && g.nodeName == "PRE") {
  259. if (g.style.left != styleleft) {
  260. dimensions.width += parseFloat(g.scrollWidth);
  261. styleleft = g.style.left
  262. }
  263. if (g.style.top != styletop) {
  264. dimensions.height += parseFloat(g.scrollHeight);
  265. styletop = g.style.top
  266. }
  267. }
  268. }
  269. return dimensions
  270. };
  271. initDimensions = function (a) {
  272. this.p = a;
  273. if (this.p.c.e0 != 5) {
  274. this.d = document.getElementById(gci(this.p.c.objectId, gc));
  275. this.dpd = document.getElementById(gci(this.p.c.objectId, gc) + "c");
  276. var tempDpd = document.getElementById(gci(this.p.c.objectId, gc) + ".png");
  277. if (tempDpd) {
  278. this.dpd = tempDpd;
  279. }
  280. var tempDpd = document.getElementById(gci(this.p.c.objectId, gc) + ".gif");
  281. if (tempDpd) {
  282. this.dpd = tempDpd;
  283. }
  284. var tempDpd = document.getElementById(gci(this.p.c.objectId, gc) + ".jpg");
  285. if (tempDpd) {
  286. this.dpd = tempDpd;
  287. }
  288. } else {
  289. this.d = document.getElementById(this.p.c.objectId);
  290. this.dpd = document.getElementById(this.p.c.objectId + "c")
  291. var tempDpd = document.getElementById(this.p.c.objectId, gc + ".png");
  292. if (tempDpd) {
  293. this.dpd= tempDpd;
  294. }
  295. var tempDpd = document.getElementById(this.p.c.objectId, gc + ".gif");
  296. if (tempDpd) {
  297. this.dpd = tempDpd;
  298. }
  299. var tempDpd = document.getElementById(this.p.c.objectId, gc + ".jpg");
  300. if (tempDpd) {
  301. this.dpd = tempDpd;
  302. }
  303. }
  304. if (this.dpd == null)
  305. this.dpd = this.d;
  306. this.h = this.d.style.height ? parseFloat(this.d.style.height) : this.d.parentNode.style.height ? parseFloat(this.d.parentNode.style.height) : parseFloat(this.d.scrollHeight);
  307. this.w = this.d.style.width ? parseFloat(this.d.style.width) : this.d.parentNode.style.width ? parseFloat(this.d.parentNode.style.width) : parseFloat(this.d.scrollWidth);
  308. if (this.h == 0 || this.w == 0) {
  309. var b = CalculateDimensions(this.dpd);
  310. this.h = b.height;
  311. this.w = b.width
  312. }
  313. this.l = this.d.style.left ? parseFloat(this.d.style.left) : parseFloat(this.d.parentNode.style.left);
  314. this.t = this.d.style.top ? parseFloat(this.d.style.top) : parseFloat(this.d.parentNode.style.top);
  315. this.op = parseFloat(DOPStyle.s(this.dpd, "opacity"));
  316. this.st = gt;
  317. this.setTrasform = function () {
  318. this.trns = this.p.getTranslate();
  319. this.scl = this.p.getScale();
  320. this.rta = this.p.getRotate();
  321. this.skw = this.p.getSkewX()
  322. };
  323. this.reset = function () {
  324. this.d.style.height = this.h + "px";
  325. this.d.style.width = this.w + "px";
  326. this.d.style.left = this.l + "px";
  327. this.d.style.top = this.t + "px";
  328. this.dpd.style.opacity = this.op;
  329. this.p.setTranslate(this.trns.x, this.trns.y);
  330. this.p.setScale(this.scl.x, this.scl.y);
  331. this.p.setRotate(this.rta);
  332. this.p.setSkewX(this.skw)
  333. }
  334. };
  335. BaseAnimation = function (c) {
  336. this.c = c;
  337. this.blks = new Array;
  338. this.gtime = function () {
  339. var a = gt;
  340. if (this.c.repetitions < 0 && this.rpdCnt > 0)
  341. a = (new Date).getTime();
  342. return a
  343. };
  344. this.initBaseAnimation = function (a) {
  345. if (typeof this.sV != "undefined")
  346. return false;
  347. this.sV = new initDimensions(this);
  348. this.sV.setTrasform();
  349. this.rpdCnt = 0;
  350. this.initT = this.st = a;
  351. if (typeof this.c.c6 != "undefined")
  352. this.aSrc = document.getElementById(this.c.c6).src;
  353. this.at = typeof this.c.e1 == "undefined" ? 1 : this.c.e1;
  354. this.InitAnimBlocks();
  355. return true
  356. };
  357. this.InitAnimBlocks = function () {
  358. if (this.at == 1)
  359. return;
  360. var p = this;
  361. var cBlk = 0;
  362. var cPara = 0;
  363. var cBlkI = 1;
  364. while (1) {
  365. var nblkId = p.c.e3[cPara] + "b" + cBlkI;
  366. if (null != document.getElementById(nblkId)) {
  367. var nBtm = p.c.e0 == 3 ? p.st + p.c.start + p.c.length + p.c.e2 * cBlk : p.st + p.c.e2 * cBlk;
  368. var pc = p.c;
  369. var nC = {
  370. objectId : nblkId,
  371. start : pc.start,
  372. length : pc.length,
  373. repetitions : 0,
  374. state: pc.state,
  375. name : pc.name,
  376. c7 : pc.c7,
  377. additionalData: pc.additionalData,
  378. additionalData2: pc.additionalData2,
  379. scaleX: pc.scaleX,
  380. scaleY: pc.scaleY,
  381. color: pc.color,
  382. transparency: pc.transparency,
  383. s6 : pc.s6,
  384. v : pc.v0,
  385. e0 : 5,
  386. e1 : 1,
  387. e2 : pc.e2,
  388. e3 : 0
  389. };
  390. if (typeof window[p.c.name] != "undefined")
  391. p.blks[cBlk] = eval("new " + p.c.name + "(nC)");
  392. else
  393. p.blks[cBlk] = new Fade(nC);
  394. var blk = p.blks[cBlk];
  395. blk.Initialize(nBtm);
  396. cBlk++;
  397. cBlkI++
  398. } else if (cPara + 1 < p.c.e3.length) {
  399. cPara++;
  400. cBlkI = 1
  401. } else
  402. break
  403. }
  404. };
  405. this.resetBaseAnimation = function () {
  406. this.pozd = false;
  407. this.stpd = false;
  408. for (x in this.blks) {
  409. this.blks[x].pozd = false;
  410. this.blks[x].stpd = false
  411. }
  412. };
  413. this.pause = function () {
  414. this.pozd = true;
  415. for (x in this.blks)
  416. this.blks[x].pozd = true
  417. };
  418. this.stop = function () {
  419. this.pozd = false;
  420. this.stpd = true;
  421. for (x in this.blks) {
  422. this.blks[x].pozd = false;
  423. this.blks[x].stpd = true
  424. }
  425. };
  426. this.reset = function () {
  427. this.rpdCnt = 0;
  428. this.st = this.initT;
  429. this.stop();
  430. this.stopAudio();
  431. if (typeof this.dltCv != "undefined")
  432. this.dltCv();
  433. if (typeof this.mc != "undefined")
  434. this.mc.cvt.clearRect(0, 0, this.w, this.h);
  435. if (typeof this.sV != "undefined")
  436. this.sV.reset();
  437. for (x in this.blks)
  438. this.blks[x].reset()
  439. };
  440. this.stopAudio = function () {
  441. if (this.aSrc == audioEl.src && audioEl.canPlayType) {
  442. if (!audioEl.paused)
  443. audioEl.pause();
  444. if (!this.pozd)
  445. audioEl.src = null
  446. }
  447. };
  448. this.playAudio = function () {
  449. if (!audioEl.canPlayType || typeof this.aSrc == "undefined" || this.aSrc == audioEl.src && !audioEl.paused)
  450. return;
  451. if (this.aSrc != audioEl.src)
  452. audioEl.src = this.aSrc;
  453. audioEl.play()
  454. };
  455. this.doRepeat = function () {
  456. this.rpdCnt++;
  457. if (this.rpdCnt < this.c.repetitions || this.c.repetitions < 0) {
  458. this.st = this.c.repetitions < 0 ? this.gtime() : this.st + this.c.length;
  459. this.stopAudio();
  460. this.play()
  461. }
  462. };
  463. this.setTranslate = function (a, b) {
  464. var c = StylePpty.Transform();
  465. var d = this.sV.d.style[c];
  466. var e = /translate\(+[^\)]+\)/;
  467. var f = "translate(" + a + "px," + b + "px)";
  468. if (-1 != d.search(e))
  469. d = d.replace(e, f);
  470. else if (null != d)
  471. d = d + f;
  472. this.sV.d.style[c] = d
  473. };
  474. this.getTranslate = function () {
  475. var a = {
  476. x : 0,
  477. y : 0
  478. };
  479. var b = StylePpty.Transform();
  480. var c = this.sV.d.style[b];
  481. var d = /translate\(+[^\)]+\)/;
  482. var e = c.match(d);
  483. if (null != e) {
  484. var f = e[0].match(/[0-9.-]+|[\d]+[^p]/g);
  485. a.x = parseFloat(f[0]);
  486. a.y = parseFloat(f[1])
  487. }
  488. return a
  489. };
  490. this.setScale = function (a, b) {
  491. var c = StylePpty.Transform();
  492. var d = this.sV.d.style[c];
  493. var e = /scale\(+[^\)]+\)/;
  494. var f = "scale(" + a + "," + b + ")";
  495. if (-1 != d.search(e))
  496. d = d.replace(e, f);
  497. else if (null != d)
  498. d = d + f;
  499. this.sV.d.style[c] = d
  500. };
  501. this.getScale = function () {
  502. var a = {
  503. x : 1,
  504. y : 1
  505. };
  506. var b = StylePpty.Transform();
  507. var c = this.sV.d.style[b];
  508. var d = /scale\(+[^\)]+\)/;
  509. var e = c.match(d);
  510. if (null != e) {
  511. var f = e[0].match(/[0-9.-]+|[\d]+[^p]/g);
  512. a.x = parseFloat(f[0]);
  513. a.y = parseFloat(f[1])
  514. }
  515. return a
  516. };
  517. this.setRotate = function (a) {
  518. var b = StylePpty.Transform();
  519. var c = this.sV.d.style[b];
  520. var d = /rotate\(+[^\)]+\)/;
  521. var e = "rotate(" + a + "deg)";
  522. if (-1 != c.search(d))
  523. c = c.replace(d, e);
  524. else if (null != c)
  525. c = c + e;
  526. this.sV.d.style[b] = c
  527. };
  528. this.getRotate = function () {
  529. var a = 0;
  530. var b = StylePpty.Transform();
  531. var c = this.sV.d.style[b];
  532. var d = /rotate\(+[^\)]+\)/;
  533. var e = c.match(d);
  534. if (null != e) {
  535. var f = e[0].match(/[0-9.-]+|[\d]+[^d]/g);
  536. a = parseFloat(f[0])
  537. }
  538. return a
  539. };
  540. this.setSkewX = function (a) {
  541. var b = StylePpty.Transform();
  542. var c = this.sV.d.style[b];
  543. var d = /skewX\(+[^\)]+\)/;
  544. var e = "skewX(" + a + "deg)";
  545. if (-1 != c.search(d))
  546. c = c.replace(d, e);
  547. else if (null != c)
  548. c = c + e;
  549. this.sV.d.style[b] = c
  550. };
  551. this.getSkewX = function () {
  552. var a = 0;
  553. var b = StylePpty.Transform();
  554. var c = this.sV.d.style[b];
  555. var d = /skewX\(+[^\)]+\)/;
  556. var e = c.match(d);
  557. if (null != e) {
  558. var f = e[0].match(/[0-9.-]+|[\d]+[^d]/g);
  559. a = parseFloat(f[0])
  560. }
  561. return a
  562. };
  563. this.plyBlockAnim = function () {
  564. function c() {
  565. if (a.pozd || a.stpd || b >= a.blks.length)
  566. return;
  567. while (1) {
  568. if (b >= a.blks.length)
  569. return;
  570. var d = a.blks[b];
  571. if (d.st <= a.gtime()) {
  572. d.play();
  573. b++
  574. } else
  575. break
  576. }
  577. CallbackFn(c)
  578. }
  579. var a = this;
  580. if (a.at == 1)
  581. return;
  582. var b = 0;
  583. CallbackFn(c)
  584. }
  585. };
  586. //REF
  587. CanvasEl = function (width, height) {
  588. this.cv = document.createElement("canvas");
  589. this.cv.height = height;
  590. this.cv.width = width;
  591. this.cvt = this.cv.getContext("2d");
  592. this.bdrawn = false;
  593. //REF
  594. this.drawCmpltDiv = function (a, b, c) {
  595. var childNode = a.childNodes;
  596. var childNodeLength = childNode.length;
  597. for (var childInd = 0; childInd < childNodeLength; childInd++) {
  598. var child = childNode[childInd];
  599. if (child.nodeType != 1 || child.nodeName != "IMG")
  600. continue;
  601. var height = DOPStyle.s(a, "height");
  602. var width = DOPStyle.s(a, "width");
  603. var parentNodeHeight = DOPStyle.s(a.parentNode, "height");
  604. var parentNodeWidth = DOPStyle.s(a.parentNode, "width");
  605. var l = height && height != "100%" ? parseFloat(height) : parseFloat(parentNodeHeight);
  606. var m = width && width != "100%" ? parseFloat(width) : parseFloat(parentNodeWidth);
  607. this.cvt.drawImage(g, b, c, m, l)
  608. }
  609. for (var childInd = 0; childInd < childNodeLength; childInd++){
  610. var child = childNode[childInd];
  611. if (child.nodeType != 1 || child.nodeName != "PRE")
  612. continue;
  613. var n = child.style.left ? b + parseFloat(child.style.left) : b;
  614. var o = child.style.top ? c + parseFloat(child.style.top) : c;
  615. this.cvt.font = DOPStyle.s(g, "fontStyle") + " " + DOPStyle.s(g, "fontWeight") + " " + DOPStyle.s(g, "fontSize") + " " + DOPStyle.s(g, "fontFamily");
  616. this.cvt.fillStyle = DOPStyle.s(g, "color");
  617. this.cvt.textBaseline = "top";
  618. this.cvt.fillText(g.innerHTML, n, o)
  619. }
  620. for (var childInd = 0; childInd < childNodeLength; childInd++) {
  621. var child = childNode[childInd];
  622. var opacity = DOPStyle.s(child, "opacity");
  623. if (child.nodeType != 1 || child.nodeName != "DIV" || opacity == "0")
  624. continue;
  625. var left = DOPStyle.s(child, "left");
  626. var right = DOPStyle.s(child, "top");
  627. var n = left ? b + parseFloat(left) : 0;
  628. var o = right ? c + parseFloat(right) : 0;
  629. this.drawCmpltDiv(g, n, o)
  630. }
  631. this.bdrawn = true
  632. };
  633. this.drawDiv = function (a) {
  634. var b = a.getElementsByTagName("img");
  635. var c = new Image;
  636. var d = this;
  637. if (b.length > 0)
  638. c.src = b[0].src;
  639. else
  640. this.drawText(a);
  641. c.onload = function () {
  642. d.cvt.drawImage(c, 0, 0, c.width, c.height, 0, 0, d.cv.width, d.cv.height);
  643. d.drawText(a)
  644. }
  645. };
  646. //REF
  647. this.drawText = function (a) {
  648. var pre = a.getElementsByTagName("pre");
  649. var c = pre.length;
  650. for (var d = 0; d < c; d++) {
  651. var e = pre[d];
  652. this.cvt.font = DOPStyle.s(e, "fontStyle") + " " + DOPStyle.s(e, "fontWeight") + " " + DOPStyle.s(e, "fontSize") + " " + DOPStyle.s(e, "fontFamily");
  653. this.cvt.fillStyle = DOPStyle.s(e, "color");
  654. this.cvt.textBaseline = "bottom";
  655. this.cvt.fillText(e.innerHTML, parseFloat(e.style.left), parseFloat(e.style.top) + e.scrollHeight)
  656. }
  657. this.bdrawn = true
  658. };
  659. this.apndTo = function (a) {
  660. a.appendChild(this.cv)
  661. };
  662. this.draw = function (a, b) {
  663. if (a.bdrawn) {
  664. if (b)
  665. this.cvt.clearRect(0, 0, this.cv.width, this.cv.height);
  666. this.cvt.drawImage(a.cv, 0, 0)
  667. }
  668. }
  669. };
  670. BCurve = function (a, b, c, d, e, f, g, h, i) {
  671. this.x0 = a;
  672. this.y0 = b;
  673. this.x1 = c;
  674. this.y1 = d;
  675. this.x2 = e;
  676. this.y2 = f;
  677. this.x3 = g;
  678. this.y3 = h;
  679. this.dn = i;
  680. this.getPointAfterT = function (a) {
  681. var b = 1 / this.dn * a;
  682. var c = 3 * (this.x1 - this.x0);
  683. var d = 3 * (this.x2 - this.x1) - c;
  684. var e = this.x3 - this.x0 - c - d;
  685. var f = 3 * (this.y1 - this.y0);
  686. var g = 3 * (this.y2 - this.y1) - f;
  687. var h = this.y3 - this.y0 - f - g;
  688. var i = e * b * b * b + d * b * b + c * b + this.x0;
  689. var j = h * b * b * b + g * b * b + f * b + this.y0;
  690. var k = {
  691. x : i,
  692. y : j
  693. };
  694. return k
  695. }
  696. };
  697. Line = function (a, b, c, d, e) {
  698. this.x0 = a;
  699. this.y0 = b;
  700. this.x1 = c;
  701. this.y1 = d;
  702. this.dn = e;
  703. this.xd = Math.abs(this.x0 - this.x1);
  704. this.yd = Math.abs(this.y0 - this.y1);
  705. this.getPointAfterT = function (a) {
  706. var b = this.xd / this.dn * a;
  707. var c = this.yd / this.dn * a;
  708. var d = this.x0 < this.x1 ? this.x0 + b : this.x0 - b;
  709. var e = this.y0 < this.y1 ? this.y0 + c : this.y0 - c;
  710. var f = {
  711. x : d,
  712. y : e
  713. };
  714. return f
  715. };
  716. this.getRevPointAfterT = function (a) {
  717. var b = this.xd / this.dn * a;
  718. var c = this.yd / this.dn * a;
  719. var d = this.x1 < this.x0 ? this.x1 + b : this.x1 - b;
  720. var e = this.y1 < this.y0 ? this.y1 + c : this.y1 - c;
  721. var f = {
  722. x : d,
  723. y : e
  724. };
  725. return f
  726. }
  727. };
  728. MotionNode = function (points) {
  729. var pointsArray = points.split(",");
  730. this.tp = pointsArray[0];
  731. this.x0 = parseFloat(pointsArray[1]);
  732. this.y0 = parseFloat(pointsArray[2]);
  733. this.dn = 0;
  734. switch (this.tp) {
  735. case "L":
  736. this.x1 = parseFloat(pointsArray[3]);
  737. this.y1 = parseFloat(pointsArray[4]);
  738. this.dn = parseFloat(pointsArray[5]) * 1e3;
  739. this.ln = new Line(this.x0, this.y0, this.x1, this.y1, this.dn);
  740. break;
  741. case "C":
  742. this.x1 = parseFloat(pointsArray[3]);
  743. this.y1 = parseFloat(pointsArray[4]);
  744. this.x2 = parseFloat(pointsArray[5]);
  745. this.y2 = parseFloat(pointsArray[6]);
  746. this.x3 = parseFloat(pointsArray[7]);
  747. this.y3 = parseFloat(pointsArray[8]);
  748. this.dn = parseFloat(pointsArray[9]) * 1e3;
  749. this.bc = new BCurve(this.x0, this.y0, this.x1, this.y1, this.x2, this.y2, this.x3, this.y3, this.dn);
  750. break
  751. }
  752. this.getNextPoint = function (x, y) {
  753. var c;
  754. switch (this.tp) {
  755. case "M":
  756. case "E":
  757. c = {
  758. x : this.x0,
  759. y : this.y0
  760. };
  761. break;
  762. case "L":
  763. c = this.ln.getPointAfterT(y);
  764. break;
  765. case "C":
  766. c = this.bc.getPointAfterT(y);
  767. break
  768. }
  769. return c
  770. }
  771. };
  772. MotionAnimation = function (point) {
  773. this.pnt = point;
  774. this.motionNodeArray = new Array;
  775. this.cNode = 0;
  776. this.prvTm = 0;
  777. this.MCmpltd = false;
  778. var b = this.pnt.c.additionalData.split("|");
  779. var c = 0;
  780. for (var i = 0; i < b.length; i++) {
  781. if (b[i].length > 1)
  782. this.motionNodeArray[c++] = new MotionNode(b[i].replace(" ", ","))
  783. }
  784. this.resetMotionAnimation = function () {
  785. if (!this.pozd) {
  786. this.cNode = 0;
  787. this.prvTm = 0;
  788. this.MCmpltd = false
  789. }
  790. this.pnt.resetBaseAnimation()
  791. };
  792. this.setEndPoint = function () {
  793. var point = this.motionNodeArray[this.motionNodeArray.length - 1];
  794. this.pnt.setTranslate(point.x0, point.y0)
  795. };
  796. this.getNextPoint = function (x, y) {
  797. var c;
  798. if (this.MCmpltd)
  799. return c;
  800. if (this.cNode >= this.motionNodeArray.length)
  801. this.cNode = this.motionNodeArray.length - 1;
  802. var d = this.motionNodeArray[this.cNode];
  803. if (d.tp == "M" && y < 20 || d.tp == "E") {
  804. c = d.getNextPoint(x, y - this.prvTm);
  805. this.cNode++;
  806. return c
  807. } else if (y > this.prvTm + d.dn) {
  808. this.prvTm += d.dn;
  809. this.cNode++;
  810. return this.getNextPoint(x, y)
  811. } else {
  812. c = d.getNextPoint(x, y - this.prvTm);
  813. return c
  814. }
  815. }
  816. };