ES6ify /scripts/util.js
Bug: Issue 6179 Change-Id: Icc3a146dd50a9444b386212ff994203b2012e27b
This commit is contained in:
parent
07dfee0786
commit
264f2f422b
@ -14,7 +14,7 @@
|
|||||||
(function(window) {
|
(function(window) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var util = window.util || {};
|
const util = window.util || {};
|
||||||
|
|
||||||
util.parseDate = function(dateStr) {
|
util.parseDate = function(dateStr) {
|
||||||
// Timestamps are given in UTC and have the format
|
// Timestamps are given in UTC and have the format
|
||||||
@ -25,14 +25,14 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
util.getCookie = function(name) {
|
util.getCookie = function(name) {
|
||||||
var key = name + '=';
|
const key = name + '=';
|
||||||
var cookies = document.cookie.split(';');
|
const cookies = document.cookie.split(';');
|
||||||
for (var i = 0; i < cookies.length; i++) {
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
var c = cookies[i];
|
let c = cookies[i];
|
||||||
while (c.charAt(0) == ' ') {
|
while (c.charAt(0) === ' ') {
|
||||||
c = c.substring(1);
|
c = c.substring(1);
|
||||||
}
|
}
|
||||||
if (c.indexOf(key) == 0) {
|
if (c.startsWith(key)) {
|
||||||
return c.substring(key.length, c.length);
|
return c.substring(key.length, c.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,7 +50,7 @@
|
|||||||
* @return {String} Returns the truncated value of a URL.
|
* @return {String} Returns the truncated value of a URL.
|
||||||
*/
|
*/
|
||||||
util.truncatePath = function(path) {
|
util.truncatePath = function(path) {
|
||||||
var pathPieces = path.split('/');
|
const pathPieces = path.split('/');
|
||||||
|
|
||||||
if (pathPieces.length < 2) {
|
if (pathPieces.length < 2) {
|
||||||
return path;
|
return path;
|
||||||
|
Loading…
Reference in New Issue
Block a user