Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.77 KB | None | 0 0
  1. $(function () {
  2. 'use strict'
  3.  
  4.  
  5. /* Settings. */
  6.  
  7. const scaleByRarity = false // Enable scaling by rarity. Default: true.
  8. const upscalePokemon = false // Enable upscaling of certain Pokemon (upscaledPokemon and notify list). Default: false.
  9. const upscaledPokemon = [] // Add Pokémon IDs separated by commas (e.g. [1, 2, 3]) to upscale icons.
  10.  
  11. // Google Analytics property ID. Leave empty to disable.
  12. // Looks like 'UA-XXXXX-Y'.
  13. const analyticsKey = ''
  14.  
  15. // MOTD.
  16. const motdEnabled = false
  17. const motdTitle = 'MOTD'
  18. const motd = 'Hi there! This is an easily customizable MOTD with optional title!'
  19.  
  20. // Only show every unique MOTD message once. If disabled, the MOTD will be
  21. // shown on every visit. Requires support for localStorage.
  22. // Updating only the MOTD title (and not the text) will not make the MOTD
  23. // appear again.
  24. const motdShowOnlyOnce = true
  25.  
  26. // What pages should the MOTD be shown on? By default, homepage and mobile
  27. // pages.
  28. const motdShowOnPages = [
  29. '/',
  30. '/mobile'
  31. ]
  32.  
  33. // Clustering! Different zoom levels for desktop vs mobile.
  34. const disableClusters = true // Default: false
  35. const maxClusterZoomLevel = 14 // Default: 14
  36. const maxClusterZoomLevelMobile = 14 // Default: same as desktop
  37. const clusterZoomOnClick = false // Default: false
  38. const clusterZoomOnClickMobile = false // Default: same as desktop
  39. const clusterGridSize = 60 // Default: 60
  40. const clusterGridSizeMobile = 60 // Default: same as desktop
  41.  
  42. // Process Pokémon in chunks to improve responsiveness.
  43. const processPokemonChunkSize = 100 // Default: 100
  44. const processPokemonIntervalMs = 100 // Default: 100ms
  45.  
  46.  
  47. /* Feature detection. */
  48.  
  49. const hasStorage = (function () {
  50. var mod = 'RocketMap'
  51. try {
  52. localStorage.setItem(mod, mod)
  53. localStorage.removeItem(mod)
  54. return true
  55. } catch (exception) {
  56. return false
  57. }
  58. }())
  59.  
  60.  
  61. /* Do stuff. */
  62.  
  63. const currentPage = window.location.pathname
  64.  
  65.  
  66. // Set custom Store values.
  67. Store.set('maxClusterZoomLevel', maxClusterZoomLevel)
  68. Store.set('clusterZoomOnClick', clusterZoomOnClick)
  69. Store.set('clusterGridSize', clusterGridSize)
  70. Store.set('processPokemonChunkSize', processPokemonChunkSize)
  71. Store.set('processPokemonIntervalMs', processPokemonIntervalMs)
  72. Store.set('scaleByRarity', scaleByRarity)
  73. Store.set('upscalePokemon', upscalePokemon)
  74. Store.set('upscaledPokemon', upscaledPokemon)
  75.  
  76. if (typeof window.orientation !== 'undefined' || isMobileDevice()) {
  77. Store.set('maxClusterZoomLevel', maxClusterZoomLevelMobile)
  78. Store.set('clusterZoomOnClick', clusterZoomOnClickMobile)
  79. Store.set('clusterGridSize', clusterGridSizeMobile)
  80. }
  81.  
  82. if (disableClusters) {
  83. Store.set('maxClusterZoomLevel', -1)
  84. }
  85.  
  86. // Google Analytics.
  87. if (analyticsKey.length > 0) {
  88. window.ga = window.ga || function () {
  89. (ga.q = ga.q || []).push(arguments)
  90. }
  91. ga.l = Date.now
  92. ga('create', analyticsKey, 'auto')
  93. ga('send', 'pageview')
  94. }
  95.  
  96. // Show MOTD.
  97. if (motdEnabled && motdShowOnPages.indexOf(currentPage) !== -1) {
  98. let motdIsUpdated = true
  99.  
  100. if (hasStorage) {
  101. const lastMOTD = window.localStorage.getItem('lastMOTD') || ''
  102.  
  103. if (lastMOTD === motd) {
  104. motdIsUpdated = false
  105. }
  106. }
  107.  
  108. if (motdIsUpdated || !motdShowOnlyOnce) {
  109. window.localStorage.setItem('lastMOTD', motd)
  110.  
  111. swal({
  112. title: motdTitle,
  113. text: motd
  114. })
  115. }
  116. }
  117. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement