Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCommanderRoot <CommanderRoot@users.noreply.github.com>2022-05-03 15:52:45 +0300
committerGitHub <noreply@github.com>2022-05-03 15:52:45 +0300
commit56640ae815fbace78c62482711cb1733d26cee5e (patch)
tree18078e6b9ec3e8ffe7cc6ac28e4c8f0a309bce94
parent34ea7bbfcbc5a79a5c7b675b8cd2134cdda74cbe (diff)
Replace deprecated String.prototype.substr() (#19111)
.substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
-rw-r--r--plugins/Actions/javascripts/actionsDataTable.js2
-rw-r--r--plugins/CoreHome/angularjs/anchorLinkFix.js6
-rw-r--r--plugins/CoreHome/angularjs/common/directives/autocomplete-matched.js2
-rw-r--r--plugins/CoreHome/angularjs/common/directives/field-condition.js2
-rw-r--r--plugins/CoreHome/angularjs/common/filters/ucfirst.js2
-rw-r--r--plugins/CoreHome/angularjs/http404check.js2
-rw-r--r--plugins/CoreHome/javascripts/broadcast.js8
-rw-r--r--plugins/CoreHome/javascripts/dataTable.js4
-rw-r--r--plugins/CoreHome/vue/dist/CoreHome.umd.js8
-rw-r--r--plugins/CoreHome/vue/src/Matomo/Matomo.ts2
-rw-r--r--plugins/CoreHome/vue/src/QuickAccess/QuickAccess.vue2
-rw-r--r--plugins/CoreHome/vue/src/ShowSensitiveData/ShowSensitiveData.ts4
-rw-r--r--plugins/CustomDimensions/javascripts/rowactions.js8
-rw-r--r--plugins/CustomDimensions/vue/src/utilities.ts2
-rw-r--r--plugins/Goals/vue/src/ManageGoals/ManageGoals.vue4
-rw-r--r--plugins/Marketplace/vue/src/PluginName/PluginName.ts4
-rw-r--r--plugins/Overlay/javascripts/Piwik_Overlay.js2
-rw-r--r--plugins/Overlay/templates/startOverlaySession.twig2
-rw-r--r--plugins/PrivacyManager/vue/src/OptOutCustomizer/OptOutCustomizer.vue6
-rw-r--r--plugins/Referrers/vue/src/CampaignBuilder/CampaignBuilder.vue4
-rw-r--r--plugins/SegmentEditor/vue/src/SegmentGenerator/SegmentGenerator.vue12
-rw-r--r--plugins/Transitions/javascripts/transitions.js4
-rw-r--r--plugins/UserCountryMap/javascripts/realtime-map.js4
-rw-r--r--plugins/UserCountryMap/javascripts/visitor-map.js8
-rw-r--r--tests/javascript/index.php8
-rw-r--r--tests/javascript/jash/Jash.js10
-rw-r--r--tests/javascript/jslint/jslint.js2
-rw-r--r--tests/lib/screenshot-testing/support/chai-extras.js2
28 files changed, 63 insertions, 63 deletions
diff --git a/plugins/Actions/javascripts/actionsDataTable.js b/plugins/Actions/javascripts/actionsDataTable.js
index 05434e2773..9d6461f683 100644
--- a/plugins/Actions/javascripts/actionsDataTable.js
+++ b/plugins/Actions/javascripts/actionsDataTable.js
@@ -19,7 +19,7 @@
var currentLevelIndex = style.indexOf('level');
if (currentLevelIndex >= 0) {
- currentLevel = Number(style.substr(currentLevelIndex + 5, 1));
+ currentLevel = Number(style.slice(currentLevelIndex + 5, currentLevelIndex + 6));
}
return currentLevel;
}
diff --git a/plugins/CoreHome/angularjs/anchorLinkFix.js b/plugins/CoreHome/angularjs/anchorLinkFix.js
index bdc55792a7..677eb31242 100644
--- a/plugins/CoreHome/angularjs/anchorLinkFix.js
+++ b/plugins/CoreHome/angularjs/anchorLinkFix.js
@@ -75,8 +75,8 @@
function handleScrollToAnchorIfPresentOnPageLoad()
{
- if (location.hash.substr(0, 2) == '#/') {
- var hash = location.hash.substr(2);
+ if (location.hash.slice(0, 2) == '#/') {
+ var hash = location.hash.slice(2);
scrollToAnchorIfPossible(hash, null);
}
}
@@ -102,7 +102,7 @@
return;
}
- var hash = newUrl.substr(hashPos + 2);
+ var hash = newUrl.slice(hashPos + 2);
scrollToAnchorIfPossible(hash, event);
}
diff --git a/plugins/CoreHome/angularjs/common/directives/autocomplete-matched.js b/plugins/CoreHome/angularjs/common/directives/autocomplete-matched.js
index 5bf1a9a6bb..995950ef2d 100644
--- a/plugins/CoreHome/angularjs/common/directives/autocomplete-matched.js
+++ b/plugins/CoreHome/angularjs/common/directives/autocomplete-matched.js
@@ -46,7 +46,7 @@
var startTerm = content.toLowerCase().indexOf(searchTerm.toLowerCase());
if (-1 !== startTerm) {
- var word = content.substr(startTerm, searchTerm.length);
+ var word = content.slice(startTerm, startTerm + searchTerm.length);
var escapedword = $sanitize(piwik.helper.htmlEntities(word));
content = content.replace(word, '<span class="autocompleteMatched">' + escapedword + '</span>');
element.html(content);
diff --git a/plugins/CoreHome/angularjs/common/directives/field-condition.js b/plugins/CoreHome/angularjs/common/directives/field-condition.js
index 3ff3116cf0..5c4c33ff8e 100644
--- a/plugins/CoreHome/angularjs/common/directives/field-condition.js
+++ b/plugins/CoreHome/angularjs/common/directives/field-condition.js
@@ -38,7 +38,7 @@
} else if (element.prop('tagName').toLowerCase() === 'select') {
var name = element.val();
if (name.indexOf('string:') === 0) {
- return name.substr('string:'.length);
+ return name.slice('string:'.length);
}
return name;
diff --git a/plugins/CoreHome/angularjs/common/filters/ucfirst.js b/plugins/CoreHome/angularjs/common/filters/ucfirst.js
index 3c9094f602..0af633e51e 100644
--- a/plugins/CoreHome/angularjs/common/filters/ucfirst.js
+++ b/plugins/CoreHome/angularjs/common/filters/ucfirst.js
@@ -15,7 +15,7 @@
}
var firstLetter = (value + '').charAt(0).toUpperCase();
- return firstLetter + value.substr(1);
+ return firstLetter + value.slice(1);
};
}
})();
diff --git a/plugins/CoreHome/angularjs/http404check.js b/plugins/CoreHome/angularjs/http404check.js
index b18b7be669..bba8ba6a65 100644
--- a/plugins/CoreHome/angularjs/http404check.js
+++ b/plugins/CoreHome/angularjs/http404check.js
@@ -42,7 +42,7 @@
-1 !== rejection.config.url.indexOf('plugins')) {
var posEndUrl = rejection.config.url.indexOf('.html') + 5;
- var url = rejection.config.url.substr(0, posEndUrl);
+ var url = rejection.config.url.slice(0, posEndUrl);
var message = 'Please check your server configuration. You may want to whitelist "*.html" files from the "plugins" directory.';
message += ' The HTTP status code is ' + rejection.status + ' for URL "' + url + '"';
diff --git a/plugins/CoreHome/javascripts/broadcast.js b/plugins/CoreHome/javascripts/broadcast.js
index 44ace8fe19..22b7c96e73 100644
--- a/plugins/CoreHome/javascripts/broadcast.js
+++ b/plugins/CoreHome/javascripts/broadcast.js
@@ -100,7 +100,7 @@ var broadcast = {
// hash doesn't contain the first # character.
if (hash && 0 === (''+hash).indexOf('/')) {
- hash = (''+hash).substr(1);
+ hash = (''+hash).slice(1);
}
@@ -773,8 +773,8 @@ var broadcast = {
*/
getValueFromHash: function (param, url) {
var hashStr = broadcast.getHashFromUrl(url);
- if (hashStr.substr(0, 1) == '#') {
- hashStr = hashStr.substr(1);
+ if (hashStr.slice(0, 1) == '#') {
+ hashStr = hashStr.slice(1);
}
hashStr = hashStr.split('#')[0];
@@ -795,7 +795,7 @@ var broadcast = {
var lookFor = param + '=';
if (url.indexOf('?') >= 0) {
- url = url.substr(url.indexOf('?')+1);
+ url = url.slice(url.indexOf('?')+1);
}
var urlPieces = url.split('&');
diff --git a/plugins/CoreHome/javascripts/dataTable.js b/plugins/CoreHome/javascripts/dataTable.js
index 214964a34a..3cd03cbea5 100644
--- a/plugins/CoreHome/javascripts/dataTable.js
+++ b/plugins/CoreHome/javascripts/dataTable.js
@@ -805,7 +805,7 @@ $.extend(DataTable.prototype, UIControl.prototype, {
$.each(patternsToReplace, function (index, pattern) {
if (0 === currentPattern.indexOf(pattern.to)) {
- currentPattern = pattern.from + currentPattern.substr(2);
+ currentPattern = pattern.from + currentPattern.slice(2);
}
});
@@ -881,7 +881,7 @@ $.extend(DataTable.prototype, UIControl.prototype, {
$.each(patternsToReplace, function (index, pattern) {
if (0 === keyword.indexOf(pattern.from)) {
- keyword = pattern.to + keyword.substr(1);
+ keyword = pattern.to + keyword.slice(1);
}
});
diff --git a/plugins/CoreHome/vue/dist/CoreHome.umd.js b/plugins/CoreHome/vue/dist/CoreHome.umd.js
index 2bee118c5c..5d2127ef79 100644
--- a/plugins/CoreHome/vue/dist/CoreHome.umd.js
+++ b/plugins/CoreHome/vue/dist/CoreHome.umd.js
@@ -367,7 +367,7 @@ Matomo_piwik.updateDateInTitle = function updateDateInTitle(date, period) {
if (originalTitle.indexOf(Matomo_piwik.siteName) === 0) {
var dateString = " - ".concat(Periods_Periods.parse(period, date).getPrettyString(), " ");
- document.title = "".concat(Matomo_piwik.siteName).concat(dateString).concat(originalTitle.substr(Matomo_piwik.siteName.length));
+ document.title = "".concat(Matomo_piwik.siteName).concat(dateString).concat(originalTitle.slice(Matomo_piwik.siteName.length));
}
};
@@ -3191,10 +3191,10 @@ var ShowSensitiveData_window = window,
var protectedData = '';
if (showCharacters > 0) {
- protectedData += sensitiveData.substr(0, showCharacters);
+ protectedData += sensitiveData.slice(0, showCharacters);
}
- protectedData += sensitiveData.substr(showCharacters).replace(/./g, '*');
+ protectedData += sensitiveData.slice(showCharacters).replace(/./g, '*');
element.html(protectedData);
function onClickHandler() {
@@ -6973,7 +6973,7 @@ function scrollFirstElementIntoView(element) {
if (category && category.lastIndexOf('\n') !== -1) {
// remove "\n\nMenu"
- category = category.substr(0, category.lastIndexOf('\n')).trim();
+ category = category.slice(0, category.lastIndexOf('\n')).trim();
}
window.$(element).find('li .item').each(function (i, subElement) {
diff --git a/plugins/CoreHome/vue/src/Matomo/Matomo.ts b/plugins/CoreHome/vue/src/Matomo/Matomo.ts
index 30b821f403..5db37c0882 100644
--- a/plugins/CoreHome/vue/src/Matomo/Matomo.ts
+++ b/plugins/CoreHome/vue/src/Matomo/Matomo.ts
@@ -24,7 +24,7 @@ piwik.updateDateInTitle = function updateDateInTitle(date: string, period: strin
if (originalTitle.indexOf(piwik.siteName) === 0) {
const dateString = ` - ${Periods.parse(period, date).getPrettyString()} `;
- document.title = `${piwik.siteName}${dateString}${originalTitle.substr(piwik.siteName.length)}`;
+ document.title = `${piwik.siteName}${dateString}${originalTitle.slice(piwik.siteName.length)}`;
}
};
diff --git a/plugins/CoreHome/vue/src/QuickAccess/QuickAccess.vue b/plugins/CoreHome/vue/src/QuickAccess/QuickAccess.vue
index c86008c139..d7812cd992 100644
--- a/plugins/CoreHome/vue/src/QuickAccess/QuickAccess.vue
+++ b/plugins/CoreHome/vue/src/QuickAccess/QuickAccess.vue
@@ -443,7 +443,7 @@ export default defineComponent({
if (category && category.lastIndexOf('\n') !== -1) {
// remove "\n\nMenu"
- category = category.substr(0, category.lastIndexOf('\n')).trim();
+ category = category.slice(0, category.lastIndexOf('\n')).trim();
}
window.$(element).find('li .item').each((i, subElement) => {
diff --git a/plugins/CoreHome/vue/src/ShowSensitiveData/ShowSensitiveData.ts b/plugins/CoreHome/vue/src/ShowSensitiveData/ShowSensitiveData.ts
index 76d5c0c53a..777394e7e6 100644
--- a/plugins/CoreHome/vue/src/ShowSensitiveData/ShowSensitiveData.ts
+++ b/plugins/CoreHome/vue/src/ShowSensitiveData/ShowSensitiveData.ts
@@ -38,9 +38,9 @@ export default {
let protectedData = '';
if (showCharacters > 0) {
- protectedData += sensitiveData.substr(0, showCharacters);
+ protectedData += sensitiveData.slice(0, showCharacters);
}
- protectedData += sensitiveData.substr(showCharacters).replace(/./g, '*');
+ protectedData += sensitiveData.slice(showCharacters).replace(/./g, '*');
element.html(protectedData);
function onClickHandler() {
diff --git a/plugins/CustomDimensions/javascripts/rowactions.js b/plugins/CustomDimensions/javascripts/rowactions.js
index 34c428d840..7b9c88fd34 100644
--- a/plugins/CustomDimensions/javascripts/rowactions.js
+++ b/plugins/CustomDimensions/javascripts/rowactions.js
@@ -17,8 +17,8 @@ $(function () {
},
trigger: function (tr, e, subTableLabel) {
var label = this.getLabelFromTr(tr);
- if (label && label.substr(0, 1) === '@') {
- label = label.substr(1);
+ if (label && label.slice(0, 1) === '@') {
+ label = label.slice(1);
}
var subtable = tr.closest('table');
@@ -42,8 +42,8 @@ $(function () {
onClick: function (actionA, tr, e) {
var segment;
var link = this.getLabelFromTr(tr);
- if (link && link.substr(0, 1) === '@') {
- link = link.substr(1);
+ if (link && link.slice(0, 1) === '@') {
+ link = link.slice(1);
}
link = 'http://' + unescape(link);
diff --git a/plugins/CustomDimensions/vue/src/utilities.ts b/plugins/CustomDimensions/vue/src/utilities.ts
index b1101df38c..da63326b3d 100644
--- a/plugins/CustomDimensions/vue/src/utilities.ts
+++ b/plugins/CustomDimensions/vue/src/utilities.ts
@@ -6,5 +6,5 @@
*/
export function ucfirst(s: string): string {
- return `${s[0].toUpperCase()}${s.substr(1)}`;
+ return `${s[0].toUpperCase()}${s.slice(1)}`;
}
diff --git a/plugins/Goals/vue/src/ManageGoals/ManageGoals.vue b/plugins/Goals/vue/src/ManageGoals/ManageGoals.vue
index af3ad41c39..f3ba68030c 100644
--- a/plugins/Goals/vue/src/ManageGoals/ManageGoals.vue
+++ b/plugins/Goals/vue/src/ManageGoals/ManageGoals.vue
@@ -701,10 +701,10 @@ export default defineComponent({
}
},
lcfirst(s: string) {
- return `${s.substr(0, 1).toLowerCase()}${s.substr(1)}`;
+ return `${s.slice(0, 1).toLowerCase()}${s.slice(1)}`;
},
ucfirst(s: string) {
- return `${s.substr(0, 1).toUpperCase()}${s.substr(1)}`;
+ return `${s.slice(0, 1).toUpperCase()}${s.slice(1)}`;
},
},
computed: {
diff --git a/plugins/Marketplace/vue/src/PluginName/PluginName.ts b/plugins/Marketplace/vue/src/PluginName/PluginName.ts
index f3f9721af3..8e8ec953d1 100644
--- a/plugins/Marketplace/vue/src/PluginName/PluginName.ts
+++ b/plugins/Marketplace/vue/src/PluginName/PluginName.ts
@@ -13,8 +13,8 @@ window.broadcast.addPopoverHandler('browsePluginDetail', (value) => {
let activeTab = null;
if (value.indexOf('!') !== -1) {
- activeTab = value.substr(value.indexOf('!') + 1);
- pluginName = value.substr(0, value.indexOf('!'));
+ activeTab = value.slice(value.indexOf('!') + 1);
+ pluginName = value.slice(0, value.indexOf('!'));
}
let url = `module=Marketplace&action=pluginDetails&pluginName=${encodeURIComponent(pluginName)}`;
diff --git a/plugins/Overlay/javascripts/Piwik_Overlay.js b/plugins/Overlay/javascripts/Piwik_Overlay.js
index 57693d0de2..9ce5302d85 100644
--- a/plugins/Overlay/javascripts/Piwik_Overlay.js
+++ b/plugins/Overlay/javascripts/Piwik_Overlay.js
@@ -380,7 +380,7 @@ var Piwik_Overlay = (function () {
var currentHashStr = broadcast.getHash();
if (currentHashStr.charAt(0) == '?') {
- currentHashStr = currentHashStr.substr(1);
+ currentHashStr = currentHashStr.slice(1);
}
currentHashStr = broadcast.updateParamValue('l=' + newFrameLocation, currentHashStr);
diff --git a/plugins/Overlay/templates/startOverlaySession.twig b/plugins/Overlay/templates/startOverlaySession.twig
index d99dc5f6fb..7e8b4d56ac 100644
--- a/plugins/Overlay/templates/startOverlaySession.twig
+++ b/plugins/Overlay/templates/startOverlaySession.twig
@@ -12,7 +12,7 @@
var match = false;
var parser = document.createElement('a');
- var urlToRedirect = window.location.hash.substr(1);
+ var urlToRedirect = window.location.hash.slice(1);
parser.href = urlToRedirect;
var hostToRedirect = parser.hostname;
diff --git a/plugins/PrivacyManager/vue/src/OptOutCustomizer/OptOutCustomizer.vue b/plugins/PrivacyManager/vue/src/OptOutCustomizer/OptOutCustomizer.vue
index f894c40c30..ca9435ae39 100644
--- a/plugins/PrivacyManager/vue/src/OptOutCustomizer/OptOutCustomizer.vue
+++ b/plugins/PrivacyManager/vue/src/OptOutCustomizer/OptOutCustomizer.vue
@@ -181,7 +181,7 @@ export default defineComponent({
return !!this.piwikurl
&& this.backgroundColor === ''
&& this.fontColor !== ''
- && nearlyWhite(this.fontColor.substr(1));
+ && nearlyWhite(this.fontColor.slice(1));
},
iframeUrl(): string {
if (this.piwikurl) {
@@ -189,8 +189,8 @@ export default defineComponent({
module: 'CoreAdminHome',
action: 'optOut',
language: this.language,
- backgroundColor: this.backgroundColor.substr(1),
- fontColor: this.fontColor.substr(1),
+ backgroundColor: this.backgroundColor.slice(1),
+ fontColor: this.fontColor.slice(1),
fontSize: this.fontSizeWithUnit,
fontFamily: this.fontFamily,
});
diff --git a/plugins/Referrers/vue/src/CampaignBuilder/CampaignBuilder.vue b/plugins/Referrers/vue/src/CampaignBuilder/CampaignBuilder.vue
index 21dabe9ca8..1e579ec1cc 100644
--- a/plugins/Referrers/vue/src/CampaignBuilder/CampaignBuilder.vue
+++ b/plugins/Referrers/vue/src/CampaignBuilder/CampaignBuilder.vue
@@ -213,8 +213,8 @@ export default defineComponent({
let urlHash = '';
if (urlHashPos >= 0) {
- urlHash = generatedUrl.substr(urlHashPos);
- generatedUrl = generatedUrl.substr(0, urlHashPos);
+ urlHash = generatedUrl.slice(urlHashPos);
+ generatedUrl = generatedUrl.slice(0, urlHashPos);
}
if (generatedUrl.indexOf('/', 10) < 0 && generatedUrl.indexOf('?') < 0) {
diff --git a/plugins/SegmentEditor/vue/src/SegmentGenerator/SegmentGenerator.vue b/plugins/SegmentEditor/vue/src/SegmentGenerator/SegmentGenerator.vue
index 7fd9b5db91..830a9bc524 100644
--- a/plugins/SegmentEditor/vue/src/SegmentGenerator/SegmentGenerator.vue
+++ b/plugins/SegmentEditor/vue/src/SegmentGenerator/SegmentGenerator.vue
@@ -216,13 +216,13 @@ function findAndExplodeByMatch(metric: string) {
if (minPos < metric.length) {
// sth found - explode
if (singleChar === true) {
- newMetric.segment = metric.substr(0, minPos);
- newMetric.matches = metric.substr(minPos, 1);
- newMetric.value = decodeURIComponent(metric.substr(minPos + 1));
+ newMetric.segment = metric.slice(0, minPos);
+ newMetric.matches = metric.slice(minPos, minPos + 1);
+ newMetric.value = decodeURIComponent(metric.slice(minPos + 1));
} else {
- newMetric.segment = metric.substr(0, minPos);
- newMetric.matches = metric.substr(minPos, 2);
- newMetric.value = decodeURIComponent(metric.substr(minPos + 2));
+ newMetric.segment = metric.slice(0, minPos);
+ newMetric.matches = metric.slice(minPos, minPos + 2);
+ newMetric.value = decodeURIComponent(metric.slice(minPos + 2));
}
// if value is only '' -> change to empty string
diff --git a/plugins/Transitions/javascripts/transitions.js b/plugins/Transitions/javascripts/transitions.js
index f8d0bf8749..31396f9b54 100644
--- a/plugins/Transitions/javascripts/transitions.js
+++ b/plugins/Transitions/javascripts/transitions.js
@@ -459,7 +459,7 @@ Piwik_Transitions.prototype.renderCenterBox = function () {
el.addClass('Transitions_Value0');
} else {
self.addTooltipShowingPercentageOfAllPageviews(el, modelProperty);
- var groupName = cssClass.charAt(0).toLowerCase() + cssClass.substr(1);
+ var groupName = cssClass.charAt(0).toLowerCase() + cssClass.slice(1);
el.hover(function () {
self.highlightGroup(groupName, highlightCurveOnSide);
}, function () {
@@ -792,7 +792,7 @@ Piwik_Transitions.prototype.highlightGroup = function (groupName, side) {
this.highlightedGroup = groupName;
this.highlightedGroupSide = side;
- var cssClass = 'Transitions_' + groupName.charAt(0).toUpperCase() + groupName.substr(1);
+ var cssClass = 'Transitions_' + groupName.charAt(0).toUpperCase() + groupName.slice(1);
this.highlightedGroupCenterEl = this.canvas.container.find('.' + cssClass);
this.highlightedGroupCenterEl.addClass('Transitions_Highlighted');
diff --git a/plugins/UserCountryMap/javascripts/realtime-map.js b/plugins/UserCountryMap/javascripts/realtime-map.js
index fbb9df1196..a03c42ffc9 100644
--- a/plugins/UserCountryMap/javascripts/realtime-map.js
+++ b/plugins/UserCountryMap/javascripts/realtime-map.js
@@ -586,7 +586,7 @@
}
}
- updateMap(location.hash && (location.hash == '#world' || location.hash.match(/^#[A-Z]{2,3}$/)) ? location.hash.substr(1) : 'world'); // TODO: restore last state
+ updateMap(location.hash && (location.hash == '#world' || location.hash.match(/^#[A-Z]{2,3}$/)) ? location.hash.slice(1) : 'world'); // TODO: restore last state
// clicking on map background zooms out
$('.RealTimeMap_map', this.$element).off('click').click(function () {
@@ -643,7 +643,7 @@
var ds = new Date().getTime() / 1000 - el.data('actiontime');
el.html(relativeTime(ds));
});
- var d = new Date(), datetime = d.toTimeString().substr(0, 8);
+ var d = new Date(), datetime = d.toTimeString().slice(0, 8);
$('.realTimeMap_datetime').html(datetime);
}, 1000);
},
diff --git a/plugins/UserCountryMap/javascripts/visitor-map.js b/plugins/UserCountryMap/javascripts/visitor-map.js
index ffbbc236d7..9a972962b0 100644
--- a/plugins/UserCountryMap/javascripts/visitor-map.js
+++ b/plugins/UserCountryMap/javascripts/visitor-map.js
@@ -192,7 +192,7 @@
if (val == 1 && metric == 'nb_visits') v = _.one_visit;
- if (metric.substr(0, 3) == 'nb_' && metric != 'nb_actions_per_visit') {
+ if (metric.slice(0, 3) == 'nb_' && metric != 'nb_actions_per_visit') {
var total;
if (id.length == 3) total = UserCountryMap.countriesByIso[id][metric];
else if (id == 'world') total = self.config.visitsSummary[metric];
@@ -761,12 +761,12 @@
function regionCode(region) {
var key = UserCountryMap.keys[iso] || 'fips';
- return key.substr(0, 4) == "fips" ? (region[key] || "").substr(2) : region[key]; // cut first two letters from fips code (=country code)
+ return key.slice(0, 4) == "fips" ? (region[key] || "").slice(2) : region[key]; // cut first two letters from fips code (=country code)
}
function regionExistsInMap(code) {
var key = UserCountryMap.keys[iso] || 'fips', q = {};
- q[key] = key.substr(0, 4) == 'fips' ? UserCountryMap.countriesByIso[iso].fips + code : code;
+ q[key] = key.slice(0, 4) == 'fips' ? UserCountryMap.countriesByIso[iso].fips + code : code;
if (map.getLayer('regions').getPaths(q).length === 0) {
return false;
}
@@ -783,7 +783,7 @@
};
if (map.getLayer('regions').getPaths(q).length) {
- region = map.getLayer('regions').getPaths(q)[0].data.fips.substr(2);
+ region = map.getLayer('regions').getPaths(q)[0].data.fips.slice(2);
}
}
diff --git a/tests/javascript/index.php b/tests/javascript/index.php
index c4241e8d60..c9a1b15e71 100644
--- a/tests/javascript/index.php
+++ b/tests/javascript/index.php
@@ -3188,7 +3188,7 @@ function PiwikTest() {
equal(tracker.getVisitorId(), visitorId, "After tracking an action and updating the ID cookie, the visitor ID is still the same.");
// Visitor ID is by default set to a UUID fingerprint
- var hashUserId = tracker.hook.test._sha1(userIdString).substr(0, 16);
+ var hashUserId = tracker.hook.test._sha1(userIdString).slice(0, 16);
notEqual(hashUserId, tracker.getVisitorId(), "Visitor ID " + tracker.getVisitorId() + " is not yet the hash of User ID " + hashUserId);
notEqual("", tracker.getVisitorId(), "Visitor ID is not empty");
ok( tracker.getVisitorId().length === 16, "Visitor ID is 16 chars string");
@@ -3231,7 +3231,7 @@ function PiwikTest() {
// Set User ID and verify it was set
tracker.setUserId(userIdString);
equal(userIdString, tracker.getUserId(), "getUserId() returns User Id");
- notEqual(tracker.hook.test._sha1(userIdString).substr(0, 16), tracker.getVisitorId(), "Visitor ID is not the sha1 of User ID (it used to be)");
+ notEqual(tracker.hook.test._sha1(userIdString).slice(0, 16), tracker.getVisitorId(), "Visitor ID is not the sha1 of User ID (it used to be)");
equal(tracker.getVisitorId(), tracker2.getVisitorId(), "After setting a User ID, Visitor ID does not change");
// Set the User ID and verify nothing's changed
@@ -3657,7 +3657,7 @@ if ($mysql) {
var piwikUrl = location.href;
if (piwikUrl.indexOf('?') > 0) {
- piwikUrl = piwikUrl.substr(0, piwikUrl.indexOf('?'));
+ piwikUrl = piwikUrl.slice(0, piwikUrl.indexOf('?'));
}
equal(tracker.getPiwikUrl(), piwikUrl, "getPiwikUrl, relative tracker url" );
@@ -4968,7 +4968,7 @@ if ($mysql) {
strictEqual(tracker.hasRememberedConsent(), true, "rememberConsentGiven, sets cookie to remember consent" );
var rememberedConsent = tracker.getRememberedConsent();
strictEqual(String(rememberedConsent).length, 13, "getRememberedConsent, returns the data in milliseconds eg '1522200406749'" );
- strictEqual(String(rememberedConsent).substr(0, 2), '16', "getRememberedConsent, starts with correct data" );
+ strictEqual(String(rememberedConsent).slice(0, 2), '16', "getRememberedConsent, starts with correct data" );
tracker.requireConsent();
strictEqual(tracker.hasConsent(), true, "when requiring consent, and we remembered consent, consent should be given" );
diff --git a/tests/javascript/jash/Jash.js b/tests/javascript/jash/Jash.js
index 80288a40aa..de05745d48 100644
--- a/tests/javascript/jash/Jash.js
+++ b/tests/javascript/jash/Jash.js
@@ -1116,7 +1116,7 @@ Jash.Indenter = {
if (tagLevel === -1) {
level--;
}
- arr = this.indentAndAdd(level,source.substr(startedAt,tagLength),arr);
+ arr = this.indentAndAdd(level,source.slice(startedAt,startedAt+tagLength),arr);
if (tagLevel === 1) {
level++;
}
@@ -1129,7 +1129,7 @@ Jash.Indenter = {
}
if (source.charAt(position) === '<') {
tagLength = position-startedAt;
- arr = this.indentAndAdd(level,source.substr(startedAt,tagLength),arr);
+ arr = this.indentAndAdd(level,source.slice(startedAt,startedAt+tagLength),arr);
}
} else {
position++;
@@ -1455,7 +1455,7 @@ Jash.TabComplete = function() {
fragLength++;
matches = this.doAllStringsInArrayHaveSameCharacterAtIndex(fragLength,arr);
}
- return arr[0].substr(0,fragLength);
+ return arr[0].slice(0,fragLength);
}
/**
* Attempt to complete an element id or class name based on what is available in all
@@ -1535,7 +1535,7 @@ Jash.TabComplete = function() {
/* tokenize classes into array */
var classes = els[i].className.split(/\s/);
for(var ii = 0; ii < classes.length; ii++) {
- if(classes[ii].indexOf(lastSelector.substr(1)) == 0 || lastSelector == ".") {
+ if(classes[ii].indexOf(lastSelector.slice(1)) == 0 || lastSelector == ".") {
/* prevent duplicate entries */
if(matches.join("***").indexOf(classes[ii]) == -1) {
matches.push("." + classes[ii]);
@@ -1547,7 +1547,7 @@ Jash.TabComplete = function() {
/* id */
} else if (lastSelector.match(/^#/)) {
for(var i = 0; i<els.length; i++) {
- if(els[i].id && els[i].id.indexOf(lastSelector.substr(1)) == 0) {
+ if(els[i].id && els[i].id.indexOf(lastSelector.slice(1)) == 0) {
matches.push("#" + els[i].id);
}
}
diff --git a/tests/javascript/jslint/jslint.js b/tests/javascript/jslint/jslint.js
index f6e37b8440..455820a0cb 100644
--- a/tests/javascript/jslint/jslint.js
+++ b/tests/javascript/jslint/jslint.js
@@ -951,7 +951,7 @@ var JSLINT = (function () {
var c, pos = 0, r = '', result;
function hex(n) {
- var i = parseInt(source_row.substr(pos + 1, n), 16);
+ var i = parseInt(source_row.slice(pos + 1, pos + 1 + n), 16);
pos += n;
if (i >= 32 && i <= 126 &&
i !== 34 && i !== 92 && i !== 39) {
diff --git a/tests/lib/screenshot-testing/support/chai-extras.js b/tests/lib/screenshot-testing/support/chai-extras.js
index e807412b57..2160673845 100644
--- a/tests/lib/screenshot-testing/support/chai-extras.js
+++ b/tests/lib/screenshot-testing/support/chai-extras.js
@@ -237,7 +237,7 @@ function assumeFileIsImageIfNotSpecified(filename) {
function endsWith(string, needle)
{
- return string.substr(-1 * needle.length, needle.length) === needle;
+ return needle.length === 0 || string.slice(-needle.length) === needle;
}
// other automatically run assertions