mardi 1 novembre 2016

Split JS code into separated include files

I have a blade file containing a script tag loaded with JS code

<script type="text/javascript">


var $gd = ;
var $gu = ;

    var guest_pc = new FusionCharts({
            "type": "pie2d",
            "renderAt": "guest-pc",
            "width": "100%",
            "dataFormat": "json",
            "dataSource": {
                "chart": {
                    "caption": "Guest",
                    "paletteColors": color_guest_down+','+color_guest_up,


                    //------- CUT 



                    "bgColor": "#fcfcfc",
                    "showBorder": "0",
                    "use3DLighting": "0",
                    "showShadow": "0",
                    "enableSmartLabels": "1",
                    "startingAngle": "90",
                    "showLabels": "0",
                    "showPercentValues": "0",
                    "showLegend": "1",
                    "legendShadow": "0",
                    "legendBorderAlpha": "0",
                    "captionFontSize": "14",
                    "subcaptionFontSize": "14",
                    "baseFont": "Roboto",
                    "baseFontColor": "#333333",
                    "decimals": "2",
                    "subcaptionFontBold": "0",
                    "toolTipColor": "#ffffff",
                    "toolTipBorderThickness": "0",
                    "toolTipBgColor": "#000000",
                    "toolTipBgAlpha": "80",
                    "toolTipBorderRadius": "2",
                    "toolTipPadding": "5",
                    "useDataPlotColorForLabels": "1",
                    "chartTopMargin": "0",
                    "chartBottomMargin": "0",
                    "pieYScale": 60,
                    "formatNumberScale" : "1",
                    "numberScaleValue": "1024,1024,1024,1024",
                    "numberScaleUnit" : "KB, MB, GB, TB",
                    "defaultNumberScale" : " B",
                    "scaleRecursively":"0",
                    "showValues": "0",


                    //------- CUT 





                },
                "data": [{
                    "label": "Downlink",
                    "value": '',
                    "displayValue" : $gd + ' '

                }, {
                    "label": "Uplink",
                    "value": '',
                    "displayValue" : $gu +  ' '

                }]
            }
        });

</script>


If I want to cut out this piece out

//------- CUT 



"bgColor": "#fcfcfc",
"showBorder": "0",
"use3DLighting": "0",
"showShadow": "0",
"enableSmartLabels": "1",
"startingAngle": "90",
"showLabels": "0",
"showPercentValues": "0",
"showLegend": "1",
"legendShadow": "0",
"legendBorderAlpha": "0",
"captionFontSize": "14",
"subcaptionFontSize": "14",
"baseFont": "Roboto",
"baseFontColor": "#333333",
"decimals": "2",
"subcaptionFontBold": "0",
"toolTipColor": "#ffffff",
"toolTipBorderThickness": "0",
"toolTipBgColor": "#000000",
"toolTipBgAlpha": "80",
"toolTipBorderRadius": "2",
"toolTipPadding": "5",
"useDataPlotColorForLabels": "1",
"chartTopMargin": "0",
"chartBottomMargin": "0",
"pieYScale": 60,
"formatNumberScale" : "1",
"numberScaleValue": "1024,1024,1024,1024",
"numberScaleUnit" : "KB, MB, GB, TB",
"defaultNumberScale" : " B",
"scaleRecursively":"0",
"showValues": "0",


//------- CUT 

and include it back in multiple files -only- that part.


Is this something that can be achievable via JS / blade / PHP ?

How would one go about and implement this ?


I'm opening to any suggestions at this moment.

Any hints / suggestions / helps on this be will be much appreciated !



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire