2019-05-22 01:22:58 +00:00
|
|
|
// Search button function
|
|
|
|
const searchClick = document.getElementById('searchClick')
|
|
|
|
searchClick.onclick = function() {
|
|
|
|
window.open('https://gitlab.com/search?utf8=%E2%9C%93&search=' +
|
|
|
|
document.getElementById('searchTxt').value +
|
|
|
|
'&group_id=&project_id=8306723&search_code=true&repository_ref=master')
|
|
|
|
}
|
2018-09-29 09:07:34 +00:00
|
|
|
|
2019-05-22 01:22:58 +00:00
|
|
|
// Add "Copy" button to code snippet
|
|
|
|
const code = document.getElementsByClassName('code')
|
2018-09-29 09:07:34 +00:00
|
|
|
|
2019-05-22 01:22:58 +00:00
|
|
|
for (let i = 0; i < code.length; i++) {
|
|
|
|
const button = document.createElement('button')
|
|
|
|
button.className = 'copy-button'
|
|
|
|
button.textContent = 'Copy'
|
2018-09-27 08:54:10 +00:00
|
|
|
|
2019-05-22 01:22:58 +00:00
|
|
|
code[i].appendChild(button)
|
|
|
|
}
|
2018-09-29 09:07:34 +00:00
|
|
|
|
2019-05-22 01:22:58 +00:00
|
|
|
/*
|
|
|
|
* Copy button and Cloudinary functions.
|
|
|
|
* Following functions only execute after
|
|
|
|
* the 'document' is ready or
|
|
|
|
* <script src> is executed.
|
|
|
|
*/
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
// Copy button
|
|
|
|
const copyCode = new ClipboardJS('.copy-button', {
|
|
|
|
target: (trigger) => {
|
|
|
|
return trigger.previousElementSibling
|
|
|
|
}
|
|
|
|
})
|
2019-05-21 01:19:30 +00:00
|
|
|
|
2019-05-22 01:22:58 +00:00
|
|
|
copyCode.on('success', (event) => {
|
|
|
|
event.clearSelection()
|
|
|
|
event.trigger.textContent = 'Copied'
|
|
|
|
window.setTimeout(() => {
|
|
|
|
event.trigger.textContent = 'Copy'
|
|
|
|
}, 2000)
|
2018-10-25 09:03:38 +00:00
|
|
|
})
|
2019-05-21 04:42:30 +00:00
|
|
|
|
2019-05-22 01:22:58 +00:00
|
|
|
copyCode.on('error', (event) => {
|
|
|
|
event.trigger.textContent = 'Press "Ctrl + C" to copy'
|
|
|
|
window.setTimeout(() => {
|
|
|
|
event.trigger.textContent = 'Copy'
|
|
|
|
}, 2000)
|
|
|
|
})
|
|
|
|
|
|
|
|
// Initialize Cloudinary responsive function
|
|
|
|
const cl = cloudinary.Cloudinary.new({ cloud_name: 'curben' })
|
|
|
|
cl.responsive()
|
|
|
|
}, false);
|