Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark remarkablemark

View GitHub Profile
View drop.js
document
.querySelector('fieldset')
.addEventListener('drop', function onDrop(event) {
var tagName = event.dataTransfer.getData('text');
event.target.appendChild(document.querySelector(tagName));
event.preventDefault();
});
View drop.html
<fieldset ondrop="onDrop(event);"></fieldset>
<script>
function onDrop(event) {
var tagName = event.dataTransfer.getData('text');
event.target.appendChild(document.querySelector(tagName));
event.preventDefault();
}
</script>
View dragover.js
document
.querySelector('fieldset')
.addEventListener('dragover', function onDragOver(event) {
event.preventDefault();
});
View dragstart.js
document
.querySelector('input')
.addEventListener('dragstart', function onDragStart(event) {
event.dataTransfer.setData('text', event.target.tagName);
});
View dragstart.html
<input
draggable="true"
ondragstart="event.dataTransfer.setData('text', event.target.tagName);"
>
View package.json
{
"version": "1.2.3",
"scripts": {
"get-version": "awk -F'\"' '/\"version\": \".+\"/{ print $4; exit; }' package.json"
}
}
View package.json
{
"version": "1.2.3",
"scripts": {
"get-version": "node -p \"require('./package').version\""
}
}
View package.json
{
"version": "1.2.3",
"scripts": {
"get-version": "jq -r .version package.json"
}
}