MDL-43734: Prevent purging of all user session cache
[moodle.git] / tag / tag.js
blob85fc306266bfd605fa71cd6b00c63901bae4c05e
1 var coursetagdivs = null;
2 var coursetag_tags = new Array();
4 function init_tag_autocomplete() {
5 YUI().use('yui2-autocomplete', 'yui2-datasource', 'yui2-animation', 'yui2-connection', function(Y) {
6     var myDataSource = new Y.YUI2.util.XHRDataSource("./tag_autocomplete.php");
7     myDataSource.responseType = Y.YUI2.util.XHRDataSource.TYPE_TEXT;
8     myDataSource.responseSchema = {
9         recordDelim: "\n",
10         fieldDelim: "\t"
11     };
12     myDataSource.maxCacheEntries = 60;
13     myDataSource.minQueryLength = 3;
15     // Instantiate the AutoComplete
16     var myAutoComp = new Y.YUI2.widget.AutoComplete("id_relatedtags", "relatedtags-autocomplete", myDataSource);
17     document.getElementById('id_relatedtags').style.width = '30%';
18     myAutoComp.allowBrowserAutocomplete = false;
19     myAutoComp.maxResultsDisplayed = 20;
20     myAutoComp.delimChar = [","," "];
21     myAutoComp.formatResult = function(oResultData, sQuery, sResultMatch) {
22         return (sResultMatch);
23     };
25     return {
26         myDataSource: myDataSource,
27         myAutoComp: myAutoComp
28     };
29 });
32 function ctags_checkinput(val) {
33     var len = val.length;
34     if (len < 2 || len > 50) {
35         alert(M.str.block_tags.jserror1);
36         return false;
37     } else if (val.indexOf("<") > 0) {
38         alert(M.str.block_tags.jserror2);
39         return false;
40     } else if (val.indexOf(">") > 0) {
41         alert(M.str.block_tags.jserror2);
42         return false;
43     } else {
44         return true;
45     }
48 function set_course_tag(key) {
49     window.coursetag_tags[window.coursetag_tags.length] = key;
52 function add_tag_footer_link(eid, ltitle, laction, ltext) {
53     var e = document.getElementById(eid);
54     if (e) {
55         var link = document.createElement('a');
56         link.setAttribute('href', '');
57         link.setAttribute('title', ltitle);
58         link.appendChild(document.createTextNode(ltext));
59         var callback = function () {
60             ctags_show_div(laction);
61         };
62         YUI().use('yui2-event', function(Y) {
63             Y.YUI2.util.Event.addListener(link, 'click', callback);
64         });
65         if (e.childNodes.length > 0) {
66             e.appendChild(document.createTextNode(' | '));
67         } else {
68             e.appendChild(document.createElement('hr'));
69         }
70         e.appendChild(link);
71     }