Last active
December 21, 2015 18:38
-
-
Save cowsrule/6348393 to your computer and use it in GitHub Desktop.
Inspect Remote
This file contains 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
window.log = console.log.bind(console); | |
window.inspectRemote = function(input) | |
{ | |
if (!input) | |
{ | |
log('Must specify either an item ID or item object to inspect'); | |
return; | |
} | |
if (!window.remoteDoc) | |
{ | |
log('Must have a remote doc loaded to inspect an item'); | |
return; | |
} | |
var lookupTable = window.remoteDoc.b.b.a.e.H.n;; | |
var item = input; | |
if ((typeof input) == "string") | |
{ | |
item = lookupTable[':' + input]; | |
} | |
var type = item.Ib; | |
log('---- Inspecting Item:', item.L, '----'); | |
log(' Type: ', type); | |
// log(' Collaborative Children: [', item.v.i, ']'); | |
// var collabKeys = Object.keys(item.v.o); | |
// for (var i = 0; i < collabKeys.length; ++i) | |
// { | |
// var keyValue = item.v.o[collabKeys[i]]; | |
// log(' [', collabKeys[i].substring(1), ']: ', keyValue); | |
// } | |
if (type === "Map") | |
{ | |
log(' Properties: [', item.f.i, ']'); | |
var nonCollabKeys = Object.keys(item.f.n); | |
for (var i = 0; i < nonCollabKeys.length; ++i) | |
{ | |
var ncKey = nonCollabKeys[i].substring(1); | |
var keyValue = item.f.n[':' + ncKey]; | |
var keyType = (keyValue.Ib ? keyValue.Ib : undefined); | |
if (keyType === "EditableString") | |
{ | |
log(' [', ncKey, '- \"' + keyValue.L +'\"]: ', keyValue.e.a.a); | |
} | |
else if (keyType === "List") | |
{ | |
log(' [', ncKey, '- \"' + keyValue.L +'\"]: ', keyValue); | |
for (var j = 0; j < keyValue.f.a.length; ++j) | |
{ | |
var child = keyValue.f.a[j]; | |
log(' [', j, ']: ', child.a); | |
} | |
} | |
else | |
{ | |
var displayValue = keyValue.a; | |
log(' [', ncKey, ']: ', displayValue); | |
} | |
} | |
} | |
else if (type === "List") | |
{ | |
log(' Children: [', item.f.e, ']'); | |
for (var i = 0; i < item.f.a.length; ++i) | |
{ | |
var child = item.f.a[i]; | |
log(' [', i, ']: ', child); | |
} | |
} | |
else if (type === "EditableString") | |
{ | |
log(' Value: ', item.e.a.a); | |
} | |
log('--------------------------------------------'); | |
return item; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment