X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;ds=sidebyside;f=js%2Fformateur.js;h=1cc88c26a541be048b101d5e3b1c6f2a6860f1b3;hb=75cd78e0253509fad9c3cbfadda4a1c193c2b6e0;hp=e0e72405dee61767dc718a1f06ce0f48760958b0;hpb=1146f3264ff7535ff3408230140414789c3c25da;p=euphorik.git
diff --git a/js/formateur.js b/js/formateur.js
index e0e7240..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("^(.*?)://");
};
@@ -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);
};