if ( StructKeyExists(request,'params') ) attributes = request.params; if ( !structKeyExists(attributes, "updateExisting") OR !IsBoolean(attributes.updateExisting) ) attributes.updateExisting = false; // Default: False if ( !structKeyExists(attributes, "preserveAliases") OR !IsBoolean(attributes.preserveAliases) ) attributes.preserveAliases = true; // Default: True if ( structKeyExists(attributes, "outputScripts") AND IsBoolean(attributes.outputScripts) ) attributes.outputInstallScripts = attributes.outputScripts; if ( !structKeyExists(attributes, "outputInstallScripts") OR !IsBoolean(attributes.outputInstallScripts) ) attributes.outputInstallScripts = true; // loadingType=early to load all js resource early if ( !structKeyExists(attributes, "loadingType") OR attributes.loadingType NEQ "early" ) attributes.loadingType = "late"; // Options: early or late - Default: late // 'useLegacyEarlyJs=true' overrides 'loadingType=late' to be 'loadingType=early' if ( !structKeyExists(attributes, "useLegacyEarlyJs") OR !IsBoolean(attributes.useLegacyEarlyJs) ) attributes.useLegacyEarlyJs = false; // Options: true or false rData = []; /* *************************************************************************************************** */ /* *** Replace the rItem STRUCTURE below with the javascript and/or css resource definitions to be *** */ /* *** registered. Add an arrayAppend() after each struct block to add it to the rData Array. *** */ /* *************************************************************************************************** */ // Date-fns 3.3 resource rItem = {}; rItem.name = "Date-fns 3.3"; rItem.aliasList = "date-fns,date-fns_3,date-fns_3_3"; rItem.category = "SECONDARY"; rItem.groups = ["current","date","date-time","date-fns"]; rItem.source = { local = { css = [], js = [ { canminify=0, sourceurl="/ADF/thirdParty/js/date-fns/3.3/date-fns.min.js", iscritical=0, cancombine=0 } ] }, external = { css = [], js = [ { canminify=0, sourceurl="https://cdn.jsdelivr.net/npm/date-fns@3.6.0/cdn.min.js", iscritical=0, cancombine=0 } ] } }; rItem.description = "Date-fns resources."; rItem.installInstructions = "Included in ADF 2.7 and later."; rItem.redistributable = 0; rItem.update = 0; rItem.silent = 0; rItem.key = application.ADF.resourceService.buildResourceKey(str=rItem.name); rItem.legacyLoadJsEarly = 0; rItem.id = 1162; ArrayAppend(rData, rItem); scriptsArr = application.ADF.resourceService.buildRegisterScriptsArr(dataArr=rData,source="local"); if ( attributes.outputInstallScripts ) WriteOutput("
");

   for ( i=1; i <= ArrayLen(scriptsArr); i++ ) {
      regData = scriptsArr[i];

      legacyLoadJSEarlyDefault = 0;
		cssProps = [];
		jsProps = [];

		// CSS: {LoadTagType=1, SourceURL="/style/style.css", canCombine=1, canMinify=0, isCritical=0, Integrity="", Crossorigin="" }
      // JS: {LoadTagType=2, SourceURL="/js/plugins.js", canCombine=1, canMinify=0, isCritical=0, Integrity="", Crossorigin="" }

		// Get the Default values from the resource data
		if ( StructKeyExists(regData,"legacyLoadJsEarly") )
			legacyLoadJSEarlyDefault = regData.legacyLoadJsEarly;

		if ( StructKeyExists(regData,"cssSourceArray") )
			cssProps = regData.cssSourceArray;
		if ( StructKeyExists(regData,"jsSourceArray") )
			jsProps = regData.jsSourceArray;

		// If enabled, use the legacyLoadJSEarlyDefault
		jsLoadEarly = attributes.useLegacyEarlyJs ? legacyLoadJSEarlyDefault : 0;

		// Set the Early and Late Properties
		propsEarly = [];
		propsLate = [];

		if ( ArrayLen(cssProps) )
			propsEarly = cssProps;

		if ( ArrayLen(jsProps) )
		{
			if ( jsLoadEarly OR attributes.loadingType EQ "early" )
				ArrayAppend(propsEarly,jsProps,true);
			else
				propsLate = jsProps;
		}

      if ( attributes.outputInstallScripts )
      {
         WriteOutput(
               'application.ADF.scriptsService.registerResource(
                  name = "#rItem.name#",
                  category = "#rItem.category#",
                  earlyLoadSourceArray = #SerializeJSON(propsEarly)#,
                  lateLoadSourceArray = #SerializeJSON(propsLate)#,
                  description = "#rItem.description#",
                  installInstructions = "#rItem.installInstructions#",
                  aliasList = "#rItem.aliasList#",
                  redistributable = #rItem.redistributable#,
                  updateExisting = #attributes.updateExisting#,
                  silent = #rItem.silent#,
                  preserveAliases = #attributes.preserveAliases#
               );'
            );
            WriteOutput("

"); } application.ADF.scriptsService.registerResource( "#rItem.name#", "#rItem.category#", propsEarly, propsLate, "#rItem.description#", "#rItem.installInstructions#", "#rItem.aliasList#" ,rItem.redistributable, attributes.updateExisting, rItem.silent ,attributes.preserveAliases ); } // END - scriptArr Loop if ( attributes.outputInstallScripts ) WriteOutput("
");