From e5ba6997ea83500e0c9a1371eec8a27839c725d3 Mon Sep 17 00:00:00 2001 From: src48597962 <48597962@qq.com> Date: Thu, 5 Sep 2024 08:27:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'SrcJuying.js'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SrcJuying.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/SrcJuying.js b/SrcJuying.js index 4e092656..ccabb0f6 100644 --- a/SrcJuying.js +++ b/SrcJuying.js @@ -398,7 +398,35 @@ function dianboerji() { //生成选集 let 列表 = erdata.lists.length>lineid?erdata.lists[lineid].filter(v=>v):[]; if(列表.length>0){ + function checkAndReverseArray(arr) { + const numbers = []; + arr.slice(0, 50).forEach(it=>{ + const digits = it.split('$')[0].match(/\d+/); + if (digits) { + numbers.push(parseInt(digits[0])); + } + }) + + if (numbers.length < 3) { + return arr; + } + let increasingCount = 0; + let decreasingCount = 0; + for (let i = 1; i < numbers.length; i++) { + if (numbers[i] > numbers[i - 1]) { + increasingCount++; + } else if (numbers[i] < numbers[i - 1]) { + decreasingCount++; + } + } + if (increasingCount > decreasingCount) { + return arr; + } else { + return arr.reverse(); + } + } try{ + /* let i1 = parseInt(列表.length / 6); let i2 = parseInt(列表.length / 4); let i3 = parseInt(列表.length / 2); @@ -408,6 +436,8 @@ function dianboerji() { if(parseInt(list1.match(/(\d+)/)[0])>parseInt(list2.match(/(\d+)/)[0]) && parseInt(list2.match(/(\d+)/)[0])>parseInt(list3.match(/(\d+)/)[0])){ 列表.reverse(); } + */ + 列表 = checkAndReverseArray(列表); }catch(e){ //xlog('强制修正选集顺序失败>'+e.message) }