From da96de2f142b028b6d29ab3065dd087a5969dcf8 Mon Sep 17 00:00:00 2001 From: Darks Date: Wed, 4 Dec 2019 22:16:29 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20d'un=20premier=20jet=20d'=C3=A9diteur?= =?UTF-8?q?=20Js=20de=20LightScript?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/scripts/pc-utils.js | 56 ------------------------------- app/templates/base/scripts.html | 6 ++-- app/templates/widgets/editor.html | 26 +++++++------- app/utils/render.py | 7 ++-- 4 files changed, 21 insertions(+), 74 deletions(-) diff --git a/app/static/scripts/pc-utils.js b/app/static/scripts/pc-utils.js index 3779769..56434ec 100644 --- a/app/static/scripts/pc-utils.js +++ b/app/static/scripts/pc-utils.js @@ -50,59 +50,3 @@ function flash_close(element) { } }, 0); } - -/* - Send post ajax request to url defined in action. - Callback the function defined in the callback attribute from the submit type. -*/ -/* We don't need Ajax at that time. Maybe later -function ajaxWrapper(evt){ - evt.preventDefault(); - var elems = evt.target; - var params = ""; - // do not embed submit value (-1) - for(i = 0; i < elems.length-1; i++){ - if(params) params += "&"; - params += encodeURIComponent(elems[i].name)+"="+encodeURIComponent(elems[i].value); - } - const req = new XMLHttpRequest(); - req.open("POST", evt.target.action, true); - req.setRequestHeader('Content-Type',"application/x-www-form-urlencoded"); - req.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); - req.onreadystatechange = function(){ - if(req.readyState == 4 && (req.status == 200 || req.status == 0)){ - var fn = window[elems[elems.length-1].getAttribute("callback")]; - if(typeof fn == 'function'){ - fn(req.responseText); - } - } - } - req.send(params); -} - -// Add event listener on submit for all form with class with-ajax. - -window.onload = function(){ - - var ele; - var elems = document.getElementsByClassName('with-ajax'); - for(i = 0; i < elems.length; i++){ - ele = elems[i]; - if(ele.addEventListener){ // Normal people - ele.addEventListener("submit", ajaxWrapper, false); - }else if(ele.attachEvent){ // Retarded user using IE - ele.attachEvent("onsubmit", ajaxWrapper); - } - } - - if(getCookie('pc_notif') == 'true') - document.getElementsByClassName('alert')[0].parentNode.removeChild(document.getElementsByClassName('alert')[0]); - if(getCookie('pc_notif_2') == 'true') - document.getElementsByClassName('alert')[0].parentNode.removeChild(document.getElementsByClassName('alert')[0]); - -} - -function login(response){ - alert(response); -} -//*/ \ No newline at end of file diff --git a/app/templates/base/scripts.html b/app/templates/base/scripts.html index 9be4f53..4405157 100644 --- a/app/templates/base/scripts.html +++ b/app/templates/base/scripts.html @@ -1,3 +1,3 @@ - - - +{% for s in scripts %} + +{% endfor %} diff --git a/app/templates/widgets/editor.html b/app/templates/widgets/editor.html index 2b8c80c..e942839 100644 --- a/app/templates/widgets/editor.html +++ b/app/templates/widgets/editor.html @@ -2,23 +2,23 @@
{{ field.label if label }}
- - - - + + + + - - - + + + - - + + - - - + + + - +
{{ field() }} {% for error in field.errors %} diff --git a/app/utils/render.py b/app/utils/render.py index 35a04d1..f20ecc6 100644 --- a/app/utils/render.py +++ b/app/utils/render.py @@ -23,10 +23,13 @@ def render(*args, styles=[], scripts=[], **kwargs): 'css/footer.css', 'css/flash.css', 'css/responsive.css', - 'css/table.css' + 'css/table.css', ] scripts_ = [ - + 'scripts/trigger_menu.js', + 'scripts/pc-utils.js', + 'scripts/smartphone_patch.js', + 'scripts/editor.js', ] for s in styles: