Skip to content

Instantly share code, notes, and snippets.

@dtinth
Created December 6, 2015 08:16
Show Gist options
  • Save dtinth/8c0a927cd4a0368cf5e2 to your computer and use it in GitHub Desktop.
Save dtinth/8c0a927cd4a0368cf5e2 to your computer and use it in GitHub Desktop.
function renote () {
var text = clipboard.readText()
var lines = text.trim().split(/\r\n|\r|\n/).slice(1)
var out = ['iBMSC Clipboard Data xNT']
var nextColumn = 5
var columns = { }
var moved = 0
var items = document.querySelector('#input').value
var COLUMN_MAP = {
a: 12,
z: 5,
s: 6,
x: 7,
d: 8,
c: 9,
f: 10,
v: 11,
}
var notes = (_(lines)
.map(function (line) {
return line.trim().split(/\s+/).map(function (x) {
return parseInt(x, 10)
})
})
.sortByAll(['1', '0'])
.value()
)
var moved = 0
notes.forEach(function (vals, index) {
var column = COLUMN_MAP[items[index]]
if (!column) {
out.push(vals.join(' '))
} else {
var outVals = vals.slice(1)
outVals.unshift(column)
moved += 1
out.push(outVals.join(' '))
}
})
clipboard.writeText(out.join('\r\n'))
show('Moved ' + moved + ' notes')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment