1. #1
    Ext User tonextone's Avatar
    Join Date
    Apr 2008
    Location
    tokyo
    Posts
    2
    Vote Rating
    0
    tonextone is on a distinguished road

      0  

    Default Ext.ux.state.LocationHashProvider

    Ext.ux.state.LocationHashProvider


    I created a simple custom state.Provider which saves state into location.hash.

    You will get the 'stateful' URL with location.hash, for example

    http://yourhost.com/path/to/app#(state data encoded)
    You can save it as bookmark, email it to your friend, or whatever you want.

    # Yes, I am not sure this naming 'state.Provider' is suitable, but anyway it may be useful for some case.

    PHP Code:
    /**
     * Ext.ux.state.LocationHashProvider which saves state into location.hash .
     *
     * @author    master@tonextone.com
     * @copyright (c) 2008, by master@tonextone.com .
     * @date      23 April 2008
     *
     * @license   http://www.opensource.org/licenses/bsd-license.php The BSD License
     */

    Ext.namespace("Ext.ux.state");

    /**
     * @class Ext.ux.state.LocationHashProvider
     * @extends Ext.state.Provider
     * Our custom Provider implementation which saves state into location.hash.
     * <br />Usage:
     <pre><code>
       Ext.state.Manager.setProvider(new Ext.ux.state.LocationHashProvider({}));
     </code></pre>
     * @constructor Create a new LocationHashProvider
     * @param {Object} config The configuration object
     */

    Ext.ux.state.LocationHashProvider = function(config){
        
    Ext.ux.state.LocationHashProvider.superclass.constructor.apply(thisarguments);
        
    Ext.apply(thisconfig);
        
    this.state this.getState();
    };

    Ext.extend(Ext.ux.state.LocationHashProviderExt.state.Provider, {
        
        
    // public
        
    set: function(namevalue){
            if(
    typeof value == "undefined" || value === null){
                
    this.clear(name);
                return;
            }
            
    this.addToLocationHash(namevalue);
            
    Ext.ux.state.LocationHashProvider.superclass.set.apply(thisarguments);
        },
        
        
    // public
        
    clear: function(name){
            
    this.removeFromLocationHash(name);
            
    Ext.ux.state.LocationHashProvider.superclass.clear.apply(thisarguments);
        },
        
        
    // private
        
    getState: function(){
            var 
    locationHash document.location.hash.replace(/^#/, '');
            
    if (!locationHash) return {};
            var 
    state Ext.decode(decodeURI(locationHash));
            return 
    state state : {};
        },
        
        
    // private
        
    addToLocationHash: function(namevalue){
            var 
    state this.getState();
            
    state[name] = value;
            
    document.location.hash encodeURI(Ext.encode(state));
        },
        
        
    // private
        
    removeFromLocationHash: function(name){
            var 
    state this.getState();
            
    delete state[name];
            
    document.location.hash encodeURI(Ext.encode(state));
        }
        
    }); 

  2. #2
    Sencha - Training Team mrsunshine's Avatar
    Join Date
    Sep 2008
    Location
    Germany - Darmstadt
    Posts
    691
    Vote Rating
    12
    mrsunshine will become famous soon enough

      0  

    Thumbs up


    Nice work , Thank you

    one question:
    why do you use the JavaScript Function
    PHP Code:
    encodeURI() 
    instead of
    PHP Code:
    Ext.urlEncode() 
    regards
    nils

  3. #3
    Ext User tonextone's Avatar
    Join Date
    Apr 2008
    Location
    tokyo
    Posts
    2
    Vote Rating
    0
    tonextone is on a distinguished road

      0  

    Default


    nils,
    thank you for your interest.

    As for Ext.urlEncode(), it is totally different from encodeURI().

    Ext.urlEncode() is something like "Object.toQueryString()".
    while encodeURI() is exactly for URI-encoding.

    http://en.wikipedia.org/wiki/Percent-encoding

    regards,
    tonextone

  4. #4
    Sencha User smartree's Avatar
    Join Date
    Jul 2008
    Location
    China
    Posts
    16
    Vote Rating
    0
    smartree is on a distinguished road

      0  

    Default


    Why not save it to Server.

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi