mirror of
				https://github.com/ae-utbm/sith.git
				synced 2025-11-04 02:53:06 +00:00 
			
		
		
		
	core: move centralized custom scripts on top of base.jinja and move getCookie inside
This commit is contained in:
		@@ -43,3 +43,22 @@ $( function() {
 | 
			
		||||
function display_notif() {
 | 
			
		||||
    $('#header_notif').toggle().parent().toggleClass("white");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// You can't get the csrf token from the template in a widget
 | 
			
		||||
// We get it from a cookie as a workaround, see this link
 | 
			
		||||
// https://docs.djangoproject.com/en/2.0/ref/csrf/#ajax
 | 
			
		||||
function getCookie(cname) {
 | 
			
		||||
    var name = cname + "=";
 | 
			
		||||
    var decodedCookie = decodeURIComponent(document.cookie);
 | 
			
		||||
    var ca = decodedCookie.split(';');
 | 
			
		||||
    for(var i = 0; i <ca.length; i++) {
 | 
			
		||||
        var c = ca[i];
 | 
			
		||||
        while (c.charAt(0) == ' ') {
 | 
			
		||||
            c = c.substring(1);
 | 
			
		||||
        }
 | 
			
		||||
        if (c.indexOf(name) == 0) {
 | 
			
		||||
            return c.substring(name.length, c.length);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return "";
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user