pre.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. !(function (window) {
  2. var env = {};
  3. window.env = env;
  4. checkPlatform(env);
  5. // var isCN = checkIsChinese();
  6. // var isRU = checkIsRU();
  7. // initTitle(isCN);
  8. // initSplash(isCN, isRU);
  9. function hideLoading() {
  10. var url = window.location.href;
  11. if (url.indexOf('?') > -1) {
  12. console.log('hide splash');
  13. var splash = document.getElementsByClassName('splash')[0];
  14. setTimeout(function () {
  15. document.body.style.backgroundColor = 'white';
  16. splash.style.display = 'none';
  17. splash.style.zIndex = 0;
  18. });
  19. console.log('no hideLoading');
  20. var loading = document.getElementsByClassName('full-screen-center')[0];
  21. setTimeout(function () {
  22. loading.style.zIndex = 1003;
  23. });
  24. return;
  25. }
  26. console.log('hideLoading');
  27. var loading = document.getElementsByClassName('full-screen-center')[0];
  28. setTimeout(function () {
  29. loading.style.zIndex = 0;
  30. });
  31. }
  32. // hideLoading();
  33. function initTitle(isCN) {
  34. document.title = isCN ? '杏聆荟' : 'Flyinsono';
  35. if (window.__wxjs_environment === 'miniprogram') {
  36. document.title = ' ';
  37. }
  38. }
  39. function initSplash(isCN, isRU) {
  40. var splash = document.getElementsByClassName('splash')[0];
  41. if (!splash) return;
  42. if (isCN) {
  43. splash.classList.add('splash_cn');
  44. return;
  45. }
  46. if (isRU) {
  47. splash.classList.add('splash_ru');
  48. return;
  49. }
  50. splash.classList.add('splash_en');
  51. }
  52. function checkPlatform(target) {
  53. // injectWinTest();
  54. var shell = window['FisShellApi'];
  55. if (shell) {
  56. target.platform = 'shell';
  57. shell.getPlatformName().then(function (res) {
  58. target.platform = res;
  59. });
  60. } else {
  61. target.platform = 'Web';
  62. }
  63. }
  64. /// inject `FisShellApi` for debug
  65. function injectWinTest() {
  66. window['FisShellApi'] = {
  67. writeLog: async (text) => {
  68. console.log(text);
  69. },
  70. getPlatformName: async () => 'Win',
  71. setTitle: async (title) => {
  72. console.log(`Set title - ${title}`);
  73. },
  74. };
  75. }
  76. function checkIsChinese() {
  77. var lang = navigator.language.split('-')[0].toLocaleLowerCase();
  78. return lang === 'zh';
  79. }
  80. // 监听storage 关闭当前标签页
  81. window.addEventListener('storage', function (event) {
  82. if (event.key === 'closeOtherTabs' && event.newValue === 'true') {
  83. window.close();
  84. }
  85. });
  86. // 关闭其他标签页
  87. window.closeOtherTabs = function () {
  88. localStorage.setItem('closeOtherTabs', 'true');
  89. setTimeout(function () {
  90. localStorage.setItem('closeOtherTabs', 'false');
  91. }, 100);
  92. };
  93. // define for fis_lib_media_rt
  94. window.getIframe = function (id) {
  95. return document.getElementById(id);
  96. };
  97. })(window);