ProjectJaraid / jaraid_source

Master and authority files of Project Jarāʾid
Other
1 stars 1 forks source link

Was there a change in <date> ? #103

Closed Mestyan closed 4 years ago

Mestyan commented 4 years ago

Dear @tillgrallert is the Oxygen project format different slightly from the previous one somehow in the date element? The present JavaScript to chronologically arrange the table in the website breaks because I think it finds null in the notAfter attribute in the date element. The part of making a date is

function makeDate(row) {
  let x = row.querySelector("td:first-of-type tei-date");
    // // rows without date should not be considered
    // if (!x) {return -1};
    //if there is notAfter its value should be considered as date and if not take "when"
    if (x.hasAttribute("notAfter")) {
        x = new Date(x.getAttribute("notAfter"));
    } else {
      x = new Date(x.getAttribute("when"));
    }
    return x;
  }

This worked until last week I think. Can you have a look please? I also try to nag @hcayless tomorrow !

tillgrallert commented 4 years ago

Dear Adam,

If the problem is the value of a @notAfter attribute in the master file, this is unrelated to either the oXygen project file or any XSLT transformation. Instead, the error must have been introduced to master file by some manual edits.

On 2. Dec 2020, at 03:41, Mestyan notifications@github.com wrote:

 Dear @tillgrallert is the Oxygen project format different slightly from the previous one somehow in the date element? The present JavaScript to chronologically arrange the table in the website breaks because I think it finds null in the notAfter attribute in the date element. The part of making a date is function makeDate(row) {

let x = row.querySelector("td:first-of-type tei-date"); // // rows without date should not be considered // if (!x) {return -1}; //if there is notAfter its value should be considered as date and if not take "when" if (x.hasAttribute("notAfter")) { x = new Date(x.getAttribute("notAfter")); } else { x = new Date(x.getAttribute("when")); } return x; } This worked until last week I think. Can you have a look please? I also try to nag @hcayless tomorrow !

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

Mestyan commented 4 years ago

Hm, i tried to look up the version history and I do not see any change in notAfter attributes recently. I did not touch them, but I investigate, thanks.

Adam

On Dec 2, 2020, at 02:08, Till Grallert notifications@github.com wrote:

 Dear Adam,

If the problem is the value of a @notAfter attribute in the master file, this is unrelated to either the oXygen project file or any XSLT transformation. Instead, the error must have been introduced to master file by some manual edits.

On 2. Dec 2020, at 03:41, Mestyan notifications@github.com wrote:

 Dear @tillgrallert is the Oxygen project format different slightly from the previous one somehow in the date element? The present JavaScript to chronologically arrange the table in the website breaks because I think it finds null in the notAfter attribute in the date element. The part of making a date is function makeDate(row) {

let x = row.querySelector("td:first-of-type tei-date"); // // rows without date should not be considered // if (!x) {return -1}; //if there is notAfter its value should be considered as date and if not take "when" if (x.hasAttribute("notAfter")) { x = new Date(x.getAttribute("notAfter")); } else { x = new Date(x.getAttribute("when")); } return x; } This worked until last week I think. Can you have a look please? I also try to nag @hcayless tomorrow !

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

tillgrallert commented 4 years ago

Dear Adam, I have had a brief look at the @notAfter attribute and cannot find a problem. Therefore and on the basis of your JS, I would assume that you have a <date> element without either @notAfter or @when.

tillgrallert commented 4 years ago

I investigated further and I could not find a <date> node without either @notAfter or @when in the main table. I also checked the content of @when and did not find any errors.

Mestyan commented 4 years ago

I eliminated now table2 where there are a number of dates without @when, I commit now, let’s see

On Dec 2, 2020, at 7:12 AM, Till Grallert notifications@github.com wrote:

Dear Adam, I have had a brief look at the @notAfter attribute and cannot find a problem. Therefore and on the basis of your JS, I would assume that you have a element without either @notAfter or @when.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ProjectJaraid/jaraid_source/issues/103#issuecomment-737191944, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFTHW4RTWIAB2NYKO4ZUBVLSSYVLLANCNFSM4UJ3QZZA.

Mestyan commented 4 years ago

it is still not working. I do not understand what is the source of the problem. There was no change in the last five days in date elements... so why is this? ncaught (in promise) TypeError: Cannot read property 'hasAttribute' of null at makeDate (sortTableChronologically.js:44) at sortTableChronologically.js:17 at Array.sort () at sortTableChronologically (sortTableChronologically.js:14) at fihris.html:19 at CETEI.domToHTML5 (CETEI.js:628) at CETEI.makeHTML5 (CETEI.js:528) at CETEI.js:517

Mestyan commented 4 years ago

did something change in CETEICean? @hcayless

tillgrallert commented 4 years ago

According to the debugger in the browser the problem is thus:

Screenshot 2020-12-02 at 13 32 04

Somehow the function returns null for x

Mestyan commented 4 years ago

yes, this is what I see - it means that x in the makeDate produces null , right?

Mestyan commented 4 years ago

Again it is only possible if notAfter is null or date is null but I do not see any such elements being null

makeDate(row) { let x = row.querySelector("td:first-of-type tei-date"); // // rows without date should not be considered // if (!x) {return -1}; //if there is notAfter its value should be considered as date and if not take "when" if (x.hasAttribute("notAfter")) { x = new Date(x.getAttribute("notAfter")); } else { x = new Date(x.getAttribute("when")); } return x; }

Mestyan commented 4 years ago

I am getting crazy with this - how can I find out what is the problem? Is there a way we can see where the function breaks exactly?

tillgrallert commented 4 years ago

Dear Adam. I would add a fallback option to your Javascript that can deal with a "faulty" <date> element. This would mean to use else if:

function makeDate(row) {
  let x = row.querySelector("td:first-of-type tei-date");
    // // rows without date should not be considered
    // if (!x) {return -1};
    //if there is notAfter its value should be considered as date and if not take "when"
    if (x.hasAttribute("notAfter")) {
        x = new Date(x.getAttribute("notAfter"));
    } else if (x.hasAttribute("when")) {
        x = new Date(x.getAttribute("when"));
    } else {
    // some fallback option
    }
    return x;
  }
Mestyan commented 4 years ago

Thank you ! I can do that but it is still a mystery as I do not see any “faulty" element. Anyway I try soon

On Dec 2, 2020, at 10:14 AM, Till Grallert notifications@github.com wrote:

Dear Adam. I would add a fallback option to your Javascript that can deal with a "faulty" element. This would mean to use else if:

function makeDate(row) { let x = row.querySelector("td:first-of-type tei-date"); // // rows without date should not be considered // if (!x) {return -1}; //if there is notAfter its value should be considered as date and if not take "when" if (x.hasAttribute("notAfter")) { x = new Date(x.getAttribute("notAfter")); } else if { x = new Date(x.getAttribute("when")); } else { // some fallback option } return x; } — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ProjectJaraid/jaraid_source/issues/103#issuecomment-737293447, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFTHW4UH5CL6QIYEJF2T75TSSZKV3ANCNFSM4UJ3QZZA.

Mestyan commented 4 years ago

@hcayless helped me to track down : there was an empty row! I deleted that and voila, all is fine !! (I will still ad a fallback option to the function, though)