From a1982e9b85ea51dec80278ee0582c3b5923da2f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alan=20P=C5=82=C3=B3cieniak?= Date: Thu, 19 May 2016 22:13:44 +0200 Subject: [PATCH] #12 | Missing database name in EE --- app/scripts.ts/sc_ext.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/scripts.ts/sc_ext.ts b/app/scripts.ts/sc_ext.ts index c6ed6a3..284999d 100644 --- a/app/scripts.ts/sc_ext.ts +++ b/app/scripts.ts/sc_ext.ts @@ -802,6 +802,19 @@ namespace SitecoreExtensions { if (pageMode == Location.Desktop) { return (document.querySelector('.scDatabaseName') as HTMLDivElement).innerText; } + if (pageMode == Location.ExperienceEditor) { + var webEditRibbonIFrame = (document.querySelector('#scWebEditRibbon') as HTMLIFrameElement) + if (webEditRibbonIFrame != null) { + var src = webEditRibbonIFrame.src + var start = src.indexOf("database="); + var end = src.indexOf("&", start); + return src.slice(start + 9, end) + } + var peBar = document.querySelector('[data-sc-id=PageEditBar]'); + if (peBar != null) { + return peBar.attributes['data-sc-database'].value + } + } else { var contendDb = document.querySelector('[data-sc-name=sitecoreContentDatabase]') if (contendDb != null) { @@ -828,7 +841,7 @@ namespace SitecoreExtensions { if (document.querySelector('input#__FRAMENAME') !== null) { return Location.Desktop; } - if (document.querySelector('#scWebEditRibbon') !== null) { + if (document.querySelector('#scWebEditRibbon') !== null || document.querySelector('[data-sc-id=PageEditBar]') != null) { return Location.ExperienceEditor; } return Location.Unknown;