The formula is a bit long but works: function round(x) { return parseFloat(Math.round(x * 10) / 10).toFixed(1).replace(/\.0/, « ») } round(458.21456); // -> 458.2 round(500); // -> 500 round(603.18); // -> 603.2
2
Déc
The formula is a bit long but works: function round(x) { return parseFloat(Math.round(x * 10) / 10).toFixed(1).replace(/\.0/, « ») } round(458.21456); // -> 458.2 round(500); // -> 500 round(603.18); // -> 603.2
Tags: javascript, Niveau débutant, Programmation
26
Nov
I was looking for a simple code for a step by step process indicator. I found a few things, but everyone seems to have forgotten about IE8… I need to support this old browser at work. So I did my own that I’m sharing here: File Uploaded → File Reviewed → File Approved And the […]
Tags: css, html, Niveau débutant, Programmation, Web Design
19
Août
In the iframe you’ll use the below code: window.parent.postMessage(« Hello World ! », « http://your.site.web »); And in the parent window: // function that will be called when the message is received function receiveMessage(event) { alert(event.data); // it’ll show « Hello World ! » } // we listen to a message if (window.addEventListener) { window.addEventListener(‘message’, receiveMessage, false); } else if (window.attachEvent) […]
Tags: javascript, Niveau débutant, Programmation
6
Août
Let’s say you have the url http://my.site.com/myfolder/mypage.aspx#hash and you want to use it as a link into your left navigation bar in Sharepoint…. If you try putting that name, Sharepoint will not keep your link. The trick here is to add a questionmark juste before the #. The URL to use will be http://my.site.com/myfolder/mypage.aspx?#hash and […]
Tags: Astuce, Niveau débutant, sharepoint
27
Mai
This is a very tiny javascript code to do an AJAX Request: /* m: method (« get », « post ») u: url a: async (true) or sync (false) c: callback (with ‘xhr’ as a parameter) d: post_data (the data to post) */ function tiny_ajax(m,u,a,c,d){with(new(this.XMLHttpRequest||ActiveXObject)(« Microsoft.XMLHTTP »))onreadystatechange=function(){readyState^4||c(this)},open(m,u,a),send(d)} And an example: tiny_ajax(‘get’, ‘http://www.google.com’, true, function(xhr) { alert(xhr.responseText) })
Tags: javascript, Niveau débutant, Programmation
3
Avr
If you use Firefox Portable in the same time as the regular Firefox, then it can be annoying to see the same icons for the both Firefox. You can easily change the icon for the main window of the portable version of Firefox. Just find the .ico you want to use and place it into […]
Tags: Astuce, Niveau débutant
26
Fév
With Sharepoint, when we want to upload a file, the « Add as a new version to existing file » is checked by default, and that could be an issue for you. Here is a JavaScript fix to add into your masterpage, just before the </head> tag : <script type= »text/javascript »> function DefaultUploadOverwriteOff() { if (document.title.indexOf(« Upload Document ») > […]
Tags: Niveau débutant, Programmation, sharepoint
17
Fév
Pour effectuer une requête MySQL qui ne sera pas sensible aux accents (par exemple ‘ö’ = ‘o’ ou ‘à’ = ‘a’) il faut rajouter le mot clé COLLATE avec la bonne collection. Après plusieurs tests, j’utilise la collection utf8_general_ci. Ce qui donnera : SELECT ID, Nom FROM Inscrits WHERE Nom LIKE ‘%heracles%’ COLLATE utf8_general_ci ORDER […]
Tags: mysql, Niveau débutant, Programmation
10
Fév
Windows 8 apporte différentes nouveautés, dont dans l’explorateur. Malheureusement ces modifications ne sont pas toujours les bienvenues… Par exemple le volet de détails apparait désormais à droite et non plus en bas de la fenêtre, ce qui n’est pas pratique et mange de la place. Heureusement il existe un moyen de la déplacer vers le […]
Tags: Astuce, Niveau débutant, Windows
28
Jan
La loi a changé concernant les cookies déposés chez les utilisateurs. Pour cela la CNIL a créé une page qui explique ce qu’il en est. Ils proposent même un bout de code pour le opt-in et le opt-out, que j’ai légèrement modifié : // Remplacez la valeur UA-XXXXXX-Y par l’identifiant analytics de votre site. var […]
Tags: javascript, Niveau débutant, Programmation