Subversion Repositories Applications.dictionnaire

Rev

Rev 3 | Rev 6 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3 Rev 5
Line 1... Line 1...
1
var dictionnaire = new Array();
1
var dictionnaire = new Array();
2
var motsAyantDefinition = null;
2
var motsAyantDefinition = null;
3
var mouseX = null;
3
var mouseX = null;
4
var mouseY = null;
4
var mouseY = null;
5
var tempsDepuisRequeteAjax = 0;
-
 
6
var active = false;
5
var active = false;
Line 7... Line 6...
7
 
6
 
8
function getUrlBaseService() {
7
function getUrlBaseService() {
9
	// provient de dictionnaire.config.js
8
	// provient de dictionnaire.config.js
Line 83... Line 82...
83
    });
82
    });
84
    return this;
83
    return this;
85
}
84
}
Line 86... Line 85...
86
 
85
 
87
function rechercherEtRemplacerMotParDefinition(texte, mot) {
-
 
88
	motSimplifie = supprimerAccents(mot).toLowerCase();
-
 
89
	mot = normaliserMotPourRecherche(mot);
86
function rechercherEtRemplacerMotParDefinition(texte, mot) {
90
	exclureSpan = '[^(?:class="definition_term">)]';
87
	exclureSpan = '[^(?:class="definition_term">)]';
91
    regExp = new RegExp(exclureSpan+"[ |,|-|;|.]+("+mot+")[a-zA-Z]{1}", 'ig');
88
    regExp = new RegExp(exclureSpan+"[ |,|-|;|.]+("+mot+")[a-zA-Z]{1}", 'ig');
92
  	termeDansTexte = regExp.exec(texte);  	
89
  	termeDansTexte = regExp.exec(texte);  	
93
  	if(termeDansTexte != null && termeDansTexte.length > 1) {
90
  	if(termeDansTexte != null && termeDansTexte.length > 1) {
94
	  	motOriginal = termeDansTexte[1];
91
	  	motOriginal = termeDansTexte[1];
95
		templateMotADefinition = formaterTemplateMotADefinition(motSimplifie, motOriginal);
92
		templateMotADefinition = formaterTemplateMotADefinition(motOriginal);
96
		texte = texte.replace(motOriginal, templateMotADefinition);
93
		texte = texte.replace(motOriginal, templateMotADefinition);
Line 97... Line 94...
97
  	}
94
  	}
98
 
95
 
Line 113... Line 110...
113
	
110
	
114
	ajouterListenerDefinitions();
111
	ajouterListenerDefinitions();
Line 115... Line 112...
115
}
112
}
116
 
113
 
117
function ajouterDefinitions(motsAvecDefinitions) {
114
function ajouterDefinitions(motsAvecDefinitions) {
118
	set = 'p, span:not("definition_term"), td, pre';
115
	set = 'p, span, td, pre, div';
Line 119... Line 116...
119
	$(set).remplacerDefinitions(motsAvecDefinitions);
116
	$(set).remplacerDefinitions(motsAvecDefinitions);
-
 
117
}
120
}
118
 
121
 
119
function formaterTemplateMotADefinition(motOriginal) {
122
function formaterTemplateMotADefinition(motSimplifie, motOriginal) {
120
	motSimplifie = supprimerAccents(motOriginal);
123
	definitionHtml = '<span rel="'+motSimplifie+'" class="definition_term">'
121
	definitionHtml = '<span rel="'+motSimplifie+'" class="definition_term">'
124
	+motOriginal+
122
	+motOriginal+
Line 147... Line 145...
147
	}
145
	}
148
}
146
}
Line 149... Line 147...
149
 
147
 
150
function chargerDefinitionDistante(element) {
148
function chargerDefinitionDistante(element) {
151
	date = new Date();
149
	date = new Date();
152
	tempsDepuisRequeteAjax = date.getTime();
150
	mot = element.attr('rel');
153
	$.ajax({
151
	$.ajax({
154
		url: getUrlBaseService()+'def/'+mot,
152
		url: getUrlBaseService()+'def/'+mot,
155
		success: function(data) {
153
		success: function(data) {
156
			retour = data;
154
			retour = data;
Line 193... Line 191...
193
	mouseX = e.pageX;
191
	mouseX = e.pageX;
194
    mouseY = e.pageY - $(window).scrollTop();
192
    mouseY = e.pageY - $(window).scrollTop();
195
});
193
});
Line 196... Line 194...
196
 
194
 
-
 
195
$(document).ready(function() {
197
$(document).ready(function() {
196
	getMotsADefinitions();
198
	afficherLienDefinitions();
197
	afficherLienDefinitions();