Welcome Guest, Not a member yet? Register   Sign In
jTable plugin Disallow Key Character
#1

[eluser]Vadorequest[/eluser]
Hi.

I use a jTable plugin (jQuery).
jTable

For manage cookies, it use a '#' for name this cookie. But with CodeIgniter, it's can works !

Because the # is refused in cookie name.

So, the must solution is to update the jTable script.

It's very easy:
Code:
/* Generates a hash key to be prefix for all cookies for this jtable instance.
        *************************************************************************/
        _generateCookieKeyPrefix: function () {

            var simpleHash = function (value) {
                var hash = 0;
                if (value.length == 0) {
                    return hash;
                }

                for (var i = 0; i < value.length; i++) {
                    var ch = value.charCodeAt(i);
                    hash = ((hash << 5) - hash) + ch;
                    hash = hash & hash;
                }

                return hash;
            };

            var strToHash = '';
            if (this.options.tableId) {
                strToHash = strToHash + this.options.tableId + '_';// Update by Vadorequest
            }

            strToHash = strToHash + this._columnList.join('$') + '#c' + this._$table.find('thead th').length;
            return 'jtable_' + simpleHash(strToHash);// Update by Vadorequest
        }

    });

I have replace # by _

If you need the minify code:

Code:
_generateCookieKeyPrefix:function(){var a="";this.options.tableId&&(a=a+this.options.tableId+"_");a=a+this._columnList.join("$")+"#c"+this._$table.find("thead th").length;var b=0;if(a.length!=0)for(var c=0;c<a.length;c++)var d=a.charCodeAt(c),b=(b<<5)-b+
d,b=b&b;return"jtable_"+b}})})(jQuery);

Before that, I've try to update the CI function who check cookie name, but, it's impossible (I think) to authorized a # in name because it's usefull for delimited regex ! I can't be escape...

My solution works. I mail the developper of the library for explain the problem, maybe he will update her library.
#2

[eluser]Unknown[/eluser]
Thank you very much

I have spent 2 days to find this solution.

You are my savior Big Grin




Theme © iAndrew 2016 - Forum software by © MyBB