commit f1402708c0cb91b25d535b9acd9a11a5e1d4068a
parent 73102eb977f63ac075ff92e039ef1ae88c0a5c2d
Author: Simon Kornblith <simon@simonster.com>
Date: Sun, 24 Oct 2010 23:41:32 +0000
kill Zotero.inArray() and Zotero.arraySearch()
Diffstat:
3 files changed, 6 insertions(+), 36 deletions(-)
diff --git a/chrome/content/zotero/xpcom/history.js b/chrome/content/zotero/xpcom/history.js
@@ -332,7 +332,7 @@ Zotero.History = new function(){
var cols = Zotero.DB.getColumns(table);
for (var i in cols){
// If column is not part of the key, log it
- if (!Zotero.inArray(cols[i], context['keys'])){
+ if (!context['keys'].indexOf(cols[i]) === -1){
var sql = "INSERT INTO transactionLog "
+ "SELECT " + transactionID + ", '" + cols[i]
+ "', " + cols[i] + fromClause;
@@ -390,7 +390,7 @@ Zotero.History = new function(){
var cols = Zotero.DB.getColumns(context['table']);
for (var i in cols){
// If column is not part of the key, log it
- if (!Zotero.inArray(cols[i], context['keys'])){
+ if (!context['keys'].indexOf(cols[i]) === -1){
var sql = "INSERT INTO transactionLog "
+ "SELECT " + transactionID + ", '" + cols[i]
+ "', " + cols[i] + fromClause;
@@ -425,7 +425,7 @@ Zotero.History = new function(){
// Update log with new values for later redo
for (var i in newValues){
- if (!Zotero.inArray(i, context['keys'])){
+ if (context['keys'].indexOf(i) === -1){
var sql = "UPDATE transactionLog SET "
+ "value=? WHERE transactionID=? AND field=?";
Zotero.DB.query(sql, [i, newValues[i], transactionID]);
diff --git a/chrome/content/zotero/xpcom/ingester.js b/chrome/content/zotero/xpcom/ingester.js
@@ -271,11 +271,11 @@ Zotero.OpenURL = new function() {
item.itemType = "journalArticle";
break;
} else if(format == "info:ofi/fmt:kev:mtx:book") {
- if(Zotero.inArray("rft.genre=bookitem", coParts)) {
+ if(coParts.indexOf("rft.genre=bookitem") !== -1) {
item.itemType = "bookSection";
- } else if(Zotero.inArray("rft.genre=conference", coParts) || Zotero.inArray("rft.genre=proceeding", coParts)) {
+ } else if(coParts.indexOf("rft.genre=conference") !== -1 || coParts.indexOf("rft.genre=proceeding") !== -1) {
item.itemType = "conferencePaper";
- } else if(Zotero.inArray("rft.genre=report", coParts)) {
+ } else if(coParts.indexOf("rft.genre=report") !== -1) {
item.itemType = "report";
} else {
item.itemType = "book";
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -67,8 +67,6 @@ var Zotero = new function(){
this.flattenArguments = flattenArguments;
this.getAncestorByTagName = getAncestorByTagName;
this.join = join;
- this.inArray = inArray;
- this.arraySearch = arraySearch;
this.arrayToHash = arrayToHash;
this.hasValues = hasValues;
this.randomString = randomString;
@@ -1180,34 +1178,6 @@ var Zotero = new function(){
}
- /*
- * PHP's in_array() for JS -- returns true if a value is contained in
- * an array, false otherwise
- */
- function inArray(needle, haystack){
- for (var i in haystack){
- if (haystack[i]==needle){
- return true;
- }
- }
- return false;
- }
-
-
- /*
- * PHP's array_search() for JS -- searches an array for a value and
- * returns the key if found, false otherwise
- */
- function arraySearch(needle, haystack){
- for (var i in haystack){
- if (haystack[i]==needle){
- return i;
- }
- }
- return false;
- }
-
-
function arrayToHash(array){
var hash = {};