Skip to content

Commit

Permalink
#6519 restored module back to original version in master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Davis committed Dec 2, 2022
1 parent 8e17d45 commit c4df557
Show file tree
Hide file tree
Showing 111 changed files with 4,100 additions and 23,271 deletions.

Large diffs are not rendered by default.

1,126 changes: 70 additions & 1,056 deletions sites/all/modules/contrib/advagg/advagg.admin.inc

Large diffs are not rendered by default.

72 changes: 33 additions & 39 deletions sites/all/modules/contrib/advagg/advagg.admin.js
Original file line number Diff line number Diff line change
@@ -1,83 +1,80 @@
/** global Drupal:false */

/**
* @file
* Used to toggle the AdvAgg Bypass Cookie client side.
*/

/* global Drupal:false */
/* eslint-disable no-unused-vars */

/**
* Test to see if the given string contains unicode.
*
* @param {int} interval
* @param int interval
* String to test.
* @param {int} granularity
* @param int granularity
* String to test.
* @param {string} langcode
* @param string langcode
* Language used in translation.
*
* @return {bool}
* @return
* true if string contains non ASCII characters.
* false if string only contains ASCII characters.
*/
Drupal.formatInterval = function (interval, granularity, langcode) {
'use strict';
Drupal.formatInterval = function(interval, granularity, langcode) {
"use strict";
granularity = typeof granularity !== 'undefined' ? granularity : 2;
langcode = typeof langcode !== 'undefined' ? langcode : null;
var output = '';

/* eslint-disable key-spacing */
while (granularity > 0) {
var value = 0;
if (interval >= 31536000) {
value = 31536000;
output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 year', '@count years', {langcode : langcode});
output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 year', '@count years', { langcode : langcode });
}
else if (interval >= 2592000) {
value = 2592000;
output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 month', '@count months', {langcode : langcode});
output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 month', '@count months', { langcode : langcode });
}
else if (interval >= 604800) {
value = 604800;
output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 week', '@count weeks', {langcode : langcode});
output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 week', '@count weeks', { langcode : langcode });
}
else if (interval >= 86400) {
value = 86400;
output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 day', '@count days', {langcode : langcode});
output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 day', '@count days', { langcode : langcode });
}
else if (interval >= 3600) {
value = 3600;
output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 hour', '@count hours', {langcode : langcode});
output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 hour', '@count hours', { langcode : langcode });
}
else if (interval >= 60) {
value = 60;
output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 min', '@count min', {langcode : langcode});
output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 min', '@count min', { langcode : langcode });
}
else if (interval >= 1) {
value = 1;
output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 sec', '@count sec', {langcode : langcode});
output += (output.length ? ' ' : '') + Drupal.formatPlural(Math.floor(interval / value), '1 sec', '@count sec', { langcode : langcode });
}

interval %= value;
granularity--;
}

return output.length ? output : Drupal.t('0 sec', {}, {langcode : langcode});
/* eslint-enable key-spacing */
};
return output.length ? output : Drupal.t('0 sec', {}, { langcode : langcode });
}

/**
* Test to see if the given string contains unicode.
*
* @param {string} str
* @param str
* String to test.
*
* @return {bool}
* @return
* true if string contains non ASCII characters.
* false if string only contains ASCII characters.
*/
function advagg_is_unicode(str) {
'use strict';
function advagg_is_unicode(str){
"use strict";
for (var i = 0, n = str.length; i < n; i++) {
if (str.charCodeAt(i) > 255) {
return true;
Expand All @@ -89,12 +86,12 @@ function advagg_is_unicode(str) {
/**
* Toggle the advagg cookie.
*
* @return {bool}
* @return
* true if hostname contains unicode.
* false so the form does not get submitted.
*/
function advagg_toggle_cookie() {
'use strict';
"use strict";
// Fallback to submitting the form for Unicode domains like ".рф".
if (advagg_is_unicode(document.location.hostname)) {
return true;
Expand All @@ -107,24 +104,21 @@ function advagg_toggle_cookie() {

// If the cookie does exist then remove it.
if (cookie_pos !== -1) {
document.cookie =
cookie_name + '='
+ '; expires=Thu, 01 Jan 1970 00:00:00 GMT'
+ '; path=' + Drupal.settings.basePath
+ '; domain=.' + document.location.hostname + ';';
document.cookie = cookie_name + '=;'
+ 'expires=Thu, 01 Jan 1970 00:00:00 GMT;'
+ ' path=' + Drupal.settings.basePath + ';'
+ ' domain=.' + document.location.hostname + ';';
alert(Drupal.t('AdvAgg Bypass Cookie Removed'));
}
// If the cookie does not exist then set it.
else {
var bypass_length = document.getElementById('edit-timespan').value;
var expire_date = new Date(new Date().getTime() + bypass_length * 1000);
var bypass_length = document.getElementById('edit-timespan').value, expire_date = new Date(new Date().getTime() + bypass_length * 1000);

document.cookie =
cookie_name + '=' + Drupal.settings.advagg.key
+ '; expires=' + expire_date.toGMTString()
+ '; path=' + Drupal.settings.basePath
+ '; domain=.' + document.location.hostname + ';';
alert(Drupal.t('AdvAgg Bypass Cookie Set for @time.', {'@time': Drupal.formatInterval(bypass_length)}));
document.cookie = cookie_name + '=' + Drupal.settings.advagg.key + ';'
+ ' expires=' + expire_date.toGMTString() + ';'
+ ' path=' + Drupal.settings.basePath + ';'
+ ' domain=.' + document.location.hostname + ';';
alert(Drupal.t('AdvAgg Bypass Cookie Set for @time.', {'@time' : Drupal.formatInterval(bypass_length)}));
}

// Must return false, if returning true then form gets submitted.
Expand Down
Loading

0 comments on commit c4df557

Please sign in to comment.