[Pkg-mozext-commits] [tabmixplus] 18/27: Implementing String.prototype.startsWith
David Prévot
taffit at moszumanska.debian.org
Fri Dec 26 01:04:30 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository tabmixplus.
commit f7f69b30c82e0e7477f915e2f449db9d41b4269f
Author: onemen <tabmix.onemen at gmail.com>
Date: Wed Dec 17 16:18:38 2014 +0200
Implementing String.prototype.startsWith
---
chrome/content/flst/lasttab.js | 2 +-
chrome/content/places/places.js | 2 +-
chrome/content/preferences/preferences.js | 2 +-
chrome/content/session/session.js | 18 +++++++++---------
chrome/content/session/sessionStore.js | 2 +-
chrome/content/tab/tab.js | 2 +-
chrome/content/tabmix.js | 4 ++--
modules/ContentClick.jsm | 4 ++--
modules/Services.jsm | 2 +-
9 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/chrome/content/flst/lasttab.js b/chrome/content/flst/lasttab.js
index 1187d9e..259816c 100644
--- a/chrome/content/flst/lasttab.js
+++ b/chrome/content/flst/lasttab.js
@@ -42,7 +42,7 @@ var TMP_LastTab = {
false);
var ietab = "chrome://ietab/content/reloaded.html?url=";
- if (gBrowser.currentURI.spec.indexOf(ietab) == 0)
+ if (gBrowser.currentURI.spec.startsWith(ietab))
tablist.focus();
this.TabListLock = true;
diff --git a/chrome/content/places/places.js b/chrome/content/places/places.js
index a5aca03..2581af0 100644
--- a/chrome/content/places/places.js
+++ b/chrome/content/places/places.js
@@ -400,7 +400,7 @@ var TMP_Places = {
if (!result && ietab) {
let prefix = "chrome://" + ietab.folder + "/content/reloaded.html?url="
if (aUrl != prefix) {
- let url = aUrl.indexOf(prefix) == 0 ?
+ let url = aUrl.startsWith(prefix) ?
aUrl.replace(prefix, "") : prefix + aUrl;
result = aCallBack.apply(this, [url]) ||
hasHref && aCallBack.apply(this, url.split("#"));
diff --git a/chrome/content/preferences/preferences.js b/chrome/content/preferences/preferences.js
index d84383b..16e4880 100644
--- a/chrome/content/preferences/preferences.js
+++ b/chrome/content/preferences/preferences.js
@@ -534,7 +534,7 @@ function openHelp(helpTopic) {
let browsers = tabBrowser.browsers;
for (let i = 0; i < browsers.length; i++) {
let browser = browsers[i];
- if (browser.currentURI.spec.indexOf(helpPage) == 0) {
+ if (browser.currentURI.spec.startsWith(helpPage)) {
tabBrowser.tabContainer.selectedIndex = i;
return true;
}
diff --git a/chrome/content/session/session.js b/chrome/content/session/session.js
index 4f5447e..a46b1d3 100644
--- a/chrome/content/session/session.js
+++ b/chrome/content/session/session.js
@@ -897,7 +897,7 @@ var TabmixSessionManager = {
var allElements = this.DATASource.GetAllResources();
while (allElements.hasMoreElements()) {
var aResource = allElements.getNext();
- if ((aResource instanceof Ci.nsIRDFResource) && (aResource.Value.indexOf(labelRoot) == 0))
+ if ((aResource instanceof Ci.nsIRDFResource) && (aResource.Value.startsWith(labelRoot)))
this.deleteNode(aResource);
}
},
@@ -1362,10 +1362,10 @@ if (container == "error") { Tabmix.log("wrapContainer error path " + path + "\n"
container = this.initContainer(path)
var pathNode, container, extID = "";
var node = aTriggerNode.parentNode.parentNode;
- if (node.id.indexOf("tm-sm-closedwindows")==0 || node.id == "btn_closedwindows")
+ if (node.id.startsWith("tm-sm-closedwindows") || node.id == "btn_closedwindows")
extID = "/" + id;
this.copySubtree(oldPath, path + extID);
- if (node.id.indexOf("tm-sm-closedwindows")==0 || node.id == "btn_closedwindows") {
+ if (node.id.startsWith("tm-sm-closedwindows") || node.id == "btn_closedwindows") {
node = this.RDFService.GetResource(path + extID);
container.InsertElementAt(node, 1, true);
this.DATASource.Unassert(node, this.getNC("dontLoad"), this.RDFService.GetLiteral("true"));
@@ -1399,7 +1399,7 @@ if (container == "error") { Tabmix.log("wrapContainer error path " + path + "\n"
var allElements = this.DATASource.GetAllResources();
while (allElements.hasMoreElements()) {
var aResource = allElements.getNext();
- if ((aResource instanceof Ci.nsIRDFResource) && (aResource.Value.indexOf(oldRoot) == 0)) {
+ if ((aResource instanceof Ci.nsIRDFResource) && (aResource.Value.startsWith(oldRoot))) {
var newNodeLabel = aResource.Value.replace(oldRoot, newRoot);
this.copyNode(aResource, this.RDFService.GetResource(newNodeLabel), oldRoot, newRoot);
}
@@ -1609,7 +1609,7 @@ if (container == "error") { Tabmix.log("wrapContainer error path " + path + "\n"
var obsAll = document.getElementById("tmp_contextmenu_AllWindows");
var obsThis = document.getElementById("tmp_contextmenu_ThisWindow");
var mSave = document.getElementById("tm-sm-Save");
- if (node.id.indexOf("tm-sm-closedwindows")==0 || node.id == "btn_closedwindows" || mValue <= -1) {
+ if (node.id.startsWith("tm-sm-closedwindows") || node.id == "btn_closedwindows" || mValue <= -1) {
if (obsAll.hidden != true)
obsAll.hidden = true;
if (obsThis.hidden != true)
@@ -1700,7 +1700,7 @@ if (container == "error") { Tabmix.log("wrapContainer error path " + path + "\n"
case Tabmix.BUTTON_OK: this.replaceStartupPref(result, "");
case Tabmix.NO_NEED_TO_REPLACE : this.removeSession(path, this._rdfRoot+'/windows');
}
- } else if (node.id.indexOf("tm-sm-closedwindows")==0 || node.id == "btn_closedwindows") {
+ } else if (node.id.startsWith("tm-sm-closedwindows") || node.id == "btn_closedwindows") {
this.removeSession(path, this.gSessionPath[0]);
this.updateClosedWindowsMenu("check");
}
@@ -1728,7 +1728,7 @@ if (container == "error") { Tabmix.log("wrapContainer error path " + path + "\n"
this.prefBranch.setIntPref("onStart.loadsession", -1);
Services.prefs.savePrefFile(null); // store the pref immediately
}
- } else if (node.id.indexOf("tm-sm-closedwindows")==0 || node.id == "btn_closedwindows") {
+ } else if (node.id.startsWith("tm-sm-closedwindows") || node.id == "btn_closedwindows") {
title = TabmixSvc.getSMString("sm.removeAll.title.closedwindow");
msg = TabmixSvc.getSMString("sm.removeAll.msg2");
result = Tabmix.promptService([Tabmix.BUTTON_CANCEL, Tabmix.HIDE_MENUANDTEXT, Tabmix.HIDE_CHECKBOX],
@@ -1874,7 +1874,7 @@ if (container == "error") { Tabmix.log("wrapContainer error path " + path + "\n"
parentID = "tm_prompt";
else if (contents != Tabmix.SHOW_CLOSED_WINDOW_LIST)
parentID = popup.parentNode.id;
- var onClosedWindowsList = parentId.indexOf("tm-sm-closedwindows")==0 || parentId == "btn_closedwindows";
+ var onClosedWindowsList = parentId.startsWith("tm-sm-closedwindows") || parentId == "btn_closedwindows";
if (onClosedWindowsList)
menuCommand = "openclosedwindow";
@@ -3268,7 +3268,7 @@ try{
if (needToReload) {
let url = TMP_SessionStore.getActiveEntryData(data).url || "";
- if (url.indexOf("file:") != 0)
+ if (!url.startsWith("file:"))
tab.setAttribute("_tabmix_load_bypass_cache", true);
}
}
diff --git a/chrome/content/session/sessionStore.js b/chrome/content/session/sessionStore.js
index 08f4f21..ee9d2ee 100644
--- a/chrome/content/session/sessionStore.js
+++ b/chrome/content/session/sessionStore.js
@@ -833,7 +833,7 @@ var TabmixConvertSession = {
let PREFIX = "tmp-session-data-";
TSTProps.forEach(function(aProp) {
if (/^([^\s=]+)=(.*)/.test(aProp) &&
- RegExp.$1.indexOf(PREFIX) == 0 && RegExp.$2)
+ RegExp.$1.startsWith(PREFIX) && RegExp.$2)
extData[RegExp.$1.substr(PREFIX.length)] = decodeURIComponent(RegExp.$2);
});
properties = properties.substr(booleanAttrLength + 1).split(" ");
diff --git a/chrome/content/tab/tab.js b/chrome/content/tab/tab.js
index 0afbac9..ed39258 100644
--- a/chrome/content/tab/tab.js
+++ b/chrome/content/tab/tab.js
@@ -1479,7 +1479,7 @@ var gTMPprefObserver = {
bottomToolbox = document.createElement("toolbox");
bottomToolbox.setAttribute("id", "tabmix-bottom-toolbox");
bottomToolbox.collapsed = !gBrowser.tabContainer.visible;
- if (navigator.oscpu.indexOf("Windows NT 6.1") == 0)
+ if (navigator.oscpu.startsWith("Windows NT 6.1"))
bottomToolbox.setAttribute("tabmix_aero", true);
// if we decide to move this box into browser-bottombox
// remember to fix background css rules for all platform
diff --git a/chrome/content/tabmix.js b/chrome/content/tabmix.js
index 8882e73..86df7a5 100644
--- a/chrome/content/tabmix.js
+++ b/chrome/content/tabmix.js
@@ -501,7 +501,7 @@ var TMP_eventListener = {
}
var tabsToolbar = document.getElementById("TabsToolbar");
- if (navigator.oscpu.indexOf("Windows NT 6.1") == 0) {
+ if (navigator.oscpu.startsWith("Windows NT 6.1")) {
Tabmix.setItem(tabsToolbar, "tabmix_aero", true);
}
@@ -519,7 +519,7 @@ var TMP_eventListener = {
Tabmix.setItem(tabsToolbar, "tabmix_skin", "classic");
}
else {
- let version = navigator.oscpu.indexOf("Windows NT 6.1") == 0 ? "v40aero" : "v40";
+ let version = navigator.oscpu.startsWith("Windows NT 6.1") ? "v40aero" : "v40";
tabBar.setAttribute("classic40", version);
Tabmix.setItem(tabsToolbar, "classic40", version);
}
diff --git a/modules/ContentClick.jsm b/modules/ContentClick.jsm
index 4113dbd..cc7c739 100644
--- a/modules/ContentClick.jsm
+++ b/modules/ContentClick.jsm
@@ -659,7 +659,7 @@ let ContentClickInternal = {
isUrlForDownload: function TMP_isUrlForDownload(linkHref) {
//we need this check when calling from onDragOver and onDrop
- if (linkHref.indexOf("mailto:") == 0)
+ if (linkHref.startsWith("mailto:"))
return true;
var filetype = TabmixSvc.prefBranch.getCharPref("filetype");
@@ -947,7 +947,7 @@ let ContentClickInternal = {
*/
checkAttr: function TMP_checkAttr(attr, string) {
if (typeof(attr) == "string")
- return attr.indexOf(string) == 0;
+ return attr.startsWith(string);
return false;
},
diff --git a/modules/Services.jsm b/modules/Services.jsm
index 2f7e741..23e40e1 100644
--- a/modules/Services.jsm
+++ b/modules/Services.jsm
@@ -62,7 +62,7 @@ let TabmixSvc = {
setLabel: function(property) {
var label, key;
- if (property.indexOf("sm.") == 0) {
+ if (property.startsWith("sm.")) {
label = this.getSMString(property + ".label");
key = this.getSMString(property + ".accesskey");
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git
More information about the Pkg-mozext-commits
mailing list