@@ -213,7 +213,7 @@ Zotero.Jasminum = new function () {
213
213
// 没有查询结果
214
214
this . Utils . showPopup (
215
215
"No results found!" ,
216
- `作者:${ fileData . author } \n篇名 :${ fileData . keyword } \n请检查设置中的文件名模板是否与实际实际情况相符 ` ,
216
+ `作者:${ fileData . author } ,\n 篇名 :${ fileData . keyword } ,\n 请检查设置中的文件名模板是否与实际实际情况相符 ` ,
217
217
true )
218
218
}
219
219
}
@@ -279,39 +279,23 @@ Zotero.Jasminum = new function () {
279
279
var creators = item . getCreators ( ) ;
280
280
for ( var i = 0 ; i < creators . length ; i ++ ) {
281
281
var creator = creators [ i ] ;
282
- if (
283
- // English Name pass
284
- creator . lastName . search ( / [ A - Z a - z ] / ) !== - 1 ||
285
- creator . firstName . search ( / [ A - Z a - z ] / ) !== - 1 ||
286
- creator . firstName // 如果有名就不拆分了
282
+ if ( // English Name
283
+ ( creator . lastName . search ( / [ A - Z a - z ] / ) >= 0 ||
284
+ creator . firstName . search ( / [ A - Z a - z ] / ) >= 0 ) &&
285
+ creator . firstName === "" // 名为空
287
286
) {
288
287
var EnglishName = creator . lastName ;
289
- var temp = EnglishName . split ( / [ \n \s + , ] / g) ;
290
- for ( var k = 0 ; k < temp . length ; k ++ ) {
291
- if ( temp [ k ] == "" ) {
292
- // 删除数组中空值
293
- temp . splice ( k , 1 ) ;
294
- k -- ;
295
- }
296
- }
297
- if ( temp . length < 3 ) {
298
- creator . lastName = temp [ 0 ] ;
299
- creator . firstName = temp [ 1 ] ;
300
- } else {
301
- creator . lastName = temp [ 0 ] ;
302
- creator . firstName = temp [ 1 ] . concat ( " " , temp [ 2 ] ) ;
303
- }
304
- creator . fieldMode = 0 ; // 0: two-field, 1: one-field (with empty first name)
305
- creators [ i ] = creator ;
306
- } else { // For Chinese Name
307
- var chineseName = creator . lastName
308
- ? creator . lastName
309
- : creator . firstName ;
288
+ var temp = EnglishName . split ( / [ \n \s + , ] / g)
289
+ . filter ( Boolean ) ; // 过滤空字段
290
+ creator . lastName = temp . pop ( ) ;
291
+ creator . firstName = temp . join ( " " ) ;
292
+ } else if ( creator . firstName === "" ) { // For Chinese Name,名为空
293
+ var chineseName = creator . lastName || creator . firstName ;
310
294
creator . lastName = chineseName . charAt ( 0 ) ;
311
295
creator . firstName = chineseName . substr ( 1 ) ;
312
- creator . fieldMode = 0 ;
313
- creators [ i ] = creator ;
314
296
}
297
+ creator . fieldMode = 0 ; // 0: two-field, 1: one-field (with empty first name)
298
+ creators [ i ] = creator ;
315
299
}
316
300
if ( creators != item . getCreators ( ) ) {
317
301
item . setCreators ( creators ) ;
@@ -325,21 +309,17 @@ Zotero.Jasminum = new function () {
325
309
var creators = item . getCreators ( ) ;
326
310
for ( var i = 0 ; i < creators . length ; i ++ ) {
327
311
var creator = creators [ i ] ;
328
- if (
329
- // English Name pass
312
+ if ( // English Name
330
313
creator . lastName . search ( / [ A - Z a - z ] / ) !== - 1 ||
331
314
creator . lastName . search ( / [ A - Z a - z ] / ) !== - 1
332
315
) {
333
- creator . lastName = creator . lastName + " " + creator . firstName ;
334
- creator . firstName = "" ;
335
- creator . fieldMode = 1 ; // 0: two-field, 1: one-field (with empty first name)
336
- creators [ i ] = creator ;
316
+ creator . lastName = creator . firstName + " " + creator . lastName ;
337
317
} else { // For Chinese Name
338
318
creator . lastName = creator . lastName + creator . firstName ;
339
- creator . firstName = "" ;
340
- creator . fieldMode = 1 ;
341
- creators [ i ] = creator ;
342
319
}
320
+ creator . firstName = "" ;
321
+ creator . fieldMode = 1 ; // 0: two-field, 1: one-field (with empty first name)
322
+ creators [ i ] = creator ;
343
323
}
344
324
if ( creators != item . getCreators ( ) ) {
345
325
item . setCreators ( creators ) ;
0 commit comments