Skip to content
Snippets Groups Projects
Commit 23a046a5 authored by Tobias Baden's avatar Tobias Baden
Browse files

Fixed the search - ONLY USE ON root/ path.

Not the best solution, but works on moodle live system.
parent 6ffa3e85
No related branches found
No related tags found
No related merge requests found
/*! hshcourselist 2018-01-29 */ /*! hshcourselist 2018-08-29 */
define(["jquery"],function(a){function b(){var a=document.location.toString(),b=a.indexOf("/",a.indexOf("://")+3),c=a.substring(0,b)+"/",d=a.indexOf("/",a.indexOf(c)+c.length);return a.substring(0,d)}function c(c,d,e,f,g,h,i,j){d&&(a("#hshcourseprogress").show(),a.ajax({type:"GET",url:b()+"/blocks/hshcourselist/hshcourselist.php",data:"course="+c+"&instanceid="+f+"&sesskey="+g+"&contextid="+h+"&idSearching="+i+"&orderbysemester="+j,dataType:"json",success:function(c){var d=JSON.stringify(c),f=JSON.parse(d),g=a("<ul class='list-group' id='hshcourselistul'></ul>");f.length>0&&a.each(f,function(c,d){switch(e){case"0":displaystr=d.shortname;break;case"1":displaystr=d.fullname;break;case"2":displaystr=d.shortname+": "+d.fullname;break;default:displaystr=d.fullname}a('<li class="list-group-item hshcoursesearchlistitem " value="'+d.id+'"><a href="'+b()+"/course/view.php?id="+d.id+'">'+displaystr+"</a> </li>").appendTo(g)}),a("#hshcourselistul").replaceWith(g),a("#hshcourseprogress").hide()},error:function(){console.error("error"),"abort"!==o.statusText&&(a("#hshcourseprogress").hide(),void 0!==o.statusText&&console.error("ABORT + STATUS : "+o.statusText))}}))}return{init:function(b){var d,b=b,e=b.instanceid,f=b.sesskey,g=b.displaymode,h=b.contextid,i=!1,j=!1,k=b.orderbysemester;a("#hshcourseprogress").hide(),a(".idSarchingLabel").hide(),a("#orderbysemestercheckbox_id").on("change",function(){k=document.getElementById("orderbysemestercheckbox_id").checked,i=!0,d=document.getElementById("hshcourselistsearch").value,"#"===d.slice(0,1)?(a(".idSarchingLabel").show(),j=!0,d=d.slice(1)):(a(".idSarchingLabel").hide(),j=!1),c(d,i,g,e,f,h,j,k)}),a("#hshcourselistsearch").on("keyup",function(b){var l=b.keyCode;k=document.getElementById("orderbysemestercheckbox_id").checked,40!==l&&38!==l&&13!==l&&(i=!0,d=document.getElementById("hshcourselistsearch").value,"#"===d.slice(0,1)?(a(".idSarchingLabel").show(),j=!0,d=d.slice(1)):(a(".idSarchingLabel").hide(),j=!1),c(d,i,g,e,f,h,j,k))}),a("#hshcourseform").on("submit",function(a){a.preventDefault,i=!0,j=!1,k=document.getElementById("orderbysemestercheckbox_id").checked,d=document.getElementById("hshcourselistsearch").value,"#"===d.slice(0,1)?(j=!0,d=d.slice(1)):j=!1,c(d,i,g,e,f,h,j,k)})}}}); define(["jquery"],function(a){function b(){var a=document.location.toString(),b=a.indexOf("/",a.indexOf("://")+3);return a.substring(0,b)+"/"}function c(c,d,e,f,g,h,i,j){d&&(a("#hshcourseprogress").show(),a.ajax({type:"GET",url:b()+"/blocks/hshcourselist/hshcourselist.php",data:"course="+c+"&instanceid="+f+"&sesskey="+g+"&contextid="+h+"&idSearching="+i+"&orderbysemester="+j,dataType:"json",success:function(c){var d=JSON.stringify(c),f=JSON.parse(d),g=a("<ul class='list-group' id='hshcourselistul'></ul>");f.length>0&&a.each(f,function(c,d){switch(e){case"0":displaystr=d.shortname;break;case"1":displaystr=d.fullname;break;case"2":displaystr=d.shortname+": "+d.fullname;break;default:displaystr=d.fullname}a('<li class="list-group-item hshcoursesearchlistitem " value="'+d.id+'"><a href="'+b()+"/course/view.php?id="+d.id+'">'+displaystr+"</a> </li>").appendTo(g)}),a("#hshcourselistul").replaceWith(g),a("#hshcourseprogress").hide()},error:function(){console.error("error"),"abort"!==o.statusText&&(a("#hshcourseprogress").hide(),void 0!==o.statusText&&console.error("ABORT + STATUS : "+o.statusText))}}))}return{init:function(b){var d,b=b,e=b.instanceid,f=b.sesskey,g=b.displaymode,h=b.contextid,i=!1,j=!1,k=b.orderbysemester;a("#hshcourseprogress").hide(),a(".idSarchingLabel").hide(),a("#orderbysemestercheckbox_id").on("change",function(){k=document.getElementById("orderbysemestercheckbox_id").checked,i=!0,d=document.getElementById("hshcourselistsearch").value,"#"===d.slice(0,1)?(a(".idSarchingLabel").show(),j=!0,d=d.slice(1)):(a(".idSarchingLabel").hide(),j=!1),c(d,i,g,e,f,h,j,k)}),a("#hshcourselistsearch").on("keyup",function(b){var l=b.keyCode;k=document.getElementById("orderbysemestercheckbox_id").checked,40!==l&&38!==l&&13!==l&&(i=!0,d=document.getElementById("hshcourselistsearch").value,"#"===d.slice(0,1)?(a(".idSarchingLabel").show(),j=!0,d=d.slice(1)):(a(".idSarchingLabel").hide(),j=!1),c(d,i,g,e,f,h,j,k))}),a("#hshcourseform").on("submit",function(a){a.preventDefault,i=!0,j=!1,k=document.getElementById("orderbysemestercheckbox_id").checked,d=document.getElementById("hshcourselistsearch").value,"#"===d.slice(0,1)?(j=!0,d=d.slice(1)):j=!1,c(d,i,g,e,f,h,j,k)})}}});
\ No newline at end of file \ No newline at end of file
...@@ -3,9 +3,10 @@ define(['jquery'], function ($) { ...@@ -3,9 +3,10 @@ define(['jquery'], function ($) {
var _location = document.location.toString(); var _location = document.location.toString();
var applicationNameIndex = _location.indexOf('/', _location.indexOf('://') + 3); var applicationNameIndex = _location.indexOf('/', _location.indexOf('://') + 3);
var applicationName = _location.substring(0, applicationNameIndex) + '/'; var applicationName = _location.substring(0, applicationNameIndex) + '/';
var webFolderIndex = _location.indexOf('/', _location.indexOf(applicationName) + applicationName.length); return applicationName;
var webFolderFullPath = _location.substring(0, webFolderIndex); //var webFolderIndex = _location.indexOf('/', _location.indexOf(applicationName) + applicationName.length);
return webFolderFullPath; //var webFolderFullPath = _location.substring(0, webFolderIndex);
//return webFolderFullPath;
} }
function search(searchstring, reloadBool, displaymode, instanceid, sesskey, contextid, idSearching, orderbysemester) { function search(searchstring, reloadBool, displaymode, instanceid, sesskey, contextid, idSearching, orderbysemester) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment