gbligh Posted April 27, 2021 Share Posted April 27, 2021 Hi, Is there any code available which only shows a certain subject within a homework calendar? @Graham Quince Link to comment Share on other sites More sharing options...
ADT Posted April 27, 2021 Share Posted April 27, 2021 1 hour ago, gbligh said: Hi, Is there any code available which only shows a certain subject within a homework calendar? @Graham Quince Something like.... <script> var widget_content_uuid = "8E087DCB200281BC21D9AFFD49EB8309617608AC35F7D646"; var subject_uuid = "FE43A21E2003151E1F67BFB693DCAD08CDDA308CD37F93E1"; var recipients_uuid= "group-4F2B17B0200138FC1A2E4F4E5494BB04E65810EC7A8FC42D"; setTimeout(function(){ $("div [data-content-uuid="+widget_content_uuid+"] select[name=subject_name]:first").val(subject_uuid).change(); }, 2000); setTimeout(function(){ $("div [data-content-uuid="+widget_content_uuid+"] select[name=recipients]:first").val(recipients_uuid).change(); }, 3000); </script> Link to comment Share on other sites More sharing options...
gbligh Posted April 27, 2021 Author Share Posted April 27, 2021 Nice! But how the hell do I use it!!! @ADT Link to comment Share on other sites More sharing options...
Graham Quince Posted April 27, 2021 Share Posted April 27, 2021 Nice one @ADT To use, add the Assignment Calendar widget to a page, and then either right-click on it and choose Inspect Element, then in the developer console look for the parent UUID: Or follow these instructions to create a bookmarklet to make it easy to get a Widget's UUID: Copy Adrian's code into an HTML widget and replace the widget-content-uuid with your widget's UUID. Save the changes and leave the editor (you may want to comment out Adrian's code first). Then right-click on the subject list in the widget and in the developer console expand the line: <select class="filter" name="subject_name"> which contains all the subject choices. The value of the option is the subject's UUID. Copy this and add it as the subject-uuid in Adrian's code. Alternatively, if you don't really want a calendar, and would prefer just a list, this discussion from a few years ago can help: Link to comment Share on other sites More sharing options...
Graham Quince Posted April 27, 2021 Share Posted April 27, 2021 Here's the complete assignment list for one subject code (I noticed the other thread has it a bit spread out): <style> .row-template { display: none; } .assignment-widget-header { background-color: #231f20; padding: 1em; position: relative; text-align: left; } .assignment-widget-header::after { content: ""; width: 98%; height: 60%; position: absolute; top: 3%; left: 1%; border-radius: 5px; } .assignment-widget-header h1 { color: #fff; font-size: 20px; margin: 0; } .no-homework { padding: 1em; text-align: center; } .assignment-list { list-style: none; padding: 0 1em; margin:0 0 0 0; } .assignment-list :hover{ background-color:#ededed; } .assignment-list .assignment-link { border-bottom: 1px solid #ddd; padding: 10px 10px 10px 10px; margin: 0.5em 0; cursor: pointer; } .assignment-list .assignment-link p { margin: 0; } .assignment-list .assignment-link .assign-icon { width: 36px; height: 36px; display: block; float: left; margin-top: 2px; } .assignment-list .assignment-link .assign-details { padding: 0 1em; float: left; } .widget-header { width: 100%; height:50px; line-height:50px; vertical-align:top; padding-left: 20px; box-sizing: border-box; background-color: #0497da; border-top-left-radius: 6px; border-top-right-radius: 6px; border: 1px solid #cccccc; border-bottom-width: 0; color: #ffffff; font-size:12pt; background: #0497da; /* Old browsers */ background: -moz-linear-gradient(top, #0497da 0%, #0064cd 100%); /* FF3.6-15 */ background: -webkit-linear-gradient(top, #0497da 0%,#0064cd 100%); /* Chrome10-25,Safari5.1-6 */ background: linear-gradient(to bottom, #0497da 0%,#0064cd 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0497da', endColorstr='#0064cd',GradientType=0 ); /* IE6-9 */ } .widget-body { background-color: white; border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; border: 1px solid #cccccc; border-top-width: 0; } </style> <div class="widget-header"> My most recent homeworks: </div> <div class="widget-body"> <p class="no-homework">You've not been set any homework yet</p> <ul class="assignment-list" style="display: none;"> </ul> </div> <script> var htmlWidget = arguments[0]; // Get this widget var assignments = FrogOS.fdp({ // FDP API url: 'assignment/getAssigned', data: { status: 'open', // open or closed limit: 15, // How many homeworks to restrieve order: 'start desc' } }); assignments.done(function(data) { // run the API call var assignments = data.response.assignments, assignment; for (var uuid in assignments) { if (assignments.hasOwnProperty(uuid)) { assignment = assignments[uuid].assignment; htmlWidget.find('.assignment-list').show(); htmlWidget.find('.no-homework').hide(); if (assignment.subject.name == "English") { var assignSubject = '<p><strong>' + assignment.subject.name + '</strong></p>'; var assignTitle = '<p>' + assignment.name + '</p>'; var assignEnd = '<p style="color: red;"><strong>Due: ' + moment(assignment.end, 'X').format('Do MMM YYYY') + '</strong></p>'; var assignLink = assignment.link; var assignmentItem = '<li class="assignment-link clearfix" data-assignment-link="' + assignLink + '"><div class="ui-app-icon-small ui-app-icon-small-assignment assign-icon"></div><div class="assign-details">' + assignSubject + '' + assignTitle + '' + assignEnd + '</div></li>'; htmlWidget.find('.assignment-list').append(assignmentItem); } } // end of has a uuid check } // end of for loop }); // end of API call $(htmlWidget).on('click', '.assignment-link', function(el){ $(this).trigger('os.app.siteviewer', { data: { site: el.currentTarget.dataset.assignmentLink } // open assignment site }); }); </script> Link to comment Share on other sites More sharing options...
ADT Posted April 28, 2021 Share Posted April 28, 2021 21 hours ago, gbligh said: Nice! But how the hell do I use it!!! @ADT If i told you that id have to kill you..... ? 1 1 Link to comment Share on other sites More sharing options...
ADT Posted April 28, 2021 Share Posted April 28, 2021 22 hours ago, gbligh said: Nice! But how the hell do I use it!!! @ADT Have you got sorted now then? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now