Skip to content

Commit

Permalink
First draft
Browse files Browse the repository at this point in the history
  • Loading branch information
Doc999tor committed Oct 6, 2016
0 parents commit d0511cb
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
18 changes: 18 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -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);
});
47 changes: 47 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
body.ltr {direction: ltr;}
body.rtl {direction: rtl;}
section {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
margin-top: 3px;
}
input {
width: 23%;
padding-left: 5px;
}
</style>
</head>
<body class="ltr">
<button onclick="
this.innerText = `Switch to ${document.body.classList[0]}`;
document.body.classList.toggle('ltr');
document.body.classList.toggle('rtl');
">Switch to rtl</button>
<section data-row="1">
<input data-row="row-0" data-column="cl-0" type="text" value="row-0 cl-0">
<input data-row="row-0" data-column="cl-1" type="text" value="row-0 cl-1">
<input data-row="row-0" data-column="cl-2" type="text" value="row-0 cl-2">
<input data-row="row-0" data-column="cl-3" type="text" value="row-0 cl-3">
</section>
<section data-row="2">
<input data-row="row-1" data-column="cl-0" type="text" value="row-1 cl-0">
<input data-row="row-1" data-column="cl-1" type="text" value="row-1 cl-1">
<input data-row="row-1" data-column="cl-2" type="text" value="row-1 cl-2">
<input data-row="row-1" data-column="cl-3" type="text" value="row-1 cl-3">
</section>
<section data-row="3">
<input data-row="row-2" data-column="cl-0" type="text" value="row-2 cl-0">
<input data-row="row-2" data-column="cl-1" type="text" value="row-2 cl-1">
<input data-row="row-2" data-column="cl-2" type="text" value="row-2 cl-2">
<input data-row="row-2" data-column="cl-3" type="text" value="row-2 cl-3">
</section>
<script type="text/javascript" src="main.js"></script>
</body>
</html>
35 changes: 35 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -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');
}
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
2 changes: 2 additions & 0 deletions start.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
subl .
start cmd /k "gulp"
Binary file added xls.xlsx
Binary file not shown.

0 comments on commit d0511cb

Please sign in to comment.