|
@@ -950,7 +950,7 @@ function renderEventAd(data) {
|
|
|
}
|
|
|
|
|
|
// 隨機對調前後順序(e.g. 5678 1234)
|
|
|
-function randomArr(ary, num) {
|
|
|
+function randomArr(ary, num = 4) {
|
|
|
// 取得隨機整數
|
|
|
let randomVal;
|
|
|
(Math.random() > 0.5) ? randomVal = 1 : randomVal = 0;
|
|
@@ -959,11 +959,8 @@ function randomArr(ary, num) {
|
|
|
let list = [];
|
|
|
|
|
|
// index < 拆分的次數
|
|
|
- // 如陣列長度為 8 跟 12,拆分次數即為 2 跟 3
|
|
|
- // 例如:[8] => [4,4] or [12] => [4,4,4]
|
|
|
- for (let index = 0; index < num; index++) {
|
|
|
- list.push(data.splice(4, 4));
|
|
|
- // list.push(test.splice(4, 4));
|
|
|
+ for (let index = 0; index < 1; index++) {
|
|
|
+ list.push(data.splice(num, num));
|
|
|
}
|
|
|
|
|
|
list = list.sort(() => Math.random() - 0.5); // 隨機排序
|
|
@@ -983,7 +980,7 @@ function randomArr(ary, num) {
|
|
|
function renderDesigner(data) {
|
|
|
data.map(list => {
|
|
|
if (list._comment === "推薦設計師") {
|
|
|
- let randomData = randomArr(list.data, 2);
|
|
|
+ let randomData = randomArr(list.data, 6);
|
|
|
let str = "";
|
|
|
|
|
|
for (let i = 0; i < randomData.length; i++) {
|
|
@@ -1067,7 +1064,7 @@ function renderTabContent(data) {
|
|
|
if (list._comment === "tab區塊-最夯設計, 影音實錄, 專欄文章") {
|
|
|
list.data.map(item => {
|
|
|
if (item.tab === "編輯精選") {
|
|
|
- let randomData = randomArr(item.data, 1);
|
|
|
+ let randomData = randomArr(item.data);
|
|
|
let str = "";
|
|
|
let tagList = [];
|
|
|
|
|
@@ -1144,7 +1141,7 @@ function renderTabContent(data) {
|
|
|
randomTag(randomData, tagList, "featured-content"); // 渲染標籤
|
|
|
|
|
|
} else if (item.tab === "最夯設計") {
|
|
|
- let randomData = randomArr(item.data, 1);
|
|
|
+ let randomData = randomArr(item.data);
|
|
|
let str = "";
|
|
|
let tagList = [];
|
|
|
|
|
@@ -1224,7 +1221,7 @@ function renderTabContent(data) {
|
|
|
randomTag(randomData, tagList, "popular-content"); // 渲染標籤
|
|
|
|
|
|
} else if (item.tab === "最新影音實錄") {
|
|
|
- let randomData = randomArr(item.data, 1);
|
|
|
+ let randomData = randomArr(item.data);
|
|
|
let str = "";
|
|
|
|
|
|
for (let i = 0; i < randomData.length; i++) {
|