Skip to content

Commit 567aaed

Browse files
authored
String.substr() is deprecated and substring() works a little differently. (#87)
1 parent fe48a17 commit 567aaed

File tree

2 files changed

+56
-56
lines changed

2 files changed

+56
-56
lines changed

git-webui/release/share/git-webui/webui/js/git-webui.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ webui.SideBarView = function(mainView) {
305305
}
306306
var cardDiv = $('<div class="card custom-card">').appendTo(accordionDiv)[0];
307307
if (id.indexOf("local-branches") > -1) {
308-
var refname = ref.substr(2);
308+
var refname = ref.substring(2);
309309
var itemId = refname + idPostfix;
310310
var cardHeader = $('<div class="card-header" id="heading-' + itemId + '">').appendTo(cardDiv);
311311
var button = $('<button class="btn btn-sm btn-default btn-branch text-left" type="button" data-toggle="collapse" data-target="#collapse-' + itemId + '" aria-expanded="true" aria-controls="collapse-' + itemId + '">'
@@ -362,7 +362,7 @@ webui.SideBarView = function(mainView) {
362362
refs = refs.map(function(ref) {
363363
var end = ref.lastIndexOf(" -> ");
364364
if (end == -1) {
365-
return ref.substr(2);
365+
return ref.substring(2);
366366
} else {
367367
return ref.substring(2, end);
368368
}
@@ -470,7 +470,7 @@ webui.LogView = function(historyView) {
470470
} else {
471471
var len = undefined;
472472
}
473-
var entry = new Entry(self, data.substr(start, len));
473+
var entry = new Entry(self, data.substring(start, start+len));
474474
if (count < maxCount) {
475475
content.appendChild(entry.element);
476476
if (!self.lineHeight) {
@@ -608,11 +608,11 @@ webui.LogView = function(historyView) {
608608

609609
function Person(data) {
610610
var nameEnd = data.indexOf("<");
611-
this.name = data.substr(0, nameEnd - 1);
611+
this.name = data.substring(0, nameEnd - 1);
612612
var emailEnd = data.indexOf(">", nameEnd);
613-
this.email = data.substr(nameEnd + 1, emailEnd - nameEnd - 1);
613+
this.email = data.substring(nameEnd + 1, emailEnd);
614614
var dateEnd = data.indexOf(" ", emailEnd + 2);
615-
var secs = data.substr(emailEnd + 2, dateEnd - emailEnd - 2);
615+
var secs = data.substring(emailEnd + 2, dateEnd);
616616
this.date = new Date(0);
617617
this.date.setUTCSeconds(parseInt(secs));
618618
};
@@ -621,15 +621,15 @@ webui.LogView = function(historyView) {
621621
var self = this;
622622

623623
self.abbrevCommitHash = function() {
624-
return self.commit.substr(0, 7);
624+
return self.commit.substring(0, 7);
625625
};
626626

627627
self.abbrevMessage = function() {
628628
var end = self.message.indexOf("\n");
629629
if (end == -1) {
630630
return self.message
631631
} else {
632-
return self.message.substr(0, end);
632+
return self.message.substring(0, end);
633633
}
634634
};
635635

@@ -648,13 +648,13 @@ webui.LogView = function(historyView) {
648648
var entryName = $("h6", self.element);
649649
self.refs.forEach(function (ref) {
650650
if (ref.indexOf("refs/remotes") == 0) {
651-
ref = ref.substr(13);
651+
ref = ref.substring(13);
652652
var reftype = "danger";
653653
} else if (ref.indexOf("refs/heads") == 0) {
654-
ref = ref.substr(11);
654+
ref = ref.substring(11);
655655
var reftype = "success";
656656
} else if (ref.indexOf("tag: refs/tags") == 0) {
657-
ref = ref.substr(15);
657+
ref = ref.substring(15);
658658
var reftype = "info";
659659
} else {
660660
var reftype = "warning";
@@ -686,25 +686,25 @@ webui.LogView = function(historyView) {
686686

687687
data.split("\n").forEach(function(line) {
688688
if (line.indexOf("commit ") == 0) {
689-
self.commit = line.substr(7, 40);
689+
self.commit = line.substring(7, 47);
690690
if (line.length > 47) {
691691
self.refs = []
692692
var s = line.lastIndexOf("(") + 1;
693693
var e = line.lastIndexOf(")");
694-
line.substr(s, e - s).split(", ").forEach(function(ref) {
694+
line.substring(s, e).split(", ").forEach(function(ref) {
695695
self.refs.push(ref);
696696
});
697697
}
698698
} else if (line.indexOf("parent ") == 0) {
699-
self.parents.push(line.substr(7));
699+
self.parents.push(line.substring(7));
700700
} else if (line.indexOf("tree ") == 0) {
701-
self.tree = line.substr(5);
701+
self.tree = line.substring(5);
702702
} else if (line.indexOf("author ") == 0) {
703-
self.author = new Person(line.substr(7));
703+
self.author = new Person(line.substring(7));
704704
} else if (line.indexOf("committer ") == 0) {
705-
self.committer = new Person(line.substr(10));
705+
self.committer = new Person(line.substring(10));
706706
} else if (line.indexOf(" ") == 0) {
707-
self.message += line.substr(4) + "\n";
707+
self.message += line.substring(4) + "\n";
708708
}
709709
});
710710

@@ -956,9 +956,9 @@ webui.DiffView = function(sideBySide, hunkSelectionAllowed, parent) {
956956
self.reverseLine = function(line) {
957957
switch (line[0]) {
958958
case '-':
959-
return '+' + line.substr(1);
959+
return '+' + line.substring(1);
960960
case '+':
961-
return '-' + line.substr(1);
961+
return '-' + line.substring(1);
962962
break;
963963
default:
964964
return line;
@@ -1173,18 +1173,18 @@ webui.TreeView = function(commitView) {
11731173
}
11741174

11751175
var end = line.indexOf(" ");
1176-
self.mode = parseInt(line.substr(0, end));
1176+
self.mode = parseInt(line.substring(0, end));
11771177
var start = end + 1;
11781178
var end = line.indexOf(" ", start);
1179-
self.type = line.substr(start, end - start);
1179+
self.type = line.substring(start, end);
11801180
start = end + 1;
11811181
var end = line.indexOf(" ", start);
1182-
self.object = line.substr(start, end - start);
1182+
self.object = line.substring(start, end);
11831183
start = end + 1;
11841184
var end = line.indexOf("\t", start);
1185-
self.size = parseInt(line.substr(start, end - start).trim());
1185+
self.size = parseInt(line.substring(start, end).trim());
11861186
start = end + 1;
1187-
self.name = line.substr(start);
1187+
self.name = line.substring(start);
11881188
}
11891189

11901190
self.update = function(treeRef) {
@@ -1570,7 +1570,7 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
15701570
var status = line[col];
15711571
if (col == 0 && status != " " && status != "?" || col == 1 && status != " ") {
15721572
++self.filesCount;
1573-
line = line.substr(3);
1573+
line = line.substring(3);
15741574
var splitted = line.split(" -> ");
15751575
var model;
15761576
if (splitted.length > 1) {
@@ -1707,7 +1707,7 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
17071707
});
17081708

17091709

1710-
$('<button class="btn btn-sm btn-danger float-right" id="confirm-staging">' + action.charAt(0).toUpperCase()+action.substr(1)+'</button>'+
1710+
$('<button class="btn btn-sm btn-danger float-right" id="confirm-staging">' + action.charAt(0).toUpperCase()+action.substring(1)+'</button>'+
17111711
'<button class="btn btn-sm btn-secondary float-right" id="cancel-staging">Cancel</button>').appendTo(popupContent);
17121712
$(popup).modal('show');
17131713

@@ -1965,7 +1965,7 @@ function removeAllChildNodes(parent) {
19651965

19661966
$(function () {
19671967
$('[data-toggle="tooltip"]').tooltip()
1968-
})
1968+
});
19691969
$(function()
19701970
{
19711971
$(document).on('click', '.btn-add', function(e)

git-webui/src/share/git-webui/webui/js/git-webui.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ webui.SideBarView = function(mainView) {
305305
}
306306
var cardDiv = $('<div class="card custom-card">').appendTo(accordionDiv)[0];
307307
if (id.indexOf("local-branches") > -1) {
308-
var refname = ref.substr(2);
308+
var refname = ref.substring(2);
309309
var itemId = refname + idPostfix;
310310
var cardHeader = $('<div class="card-header" id="heading-' + itemId + '">').appendTo(cardDiv);
311311
var button = $('<button class="btn btn-sm btn-default btn-branch text-left" type="button" data-toggle="collapse" data-target="#collapse-' + itemId + '" aria-expanded="true" aria-controls="collapse-' + itemId + '">'
@@ -362,7 +362,7 @@ webui.SideBarView = function(mainView) {
362362
refs = refs.map(function(ref) {
363363
var end = ref.lastIndexOf(" -> ");
364364
if (end == -1) {
365-
return ref.substr(2);
365+
return ref.substring(2);
366366
} else {
367367
return ref.substring(2, end);
368368
}
@@ -470,7 +470,7 @@ webui.LogView = function(historyView) {
470470
} else {
471471
var len = undefined;
472472
}
473-
var entry = new Entry(self, data.substr(start, len));
473+
var entry = new Entry(self, data.substring(start, start+len));
474474
if (count < maxCount) {
475475
content.appendChild(entry.element);
476476
if (!self.lineHeight) {
@@ -608,11 +608,11 @@ webui.LogView = function(historyView) {
608608

609609
function Person(data) {
610610
var nameEnd = data.indexOf("<");
611-
this.name = data.substr(0, nameEnd - 1);
611+
this.name = data.substring(0, nameEnd - 1);
612612
var emailEnd = data.indexOf(">", nameEnd);
613-
this.email = data.substr(nameEnd + 1, emailEnd - nameEnd - 1);
613+
this.email = data.substring(nameEnd + 1, emailEnd);
614614
var dateEnd = data.indexOf(" ", emailEnd + 2);
615-
var secs = data.substr(emailEnd + 2, dateEnd - emailEnd - 2);
615+
var secs = data.substring(emailEnd + 2, dateEnd);
616616
this.date = new Date(0);
617617
this.date.setUTCSeconds(parseInt(secs));
618618
};
@@ -621,15 +621,15 @@ webui.LogView = function(historyView) {
621621
var self = this;
622622

623623
self.abbrevCommitHash = function() {
624-
return self.commit.substr(0, 7);
624+
return self.commit.substring(0, 7);
625625
};
626626

627627
self.abbrevMessage = function() {
628628
var end = self.message.indexOf("\n");
629629
if (end == -1) {
630630
return self.message
631631
} else {
632-
return self.message.substr(0, end);
632+
return self.message.substring(0, end);
633633
}
634634
};
635635

@@ -648,13 +648,13 @@ webui.LogView = function(historyView) {
648648
var entryName = $("h6", self.element);
649649
self.refs.forEach(function (ref) {
650650
if (ref.indexOf("refs/remotes") == 0) {
651-
ref = ref.substr(13);
651+
ref = ref.substring(13);
652652
var reftype = "danger";
653653
} else if (ref.indexOf("refs/heads") == 0) {
654-
ref = ref.substr(11);
654+
ref = ref.substring(11);
655655
var reftype = "success";
656656
} else if (ref.indexOf("tag: refs/tags") == 0) {
657-
ref = ref.substr(15);
657+
ref = ref.substring(15);
658658
var reftype = "info";
659659
} else {
660660
var reftype = "warning";
@@ -686,25 +686,25 @@ webui.LogView = function(historyView) {
686686

687687
data.split("\n").forEach(function(line) {
688688
if (line.indexOf("commit ") == 0) {
689-
self.commit = line.substr(7, 40);
689+
self.commit = line.substring(7, 47);
690690
if (line.length > 47) {
691691
self.refs = []
692692
var s = line.lastIndexOf("(") + 1;
693693
var e = line.lastIndexOf(")");
694-
line.substr(s, e - s).split(", ").forEach(function(ref) {
694+
line.substring(s, e).split(", ").forEach(function(ref) {
695695
self.refs.push(ref);
696696
});
697697
}
698698
} else if (line.indexOf("parent ") == 0) {
699-
self.parents.push(line.substr(7));
699+
self.parents.push(line.substring(7));
700700
} else if (line.indexOf("tree ") == 0) {
701-
self.tree = line.substr(5);
701+
self.tree = line.substring(5);
702702
} else if (line.indexOf("author ") == 0) {
703-
self.author = new Person(line.substr(7));
703+
self.author = new Person(line.substring(7));
704704
} else if (line.indexOf("committer ") == 0) {
705-
self.committer = new Person(line.substr(10));
705+
self.committer = new Person(line.substring(10));
706706
} else if (line.indexOf(" ") == 0) {
707-
self.message += line.substr(4) + "\n";
707+
self.message += line.substring(4) + "\n";
708708
}
709709
});
710710

@@ -956,9 +956,9 @@ webui.DiffView = function(sideBySide, hunkSelectionAllowed, parent) {
956956
self.reverseLine = function(line) {
957957
switch (line[0]) {
958958
case '-':
959-
return '+' + line.substr(1);
959+
return '+' + line.substring(1);
960960
case '+':
961-
return '-' + line.substr(1);
961+
return '-' + line.substring(1);
962962
break;
963963
default:
964964
return line;
@@ -1173,18 +1173,18 @@ webui.TreeView = function(commitView) {
11731173
}
11741174

11751175
var end = line.indexOf(" ");
1176-
self.mode = parseInt(line.substr(0, end));
1176+
self.mode = parseInt(line.substring(0, end));
11771177
var start = end + 1;
11781178
var end = line.indexOf(" ", start);
1179-
self.type = line.substr(start, end - start);
1179+
self.type = line.substring(start, end);
11801180
start = end + 1;
11811181
var end = line.indexOf(" ", start);
1182-
self.object = line.substr(start, end - start);
1182+
self.object = line.substring(start, end);
11831183
start = end + 1;
11841184
var end = line.indexOf("\t", start);
1185-
self.size = parseInt(line.substr(start, end - start).trim());
1185+
self.size = parseInt(line.substring(start, end).trim());
11861186
start = end + 1;
1187-
self.name = line.substr(start);
1187+
self.name = line.substring(start);
11881188
}
11891189

11901190
self.update = function(treeRef) {
@@ -1570,7 +1570,7 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
15701570
var status = line[col];
15711571
if (col == 0 && status != " " && status != "?" || col == 1 && status != " ") {
15721572
++self.filesCount;
1573-
line = line.substr(3);
1573+
line = line.substring(3);
15741574
var splitted = line.split(" -> ");
15751575
var model;
15761576
if (splitted.length > 1) {
@@ -1707,7 +1707,7 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
17071707
});
17081708

17091709

1710-
$('<button class="btn btn-sm btn-danger float-right" id="confirm-staging">' + action.charAt(0).toUpperCase()+action.substr(1)+'</button>'+
1710+
$('<button class="btn btn-sm btn-danger float-right" id="confirm-staging">' + action.charAt(0).toUpperCase()+action.substring(1)+'</button>'+
17111711
'<button class="btn btn-sm btn-secondary float-right" id="cancel-staging">Cancel</button>').appendTo(popupContent);
17121712
$(popup).modal('show');
17131713

@@ -1965,7 +1965,7 @@ function removeAllChildNodes(parent) {
19651965

19661966
$(function () {
19671967
$('[data-toggle="tooltip"]').tooltip()
1968-
})
1968+
});
19691969
$(function()
19701970
{
19711971
$(document).on('click', '.btn-add', function(e)

0 commit comments

Comments
 (0)