Commit 60989fea authored by Sylvain Coulange's avatar Sylvain Coulange
Browse files

ajout icône motInconnu et motNonAlignable + ajout fonction ajout dans...

ajout icône motInconnu et motNonAlignable + ajout fonction ajout dans dictionnaire depuis Coloriseur.html
parent 835e3865
......@@ -108,6 +108,15 @@ def editEntry(request):
}
return JsonResponse(rep)
def addEntry(request):
mot = request.GET.get('mot', None)
trans = request.GET.get('trans', None)
ipCli = get_client_ip(request)
rep = {
'reponse': txtphono.addEntry(ipCli,mot,trans)
}
return JsonResponse(rep)
def getLog(request):
rep = txtphono.sendMeLogPlease()
return JsonResponse(rep)
......
......@@ -15,7 +15,7 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import path
from colorapp.views import main, dicoView, editEntry, redirApp, main0, dicoReq, getLog
from colorapp.views import main, dicoView, editEntry, addEntry, redirApp, main0, dicoReq, getLog
urlpatterns = [
path('admin/', admin.site.urls),
......@@ -25,5 +25,6 @@ urlpatterns = [
path('app/dico/', dicoView),
path('dicoSearch/', dicoReq),
path('modifEntry/', editEntry),
path('addEntry/', addEntry),
path('getLog/', getLog)
]
......@@ -2,26 +2,90 @@ $(document).ready(function(){
var txtarea = document.getElementById("inText");
txtarea.selectionEnd = txtarea.innerHTML.length;
txtarea.focus();
unknownMark();
bugMark();
});
function unknownMark() {
var marks = document.getElementsByClassName('unknownMark');
var i;
for (i=0; i < marks.length; i++) {
marks[i].parentNode.removeChild(marks[i]);
}
var unknowns = document.getElementsByClassName('phon_inconnu');
var i;
for (i = 0; i < unknowns.length; i++) {
var newMark = document.createElement('span');
newMark.classList = 'glyphicon glyphicon-plus-sign unknownMark';
//<span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span>
newMark.classList = 'glyphicon glyphicon-edit unknownMark';
newMark.title = "Ajouter ce mot au dictionnaire";
newMark.value = unknowns[i].innerHTML;
newMark.onclick = function(){
dicoAddPop(this.value);
};
unknowns[i].parentNode.insertBefore(newMark,unknowns[i].nextSibling);
};
}
function dicoAddPop(mot) {
document.getElementById('popAddwMot').innerHTML = "« "+mot+" »";
document.getElementById('popAddwTrans').value = '';
var modalpopAddw = document.getElementById('popAddw');
modalpopAddw.style.display = "block";
getAPIkeyboard();
window.onclick = function(event) {
if (event.target == modalpopAddw) {
modalpopAddw.style.display = "none";
}
}
document.getElementById('popAddwValid').addEventListener('click', function(){
var trans = document.getElementById('popAddwTrans').value;
if (trans.length > 0) {
validEntry(mot, trans);
}
});
}
function validEntry(mot, trans) {
document.getElementById('actionBlock').style.display = '';
document.body.style.cursor = "wait";
$.ajax({
url: '/addEntry/',
data: {
mot: mot,
trans: trans
},
dataType: 'json',
success: function(data) {
document.body.style.cursor = "default";
document.getElementById('actionBlock').style.display = 'none';
console.log(data.reponse);
window.alert(data.reponse);
document.getElementById('popAddw').style.display = 'none';
},
error: function(){
// document.getElementById('loader').style.display = 'none';
document.body.style.cursor = "default";
document.getElementById('actionBlock').style.display = 'none';
window.alert("L'ajout n'a pas pu être effectué !");
}
});
}
function bugMark() {
var marks = document.getElementsByClassName('bugMark');
var i;
for (i=0; i < marks.length; i++) {
marks[i].parentNode.removeChild(marks[i]);
}
var bugs = document.getElementsByClassName('phon_echec');
var i;
for (i = 0; i < bugs.length; i++) {
var newMark = document.createElement('span');
newMark.classList = 'glyphicon glyphicon-question-sign unknownMark';
//<span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span>
newMark.classList = 'glyphicon glyphicon-flash bugMark';
newMark.title = "Colorisation impossible !";
bugs[i].parentNode.insertBefore(newMark,bugs[i].nextSibling);
};
}
......@@ -55,6 +119,8 @@ function changeAlign(tok) {
if (document.getElementById('bicolor').checked == true) {
toBicolor();
};
unknownMark();
bugMark();
};
......
......@@ -166,6 +166,20 @@ def modifEntry(user,mot,newTransList):
print("Modification du dictionnaire par",user,": mot =",mot,"; oldTransList =",oldTransList,"; newTransList = ",newTransList)
return "Modification effectuée avec succès !"
def addEntry(user,mot,trans):
trans = trans.replace('g','ɡ')
mot = mot.lower()
transList = trans.split(',')
for ind,i in enumerate(transList):
transList[ind] = i.strip()
word2trans[mot] = transList
rewriteDico()
writeLog(Type="ADD", user=user, mot=mot, oldTransList="", newTransList=transList)
print("Modification du dictionnaire par",user,": ajout de mot =",mot,"; transList = ",transList)
return "Ajout effectué avec succès ! Merci pour votre participation !"
def rewriteDico():
with tempfile.NamedTemporaryFile(dir='.', delete=False, mode="w") as tmp:
......
......@@ -162,4 +162,40 @@
background-color: #7fbaf1;
font-style: italic;
text-align: right;
}
\ No newline at end of file
}
/* POP ADD WORD TO DIC */
.popAddw-content {
position: relative;
background-color: #fefefe;
margin: auto;
padding: 0;
border: 1px solid #888;
width: 40%;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
-webkit-animation-name: animatetop;
-webkit-animation-duration: 0.4s;
animation-name: animatetop;
animation-duration: 0.4s
}
/* Add Animation */
@-webkit-keyframes animatetop {
from {left:-300px; opacity:0}
to {left:0; opacity:1}
}
@keyframes animatetop {
from {left:-300px; opacity:0}
to {left:0; opacity:1}
}
.popAddw-header {
padding: 2px 16px;
background-color: #5cb85c;
color: white;
}
.popAddw-body {padding: 20px 16px;}
\ No newline at end of file
......@@ -103,6 +103,17 @@ textarea {
vertical-align: super;
padding: 5px;
}
.unknownMark:hover {
color: green;
cursor: pointer;
}
.bugMark {
font-size: 13pt;
vertical-align: super;
}
.bugMark:hover{
color: red;
}
#graphies {
background-color: black;
......
......@@ -6,10 +6,13 @@
<meta charset="utf-8">
<link rel="shortcut icon" type="image/png" href="{% static 'wikicolor.ico' %}"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link href="{% static 'styles/keyboard-dark.css'%}" rel="stylesheet">
<link href="{% static 'styles/loading.css'%}" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="{% static 'styles/kinephones_style_v2.css'%}">
<link rel="stylesheet" type="text/css" href="{% static 'styles/styles.css'%}">
<link rel="stylesheet" type="text/css" href="{% static 'styles/popup.css'%}">
<script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
<script src="{% static 'scripts/jquery.keyboard.js'%}"></script>
</head>
<body>
......@@ -76,6 +79,20 @@
</div>
</div>
<!-- Modal qui apparaît pour ajouter un mot au dictionnaire -->
<div id="popAddw" class="modal">
<div class="popAddw-content">
<div class="popAddw-header">
Ajouter un mot au dictionnaire
</div>
<div class="popAddw-body">
<b>Mot : </b><span id="popAddwMot"></span><br/>
<b>Transcription (API) : </b><input id="popAddwTrans" class="popAddwTrans api-kb" type="text" value=""/>
<button id="popAddwValid" style="margin: 5px;">Ajouter</button>
</div>
</div>
</div>
<div id="actionBlock" style="display: none;"><div class="loader mainLoad"></div></div>
{% include 'footer.html' %}
......@@ -98,6 +115,7 @@
</script>
<script src="{% static 'scripts/main.js' %}"></script>
<script src="{% static 'scripts/keyboard.js' %}"></script>
</body>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment