Created
October 14, 2021 23:06
-
-
Save arturmkrtchyan/6e6b710f7eeec072dd1ead73afbf3aa5 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
<script> | |
/** this needs to be changed if block ids get changed score fields get changed **/ | |
const blockMapping = { | |
'list-details7': { | |
'field1' : 'F.O.R. Score', | |
'field2' : 'Status FOR' | |
}, | |
'list-details6': { | |
'field1' : 'High Score 4', | |
'field2' : 'Test 4 Status' | |
}, | |
'list-details3': { | |
'field1' : 'High Score 3', | |
'field2' : 'Test 3 Status' | |
}, | |
'list-details2': { | |
'field1' : 'High Score 2', | |
'field2' : 'Test 2 Status' | |
}, | |
'list-details1': { | |
'field1' : 'High Score 1', | |
'field2' : 'Test 1 Status' | |
} | |
} | |
const recordId = getUrlParam('recordId'); | |
let intervalLimit = 100; | |
const recordInterval = setInterval(function(){ | |
if(window.records[recordId] && window.records[recordId].record) { | |
let record = window.records[recordId].record; | |
clearInterval(recordInterval); | |
Object.keys(blockMapping).forEach(function(key) { | |
if(!record.fields[blockMapping[key]['field1']] && !record.fields[blockMapping[key]['field2']]) { | |
$('#' + key).addClass('d-none'); | |
} | |
}); | |
} | |
intervalLimit--; | |
if(intervalLimit == 0) { | |
clearInterval(recordInterval); | |
} | |
}, 200); | |
function getUrlParam(name) { | |
const url = new URL(window.location.href); | |
let param; | |
for(var key of url.searchParams.keys()) { | |
if(key.toLowerCase() === name.toLowerCase()) { | |
param = url.searchParams.get(name); | |
break; | |
} | |
} | |
if(!param && name.toLowerCase() === 'recordid') { | |
param = getRecordIdFromPath(); | |
} | |
return param; | |
} | |
function getRecordIdFromPath() { | |
let pathName = window.location.pathname; | |
if (pathName.indexOf('/r/rec') !== -1) { | |
pathName = pathName.substr(pathName.indexOf('/r/rec') + 3); | |
if (pathName.indexOf("/") !== -1) { | |
pathName = pathName(0, pathName.indexOf('/')) | |
} | |
return pathName; | |
} | |
return undefined; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment