Ticket #1859: coins-ordering.patch
| File coins-ordering.patch, 2.1 KB (added by ajlyon, 5 years ago) |
|---|
-
chrome/content/zotero/xpcom/openurl.js
358 358 if(complexAu.length && !lastCreator.lastName && !lastCreator.institutional) { 359 359 lastCreator.lastName = value; 360 360 } else { 361 complexAu.push({lastName:value, creatorType:(key == "rft.aulast" ? "author" : "inventor") });361 complexAu.push({lastName:value, creatorType:(key == "rft.aulast" ? "author" : "inventor"), offset:item.creators.length}); 362 362 } 363 363 } else if(key == "rft.aufirst" || key == "rft.invfirst") { 364 364 var lastCreator = complexAu[complexAu.length-1]; 365 365 if(complexAu.length && !lastCreator.firstName && !lastCreator.institutional) { 366 366 lastCreator.firstName = value; 367 367 } else { 368 complexAu.push({firstName:value, creatorType:(key == "rft.aufirst" ? "author" : "inventor") });368 complexAu.push({firstName:value, creatorType:(key == "rft.aufirst" ? "author" : "inventor"), offset:item.creators.length}); 369 369 } 370 370 } else if(key == "rft.au" || key == "rft.creator" || key == "rft.contributor" || key == "rft.inventor") { 371 371 if(key == "rft.contributor") { … … 439 439 } 440 440 } 441 441 } 442 443 // To maintain author ordering when complex and simple authors are combined, 444 // we remember where they were and the correct offsets 445 var inserted = 0; 442 446 443 447 // combine two lists of authors, eliminating duplicates 444 448 for(var i=0; i<complexAu.length; i++) { 445 449 var pushMe = true; 450 var offset = complexAu[i].offset; 451 delete complexAu[i].offset; 446 452 for(var j=0; j<item.creators.length; j++) { 447 453 // if there's a plain author that is close to this author (the 448 454 // same last name, and the same first name up to a point), keep … … 455 461 break; 456 462 } 457 463 } 458 if(pushMe) item.creators.push(complexAu[i]); 464 // Splice in the complex creator at the correct location, 465 // accounting for previous insertions 466 if(pushMe) { 467 item.creators = item.creators.splice(offset + inserted, 0, complexAu[i]); 468 inserted++; 469 } 459 470 } 460 471 461 472 return item;