diff --git a/amd/build/jmodule.min.js b/amd/build/jmodule.min.js index 3f1f3cb44bc7704f00e9ca2a5c63fea85deb4fb6..cc2ed41c748cf1a124ab7c65520a9023c96123c2 100644 --- a/amd/build/jmodule.min.js +++ b/amd/build/jmodule.min.js @@ -1,2 +1,2 @@ /*! hshcourselist 2018-08-29 */ -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 +define(["jquery"],function(a){function b(b,c,d,e,f,g,h,i,j){c&&(a("#hshcourseprogress").show(),a.ajax({type:"GET",url:j+"/blocks/hshcourselist/hshcourselist.php",data:"course="+b+"&instanceid="+e+"&sesskey="+f+"&contextid="+g+"&idSearching="+h+"&orderbysemester="+i,dataType:"json",success:function(b){var c=JSON.stringify(b),e=JSON.parse(c),f=a("<ul class='list-group' id='hshcourselistul'></ul>");e.length>0&&a.each(e,function(b,c){switch(d){case"0":displaystr=c.shortname;break;case"1":displaystr=c.fullname;break;case"2":displaystr=c.shortname+": "+c.fullname;break;default:displaystr=c.fullname}a('<li class="list-group-item hshcoursesearchlistitem " value="'+c.id+'"><a href="'+j+"/course/view.php?id="+c.id+'">'+displaystr+"</a> </li>").appendTo(f)}),a("#hshcourselistul").replaceWith(f),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(c,d){var e,c=c,f=c.instanceid,g=c.sesskey,h=c.displaymode,i=c.contextid,j=!1,k=!1,l=c.orderbysemester;a("#hshcourseprogress").hide(),a(".idSarchingLabel").hide(),a("#orderbysemestercheckbox_id").on("change",function(){l=document.getElementById("orderbysemestercheckbox_id").checked,j=!0,e=document.getElementById("hshcourselistsearch").value,"#"===e.slice(0,1)?(a(".idSarchingLabel").show(),k=!0,e=e.slice(1)):(a(".idSarchingLabel").hide(),k=!1),b(e,j,h,f,g,i,k,l,d)}),a("#hshcourselistsearch").on("keyup",function(c){var m=c.keyCode;l=document.getElementById("orderbysemestercheckbox_id").checked,40!==m&&38!==m&&13!==m&&(j=!0,e=document.getElementById("hshcourselistsearch").value,"#"===e.slice(0,1)?(a(".idSarchingLabel").show(),k=!0,e=e.slice(1)):(a(".idSarchingLabel").hide(),k=!1),b(e,j,h,f,g,i,k,l,d))}),a("#hshcourseform").on("submit",function(a){a.preventDefault,j=!0,k=!1,l=document.getElementById("orderbysemestercheckbox_id").checked,e=document.getElementById("hshcourselistsearch").value,"#"===e.slice(0,1)?(k=!0,e=e.slice(1)):k=!1,b(e,j,h,f,g,i,k,l,d)})}}}); \ No newline at end of file diff --git a/amd/src/jmodule.js b/amd/src/jmodule.js index e2bcbed25e2e31676e1fe3d49caa79d291fb1816..88e8444bfba58117eb0412c94c9f899662e0e217 100644 --- a/amd/src/jmodule.js +++ b/amd/src/jmodule.js @@ -1,20 +1,10 @@ define(['jquery'], function ($) { - function getRootWebSitePath() { - var _location = document.location.toString(); - var applicationNameIndex = _location.indexOf('/', _location.indexOf('://') + 3); - var applicationName = _location.substring(0, applicationNameIndex) + '/'; - return applicationName; - //var webFolderIndex = _location.indexOf('/', _location.indexOf(applicationName) + applicationName.length); - //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, wwwroot) { if (reloadBool) { $("#hshcourseprogress").show(); $.ajax({ type: 'GET', - url: getRootWebSitePath() + '/blocks/hshcourselist/hshcourselist.php', + url: wwwroot + '/blocks/hshcourselist/hshcourselist.php', data: 'course=' + searchstring + '&instanceid=' + instanceid + '&sesskey=' + sesskey + '&contextid=' + contextid + '&idSearching=' + idSearching + '&orderbysemester=' + orderbysemester, @@ -43,7 +33,7 @@ define(['jquery'], function ($) { break; } $('<li class="list-group-item hshcoursesearchlistitem " value="' + course.id + '">' - + '<a href="' + getRootWebSitePath() + '/course/view.php?id=' + course.id + '">' + displaystr + '</a> </li>') + + '<a href="' + wwwroot + '/course/view.php?id=' + course.id + '">' + displaystr + '</a> </li>') .appendTo(list); }); } @@ -65,7 +55,7 @@ define(['jquery'], function ($) { } return { - init: function (jsdataobject) { + init: function (jsdataobject, wwwroot) { var jsdataobject = jsdataobject; var instanceid = jsdataobject.instanceid; var sesskey = jsdataobject.sesskey; @@ -92,7 +82,7 @@ define(['jquery'], function ($) { $(".idSarchingLabel").hide(); idSearching = false; } - search(searchstring, reloadList, displaymode, instanceid, sesskey, contextid, idSearching, orderbysemester); + search(searchstring, reloadList, displaymode, instanceid, sesskey, contextid, idSearching, orderbysemester, wwwroot); }); $('#hshcourselistsearch').on('keyup', function (e) { @@ -109,7 +99,7 @@ define(['jquery'], function ($) { $(".idSarchingLabel").hide(); idSearching = false; } - search(searchstring, reloadList, displaymode, instanceid, sesskey, contextid, idSearching, orderbysemester); + search(searchstring, reloadList, displaymode, instanceid, sesskey, contextid, idSearching, orderbysemester, wwwroot); } }); $('#hshcourseform').on('submit', function (e) { @@ -124,7 +114,7 @@ define(['jquery'], function ($) { } else { idSearching = false; } - search(searchstring, reloadList, displaymode, instanceid, sesskey, contextid, idSearching, orderbysemester); + search(searchstring, reloadList, displaymode, instanceid, sesskey, contextid, idSearching, orderbysemester, wwwroot); }); }, } diff --git a/block_hshcourselist.php b/block_hshcourselist.php index 2c10558d70621b37d2f2b9864a7e109234764716..34664b51632e197b16cc6c9dc4458fac35fe4de3 100644 --- a/block_hshcourselist.php +++ b/block_hshcourselist.php @@ -172,7 +172,7 @@ class block_hshcourselist extends block_base { 'orderbysemester' => $orderbysemester, 'contextid' => $this->page->context->id ); - $this->page->requires->js_call_amd('block_hshcourselist/jmodule', 'init', array($jsdata)); + $this->page->requires->js_call_amd('block_hshcourselist/jmodule', 'init', array($jsdata, $CFG->wwwroot)); //Einstellungen für den Custom-Footer if (!empty($this->config->footer) && $this->config->enablefooter) { diff --git a/version.php b/version.php index 271244765d43e66152bd63f1d33d56b47da5435c..0053e00421fe3405bbbee083200f4aec66569476 100644 --- a/version.php +++ b/version.php @@ -1,4 +1,4 @@ <?php $plugin->component = 'block_hshcourselist'; -$plugin->version = 2018082800; // YYYYMMDDHH +$plugin->version = 2018082802; // YYYYMMDDHH $plugin->requires = 2016112900; // YYYYMMDDHH