The JavaScript code CourseSales.com staff use by default for the public pages is below. You can just copy and paste this into your own, making modifications where necessary. In fact you might be able to download your copy by visiting https://{shortname}.coursesales.com/co/{shortname}/{shortname}.js
If this is the case then perhaps a file has been created for your already and it might have some customizations that you rely on! Don’t just overwrite it - be sure to take a backup.
$(document).ready(function() {
csInit();
$("form#csSearchForm").ajaxForm({
beforeSerialize: csSearchBegin,
success: csSearchResults,
dataType: 'json',
contentType: "application/x-www-form-urlencoded;charset=utf-8",
timeout: 15000
});
// this shows and hides Terms or other content, add content with a <span class=toggle-wrap>content here</span> to make this work (css req too) */
$(".toggle-trigger").click(function() {
$(this).parent().nextAll('.toggle-wrap').first().toggle('slow');
});
// This hides the draw on a document by simulating the click on the toggle checkbox (configured to include 'ToggleSurvey' as the class)
$(".ToggleSurvey").trigger('click');
};
//clears the postcode/locality lookup to avoid confusion (without this only the first locality in list is displayed)
$(".ACaddress input[type=\"text\"]").val("");
initOnCompleteLoad();
// Copy details on click of 'Copy address details' button
$('#ACbutton').on('click', function(){
autoAdd();
});
//When the USI links are clicked these functions open the pretty windows to create or find a USI.
$('#JumpLinkUSICreate').on('click', function(){
JumpLinkUSICreate();
});
$('#JumpLinkUSIForgot').on('click', function(){
JumpLinkUSIForgot();
});
});
//Functions to create the windows for the USI links.
function JumpLinkUSICreate() {
window.open('https://portal.usi.gov.au/student/Usi/Create/OnBehalfOf','_blank','height=400,menubar=no,status=no,scrollbars=yes,titlebar=yes,toolbar=no,width=400','');
}
function JumpLinkUSIForgot() {
window.open('https://portal.usi.gov.au/student/Usi/Forgotten','_blank','height=400,menubar=no,status=no,scrollbars=yes,titlebar=yes,toolbar=no,width=400','');
}
//The following is for copying the postcode, locality and state to the respective fields from the autolookup
var selStateId= '';
function initOnCompleteLoad() {
/*To disable editing make text fields readonly and select field disabled plus a hidden field*/
/*important that the hidden field is created before the original field is disabled. */
sid= $('div.ACstate select').attr('id');
sval = $('div.ACstate select').val();
sname= $('div.ACstate select').attr('name');
selStateId = sid;
$("div.ACstate select").attr('name', 'selState');
$("div.ACstate select").attr('id', 'selState');
$("div.ACstate").append('<input type=hidden name=' + sname + ' id=' + sid + ' value="'+sval+'" >');
//Comment these next three lines if you wish to be able to edit the values eg for OSPC entries (otherwise they are disabled)
$("div.ACstate select").prop('disabled', true);
$('input[type="text"].ACpostcode').prop('readonly', true);
$('input[type="text"].AClocality').prop('readonly', true);
$("div.ACaddress").parent().after('<div class="fld fldWd25 fldfl"><div class="wdg"><label></label><br><input type="button" id="ACbutton" value="Copy address details..."></div></div>');
}
function autoAdd() {
/* Get the autocomplete value and split based on ' - ' getting the Postcode first, tidy up spaces before or after */
Section1 = $(".ACaddress input[type=\"text\"]").val();
Section1 = Section1.trim();
Postcode = Section1.split(" - ")[0];
Postcode = Postcode.trim();
/* now get the suburb, tidy up spaces before or after */
Section1 = Section1.split(" - ")[1];
Section1 = Section1.trim();
Suburb = Section1.split(/ [^ ]*$/)[0];
Section1 = Section1.replace(Suburb, "");
Section1 = Section1.trim();
/*now change the 3-letter code to the AVETMISS numerical values then pick off the number*/
Section1 = Section1.replace("QLD", "3");
Section1 = Section1.replace("NSW", "1");
Section1 = Section1.replace("NT", "7");
Section1 = Section1.replace("VIC", "2");
Section1 = Section1.replace("ACT", "8");
Section1 = Section1.replace("SA", "4");
Section1 = Section1.replace("WA", "5");
Section1 = Section1.replace("TAS", "6");
myreg = /[^ ]*$/;
State = myreg.exec(Section1);
/* Define the field values */
$('#' + selStateId).val(State);
$('input[type="text"].AClocality').val(Suburb);
$('input[type="text"].ACpostcode').val(Postcode);
$("div.ACstate select").val(Section1);
return this;
}
function csInit() {
$("span.crsDscMore").click(function() {
var p = $(this).parents("div.crsRow");
var s = p.children("div.crsDscLng");
var r = s.attr('id');
var f = $("div#" + r + 'File');
if (f.length === 0) {
var cid = p.children("input.CourseMasterId").val();
$.ajax({
url: getCsBaseUrl() + '/public/filelistajax?r=' + r + '&CourseMasterId=' + cid,
dataType: 'json',
success: function(data) {
var x = data['x'];
if (x === 1) {
return;
}
var r = data['r'];
var h = data['h'];
var t = $("div#" + r);
var o = '<div style="clear:both; float:left; margin-top:12px;" id="' + r + 'File"><div style="font-weight:bold;">Downloads</div>';
var c = '</div>';
t.append(o + h + c);
},
timeout: 15000
});
}
p.find("div.crsDscLng").show();
$(this).parent().hide();
});
$("span.crsDscLess").click(function() {
$(this).parents("div.crsRow").find("div.crsDscSht").show();
$(this).parent().hide();
});
}
function csSearchBegin() {
$("input[namebtnsearch]").attr('disabled', true);
$("div#csCourseList").fadeTo(300, 0.3);
}
function csSearchResults(data) {
$("input[namebtnsearch]").removeAttr('disabled');
$("div#csCourseList").html(data);
csInit();
$("div#csCourseList").fadeTo(400, 1);
}
function csDfAcOptLoc() {
$("input.csDfAutCplLoc").autocomplete(csDfAcInitAjax('/public/locationajax'));
}
function csDfAcOptCat() {
$("input.csDfAutCplCat").autocomplete(csDfAcInitAjax('/public/categoryajax'));
}
function getDfCsBaseUrl() {
return $("div#baseUrl").html();
}
function csDfAcInitAjax(csDfAcPath) {
return {
source: getDfCsBaseUrl() + csDfAcPath,
minLength: 3,
delay: 500,
select: csDfAcSelect,
focus: csDfAcSelect
};
}
function csDfAcInitFn(csDfAcFn) {
return {
source: csDfAcFn,
minLength: 3,
delay: 500,
select: csDfAcSelect,
focus: csDfAcSelect
};
}
function csDfAcAjax(q, response) {
$.ajax({
url: q,
success: function(data) {
response(data);
},
dataType: "json",
timeout: 15000,
error: function() {
response();
return;
}
});
}
function csDfAcSelect(event, ui) {
event.stopPropagation();
var value = ui.item.value;
var label = ui.item.label;
var target = event.target.id;
var targetId = target.substring(0, target.length - 4);
$("input#" + targetId).val(value);
$("input#" + targetId).change();
$("input#" + target).val(label);
$("span#" + targetId + "-Old").text(label);
return false;
}
function csDfInitAjaxForm(csRef) {
var frmName;
if (csObjectNotSet(csRef)) {
frmName = "csAjxFrm";
} else {
frmName = csRef;
}
$("form." + frmName).ajaxForm({
beforeSerialize: csAjaxFormPost,
success: csAjaxFormResponse,
dataType: 'json',
contentType: "application/x-www-form-urlencoded;charset=utf-8",
timeout: 15000
});
}
function csDfAjaxFormPost(form, options) {
try {
$(form).find("div.wdg").removeClass("vldMsg");
$(form).find("span.vldMsg").remove();
var tmce = $('textarea:tinymce');
if (tmce.length > 0) {
tmce.tinymce().save();
}
} catch (e) {
}
}
function csDfAjaxFormResponse(data, status, xhr, form) {
var msg;
var formClass = form.attr("class");
if (data === null || typeof data === 'undefined') {
msg = '<span class="vldMsg">';
msg += 'Sorry, the server did not respond please try again.';
msg += '</span>';
$("form." + formClass).prepend(msg);
return;
}
var c=0;
for (var i in data) {
var pfx = i.substring(0, 3);
if (pfx == 'vld') {
var id = i.substring(3);
var d = $("div#div" + id);
d.addClass("vldMsg");
var m = '<span class="vldMsg">' + data[i] + "</span>";
d.append(m);
c++;
} else {
$("#" + i).val(data[i]);
$("#" + i).html(data[i]);
}
}
if (c > 0) {
csProcessValidationError("form." + formClass);
}
var goTo = data["go2"];
if (csObjectSet(goTo)) {
var baseUrl = getCsBaseUrl();
window.location = baseUrl + "/" + goTo;
return;
}
}