MediaWiki:Common.js: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| (17 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
/* For Main Page Announcement area //this code pulls from the https://ilc.upd.edu.ph/all-posts-and-announcements/ PAGE */ | |||
console.log("JS WORKING"); | |||
(function () { | |||
console.log("RUNNING IMMEDIATELY"); | |||
const container = | |||
document.getElementById("ilc-announcements"); | |||
console.log("Container:", container); | |||
if (!container) return; | |||
container.innerHTML = "Loading script..."; | |||
fetch("https://ilc.upd.edu.ph/wp-json/wp/v2/posts?per_page=5") | |||
.then(res => res.json()) | |||
.then(posts => { | |||
let html = ""; | |||
posts.forEach(post => { | |||
html += ` | |||
<p> | |||
<a href="${post.link}" target="_blank"> | |||
${post.title.rendered} | |||
</a> | |||
</p> | |||
`; | |||
}); | |||
container.innerHTML = html; | |||
}) | |||
.catch(err => { | |||
console.error("FETCH ERROR:", err); | |||
container.innerHTML = "<p>Failed to load announcements</p>"; | |||
}); | |||
})(); | |||
/*end of new code */ | |||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
$(window).on('load', function(){ | $(window).on('load', function(){ | ||
$('#site-tools ul').append("<li><a href='https://iskwiki.upd.edu.ph' target='_blank'>Flipbook</li>"); | $('#site-tools ul').append("<li><a href='https://iskwiki.upd.edu.ph' target='_blank'>Flipbook</li>"); | ||
}); | |||
/*Helpdesk bubble*/ | |||
/* | |||
$(function () { | |||
var bubble = $('<div id="ost-bubble">💬</div>'); | |||
var panel = $('<div id="ost-panel"><iframe src="https://helpdesk.ilc.upd.edu.ph/o.php"></iframe></div>'); | |||
$('body').append(bubble).append(panel); | |||
bubble.on('click', function () { | |||
panel.toggle(); | |||
}); | |||
}); | |||
*/ | |||
/* Helpdesk bubble */ | |||
$(function () { | |||
var bubble = $('<div id="ost-bubble">💬</div>'); | |||
var panel = $( | |||
'<div id="ost-panel">' + | |||
'<div id="ost-panel-header">' + | |||
'<img src="https://helpdesk.ilc.upd.edu.ph/logo.php" alt="Helpdesk" style="height:80px;"> ' + | |||
'<span id="ost-panel-close">×</span>' + | |||
'</div>' + | |||
'<div id="ost-panel-body">' + | |||
'<iframe src="https://helpdesk.ilc.upd.edu.ph/o.php"></iframe>' + | |||
'</div>' + | |||
'<div id="ost-panel-footer">' + | |||
'' + | |||
'</div>' + | |||
'</div>' | |||
); | |||
$('body').append(bubble).append(panel); | |||
bubble.on('click', function () { | |||
panel.toggleClass('ost-open'); | |||
}); | |||
panel.find('#ost-panel-close').on('click', function () { | |||
panel.removeClass('ost-open'); | |||
}); | |||
}); | }); | ||
Latest revision as of 03:39, 17 June 2026
/* For Main Page Announcement area //this code pulls from the https://ilc.upd.edu.ph/all-posts-and-announcements/ PAGE */
console.log("JS WORKING");
(function () {
console.log("RUNNING IMMEDIATELY");
const container =
document.getElementById("ilc-announcements");
console.log("Container:", container);
if (!container) return;
container.innerHTML = "Loading script...";
fetch("https://ilc.upd.edu.ph/wp-json/wp/v2/posts?per_page=5")
.then(res => res.json())
.then(posts => {
let html = "";
posts.forEach(post => {
html += `
<p>
<a href="${post.link}" target="_blank">
${post.title.rendered}
</a>
</p>
`;
});
container.innerHTML = html;
})
.catch(err => {
console.error("FETCH ERROR:", err);
container.innerHTML = "<p>Failed to load announcements</p>";
});
})();
/*end of new code */
/* Any JavaScript here will be loaded for all users on every page load. */
$(window).on('load', function(){
$('#site-tools ul').append("<li><a href='https://iskwiki.upd.edu.ph' target='_blank'>Flipbook</li>");
});
/*Helpdesk bubble*/
/*
$(function () {
var bubble = $('<div id="ost-bubble">💬</div>');
var panel = $('<div id="ost-panel"><iframe src="https://helpdesk.ilc.upd.edu.ph/o.php"></iframe></div>');
$('body').append(bubble).append(panel);
bubble.on('click', function () {
panel.toggle();
});
});
*/
/* Helpdesk bubble */
$(function () {
var bubble = $('<div id="ost-bubble">💬</div>');
var panel = $(
'<div id="ost-panel">' +
'<div id="ost-panel-header">' +
'<img src="https://helpdesk.ilc.upd.edu.ph/logo.php" alt="Helpdesk" style="height:80px;"> ' +
'<span id="ost-panel-close">×</span>' +
'</div>' +
'<div id="ost-panel-body">' +
'<iframe src="https://helpdesk.ilc.upd.edu.ph/o.php"></iframe>' +
'</div>' +
'<div id="ost-panel-footer">' +
'' +
'</div>' +
'</div>'
);
$('body').append(bubble).append(panel);
bubble.on('click', function () {
panel.toggleClass('ost-open');
});
panel.find('#ost-panel-close').on('click', function () {
panel.removeClass('ost-open');
});
});