Category Archives: javascript

load css with javascript

Following javascript function loads css file if it’s not already loaded

javascript : scroll window or container to view element

prototypsjs framework is used for that.

– scroll container to view element inside : scrollTo(myElement, divContainer);
– scroll window to view element inside : scrollTo(myElement, null);

list html page elements not having id

Icefaces ajax render performances issues could be sequence of dom elements without id. The present post helps to list all elements not having id to be fixed.

Open your page in your browser.
In developer console create following function

then call chkid with any dom element. To get all, call chkid with body element

Nota : Here we use prototypejs framework

ajax displaying jboss server state

We aim to have web page which displays continually three jboss7 servers states.
For this we need the shell script ( to be found here.

environment requirement

    servers in same machine :
  • apache server
  • three jboss7 servers: jboss1, jboss2, jboss3

get result of in our php file

Following php code displays one jboss server state

For our example we need three php files containing the previous one line php code corresponding to each one of the three jboss server : state-jboss1.php, state-jboss2.php, and state-jboss3.php

ajax state display

We need here the load() method of jquery javascript framework.

continuous update of servers state

We’ll resort to javascript timer


    root folder :
  • create folder jboss-state in apache server root www
    files :
  • www/jboss-state/
  • www/jboss-state/index.html
  • www/jboss-state/state-jboss1.php
  • www/jboss-state/state-jboss2.php
  • www/jboss-state/state-jboss3.php

full code (myArtifactName string in code must be replaced by the right artifact name)





Use colsure (javascript code analyser)

First of all you must have easy_install python module : cf. get-easyinstall-python-module

Install closure linter :

Processing closure_linter-latest.tar.gz
Writing /tmp/easy_install-Xt6LOk/closure_linter-2.3.11/setup.cfg
Running closure_linter-2.3.11/ -q bdist_egg –dist-dir /tmp/easy_install-Xt6LOk/closure_linter-2.3.11/egg-dist-tmp-w7sS6l
zip_safe flag not set; analyzing archive contents…
Adding closure-linter 2.3.11 to easy-install.pth file
Installing fixjsstyle script to /usr/local/bin
Installing gjslint script to /usr/local/bin

Installed /usr/local/lib/python2.7/dist-packages/closure_linter-2.3.11-py2.7.egg
Processing dependencies for closure-linter==2.3.11
Searching for python-gflags
Best match: python-gflags 2.0
Processing python-gflags-2.0.tar.gz
Writing /tmp/easy_install-SlgYwJ/python-gflags-2.0/setup.cfg
Running python-gflags-2.0/ -q bdist_egg –dist-dir /tmp/easy_install-SlgYwJ/python-gflags-2.0/egg-dist-tmp-kTyloa
zip_safe flag not set; analyzing archive contents…
Adding python-gflags 2.0 to easy-install.pth file

Installed /usr/local/lib/python2.7/dist-packages/python_gflags-2.0-py2.7.egg
Finished processing dependencies for closure-linter==2.3.11

Once finished you can use closure linter as following :

Analyse one js script file :

Analyse entire directory :

more details here :


Utile pour les développeurs javascript. est une application Saas permettant :- d’éditer une application javascript et voir le résultat instantanément
– de choisir son framework js : Prototype, mootools, jquery … etc
– de lier des scripts externes
et plus d’autres fonctionnalités à découvrir

simple nodejs http server

================================================= 14/06/2013
simple nodejs http server:
– install nodejs
– create file server.js with following content:
var url = require(“url”);

function handleHttpRequest(request, response){
response.writeHead(200, {“Content-Type”: “text/html”});

var http = require(“http”);
– in command line: node /path/to/server.js
– go to http://localhost:8888
– go to http://localhost:8888/sevice?user=nour&age=42