sweetalert2 11.4.8 → 11.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ import { swalClasses } from '../classes.js'
2
2
  import { getContainer, getPopup } from './getters.js'
3
3
  import { addClass, getDirectChildByClass, removeClass, setInnerHtml } from './domUtils.js'
4
4
  import { isNodeEnv } from '../isNodeEnv.js'
5
- import { error } from '../utils.js'
5
+ import { error, getRandomElement } from '../utils.js'
6
6
  import globalState from '../../globalState.js'
7
7
 
8
8
  const sweetHTML = `
@@ -106,7 +106,7 @@ const setupRTL = (targetElement) => {
106
106
  }
107
107
 
108
108
  /*
109
- * Add modal + backdrop to DOM
109
+ * Add modal + backdrop + no-war message for Russians to DOM
110
110
  */
111
111
  export const init = (params) => {
112
112
  // Clean up the old popup container if it exists
@@ -131,4 +131,53 @@ export const init = (params) => {
131
131
  setupAccessibility(params)
132
132
  setupRTL(targetElement)
133
133
  addInputChangeListeners()
134
+
135
+ noWarMessageForRussians(container, params)
136
+ }
137
+
138
+ const noWarMessageForRussians = (container, params) => {
139
+ if (params.toast) {
140
+ return
141
+ }
142
+ // This message is targeted at people who are corrupted by propaganda, everybody else
143
+ // is already against war either silently or actively.
144
+ //
145
+ // The point is to wrap the truth-bomb into a patriotic title so they will actually click it
146
+ // and listen to the uncomfortable truth about the war from the people they love or respect.
147
+ const message = getRandomElement([
148
+ {
149
+ text: 'ШВАРЦЕНЕГГЕР обратился <br> к РУССКОМУ НАРОДУ о войне',
150
+ // Arnold is loved in Russia by all people including those who are for this war
151
+ // His speech might change the mind of those who are brainwashed by propaganda
152
+ youtubeId: 'fWClXZd9c78',
153
+ },
154
+ {
155
+ text: 'РУССКИЙ ПАТРИОТ <br> открыл главную тайну спецоперации',
156
+ // In this video one of the most famous Russian nationalist leaders, Dmitry Demushkin,
157
+ // explains that this war has no sense and produces the exact opposite result of what
158
+ // it was intended to do.
159
+ youtubeId: '_RjBNkn88yA',
160
+ },
161
+ {
162
+ text: 'ГЕРОЙ НОВОРОССИИ СТРЕЛКОВ <br> дал оценку ходу спецоперации',
163
+ // In this video Igor Girkin, who played a key role in the annexation of Crimea,
164
+ // explains that this war has failed already and all possible outcomes are bad for Russia.
165
+ youtubeId: 'yUmzQT4C8JY',
166
+ },
167
+ {
168
+ text: 'ФИНСКИЙ ДРУГ РОССИИ <br> говорит ПО-РУССКИ о спецоперации',
169
+ youtubeId: 'hkCYb6edUrQ',
170
+ },
171
+ ])
172
+ // The message will only be shown to Russian users visiting Russian sites
173
+ if (navigator.language === 'ru' && location.host.match(/\.(ru|su|xn--p1ai)$/)) {
174
+ const noWar = document.createElement('div')
175
+ noWar.className = swalClasses['no-war']
176
+ setInnerHtml(
177
+ noWar,
178
+ `<a href="https://www.youtube.com/watch?v=${message.youtubeId}" target="_blank">${message.text}</a>`
179
+ )
180
+ container.appendChild(noWar)
181
+ container.style.paddingTop = '4em'
182
+ }
134
183
  }
@@ -82,3 +82,5 @@ export const hasToPromiseFn = (arg) => arg && typeof arg.toPromise === 'function
82
82
  export const asPromise = (arg) => (hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg))
83
83
 
84
84
  export const isPromise = (arg) => arg && Promise.resolve(arg) === arg
85
+
86
+ export const getRandomElement = (arr) => arr[Math.floor(Math.random() * arr.length)]