Changeset - 2a9468d5e032
[Not reviewed]
default
0 5 1
Kallithea Admin (captain) - 13 months ago 2020-08-06 10:59:12
veto@myridia.com
update
6 files changed with 247 insertions and 16 deletions:
0 comments (0 inline, 0 general)
o.html
Show inline comments
 
new file 100644
 
<!DOCTYPE html>
 
<html>
 
  <head>
 
    <meta charset="UTF-8">
 
    <link rel="stylesheet" href="./node_modules/tacit-css/dist/tacit-css-1.3.3.min.css">
 
    <link rel="stylesheet" href="./css/screen.css">
 
    <title>SQLmaker</title>
 
  </head>
 
  <body>
 
    <h1><span>Create SQL lines</span> <span id="msg"></span></h1>
 
    <div id="content">
 
    <form id="form1" name="form1">
 

	
 
      <fieldset>
 
        <label for="query">Query: {}=placeholder example: DELETE FROM table1 WHERE name = '{}' AND  date = '{}';</label><br/>
 
        <textarea id="query"></textarea><br/>
 
      </fieldset>
 
      <fieldset>
 
      <label class="value_label">Values:</label>
 
      <ul class="columns" id="columns">
 
      <li><textarea rows="20" id="c1"></textarea></li>
 
      <li><textarea rows="20" id="c2"></textarea></li>
 
      <li><textarea rows="20" id="c3"></textarea></li>
 
      <li><textarea rows="20" id="c4"></textarea></li>
 
      </ul>
 
      </fieldset>
 
      <fieldset><input type="submit" value="Create Query"></fieldset>
 
    </form>
 
    <div>
 
    <label for="result">Result:</label><br/>
 
    <textarea id="result"></textarea>
 
    </div>
 
    </div>
 
    <script>
 
//      require('./renderer.js')
 
    </script>
 
    <script src="./js/app.js"></script>
 
  </body>
 
</html>
public/css/app.css
Show inline comments
 
body {
 
  background-color: #eee;
 
}
 
h1 {
 
  font-size: 18px;
 
  margin:-30px 0 0 0;
 
  padding:0;
 
}
 

	
 
h1 #msg {
 
  margin-left: 18px;
 
  color: #ff0000;
 
}
 

	
 

	
 

	
 

	
 
fieldset {
 
  margin:0;
 
  padding:0;
 
}
 

	
 
#query {
 
  margin:0 0 3px 0;
 
  width: 100% !important;
 
  background-color:#eee;
 
  font-size: 12px;
 
  line-height:1;
 
}
 

	
 
#result {
 
  margin:0;
 
  width: 100% !important;
 
  background-color:#eee;
 
  font-size: 12px;
 
  line-height:1;
 
  height:150px;
 
}
 

	
 
.columns{
 
  margin:0;
 
  padding:0;
 
}
 

	
 
.columns li{
 
  display:inline;
 
  marign:0;
 
  padding:0;
 
  width:1em;
 
}
 

	
 
body .columns textarea{
 
  background-color:#eee;
 
  min-width: 50px;
 
  max-width: 200px;
 
  font-size: 10px;
 
  line-height:1;
 
}
 

	
 
label {
 
  font-size:14px;
 
  margin:0;
 
  padding:0;
 
}
 

	
 
input[type=submit] {
 
  margin:0;
 
}
public/index.html
Show inline comments
 
<!doctype html>
 
<html lang="en">
 
  <head>
 
  <meta charset="utf-8">
 

	
 
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
 
  <meta name="theme-color" content="white"/>
 
  <meta name="theme-color" content="#ffffff">
 
  <meta name="apple-mobile-web-app-capable" content="yes">
 
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
 
  <meta name="apple-mobile-web-app-title" content="PM">
...
 
@@ -20,21 +20,43 @@
 
  <link rel="icon" type="image/png" sizes="32x32" href="img/favicon-32x32.png">
 
  <link rel="icon" type="image/png" sizes="96x96" href="img/favicon-96x96.png">
 
  <link rel="icon" type="image/png" sizes="16x16" href="img//favicon-16x16.png">
 
  <meta name="msapplication-TileColor" content="#ffffff">
 
  <link rel="manifest" href="/manifest.json">
 

	
 
  <link rel="icon" href="favicon.ico" type="img/x-icon" />
 
  <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
 
  <link rel="stylesheet" href="node_modules/jqueryui/jquery-ui.min.css">
 
  <link rel="stylesheet" href="node_modules/font-awesome/css/font-awesome.css ">
 
  <link rel="stylesheet" href="node_modules/tacit-css/dist/tacit-css-1.5.1.min.css">
 
  <link rel="stylesheet" href="css/app.css">
 

	
 
  <meta name="msapplication-TileImage" content="img/ms-icon-144x144.png">
 
  <meta name="theme-color" content="#ffffff">
 
  <link rel="manifest" href="/manifest.json">
 
  <link rel="icon" href="favicon.ico" type="img/x-icon" />
 

	
 
  <title>Textmaker</title>
 
  </head>
 
  <body>
 
  test
 
  <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
 
  <link rel="stylesheet" href="node_modules/jqueryui/jquery-ui.min.css">
 
  <link rel="stylesheet" href="node_modules/free-jqgrid/css/ui.jqgrid.min.css">
 
  <link rel="stylesheet" href="node_modules/font-awesome/css/font-awesome.css ">
 
  <link rel="stylesheet" href="../node_modules/jqueryui/jquery-ui.min.css">
 
  <link rel="stylesheet" href="css/app.css">
 
    <h1><span>Create SQL lines</span> <span id="msg"></span></h1>
 
    <div id="content">
 
      <form id="form1" name="form1">
 
        <fieldset>
 
          <label for="query">Query: {}=placeholder example: DELETE FROM table1 WHERE name = '{}' AND  date = '{}';</label><br/>
 
          <textarea id="query"></textarea><br/>
 
        </fieldset>
 
        <fieldset>
 
          <label class="value_label">Values:</label>
 
          <ul class="columns" id="columns">
 
            <li><textarea rows="20" id="c1"></textarea></li>
 
            <li><textarea rows="20" id="c2"></textarea></li>
 
            <li><textarea rows="20" id="c3"></textarea></li>
 
            <li><textarea rows="20" id="c4"></textarea></li>
 
          </ul>
 
        </fieldset>
 
        <fieldset><input type="submit" value="Create Query"></fieldset>
 
      </form>
 
      <div>
 
        <label for="result">Result:</label><br/>
 
        <textarea id="result"></textarea>
 
      </div>
 
    </div>
 
  <script src="node_modules/jquery/dist/jquery.min.js"></script>
 
  <script src="node_modules/jqueryui/jquery-ui.min.js"></script>
 
  <script src="node_modules/jquery-migrate/dist/jquery-migrate.min.js"></script>
