public static void AddUISettingsToDom(HtmlDom pageDom, CollectionSettings collectionSettings, IFileLocator fileLocator)
{
CheckDynamicStrings();
XmlElement existingElement = pageDom.RawDom.SelectSingleNode("//script[@id='ui-settings']") as XmlElement;
XmlElement element = pageDom.RawDom.CreateElement("script");
element.SetAttribute("type", "text/javascript");
element.SetAttribute("id", "ui-settings");
var d = new Dictionary<string, string>();
//d.Add("urlOfUIFiles", "file:///" + fileLocator.LocateDirectory("ui", "ui files directory"));
if (!String.IsNullOrEmpty(Settings.Default.LastSourceLanguageViewed))
{
d.Add("defaultSourceLanguage", Settings.Default.LastSourceLanguageViewed);
}
d.Add("languageForNewTextBoxes", collectionSettings.Language1Iso639Code);
d.Add("isSourceCollection", collectionSettings.IsSourceCollection.ToString());
// BL-2357 To aid in smart ordering of source languages in source bubble
if (!String.IsNullOrEmpty(collectionSettings.Language2Iso639Code))
{
d.Add("currentCollectionLanguage2", collectionSettings.Language2Iso639Code);
}
if (!String.IsNullOrEmpty(collectionSettings.Language3Iso639Code))
{
d.Add("currentCollectionLanguage3", collectionSettings.Language3Iso639Code);
}
d.Add("browserRoot", FileLocator.GetDirectoryDistributedWithApplication(BloomFileLocator.BrowserRoot).ToLocalhost());
element.InnerText = String.Format("function GetSettings() {{ return {0};}}", JsonConvert.SerializeObject(d));
var head = pageDom.RawDom.SelectSingleNode("//head");
if (existingElement != null)
head.ReplaceChild(element, existingElement);
else
head.InsertAfter(element, head.LastChild);
_collectDynamicStrings = false;
}