diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..30bc162 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/node_modules \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..006c945 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,18 @@ +var gulp = require('gulp'), + watch = require('gulp-watch'), + browserSync = require("browser-sync").create(), + reload = browserSync.reload; + +var config = { + server: {baseDir: "./"}, + port: 9000, + open: true +}; + +gulp.task('watch', function () { + gulp.watch(['index.html', 'main.js', 'style.css']).on('change', reload); +}); + +gulp.task('default', ['watch'], function () { + browserSync.init(config); +}); diff --git a/index.html b/index.html new file mode 100644 index 0000000..e4eeb1e --- /dev/null +++ b/index.html @@ -0,0 +1,47 @@ + + + + + + + + + +
+ + + + +
+
+ + + + +
+
+ + + + +
+ + + \ No newline at end of file diff --git a/main.js b/main.js new file mode 100644 index 0000000..b5e7cdf --- /dev/null +++ b/main.js @@ -0,0 +1,35 @@ +Array.from(document.querySelectorAll('input')).forEach(input => { + input.addEventListener('paste', e => { + e.preventDefault(); + e.stopPropagation(); + addData(e.currentTarget, e.clipboardData.getData('Text')); + return false; + }); +}); + +function addData (input, text) { + console.time('addData'); + let [rowInput, columnInput] = [ + parseInt(input.dataset.row.match(/\d/)[0]), + parseInt(input.dataset.column.match(/\d/)[0]) + ]; + + let cells = []; + let rows = text + .split('\n') + .forEach((row, index) => { + cells[index] = row.split('\t'); + }); + rows = null; + + cells.forEach((rowData, indexRow) => { + rowData.forEach((value, indexColumn) => { + let query = `input[data-row=row-${indexRow + rowInput}][data-column=cl-${indexColumn + columnInput}]`; + let el = document.querySelector(query); + if (el) { + el.value = value; + } + }); + }); + console.timeEnd('addData'); +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..36c0600 --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "name": "zoominfo-test-task", + "version": "1.0.0", + "description": "", + "main": "", + "scripts": {}, + "author": "Victor", + "license": "ISC", + "devDependencies": { + "browser-sync": "^2.11.2", + "gulp": "^3.9.1", + "gulp-watch": "^4.3.5" + } +} diff --git a/start.bat b/start.bat new file mode 100644 index 0000000..461eb44 --- /dev/null +++ b/start.bat @@ -0,0 +1,2 @@ +subl . +start cmd /k "gulp" \ No newline at end of file diff --git a/xls.xlsx b/xls.xlsx new file mode 100644 index 0000000..94d53b0 Binary files /dev/null and b/xls.xlsx differ