Created
August 31, 2016 11:05
-
-
Save splinter/4d9280284c65c846122c49da30777bb1 to your computer and use it in GitHub Desktop.
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
jsonFormatter: function (page) { | |
if (page.meta.pageName === 'details') { | |
var contacts = page.assets.attributes.contacts_entry; | |
if (contacts) { | |
var contacts_entry = []; | |
if (contacts.constructor === Array) { | |
for (var index in contacts) { | |
var contact = contacts[index].split(':'); | |
var contact_entry = {}; | |
contact_entry.name = contact[0]; | |
contact_entry.value = contact[1]; | |
contacts_entry.push(contact_entry); | |
} | |
} else { | |
var contact = contacts.split(':'); | |
var contact_entry = {}; | |
contact_entry.name = contact[0]; | |
contact_entry.value = contact[1]; | |
contacts_entry.push(contact_entry); | |
} | |
page.assets.attributes.contacts_entry = contacts_entry; | |
} | |
var endpoints = page.assets.attributes.endpoints_entry; | |
if (endpoints) { | |
var endpoints_entry = []; | |
if (endpoints.constructor === Array) { | |
for (var index in endpoints) { | |
var splitIndex = endpoints[index].indexOf(':'); | |
var endpoint = [endpoints[index].slice(0, splitIndex), endpoints[index].slice(splitIndex + 1)]; | |
var endpoint_entry = {}; | |
endpoint_entry.name = endpoint[0]; | |
endpoint_entry.value = endpoint[1]; | |
endpoints_entry.push(endpoint_entry); | |
} | |
} else { | |
var splitIndex = endpoints.indexOf(':'); | |
var endpoint = [endpoints.slice(0, splitIndex), endpoints.slice(splitIndex + 1)]; | |
var endpoint_entry = {}; | |
endpoint_entry.name = endpoint[0]; | |
endpoint_entry.value = endpoint[1]; | |
endpoints_entry.push(endpoint_entry); | |
} | |
page.assets.attributes.endpoints_entry = endpoints_entry; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment