kill Zotero.inArray() and Zotero.arraySearch()
This commit is contained in:
parent
73102eb977
commit
f1402708c0
3 changed files with 6 additions and 36 deletions
|
@ -332,7 +332,7 @@ Zotero.History = new function(){
|
||||||
var cols = Zotero.DB.getColumns(table);
|
var cols = Zotero.DB.getColumns(table);
|
||||||
for (var i in cols){
|
for (var i in cols){
|
||||||
// If column is not part of the key, log it
|
// 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 "
|
var sql = "INSERT INTO transactionLog "
|
||||||
+ "SELECT " + transactionID + ", '" + cols[i]
|
+ "SELECT " + transactionID + ", '" + cols[i]
|
||||||
+ "', " + cols[i] + fromClause;
|
+ "', " + cols[i] + fromClause;
|
||||||
|
@ -390,7 +390,7 @@ Zotero.History = new function(){
|
||||||
var cols = Zotero.DB.getColumns(context['table']);
|
var cols = Zotero.DB.getColumns(context['table']);
|
||||||
for (var i in cols){
|
for (var i in cols){
|
||||||
// If column is not part of the key, log it
|
// 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 "
|
var sql = "INSERT INTO transactionLog "
|
||||||
+ "SELECT " + transactionID + ", '" + cols[i]
|
+ "SELECT " + transactionID + ", '" + cols[i]
|
||||||
+ "', " + cols[i] + fromClause;
|
+ "', " + cols[i] + fromClause;
|
||||||
|
@ -425,7 +425,7 @@ Zotero.History = new function(){
|
||||||
|
|
||||||
// Update log with new values for later redo
|
// Update log with new values for later redo
|
||||||
for (var i in newValues){
|
for (var i in newValues){
|
||||||
if (!Zotero.inArray(i, context['keys'])){
|
if (context['keys'].indexOf(i) === -1){
|
||||||
var sql = "UPDATE transactionLog SET "
|
var sql = "UPDATE transactionLog SET "
|
||||||
+ "value=? WHERE transactionID=? AND field=?";
|
+ "value=? WHERE transactionID=? AND field=?";
|
||||||
Zotero.DB.query(sql, [i, newValues[i], transactionID]);
|
Zotero.DB.query(sql, [i, newValues[i], transactionID]);
|
||||||
|
|
|
@ -271,11 +271,11 @@ Zotero.OpenURL = new function() {
|
||||||
item.itemType = "journalArticle";
|
item.itemType = "journalArticle";
|
||||||
break;
|
break;
|
||||||
} else if(format == "info:ofi/fmt:kev:mtx:book") {
|
} 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";
|
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";
|
item.itemType = "conferencePaper";
|
||||||
} else if(Zotero.inArray("rft.genre=report", coParts)) {
|
} else if(coParts.indexOf("rft.genre=report") !== -1) {
|
||||||
item.itemType = "report";
|
item.itemType = "report";
|
||||||
} else {
|
} else {
|
||||||
item.itemType = "book";
|
item.itemType = "book";
|
||||||
|
|
|
@ -67,8 +67,6 @@ var Zotero = new function(){
|
||||||
this.flattenArguments = flattenArguments;
|
this.flattenArguments = flattenArguments;
|
||||||
this.getAncestorByTagName = getAncestorByTagName;
|
this.getAncestorByTagName = getAncestorByTagName;
|
||||||
this.join = join;
|
this.join = join;
|
||||||
this.inArray = inArray;
|
|
||||||
this.arraySearch = arraySearch;
|
|
||||||
this.arrayToHash = arrayToHash;
|
this.arrayToHash = arrayToHash;
|
||||||
this.hasValues = hasValues;
|
this.hasValues = hasValues;
|
||||||
this.randomString = randomString;
|
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){
|
function arrayToHash(array){
|
||||||
var hash = {};
|
var hash = {};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue