Skip to content

Instantly share code, notes, and snippets.

@chrismrgn

chrismrgn/OpenSchema.js

Last active Aug 29, 2015
Embed
What would you like to do?
OpenSchema.js
javascript: (function (UI, B, e, a, r, d)
{
if ( typeof String.prototype.endsWith != 'function' ) {
String.prototype.endsWith = function( str ) {
return this.substring( this.length - str.length, this.length ) === str;
}
};
try
{
while (r = UI.frames[e++])
{
if ((a = r.$display && r.$display.getView()) && a.getId() == B)
{
d = a;
break;
}
}
var m1 = window.top.frames[1];
var itemId = d.getMainInterface().getListSelection().getVersionlessIds()[0];
var item = m1.$models.getItem(itemId);
if(item.getTypeName().endsWith('Component'))
{
console.log('Got a Component');
var schema = item.getSchema();
schema.load();
setTimeout(function(){
var schemaTCM = item.getSchemaId();
var schemaTCMArray = schemaTCM.split('-');
var parentPublicationTCM = schema.getOwningPublicationId();
var parentPublicationTCMArray = parentPublicationTCM.split('-');
var parentPublicationId = parentPublicationTCMArray[1];
schemaTCMArray[0] = 'tcm:'+parentPublicationId;
var parentSchemaId = schemaTCMArray.join('-');
var win = window.open('/WebUI/item.aspx?tcm=8#id='+parentSchemaId, '_blank');
win.focus();
}, 500);
}
else
{
alert('Only works on Components');
}
}
catch (x) {alert(x);};
})(window.top, 'DashboardView', 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment