kill Zotero.inArray() and Zotero.arraySearch()

This commit is contained in:
Simon Kornblith 2010-10-24 23:41:32 +00:00
parent 73102eb977
commit f1402708c0
3 changed files with 6 additions and 36 deletions

View File

@ -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]);

View File

@ -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";

View File

@ -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 = {};