base.supply_v1.0.0.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. /**
  2. * 对公用JS库的补充
  3. * @time 20190731
  4. * @name test
  5. */
  6. (function(PageH5) {
  7. function tip(info, second, id, timerName) {
  8. if (info === undefined || info === '') return;
  9. second = second || 3;
  10. id = id || id;
  11. if (!G(id)) {
  12. var dom = document.createElement('div');
  13. dom.id = id;
  14. document.body.appendChild(dom);
  15. }
  16. G(id).innerHTML = info;
  17. S(id);
  18. if (second > 0) {
  19. if (PageH5[timerName]) clearTimeout(PageH5[timerName]);
  20. PageH5[timerName] = setTimeout('H("' + id + '")', second * 1000);
  21. }
  22. }
  23. PageH5.extend = function(params) {
  24. for (var i in params) this[i] = params[i];
  25. };
  26. PageH5.extend({
  27. tip: function(info, second) {
  28. tip(info, second, 'default_tip_css', '_tip_timer');
  29. },
  30. ykqTip: function(info, second) {
  31. tip(info, second, 'default_ykq_tip_css', '_ykq_tip_timer');
  32. },
  33. getBasePath: function() {
  34. var contextPath = '/' + location.href.split('/')[3];
  35. return contextPath;
  36. },
  37. isArray: function(obj) {
  38. return Object.prototype.toString.call(obj) === '[object Array]' || (obj instanceof Array);
  39. },
  40. jump: function(href, f) {
  41. if (f === undefined) f = PageH5.btn.current.id;
  42. window.location.href = href + '&f=' + f;
  43. },
  44. trim: function(str) {
  45. if (str) return str.replace(/^\s*(.*?)\s*$/g, '$1');
  46. },
  47. toHump: function(str, flag) {
  48. return str.replace(new RegExp(flag + '(\\w)', 'g'),
  49. function(m, $1, idx, str) {
  50. return $1.toUpperCase();
  51. });
  52. },
  53. hasClass: function(obj, cls) {
  54. if (!obj) return;
  55. return obj.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
  56. },
  57. addClass: function(obj, cls) {
  58. if (!obj) return;
  59. var className = obj.className;
  60. if (!this.hasClass(obj, cls)) obj.className += (className ? ' ': '') + cls;
  61. },
  62. removeClass: function(obj, cls) {
  63. if (obj && this.hasClass(obj, cls)) {
  64. obj.className = obj.className.replace(new RegExp('(\\s|^)' + cls + '(\\s|$)'),
  65. function(m, $1, $2) {
  66. return ($1 && $2) ? ' ': '';
  67. });
  68. }
  69. },
  70. on: function(obj, event, fn) {
  71. var events = event.split(' ');
  72. for (var i in events) obj.addEventListener(events[i], fn, false);
  73. },
  74. off: function(obj, event, fn) {
  75. var events = event.split(' ');
  76. for (var i in events) obj.removeEventListener(events[i], fn);
  77. },
  78. one: function(obj, event, fn) {
  79. var tempFn = function() {
  80. fn();
  81. PageH5.off(obj, event, tempFn);
  82. };
  83. PageH5.on(obj, event, tempFn);
  84. },
  85. twinkle: {
  86. start: function(id, time) {
  87. this.stop();
  88. id = id || PageH5.btn.current.id;
  89. time = (typeof time === 'number') ? time: 200;
  90. this._id = id;
  91. this._is_hide = false;
  92. this._timer = setInterval(function() {
  93. if (PageH5.twinkle._is_hide) S(PageH5.twinkle._id);
  94. else H(PageH5.twinkle._id);
  95. PageH5.twinkle._is_hide = !PageH5.twinkle._is_hide;
  96. },
  97. time);
  98. },
  99. stop: function() {
  100. if (this._timer) {
  101. clearInterval(this._timer);
  102. this._timer = undefined;
  103. S(PageH5.twinkle._id);
  104. }
  105. }
  106. }
  107. });
  108. var curCSS;
  109. if (window.getComputedStyle) {
  110. curCSS = function(elem, name) {
  111. name = PageH5.toHump(name, '-');
  112. var ret, computed = window.getComputedStyle(elem, null),
  113. style = elem.style;
  114. if (computed) ret = computed[name];
  115. if (!ret) ret = style[name];
  116. return ret;
  117. };
  118. } else if (document.documentElement.currentStyle) {
  119. curCSS = function(elem, name) {
  120. name = PageH5.toHump(name, '-');
  121. var ret = elem.currentStyle && elem.currentStyle[name],
  122. style = elem.style;
  123. if (!ret && style && style[name]) {
  124. ret = style[name];
  125. }
  126. return ret === '' ? 'auto': ret;
  127. };
  128. } else {
  129. curCSS = function(elem, name) {
  130. name = PageH5.toHump(name, '-');
  131. var style = elem.style;
  132. return style[name];
  133. };
  134. }
  135. PageH5.css = function(obj, name, value) {
  136. if (value === undefined) {
  137. var temp = curCSS(obj, name);
  138. if (temp === '' || temp === 'auto') temp = 0;
  139. return temp;
  140. } else {
  141. var pxs = ['left', 'top', 'right', 'bottom', 'width', 'height', 'line-height', 'font-size'];
  142. var isPx = pxs.indexOf(name) >= 0;
  143. if (isPx && !/.*px$/g.test(value + '') && value !== 'auto') value += 'px';
  144. obj.style[PageH5.toHump(name)] = value;
  145. }
  146. };
  147. PageH5.key = {
  148. keys: {},
  149. ids: {},
  150. set: function(code, action) {
  151. if (typeof code === 'string' && action !== undefined) {
  152. var _code = code;
  153. code = {};
  154. code[_code] = action;
  155. }
  156. if (typeof code === 'object') {
  157. var obj = code;
  158. for (var i in obj) {
  159. if (i.indexOf('KEY_') === 0 || i.indexOf('EVENT_') === 0) this.keys[i] = obj[i];
  160. else this.ids[i] = obj[i];
  161. }
  162. } else if (typeof code === 'number') {}
  163. return this;
  164. },
  165. add: function(code, action) {
  166. return this.set(code, action);
  167. },
  168. del: function(code) {
  169. if (! (code instanceof Array)) code = [code];
  170. for (var i = 0; i < code.length; i++) {
  171. if (this.ids[code[i]]) this.ids[code[i]] = 'PageH5.key.emptyFn()';
  172. if (this.keys[code[i]]) this.keys[code[i]] = 'PageH5.key.emptyFn()';
  173. }
  174. return this;
  175. },
  176. emptyFn: function() {},
  177. init: function() {
  178. if (!PageH5.eventHandler) {
  179. PageH5.eventHandler = function(code) {
  180. for (var i in PageH5.key.ids) if (PageH5.Button.current.id === i) PageH5.call(PageH5.key.ids[i], code);
  181. for (var i in PageH5.key.keys) if (code === window[i]) PageH5.call(PageH5.key.keys[i], code);
  182. };
  183. }
  184. }
  185. };
  186. PageH5.cookie = {
  187. get: function(cookieName, defaultValue, parseNumber, isUnescape) {
  188. var temp = new RegExp('(^|;| )' + cookieName + '=([^;]*)(;|$)', 'g').exec(document.cookie);
  189. if (temp != null) {
  190. var value = temp[2];
  191. if (value === '""') return defaultValue;
  192. if (parseNumber == true) return parseFloat(value);
  193. if (isUnescape) return unescape(value);
  194. return value;
  195. }
  196. return defaultValue;
  197. },
  198. set: function(name, value, day, path) {
  199. day = day == undefined ? 30 : day;
  200. path = path == undefined ? PageH5.getBasePath() : path;
  201. var str = name + '=' + value + '; ';
  202. if (day) {
  203. var date = new Date();
  204. date.setTime(date.getTime() + day * 24 * 3600 * 1000);
  205. str += 'expires=' + date.toGMTString() + '; ';
  206. }
  207. if (path) str += 'path=' + path;
  208. document.cookie = str;
  209. },
  210. del: function(name, path) {
  211. this.set(name, null, -1, path);
  212. }
  213. };
  214. PageH5.marquee = {
  215. start: function(maxLength, id, amount, delay, dir, behavior) {
  216. maxLength = maxLength || 7;
  217. id = id || PageH5.Button.current.id + '_txt';
  218. amount = amount || 40;
  219. delay = delay || 10;
  220. dir = dir || 'left';
  221. behavior = behavior || 'alternate';
  222. if (!this.rollId) {
  223. var marqueeParent = G(id);
  224. var html = PageH5.trim(marqueeParent.innerHTML);
  225. if (maxLength !== undefined && html.length > maxLength) {
  226. this.rollId = id;
  227. this.innerHTML = html;
  228. marqueeParent.innerHTML = '<div id="' + id + '_marquee" class="common_marquee">' + html + '</div>';
  229. var marqueeChild = G(id + '_marquee');
  230. var width1 = parseInt(PageH5.css(marqueeParent, 'width'));
  231. var width2 = parseInt(PageH5.css(marqueeChild, 'width'));
  232. var maxLeft = width2 - width1;
  233. if (maxLeft <= 0) return;
  234. var marquee_idx = Math.ceil(maxLeft / 50) * 50;
  235. marquee_idx = marquee_idx > 400 ? 400 : marquee_idx;
  236. var time = (maxLeft / amount).toFixed(2);
  237. if (maxLeft < 30) {
  238. time = 0.7;
  239. }
  240. var animation = 'common_marquee_' + marquee_idx + ' ' + time + 's linear 50ms infinite alternate';
  241. marqueeChild.style.webkitAnimation = animation;
  242. marqueeChild.style.animation = animation;
  243. }
  244. }
  245. },
  246. stop: function() {
  247. if (this.rollId) {
  248. G(this.rollId).innerHTML = this.innerHTML;
  249. this.rollId = undefined;
  250. }
  251. }
  252. };
  253. PageH5.fx = {
  254. interval: 13,
  255. tagIdx: 0,
  256. animates: {},
  257. start: function(obj, params, speed, easing, callback, tag) {
  258. var speeds = {
  259. fast: 200,
  260. normal: 400,
  261. slow: 600
  262. };
  263. speed = (typeof speed === 'string' ? speeds[speed] : speed) || speeds.normal;
  264. if (typeof easing === 'function') {
  265. tag = callback;
  266. callback = easing;
  267. easing = '';
  268. }
  269. easing = easing || 'swing';
  270. tag = tag || 'default';
  271. for (var i in this.animates) {
  272. if (i.indexOf(tag) >= 0) this.stop(i);
  273. }
  274. var oldParams = params;
  275. params = {};
  276. var canContinue = false;
  277. for (var i in oldParams) {
  278. var p = oldParams[i];
  279. if (!PageH5.isArray(p)) p = [PageH5.css(obj, i), p];
  280. else PageH5.css(obj, i, p[0]);
  281. params[i] = {
  282. start: parseFloat(p[0]),
  283. end: parseFloat(p[1])
  284. };
  285. if (params[i].start !== params[i].end) canContinue = true;
  286. }
  287. if (!canContinue) return;
  288. tag += '_' + (++this.tagIdx);
  289. this.animates[tag] = {
  290. obj: obj,
  291. params: params,
  292. speed: speed,
  293. easing: easing,
  294. callback: callback,
  295. startTime: Date.now(),
  296. idx: 0,
  297. timer: undefined
  298. };
  299. this.animates[tag].timer = setInterval(function() {
  300. var animate = PageH5.fx.animates[tag];
  301. animate.idx++;
  302. var n = Date.now() - animate.startTime;
  303. if (n > animate.speed) {
  304. PageH5.fx.stop(tag);
  305. return;
  306. }
  307. var percent = n / animate.speed;
  308. var pos = PageH5.fx.easing[animate.easing](percent, n, 0, 1, animate.speed);
  309. for (var i in animate.params) {
  310. var p = animate.params[i];
  311. PageH5.css(animate.obj, i, p.start + (p.end - p.start) * pos);
  312. }
  313. },
  314. this.interval);
  315. },
  316. stop: function(tag) {
  317. var animate = PageH5.fx.animates[tag];
  318. if (!animate) return false;
  319. clearInterval(animate.timer);
  320. var ps = animate.params;
  321. for (var i in ps) PageH5.css(animate.obj, i, ps[i].end);
  322. PageH5.call(animate.callback);
  323. delete PageH5.fx.animates[tag];
  324. return true;
  325. },
  326. easing: {
  327. linear: function(p, n, firstNum, diff) {
  328. return firstNum + diff * p;
  329. },
  330. swing: function(p, n, firstNum, diff) {
  331. return 0.5 - Math.cos(p * Math.PI) / 2;
  332. }
  333. }
  334. };
  335. PageH5.animate = function(obj, params, speed, easing, callback, tag) {
  336. PageH5.fx.start(obj, params, speed, easing, callback, tag);
  337. };
  338. })(PageH5);
  339. (function(PageH5) {
  340. var positions = {};
  341. function getBtn(cid, dir) {
  342. var current = positions[cid];
  343. var store = [];
  344. var leftOrRight = (dir === 'left' || dir === 'right');
  345. var hasFindDegIsZero = false;
  346. for (var i in positions) {
  347. if (i === cid) continue;
  348. var next = positions[i];
  349. if ((dir === 'left' && next.left >= current.left) || (dir === 'right' && next.right <= current.right) || (dir === 'up' && next.top >= current.top) || (dir === 'down' && next.bottom <= current.bottom)) continue;
  350. if (leftOrRight && ((next.centerY >= current.top && next.centerY <= current.bottom) || (next.top <= current.centerY && next.bottom >= current.bottom) || (next.top <= current.top && next.bottom >= current.centerY))) {
  351. store.push({
  352. id: i,
  353. distance: next.left,
  354. deg: 0
  355. });
  356. hasFindDegIsZero = true;
  357. } else if (!leftOrRight && ((next.centerX >= current.left && next.centerX <= current.right) || (next.left <= current.centerX && next.right >= current.right) || (next.left <= current.left && next.right >= current.centerX))) {
  358. store.push({
  359. id: i,
  360. distance: next.top,
  361. deg: 0
  362. });
  363. hasFindDegIsZero = true;
  364. } else if (!hasFindDegIsZero) {
  365. var key1 = leftOrRight ? dir: 'centerX';
  366. var key2 = !leftOrRight ? (dir == 'up' ? 'top': 'bottom') : 'centerY';
  367. var tan = (next[key1] - current[key1]) / (next[key2] - current[key2]);
  368. var cdeg = Math.abs(Math.atan(leftOrRight ? (1 / tan) : tan) * 360 / 2 / Math.PI);
  369. store.push({
  370. id: i,
  371. distance: next[leftOrRight ? 'left': 'top'],
  372. deg: cdeg
  373. });
  374. }
  375. }
  376. var tidu = [0, 30, 45, 60, 85];
  377. var _store = [];
  378. for (var i = 0; i < tidu.length; i++) {
  379. _store = [];
  380. for (var j = 0; j < store.length; j++) if (store[j].deg <= tidu[i]) _store.push(store[j]);
  381. if (_store.length > 0) break;
  382. }
  383. store = _store.length ? _store: [];
  384. store.sort(function(a, b) {
  385. var desc = (dir === 'left' || dir === 'up') ? -1 : 1;
  386. return (a.distance < b.distance ? -1 : (a.distance > b.distance ? 1 : 0)) * desc;
  387. });
  388. var nearest;
  389. var result = '';
  390. var key = leftOrRight ? 'top': 'left';
  391. for (var i = 0; i < store.length; i++) {
  392. if (i > 0 && store[i].distance != store[0].distance) break;
  393. var distance = Math.abs(positions[store[i].id][key] - current[key]);
  394. if (nearest === undefined || distance < nearest) {
  395. nearest = distance;
  396. result = store[i].id;
  397. }
  398. }
  399. return result;
  400. };
  401. PageH5.getAbsolutePosition = function(elem) {
  402. if (elem == null) return {
  403. left: 0,
  404. top: 0,
  405. width: 0,
  406. height: 0,
  407. right: 0,
  408. bottom: 0
  409. };
  410. var left = elem.offsetLeft,
  411. top = elem.offsetTop,
  412. width = elem.offsetWidth,
  413. height = elem.offsetHeight;
  414. while (elem = elem.offsetParent) {
  415. left += elem.offsetLeft;
  416. top += elem.offsetTop;
  417. }
  418. return {
  419. left: left,
  420. top: top,
  421. width: width,
  422. height: height,
  423. right: left + width,
  424. bottom: top + height
  425. };
  426. };
  427. PageH5.createButtonDir = function(allButtons) {
  428. var start = new Date().getTime();
  429. var btnGroups = {};
  430. for (var i = 0; i < allButtons.length; i++) {
  431. if (allButtons[i].autoDirGroup === false) continue;
  432. var gname = 'group_' + (allButtons[i].autoDirGroup === undefined ? 'default': allButtons[i].autoDirGroup);
  433. btnGroups[gname] = btnGroups[gname] || [];
  434. btnGroups[gname].push(allButtons[i]);
  435. }
  436. for (var gname in btnGroups) {
  437. positions = {};
  438. var btns = btnGroups[gname];
  439. for (var i = 0; i < btns.length; i++) {
  440. if (btns[i].autoDir === false) continue;
  441. var id = btns[i].id;
  442. var obj = document.getElementById(id);
  443. var position = PageH5.getAbsolutePosition(obj);
  444. position.obj = obj;
  445. position.centerX = position.left + position.width / 2;
  446. position.centerY = position.top + position.height / 2;
  447. positions[id] = position;
  448. }
  449. var dirs = ['left', 'right', 'up', 'down'];
  450. for (var i = 0; i < btns.length; i++) {
  451. for (var j = 0; j < dirs.length; j++) {
  452. btns[i][dirs[j]] = btns[i][dirs[j]] || getBtn(btns[i].id, dirs[j]);
  453. }
  454. }
  455. }
  456. var end = new Date().getTime();
  457. };
  458. })(PageH5);
  459. (function() {
  460. PageH5.scrollScreen = {
  461. init: function(option) {
  462. this.config.enable = true;
  463. for (var i in option) {
  464. if (option[i] !== undefined && option[i] !== "") {
  465. this.config[i] = option[i];
  466. }
  467. }
  468. this.scroll(PageH5.getParamInt('scrollTop', 0));
  469. },
  470. check: function(button, dir) {
  471. if (!this.config.enable) return;
  472. if (button.restoreScroll) {
  473. this.scroll( - this.config.scrollTop);
  474. return;
  475. }
  476. if (!this.config.enableToAllBtn && !button.scrollScreen) return;
  477. var id = button.id;
  478. var position = document.getElementById(id).getBoundingClientRect();
  479. var target = document.getElementById(this.config.wrapperId);
  480. var safePx = this.config.safePx;
  481. var wrapperPosition = document.getElementById(this.config.wrapperId).getBoundingClientRect();
  482. if (position.bottom >= (wrapperPosition.bottom - safePx)) {
  483. this.scroll((position.bottom + safePx - wrapperPosition.bottom));
  484. } else if (position.top - wrapperPosition.top < safePx) {
  485. this.scroll((wrapperPosition.top - position.top + safePx) * -1);
  486. }
  487. },
  488. repair: function() {
  489. if (!this.config.enable) return;
  490. var target = document.getElementById(this.config.wrapperId);
  491. if (PageH5.scrollScreen.config.scrollTop !== target.scrollTop) {
  492. target.scrollTop = PageH5.scrollScreen.config.scrollTop;
  493. }
  494. },
  495. scroll: function(addScrollTop) {
  496. var target = document.getElementById(this.config.wrapperId);
  497. var from = this.config.scrollTop;
  498. this.config.scrollTop += addScrollTop;
  499. if (enable_animate === false || !this.config.animate || addScrollTop === 0) {
  500. target.scrollTop = this.config.scrollTop;
  501. return;
  502. }
  503. var rate = 13,
  504. speed = 600,
  505. start = Date.now(),
  506. easing = 'swing';
  507. if (this.config._interval) {
  508. clearInterval(this.config._interval);
  509. this.config._interval = undefined;
  510. }
  511. this.config._interval = setInterval(function() {
  512. var n = Date.now() - start;
  513. if (n > speed) {
  514. clearInterval(PageH5.scrollScreen.config._interval);
  515. PageH5.scrollScreen.config._interval = undefined;
  516. n = speed;
  517. }
  518. var pos = PageH5.fx.easing[easing](n / speed, n, 0, 1);
  519. target.scrollTop = from + pos * addScrollTop;
  520. },
  521. rate);
  522. },
  523. config: {
  524. animate: true,
  525. enable: false,
  526. enableToAllBtn: false,
  527. wrapperId: 'wrapper',
  528. scrollTop: 0,
  529. safePx: 40,
  530. topSafePx: 40
  531. }
  532. };
  533. })();
  534. (function() {
  535. PageH5.scroll = {
  536. init: function(option) {
  537. this.config.enable = true;
  538. for (var i in option) {
  539. if (option[i] !== undefined && option[i] !== '') {
  540. this.config[i] = option[i];
  541. }
  542. }
  543. this.scr(PageH5.getParamInt('scrollLeft', 0));
  544. },
  545. check: function(button, dir) {
  546. if (!this.config.enable) return;
  547. if (button.restoreScroll) {
  548. this.scr( - this.config.scrollLeft);
  549. return;
  550. }
  551. if (!this.config.enableToAllBtn && !button.scrollScreen) return;
  552. var id = button.id;
  553. var position = document.getElementById(id).getBoundingClientRect();
  554. var wrapperPosition = document.getElementById(this.config.wrapperId).getBoundingClientRect();
  555. var safePx = this.config.safePx;
  556. if (position.right >= (wrapperPosition.right - safePx)) {
  557. this.scr((position.right + safePx - wrapperPosition.right));
  558. } else if (position.left - wrapperPosition.left < safePx) {
  559. this.scr((wrapperPosition.left - position.left + safePx) * -1);
  560. }
  561. },
  562. repair: function() {
  563. if (!this.config.enable) return;
  564. var target = document.getElementById(this.config.wrapperId);
  565. if (PageH5.scroll.config.scrollLeft !== target.scrollLeft) {
  566. target.scrollLeft = PageH5.scroll.config.scrollLeft;
  567. }
  568. },
  569. scr: function(addScrollLeft) {
  570. var target = document.getElementById(this.config.wrapperId);
  571. var form = this.config.scrollLeft;
  572. this.config.scrollLeft += addScrollLeft;
  573. if (enable_animate === false || !this.config.animate || addScrollLeft === 0) {
  574. target.scrollLeft = this.config.scrollLeft;
  575. return;
  576. }
  577. var rate = 13,
  578. speed = 600,
  579. start = Date.now(),
  580. easing = 'swing';
  581. if (this.config._interval) {
  582. clearInterval(this.config._interval);
  583. this.config._interval = undefined;
  584. }
  585. this.config._interval = setInterval(function() {
  586. var n = Date.now() - start;
  587. if (n > speed) {
  588. clearInterval(PageH5.scroll.config._interval);
  589. PageH5.scroll.config._interval = undefined;
  590. n = speed;
  591. }
  592. var pos = PageH5.fx.easing[easing](n / speed, n, 0, 1);
  593. target.scrollLeft = form + pos * addScrollLeft;
  594. },
  595. rate);
  596. },
  597. config: {
  598. animate: true,
  599. enable: false,
  600. enableToAllBtn: false,
  601. wrapperId: 'wrapper',
  602. scrollLeft: 0,
  603. safePx: 40
  604. }
  605. };
  606. })();
  607. (function() {
  608. PageH5.getCurrentURI = function() {
  609. var currentURI = CONFIG.CURRENT_URI || (location.pathname + location.search);
  610. if (!/^\//g.test(currentURI)) currentURI = CONFIG.CONTEXT_PATH + currentURI;
  611. return currentURI + (currentURI.indexOf('?') > 0 ? '': '?1=1');
  612. };
  613. PageH5.go = function(url) {
  614. var backURI = PageH5.getCurrentURI() + '&f=' + PageH5.btn.current.id;
  615. if (PageH5.scrollScreen && PageH5.scrollScreen.config.enable) backURI += ('&scrollTop=' + PageH5.scrollScreen.config.scrollTop);
  616. if (PageH5.scroll && PageH5.scroll.config.enable) backURI += ('&scrollLeft=' + PageH5.scroll.config.scrollLeft);
  617. var backUriList = eval("(" + unescape(PageH5.cookie.get('back_page_list', '[]')) + ")");
  618. backUriList.push(backURI);
  619. var jStr = "";
  620. for (var i = 0,
  621. length = backUriList.length; i < length; i++) {
  622. jStr += '"' + backUriList[i] + '",';
  623. }
  624. jStr = "[" + jStr.slice(0, -1) + "]";
  625. PageH5.cookie.set('back_page_list', escape(jStr));
  626. location.href = CONFIG.CONTEXT_PATH + url;
  627. };
  628. PageH5.getBackURI = function() {
  629. var backUriList = eval("(" + unescape(PageH5.cookie.get('back_page_list', '[]')) + ")");
  630. var backURI = backUriList.pop() || (CONFIG.CONTEXT_PATH + 'index.html');
  631. var jStr = "";
  632. for (var i = 0,
  633. length = backUriList.length; i < length; i++) {
  634. jStr += '"' + backUriList[i] + '",';
  635. }
  636. jStr = "[" + jStr.slice(0, -1) + "]";
  637. PageH5.cookie.set('back_page_list', escape(jStr));
  638. return backURI;
  639. };
  640. PageH5.goPlayVideo = function(url) {
  641. var playEndURI = PageH5.getCurrentURI() + '&f=' + PageH5.btn.current.id;
  642. if (PageH5.scrollScreen && PageH5.scrollScreen.config.enable) playEndURI += ('&scrollTop=' + PageH5.scrollScreen.config.scrollTop);
  643. PageH5.cookie.set('play_end_page', escape(playEndURI));
  644. location.href = CONFIG.CONTEXT_PATH + url;
  645. };
  646. PageH5.getPlayEndURI = function() {
  647. var playEndURI = unescape(PageH5.cookie.get('play_end_page', CONFIG.CONTEXT_PATH + 'index.html'));
  648. return playEndURI;
  649. };
  650. })();
  651. PageH5.getParam = function(name, defaultValue) {
  652. defaultValue = defaultValue === undefined ? '': defaultValue;
  653. var result = new RegExp('(\\?|&)' + name + '=(.*?)(&|$)', 'g').exec(location.search);
  654. return result ? result[2] : defaultValue;
  655. };
  656. PageH5.getParamInt = function(name, defaultValue) {
  657. defaultValue = defaultValue === undefined ? 0 : defaultValue;
  658. return parseInt(PageH5.getParam(name, defaultValue));
  659. };
  660. PageH5.focusHandler = function() {
  661. PageH5.marquee.start();
  662. };
  663. PageH5.blurHandler = function() {
  664. PageH5.marquee.stop();
  665. };
  666. (function() {
  667. var aimg = document.createElement('img');
  668. aimg.setAttribute('src', CONFIG.SPACER);
  669. var atag = document.createElement('a');
  670. atag.id = 'myDefaultLink';
  671. atag.setAttribute('href', '#');
  672. atag.appendChild(aimg);
  673. document.body.appendChild(atag);
  674. document.getElementById('myDefaultLink').focus();
  675. })();