using System; using System.Diagnostics; using System.IO; using System.Text; using System.Threading; using System.Web.UI; using Swarmops.Logic.Support; namespace Swarmops.Frontend.Controls.Meta { public partial class ExternalScripts : ControlV5Base { public string Package { get; set; } public new string Controls { get; set; } protected void Page_Load(object sender, EventArgs e) { string externalScriptUrl = "//hostedscripts.falkvinge.net"; string testFolderName = Server.MapPath("~/Scripts/ExternalScripts"); if (Directory.Exists(testFolderName)) { externalScriptUrl = "/Scripts/ExternalScripts"; } // If we're debugging a seriously experimental new version of JEasyUI, look for it in /Scripts/Experimental // (a folder which doesn't commit to the github repo) if (File.Exists(Server.MapPath("~/Scripts/Experimental/easyui/jquery.easyui.min.js"))) { externalScriptUrl = "/Scripts/Experimental"; } StringBuilder scriptRef = new StringBuilder(); switch (Package.ToLowerInvariant()) { case "easyui": scriptRef.Append("\r\n"); scriptRef.Append("\r\n"); scriptRef.Append("\r\n"); // Supposed to contain all CSS if (Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft) { scriptRef.Append("\r\n"); scriptRef.Append("\r\n"); } /* -- with the inclusion of the catchall CSS file, this code _should_ no longer be necessary... string[] controlNames = Controls.Split(','); foreach (string controlName in controlNames) { string controlNameLower = controlName.Trim().ToLowerInvariant(); if (controlNameLower != "unknown") { scriptRef.AppendFormat ( "\r\n", controlNameLower); } }*/ break; case "fancybox": scriptRef.Append("\r\n"); scriptRef.Append("\r\n"); // Supposed to contain all CSS // If we're including Fancybox, always also include Elevated Zoom, which isn't external scriptRef.Append( "\r\n"); break; default: throw new NotImplementedException("Unimplemented external script package"); } this.LiteralReference.Text = scriptRef.ToString(); } } }