Last active
November 11, 2018 15:19
-
-
Save theredpea/d08d5918a8c88889dfa26ad72dd17140 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function () { | |
//Served by rawgit: https://rawgit.com/ | |
//From https://gist.github.com/theredpea/d08d5918a8c88889dfa26ad72dd17140#file-adapting_showobjectids-js | |
//To https://cdn.rawgit.com/theredpea/d08d5918a8c88889dfa26ad72dd17140/raw/9b32a0d0ac9e1a9cc85005fcbf83e20275d99fd4/adapting_showObjectIds.js | |
document.body.appendChild(document.createElement('script')).src = 'https://rawgit.com/abodelot/jquery.json-viewer/master/json-viewer/jquery.json-viewer.js'; | |
var head = document.getElementsByTagName('head')[0]; | |
$(document.createElement('link')).attr({ | |
type: 'text/css', | |
href: 'https://rawgit.com/abodelot/jquery.json-viewer/master/json-viewer/jquery.json-viewer.css', | |
rel: 'stylesheet' | |
}).appendTo(head); | |
var getPopoverelement = function (content) { | |
var html = '<div class="popover-content" style="display: none;"> \ | |
<div class="meta-info lui-popover" style="height: 70%; width: 70%; top: 70px; left: 100px; z-index: 1000001; position: fixed"> \ | |
<div class="lui-popover__header"> \ | |
<div class="lui-popover__title"> \ | |
<button class="lui-button lui-popover__button_copy">Copy ObjectID</button> \ | |
</div> \ | |
</div> \ | |
<div class="meta-info-body lui-popover__body" style="overflow: scroll">' + content + '</div> \ | |
<div class="lui-popover__footer"> \ | |
<button class="lui-button lui-popover__button close-popover">Close</button> \ | |
</div> \ | |
</div> \ | |
</div> \ | |
</div>'; | |
return html; | |
}; | |
var getMeta = function (obj) { | |
var scope = angular.element(obj).scope(); | |
scope.model && scope.model.getProperties() | |
.then(function (properties) { | |
delete properties['qMetaDef']; | |
var propertiesJson = JSON.stringify(properties, null, 4); | |
$(".meta-info-body").jsonViewer(properties); | |
$('.lui-popover__button_copy').on('click', function (e) { | |
window.prompt("Copy ObjectID to clipboard:", properties.qInfo.qId); | |
}); | |
$('.popover-content').show(); | |
}); | |
$('.show-meta').remove(); | |
}; | |
$('body').append(getPopoverelement()); | |
$('.close-popover').on('click', function (e) { | |
$('.popover-content').remove(); | |
}); | |
var objects = $(".qv-object"); | |
objects.each(function (i, e) { | |
var button = $('<input style="z-index: 1000000; position: fixed; color: white; background-color: red; width:80px; height:40px;" class="show-meta" />'); | |
var tid_attr = $(e).closest('.cell[tid]').attr('tid') | |
button.css($(e).offset()); | |
button.val(tid_attr) | |
button.on('click', function () { | |
getMeta(e); | |
}); | |
$('body').append(button); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment