Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
pdn-certic
MaX
Commits
ebd99d2b
Commit
ebd99d2b
authored
May 06, 2022
by
Anne Goloubkoff-Duponchel
Browse files
corrections quand lacunaEnd seul dans fragment
parent
cdf1d8f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
plugins/apparat_critique/apparat_critique.js
View file @
ebd99d2b
...
...
@@ -16,12 +16,38 @@ class ApparatPlugin extends Plugin{
this
.
wrapLacunas
();
this
.
showWitness
(
"
lem
"
);
this
.
witnessTooltiping
();
this
.
changecolorApp
();
}
changecolorApp
()
{
document
.
querySelectorAll
(
"
.togglerInfobulle
"
).
forEach
(
toggler
=>
{
toggler
.
addEventListener
(
"
focusin
"
,
(
event
)
=>
{
var
aColorer
=
toggler
.
parentNode
.
previousElementSibling
;
aColorer
.
style
.
color
=
'
rgb(194, 35, 2)
'
;
});
toggler
.
addEventListener
(
"
focusout
"
,
(
event
)
=>
{
var
aColorer
=
toggler
.
parentNode
.
previousElementSibling
;
aColorer
.
style
.
color
=
'
inherit
'
;
});
});
}
showWitness
(
witnessClass
)
{
document
.
querySelectorAll
(
"
.apparat
"
).
forEach
((
e
)
=>
e
.
style
.
display
=
'
none
'
);
document
.
querySelectorAll
(
"
.lacuna, .
"
+
witnessClass
).
forEach
((
e
)
=>
e
.
style
.
display
=
'
inline
'
);
document
.
querySelectorAll
(
"
.lacuna
"
+
"
.
"
+
witnessClass
).
forEach
((
e
)
=>
e
.
style
.
display
=
'
none
'
);
//on affiche les appels de note et les notes de bas de page uniquement pour la version par défaut
if
(
witnessClass
!=
'
lem
'
)
{
document
.
querySelectorAll
(
"
.togglerInfobulle
"
).
forEach
((
e
)
=>
e
.
style
.
display
=
'
none
'
);
document
.
querySelectorAll
(
"
#bas_de_page
"
).
forEach
((
e
)
=>
e
.
style
.
display
=
'
none
'
);
document
.
querySelectorAll
(
"
#citation
"
).
forEach
((
e
)
=>
e
.
style
.
display
=
'
none
'
);
}
else
{
document
.
querySelectorAll
(
"
.togglerInfobulle
"
).
forEach
((
e
)
=>
e
.
style
.
display
=
'
inline
'
);
document
.
querySelectorAll
(
"
#bas_de_page
"
).
forEach
((
e
)
=>
e
.
style
.
display
=
'
inline-block
'
);
document
.
querySelectorAll
(
"
#citation
"
).
forEach
((
e
)
=>
e
.
style
.
display
=
'
inline-block
'
);
}
}
witnessTooltiping
()
{
...
...
@@ -32,16 +58,15 @@ class ApparatPlugin extends Plugin{
}
wrapLacunas
()
{
if
(
document
.
querySelectorAll
(
"
#text .lacunaStart
"
).
length
>
0
)
{
document
.
querySelectorAll
(
'
.lacunaStart
'
).
forEach
((
lstart
)
=>
{
const
wit
=
lstart
.
getAttribute
(
'
data-lacuna-wit
'
).
replace
(
'
#
'
,
''
);
console
.
log
(
'
wit->
'
,
wit
);
if
(
document
.
querySelectorAll
(
"
#text .lacunaStart
"
).
length
>
0
)
{
document
.
querySelectorAll
(
'
.lacunaStart
'
).
forEach
((
lstart
)
=>
{
const
wit
=
lstart
.
getAttribute
(
'
data-lacuna-wit
'
).
replace
(
'
#
'
,
''
);
console
.
log
(
'
wit->
'
,
wit
);
let
searchedId
=
lstart
.
getAttribute
(
'
data-lacuna-synch
'
);
console
.
log
(
"
searchedid
"
,
searchedId
);
// let endElement = document.getElementById(searchedId);
// console.log('traitement de la lacuna ' + lstart.getAttribute('id'));
// endElement = endElement.length === 0 ? document.getElementById('bas_de_page') : endElement
let
endElement
=
document
.
querySelector
(
"
#
"
+
searchedId
);
//let endElement = document.getElementById(searchedId);
console
.
log
(
'
traitement de la lacuna
'
+
lstart
.
getAttribute
(
'
id
'
));
let
endElement
=
document
.
querySelector
(
"
#
"
+
searchedId
);
endElement
=
endElement
===
null
?
document
.
querySelector
(
'
#bas_de_page
'
)
:
endElement
let
eltsBetween
=
this
.
getElementsBetweenTree
(
lstart
,
endElement
);
//$(self.getElementsBetweenTree(($(this))[0], endElement[0]))
console
.
log
(
"
Nombre d'éléments à masquer (lacune
"
+
lstart
.
getAttribute
(
'
id
'
)
+
"
)
"
+
eltsBetween
.
length
);
...
...
@@ -53,14 +78,15 @@ class ApparatPlugin extends Plugin{
span
.
append
(
elt
.
cloneNode
(
true
));
elt
.
replaceWith
(
span
);
})
})
}
})
}
else
{
document
.
querySelectorAll
(
'
.lacunaEnd
'
).
forEach
((
lend
)
=>
{
let
lstart
=
document
.
querySelector
(
'
#text
'
)
let
lstart
=
document
.
querySelector
(
'
#text
> *:first-child > *:first-child
'
)
let
endElement
=
lend
let
eltsBetween
=
this
.
getElementsBetweenTree
(
lstart
,
endElement
);
eltsBetween
.
forEach
((
elt
)
=>
{
const
wit
=
"
B
"
;
let
span
=
document
.
createElement
(
"
span
"
);
span
.
classList
.
add
(
'
generated_lacuna
'
);
span
.
classList
.
add
(
'
lacuna
'
);
...
...
@@ -70,17 +96,19 @@ class ApparatPlugin extends Plugin{
})
})
}
/*Cas où un couple lacunaStart/lacunaEnd se trouve respectivement dans
des fragments qui précédent et suivent le fragment courant:
nécessite une requête sur la DB pour accedéer aux autres noeuds XML*/
}
getElementsBetweenTree
(
start
,
end
)
{
let
ancestor
=
this
.
commonAncestor
(
start
,
end
);
console
.
log
(
ancestor
)
console
.
log
(
start
)
let
before
=
[];
while
(
start
.
parentNode
!==
ancestor
)
{
var
el
=
start
;
while
(
el
.
nextSibling
)
...
...
@@ -114,11 +142,11 @@ class ApparatPlugin extends Plugin{
commonAncestor
(
node1
,
node2
)
{
let
parents1
=
this
.
ancestors
(
node1
)
let
parents2
=
this
.
ancestors
(
node2
)
if
(
parents1
[
0
]
!==
parents2
[
0
])
throw
"
No common ancestor!
"
for
(
var
i
=
0
;
i
<
parents1
.
length
;
i
++
)
{
if
(
parents1
[
i
]
!==
parents2
[
i
])
return
parents1
[
i
-
1
]
let
lparents1
=
parents1
.
length
>
parents2
.
lenght
?
parents2
:
parents1
let
lparents2
=
parents2
.
length
>
parents1
.
lenght
?
parents1
:
parents2
for
(
var
i
=
0
;
i
<
lparents1
.
length
;
i
++
)
{
if
(
lparents1
[
i
]
!==
lparents2
[
i
])
return
lparents1
[
i
-
1
]
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment