Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Canal Ciência
Plugin Omeka WP
Commits
79ca46e0
Commit
79ca46e0
authored
1 year ago
by
Andre Togawa
Browse files
Options
Download
Email Patches
Plain Diff
fix: multiplos videos no listFullFields e audio
parent
073f43ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
49 deletions
+51
-49
js/on_page_load.js
js/on_page_load.js
+51
-49
No files found.
js/on_page_load.js
View file @
79ca46e0
...
...
@@ -210,8 +210,8 @@ if(runFetch){
divItemImage
=
document
.
getElementsByClassName
(
'
getod-empty-image
'
);
getMoreImageData
(
divItemImage
)
divItemAudio
=
document
.
getElementsByClassName
(
'
getod-empty-audio
'
);
//
getMoreAudioData(divItemAudio);
divItemAudio
=
document
.
getElementsByClassName
(
'
getod-empty-audio
'
);
getMoreAudioData
(
divItemAudio
);
divItemVideo
=
document
.
getElementsByClassName
(
'
getod-empty-video
'
);
getMoreVideoData
(
divItemVideo
);
...
...
@@ -1151,64 +1151,66 @@ for (let i = 0; i < divItem.length; ) {
// == Populate images with more information ==//
async
function
getMoreVideoData
(
divItem
)
{
DEBUG
&&
console
.
log
(
"
%c Running: getMoreVideoData
"
,
'
background: #333; color: #bada55
'
)
// recebe uma lista de divItem com classe getod-empty-video
// em seguida adiciona a imagem e os dados
for
(
let
i
=
0
;
i
<
divItem
.
length
;
)
{
var
item
=
divItem
[
i
];
let
itemUrl
=
item
.
getAttribute
(
"
getod_video_url
"
);
let
classToRemove
=
item
.
getAttribute
(
"
remove_css
"
);
if
(
itemUrl
!=
''
&&
itemUrl
!=
null
&&
itemUrl
!=
undefined
&&
itemUrl
!=
'
undefined
'
&&
itemUrl
!=
'
null
'
&&
isValidURL
(
itemUrl
)){
await
fetch
(
itemUrl
)
.
then
(
function
(
response
)
{
let
j
=
0
for
(
let
i
=
0
;
i
<
divItem
.
length
;
j
++
)
{
return
response
.
json
();
})
.
then
(
function
(
jsonData
)
{
// !!!! Corrigir daqui para baixo pois só copiei da imagem e nao ajustei para video
// Em algum lugar adicionar: removeHidden(classToRemove);
mediaType
=
jsonData
[
'
o:media_type
'
];
if
(
mediaType
!=
undefined
){
mediaType
=
mediaType
.
substring
(
0
,
mediaType
.
indexOf
(
"
/
"
));
}
itemUrl
=
getValueForAttribute
(
jsonData
[
'
o:original_url
'
]);
if
(
jsonData
[
'
o:ingester
'
]
==
"
youtube
"
){
let
youtubeID
=
/
[^
=
]
*$/
.
exec
(
jsonData
[
'
o:source
'
])[
0
];
g
=
document
.
createElement
(
'
div
'
);
g
.
setAttribute
(
"
id
"
,
"
youtube
"
+
i
);
item
.
replaceWith
(
g
)
//youtube code
let
obj
=
{
"
video
"
:
{
"
value
"
:
'
<iframe width="700" height="400" src="https://www.youtube.com/embed/
'
+
youtubeID
+
'
" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
'
}}
jQuery
(
"
#youtube
"
+
i
).
html
(
obj
.
video
.
value
);
let
item
=
divItem
[
i
];
let
itemUrl
=
item
.
getAttribute
(
"
getod_video_url
"
);
let
classToRemove
=
item
.
getAttribute
(
"
remove_css
"
);
console
.
log
(
item
)
if
(
itemUrl
!=
''
&&
itemUrl
!=
null
&&
itemUrl
!=
undefined
&&
itemUrl
!=
'
undefined
'
&&
itemUrl
!=
'
null
'
&&
isValidURL
(
itemUrl
)){
await
fetch
(
itemUrl
)
.
then
(
function
(
response
)
{
return
response
.
json
();
})
.
then
(
function
(
jsonData
)
{
mediaType
=
jsonData
[
'
o:media_type
'
];
if
(
mediaType
!=
undefined
){
mediaType
=
mediaType
.
substring
(
0
,
mediaType
.
indexOf
(
"
/
"
));
}
itemUrl
=
getValueForAttribute
(
jsonData
[
'
o:original_url
'
]);
}
if
(
jsonData
[
'
o:ingester
'
]
==
"
youtube
"
){
let
youtubeID
=
/
[^
=
]
*$/
.
exec
(
jsonData
[
'
o:source
'
])[
0
];
g
=
document
.
createElement
(
'
div
'
);
g
.
setAttribute
(
"
id
"
,
"
youtube
"
+
j
);
item
.
replaceWith
(
g
)
//youtube code
let
obj
=
{
"
video
"
:
{
"
value
"
:
'
<iframe width="700" height="400" src="https://www.youtube.com/embed/
'
+
youtubeID
+
'
" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
'
}}
jQuery
(
"
#youtube
"
+
j
).
html
(
obj
.
video
.
value
);
removeHidden
(
classToRemove
);
else
{
// parei aqui
let
source
=
document
.
createElement
(
'
source
'
);
source
.
src
=
itemUrl
;
}
else
{
// parei aqui precisa puxar videos sem ser youtube
let
source
=
document
.
createElement
(
'
source
'
);
source
.
src
=
itemUrl
;
item
.
appendChild
(
source
);
item
.
appendChild
(
source
);
item
.
insertBefore
(
source
,
item
.
firstChild
);
}
item
.
classList
.
remove
(
"
getod-empty-video
"
);
item
.
insertBefore
(
source
,
item
.
firstChild
);
})
.
catch
(
function
(
err
)
{
console
.
log
(
"
Something went wrong!
"
,
err
);
});
}
else
{
DEBUG
&&
console
.
log
(
"
%c getMoreVideoData: No video url found
"
,
'
background: #ccc; color: #080
'
)
if
(
classToRemove
!=
null
){
//if there is css to remove, remove it
removeClasses
(
classToRemove
)
}
item
.
classList
.
remove
(
"
getod-empty-video
"
);
})
.
catch
(
function
(
err
)
{
console
.
log
(
"
Something went wrong!
"
,
err
);
});
}
else
{
DEBUG
&&
console
.
log
(
"
%c getMoreVideoData: No video url found
"
,
'
background: #ccc; color: #080
'
)
if
(
classToRemove
!=
null
){
//if there is css to remove, remove it
removeClasses
(
classToRemove
)
}
item
.
classList
.
remove
(
"
getod-empty-video
"
);
}
}
}
}
// == Populate List Full Fields ==//
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
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