demoFeature.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Features specially written for demo
  2. (function () {
  3. // language
  4. function language(params) {
  5. var lang = navigator.language || navigator.userLanguage;//常规浏览器语言和IE浏览器
  6. lang = lang.substr(0, 2);//截取lang前2位字符
  7. return lang;
  8. }
  9. // Tencent Forum Link Button
  10. function supportButton() {
  11. const text = language() === 'zh' ? '反馈' : 'Forum';
  12. const link = language() === 'zh' ? 'https://support.qq.com/product/288322' : 'https://groups.google.com/g/luckysheet';
  13. document.querySelector("body").insertAdjacentHTML('beforeend', '<a id="container" href="' + link + '" target="_blank" style="z-index:2;width:50px;height:50px;line-height:50px;position:fixed;right:40px;bottom:86px;border-radius:50px;cursor:pointer;background:rgb(71,133,249);color:#fff;text-align:center;text-decoration:none;font-size: 12px;">' + text + '</a>');
  14. }
  15. supportButton()
  16. /**
  17. * Get url parameters
  18. */
  19. function getRequest() {
  20. var vars = {};
  21. var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,
  22. function (m, key, value) {
  23. vars[key] = value;
  24. });
  25. return vars;
  26. }
  27. window.luckysheetDemoUtil = {
  28. language: language,
  29. getRequest: getRequest
  30. }
  31. })()