public/js/app.js
Show inline comments
...
 
@@ -58,3 +58,90 @@ async function register_pwa(e)
 
}
 

	
 

	
 

	
 

	
 

	
 
function escape_values(columns)
 
{
 
  for (let i=0; i< columns.length; i++)   
 
  {
 
    for (let ii=0; ii< columns[i].length; ii++)    
 
    {
 
      let s = columns[i][ii];
 
      if(s.indexOf("'") > -1)
 
      {
 
        s = s.replace(/'/g, "''");
 
        columns[i][ii] = s;
 
      }
 
    }
 
  }  
 
  return columns;
 
}
 

	
 
function make_queries(query,column) //templating the columns into the placeholder
 
{
 
  let n = (query.split("{}").length - 1) ;
 
  let queries = [];
 
  for (let i=0; i< column.length; i++)   
 
  {
 
     queries[i] = query;
 
  }
 

	
 
  for (let i=0; i<n; i++)
 
  {
 
    for (let ii=0; ii< column.length; ii++)   
 
    {
 
       queries[ii] = queries[ii].replace("{}",column[ii][i]);
 
    }
 
  }
 
  return queries;
 
}
 

	
 

	
 
function get_columns() //getting the filled columes and send them back as array
 
{
 
  let c = [];
 
  let columns = document.getElementById('columns');
 
  let e = columns.getElementsByTagName('textarea');
 
  for (let i=0; i<e.length; i++) 
 
  {
 
    let arr = e[i].value.split('\n');
 
    // let arr = e[i].value.match(/[^\r\n]+/g);
 
    if(arr.length > 1)
 
    {
 
      c[i] = arr;
 
    }
 
  }
 
  return c;
 
}
 

	
 

	
 
function unite_columns(c) //take the smallest column and create one master column with other columns as nested array 
 
{
 
  let rows = c[0].length;
 
  for(var i=0; i<c.length; i++) 
 
  {
 
    if(c[i].length < rows) //get colum with the least rows
 
    {
 
      rows = c[i].length;
 
    }
 
  }
 

	
 
  let columns = [];
 
  for(let i=0; i < rows; i++) 
 
  {
 
    columns[i] = [];
 
  }
 

	
 
  for(let i=0; i<c.length; i++) 
 
  {
 
    for(let ii=0; ii < c[i].length; ii++) 
 
    {
 
      if(ii < rows)
 
      {
 
        columns[ii].push(c[i][ii]);
 
      }
 
    }     
 
  }
 
  return columns;
 
}
public/js/main.js
Show inline comments
...
 
@@ -6,7 +6,21 @@ window.onload = () => {
 
    jQuery('.offcanvas-collapse').toggleClass('open');
 
  });
 

	
 
  start();
 
  pwa();
 

	
 
  form1.onsubmit=function()
 
  { 
 
    let query = document.getElementById("query").value;
 
    let columns = get_columns();
 
    columns = escape_values(columns);
 
    let column = unite_columns(columns);
 
    let queries = make_queries(query,column);
 
    document.getElementById('result').value = queries.join('\n');
 
    return false;
 
  };
 

	
 

	
 

	
 
  //start();
 
  //pwa();
 

	
 
};
public/package.json
Show inline comments
...
 
@@ -12,10 +12,11 @@
 
  "dependencies": {
 
    "bootstrap": "^4.3.1",
 
    "bootstrap-waitingfor": "^1.2.7",
 
    "font-awesome": "^4.7.0",
 
    "jquery": "^3.3.1",
 
    "jquery-migrate": "^3.1.0",
 
    "jqueryui": "^1.11.1",
 
    "npm": "^6.12.1",
 
    "font-awesome": "^4.7.0"
 
    "tacit-css": "^1.5.1"
 
  }
 
}
0 comments (0 inline, 0 general)