Skip to content

Instantly share code, notes, and snippets.

@isubas
Last active March 9, 2016 15:23
Show Gist options
  • Save isubas/5dff4504c4dc95e103ca to your computer and use it in GitHub Desktop.
Save isubas/5dff4504c4dc95e103ca to your computer and use it in GitHub Desktop.
Javascript Moodle
<script type="text/javascript">
$( document ).ready(function() {
url = window.location.pathname;
is_course_page_visit = url.indexOf("course") !== -1;
is_not_edit = $("i.fa-power-off").length == 0;
hedef = ""
general = '<div class="alert alert-info alert-dismissible fade in" role="alert" style="padding:10px;">' +
'<h4>Canlı Ders Merkezi</h4><br>' +
'<p>Bu dersin canlı dersleri ile ilgili tüm işlemler elinizin altında. Canlı ders merkezinde yapabilecekleriniz.</p>' +
'<ul class="list-style-3 colored">' +
'<li>Canlı derslere katılabilirsiniz</li>' +
'<li>Geçmiş canlı ders kayıtlarını izleyebilirsiniz.</li>' +
'<li>Canlı ders programını görebilirsiniz.</li>' +
'</ul><br>'
general_end = '</p></div>'
newElement = "";
if (is_not_edit && is_course_page_visit ){
mainElement = $(".activity.adobeconnect");
mainElementCount = mainElement.length
mainElement.each(function(index, item) {
editElement = $( this ).find(".activityinstance a").not(".dimmed");
link = editElement.attr("href");
if (link != undefined){
control = editElement.find("span.instancename:not('.accesshide')").text();
titletext = "";
if (control.indexOf("- A Şubesi") >= 0){
titletext = "A Şubesi ";
}else if(control.indexOf("- B Şubesi") >= 0){
titletext = "B Şubesi ";
};
text = titletext + "Canlı Ders Merkezine Git"
link = '<a class="btn btn-info" href="'+link+'" style="margin-left:4px;" target="_blank">' +
'<i class="fa fa-video-camera"></i> '+ text +' </a>'
newElement += link
target = $( this ).parent().children(".lesson").find(".no-overflow .no-overflow").first();
if (target.length > 0){
if (index + 1 == mainElementCount){
target.append(general + newElement + general_end);
}
$( this ).hide();
}else {
if (index + 1 == mainElementCount){
$( this ).html(general + newElement + general_end)
}else {
$( this ).html("")
}
}
}
});
};
// assing roles hide
is_course_page_visit = url.indexOf("adobeconnect") !== -1
if(is_course_page_visit){
$(".aconbtnroles").hide();
};
// activities Adobe Connect replace with Canlı Ders
$("p.activity:contains('Adobe Connect')").each(function() {
var text = $(this).html();
$(this).html(text.replace('Adobe Connect', 'Canlı Ders'));
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment