Skip to content

Commit 0a7bfd9

Browse files
committed
u
1 parent 939008f commit 0a7bfd9

File tree

6 files changed

+58
-510
lines changed

6 files changed

+58
-510
lines changed

books/barbahariDFK.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

js/barbahariDFK-script.js

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,48 @@ $(document).ready(() => {
5858
});
5959
} //= =================== end if else
6060

61+
// cgpt code
62+
63+
/*
64+
i have a 2d json nested array, one of them is an object called
65+
const barbahari_DB=[[...
66+
it has 9 columns
67+
68+
the other is an object called
69+
const barbahariDFK_DB=[[
70+
it has 2 columns
71+
72+
using js, i want to take the 1st, 5th and 7th column of barbahari_DB, and join them rowwise with barbahariDFK_DB, and flatten them. generating empty values where needed for 5th column. result should also be 2d json
73+
74+
*/
75+
76+
// Ensure both arrays have the same number of rows
77+
const numRows = Math.max(barbahari_DB.length, barbahariDFK_DB.length);
78+
const result = [];
79+
80+
for (let i = 0; i < numRows; i++) {
81+
const row1 = barbahari_DB[i] || [];
82+
const row2 = barbahariDFK_DB[i] || [];
83+
84+
const col1 = row1[0] || "";
85+
const col5 = row1[4] || "";
86+
const col7 = row1[6] || "";
87+
88+
const combinedRow = [col1, col5, col7, ...row2];
89+
result.push(combinedRow);
90+
}
91+
92+
console.log(result);
93+
94+
// end
95+
6196
const table = $("#barbahariDFKTable").DataTable({
6297
// var table = $("#fortyNawawi").DataTable({
6398
// NOT DataTable();
6499

65100
// CHANGE123 JSON
66-
data: barbahariDFK_DB, // https://datatables.net/manual/ajax
101+
//data: barbahariDFK_DB, // https://datatables.net/manual/ajax
102+
data: result,
67103

68104
columns: [
69105
/* add # string to hadith no */
@@ -161,7 +197,7 @@ $(document).ready(() => {
161197
{
162198
className: "ColTakhrij", // ar footnote
163199
targets: [3],
164-
visible: true,
200+
visible: false,
165201
searchable: false,
166202
searchPanes: {
167203
show: false,

js/barbahariDFK-script.min.js

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/json/barbahariDFK.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)