Friday, September 28, 2012

JQuery in place editing with autocomplete (with dummy data)

Pick the corresponding libraries from here : 

Then edit the file named : jquery.editinplace.js like this ; 

(Modify) createEditorElement: function() {
if (-1 === $.inArray(this.settings.field_type, ['autocomplete','text', 'textarea', 'select']))
throw "Unknown field_type <fnord>, supported are 'text', 'autocomplete','textarea' and 'select'";
var editor = null;
if ("select" === this.settings.field_type)
editor = this.createSelectEditor();
else if ("autocomplete" === this.settings.field_type)
editor = this.createAutoCompleteEditor();
else if ("text" === this.settings.field_type)
editor = $('<input type="text" ' + this.inputNameAndClass() 
+ ' size="' + this.settings.text_size  + '" />');
else if ("textarea" === this.settings.field_type)
editor = $('<textarea ' + this.inputNameAndClass() 
+ ' rows="' + this.settings.textarea_rows + '" '
+ ' cols="' + this.settings.textarea_cols + '" />');
return editor;
},

(Add) createAutoCompleteEditor: function() {
var editor = $("<input "+this.inputNameAndClass()+" type=\"text\"/>");
   editor.autocomplete({
        minChars: 1,data: [
            ['apple', 1],
            ['apricot', 2],
            ['pear', 3],
            ['prume', 4],
            ['Doyenné du Comice', 5]
        ]
    });
return editor;
},

Now, modify the dummy data with real data and specify field_type as autocomplete when creating an inPlaceEdit element.

Monday, September 10, 2012

Websockets deployment on a dedicated server

I was able to test a websockets based application perfectly on my localhost but when I tried to deploy it on the production server there were problems.

Here is what I did : 

1. Edit the file : /etc/sysconfig/iptables
and add this line : 
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8123 -j ACCEPT
assuming that you want to run your websocket server on port 8123.

2. service iptables restart

3. When you start your websocket server, start it on 0.0.0.0. It will ensure that it's open to connection on all interfaces - be it LAN or external IPs.

4. To test whether it's accepting connection on the above port, do telnet IP Port. If it's successful then you can proceed with your websocket related stuff.

Blog Archive