Created
August 30, 2016 23:49
-
-
Save tstachl/dc80c08e4136a3c1fae6b860be856b92 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
<!doctype html> | |
<html> | |
<head> | |
<script src="//ajax.deskapi.com/libs/desk/opencti/current/interaction.min.js"></script> | |
<script> | |
(function() { | |
desk.ready(function() { | |
var form = document.querySelector('form') | |
, text = document.querySelector('input') | |
function handlePopResponse(response) { | |
if (response.result) { | |
alert('screenPop successful.'); | |
} else { | |
alert('screenPop failed.' + error.message); | |
} | |
} | |
function popCase(response) { | |
// some error handling here | |
if (response.status === 200) { | |
// screen pop the case you found | |
desk.interaction.screenPop( | |
response.data.entries[0].id, | |
'object=case', | |
handlePopResponse | |
); | |
} | |
} | |
function search(string, callback) { | |
// you need to make sure to normalize and url encode the query | |
// string yourself here. | |
desk.interaction.ajax('/api/v2/cases/search?q=' + string, { | |
method: 'GET' | |
}, callback); | |
} | |
function submit(evt) { | |
evt.preventDefault(); | |
search(text.value, popCase); | |
} | |
// add the handler | |
form.addEventListener('submit', submit, false); | |
// show the form when everything is loaded | |
form.style.display = ''; | |
}); | |
}()); | |
</script> | |
</head> | |
<body> | |
<form style="display: none;"> | |
<input type="text"> | |
<button type="submit">Custom Search</button> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment