X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=js%2Fformateur.js;h=1cc88c26a541be048b101d5e3b1c6f2a6860f1b3;hb=79f0cfc91b7220d98e4caf50fbb3857807fc6bc4;hp=23f253187d0726dab6df3dbd0462f25e0c53ac63;hpb=107016b49c680e6bc4ff8ae9685f7c57e46cc450;p=euphorik.git
diff --git a/js/formateur.js b/js/formateur.js
index 23f2531..1cc88c2 100644
--- a/js/formateur.js
+++ b/js/formateur.js
@@ -16,8 +16,6 @@
// You should have received a copy of the GNU General Public License
// along with Euphorik. If not, see .
-/*jslint laxbreak:true */
-
/**
* Classe permettant de formater du texte par exemple pour la substitution des liens dans les
@@ -30,7 +28,7 @@ euphorik.Formateur = function() {
this.regexUrl = new RegExp("(?:(?:" + this.protocoles + ")://|www\\.)[^ ]*", "gi");
this.regexImg = new RegExp("^.*?\\.(gif|jpg|png|jpeg|bmp|tiff)$", "i");
- this.regexDomaine = new RegExp("^(?:(?:" + this.protocoles + ")://|www\\.).*?([^/.]+\\.[^/.]+)(?:$|/).*$", "i");
+ this.regexDomaine = new RegExp("^(?:(?:" + this.protocoles + ")://)(.*?)(?:$|/).*$", "i");
this.regexTestProtocoleExiste = new RegExp("^(?:" + this.protocoles + ")://.*$", "i");
this.regexNomProtocole = new RegExp("^(.*?)://");
};
@@ -46,7 +44,7 @@ euphorik.Formateur.prototype.filtrerInputPseudo = function(pseudo) {
euphorik.Formateur.prototype.getSmilesHTML = function() {
var XHTML = "";
- this.smiles.each(function(nom) {
+ objectEach(this.smiles, function(nom) {
XHTML += "";
});
return XHTML;
@@ -81,7 +79,7 @@ euphorik.Formateur.prototype.traiterLiensConv = function(m) {
* moyenne sur échantillon : 234ms
*/
euphorik.Formateur.prototype.traiterSmiles = function(m) {
- this.smiles.each(function(nom, smiles) {
+ objectEach(this.smiles, function(nom, smiles) {
for (var i = 0; i < smiles.length; i++) {
m = m.replace(smiles[i], "");
}
@@ -112,12 +110,12 @@ euphorik.Formateur.prototype.traiterURL = function(m, pseudo) {
*/
euphorik.Formateur.prototype.traiterWikiSyntaxe = function(m) {
return m.replace(
- /_(.*?)_/g,
+ /(?:^| )_(.*?)_(?:$| )/g,
function(texte, capture) {
return '' + capture + '';
}
).replace(
- /\*(.*?)\*/g,
+ /(?:^| )\*(.*?)\*(?:$| )/g,
function(texte, capture) {
return '' + capture + '';
}
@@ -126,7 +124,7 @@ euphorik.Formateur.prototype.traiterWikiSyntaxe = function(m) {
/**
* Renvoie une version courte de l'url.
- * par exemple : http://en.wikipedia.org/wiki/Yakov_Smirnoff devient wikipedia.org
+ * par exemple : http://en.wikipedia.org/wiki/Yakov_Smirnoff devient en.wikipedia.org
*/
euphorik.Formateur.prototype.getShort = function(url) {
var estUneImage = false;
@@ -154,14 +152,25 @@ euphorik.Formateur.prototype.getShort = function(url) {
return [versionShort ? versionShort : "url", estUneImage];
};
+euphorik.Formateur.prototype.supprimerSmiles = function(m) {
+ objectEach(this.smiles, function(nom, smiles) {
+ for (var i = 0; i < smiles.length; i++) {
+ m = m.replace(smiles[i], "");
+ }
+ });
+ return m;
+};
+
/**
* Traite les pseudo et messages à être affiché dans le titre d'une image visualisé avec lightbox.
+ * Supprime les smiles pour pas qu'ils puissent être remplacés par la fonction 'traiterSmiles'.
+ * TODO : trouver un moyen pour que les smiles puissent être conservés
*/
euphorik.Formateur.prototype.traiterPourFenetreLightBox = function(M, urlCourante) {
var thisFormateur = this;
var traitementUrl = function(url) {
- return "[" + thisFormateur.getShort(url)[0] + (urlCourante == url ? "*" : "") + "]";
+ return "[" + thisFormateur.getShort(url)[0] + (urlCourante === url ? "*" : "") + "]";
};
- return this.remplacerBalisesHTML(M).replace(this.regexUrl, traitementUrl);
+ return this.remplacerBalisesHTML(this.supprimerSmiles(M)).replace(this.regexUrl, traitementUrl);
};