Snazzy Map to Google Static Map

A tool for my answer at http://stackoverflow.com/a/23154011/128165 simple converter for snazzymap json to Google Static Map Styles

HTML

<input type="text" id="map-url" placeholder="URL of unstyled static map" /><br/>
<em><strong>example: </strong><span>http://maps.googleapis.com/maps/api/staticmap?sensor=false&amp;size=512x512&amp;zoom=15&amp;center=Chicago</span></em><br/>
<textarea id="map-style" placeholder="Copy/Paste the snazzymap JSON in here"></textarea><br/>
<button>Convert to Static Map</button>
<hr/>
<div id="map">
    <img/>
</div>
<div id="final-url"></div>

CSS

#map-url{width:400px;}
#map-style{
    width:400px;
    height:300px;
}
#map{border:1px solid #000;padding:3px;margin:10px;display:inline-block;min-width:200px;min-height:200px;}
#map img{display:block;}

JavaScript

var StaticParams = (function(){
    var _items = [],
        separator = '|',
        _parameters = '';
    
    function isColor(value){return /^#[0-9a-f]{6}$/i.test(value.toString());}
    function toColor(value){return '0x' + value.slice(1);}
    function parse(jsonString){
        var json;
        try {
            json = JSON.parse(jsonString);
        } catch (e){
            return;
        }
           
            
        
        _items.length = 0;
        
        for (var i = 0; i < json.length; i++){
            var item = json[i],
                hasFeature = item.hasOwnProperty('featureType'),
                hasElement = item.hasOwnProperty('elementType'),
                stylers = item.stylers,
                target = '',
                style = '';
            
            if (!hasFeature && !hasElement){
                target = 'feature:all';
            } else {
                if (hasFeature){
                    target = 'feature:' + item.featureType;
                }
                if (hasElement){
                    target = target ? target + separator : '';
                    target += 'element:' + item.elementType;
                }
            }
            
            for (var s = 0; s< stylers.length; s++){
                var styleItem = stylers[s],
                    key = Object.keys(styleItem)[0]; // there is only one per element
                
                style = style ? style + separator : '';
                style += key + ':' + (isColor(styleItem[key]) ? toColor(styleItem[key]) : styleItem[key]);
            }
            
            _items.push(target + separator + style);
        }
    }
    
    return {
        get: function(){return '&style=' + _items.join('&style=');},
        parse: parse
    }
})();


$(function(){
    var mapImg = $('#map img'),
        url = $('#map-url'),
        json = $('#map-style'),
        finalUrl = $('#final-url');
    
    $('button').on('click', function(e){
       ...