更新 'SrcJuPublic.js'

Ju
src48597962 1 year ago
parent f366977511
commit bc114d0039
  1. 23
      SrcJuPublic.js

@ -105,7 +105,8 @@ function selectSource(selectType) {
return "toast://当前分类无接口"
}
if(getItem('sourceListSort','update') == 'name'){
sourcenames.sort(SortList);
//sourcenames.sort(SortList);
sourcenames = sortByPinyin(sourcenames);
}
//return $(sourcenames,3,"选择 "+selectType+" 主页源").select((runMode,sourcename,cfgfile,Juconfig) => {
hikerPop.selectCenterIcon({iconList: sourcenames, title: selectType + ">主页源>" + sourcename, columns: 2, click(input) {
@ -473,3 +474,23 @@ function SortList(a, b) {
return aFirstChar.localeCompare(bFirstChar);
}
function sortByPinyin(arr) {
var arrNew = arr.sort((a, b) => a.title.localeCompare(b.title));
for (var m in arrNew) {
var mm = /^[\u4e00-\u9fa5]/.test(arrNew[m].title) ? m : '-1';
if (mm > -1) {
break;
}
}
for (var n = arrNew.length - 1; n >= 0; n--) {
var nn = /^[\u4e00-\u9fa5]/.test(arrNew[n].title) ? n : '-1';
if (nn > -1) {
break;
}
}
if (mm > -1) {
var arrTmp = arrNew.splice(m, parseInt(n - m) + 1);
arrNew = arrNew.concat(arrTmp);
}
return arrNew
}
Loading…
Cancel
Save