Table inputs are now object now arrays

This commit is contained in:
2016-02-15 16:06:12 +08:00
parent f5b2d9eb08
commit e3e832e9ba
4 changed files with 118 additions and 69 deletions
+2
View File
@@ -1,4 +1,6 @@
notes
# Created by https://www.gitignore.io/api/node,bower,linux
### Node ###
+28 -20
View File
@@ -7,12 +7,13 @@
<meta property="og:title" content="Keyword Shitter2 - The Bulk Keyword Tool" />
<meta property="og:image" content="img/bl.png" />
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css"/>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css"/>
<!-- <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.1.0/css/buttons.dataTables.min.css"/> -->
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/fixedheader/3.1.0/css/fixedHeader.dataTables.min.css"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/keytable/2.1.0/css/keyTable.dataTables.min.css"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/responsive/2.0.0/css/responsive.dataTables.min.css"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/scroller/1.4.0/css/scroller.dataTables.min.css"/>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/fixedheader/3.1.0/css/fixedHeader.dataTables.min.css"/>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/keytable/2.1.0/css/keyTable.dataTables.min.css"/>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/responsive/2.0.0/css/responsive.dataTables.min.css"/>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/scroller/1.4.0/css/scroller.dataTables.min.css"/>
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/progress.js/0.1.0/progressjs.min.css"/>
@@ -36,16 +37,17 @@
<div class="row">
<div class="col-sm-12">
<div class="col-sm-7">
<div id="numofkeywords"></div>
<div class="form-group">
<label for="input" ><h3>Input:</h3></label>
<textarea id="input" autocomplete="off" autocorrect="off" style="height: 400px; width: 400px;" autocapitalize="off" spellcheck="false" rows="8" title="queue" class="form-control" placeholder="I accidentally
<textarea id="input" autocomplete="off" autocorrect="off" style="resize: none; height: 400px; width: 400px;" autocapitalize="off" spellcheck="false" rows="8" title="queue" class="form-control" placeholder="I accidentally
on purpose">I accidentally
on purpose
dismantled my
lying internet</textarea>
</div>
<a class="btn btn-primary btn-lg" id="startjob" type="button" value="Shit Keywords!">Shit Keywords!</a>
@@ -58,11 +60,14 @@ lying internet</textarea>
</button>
<a class="btn btn-default" id="reset" title="Empty all input and results" type="button" value="Reset">Reset</a>
</div>
<div class="col-sm-5">
<form id="advanced" class="collapse">
<br>
<a class="btn btn-default" id="load-from-cache" title="Load cached data from previous sessions" type="button" value="load">Load cache</a>
<a class="btn btn-default" id="export-from-cache" title="Export cached data from previous sessions as a json file" type="button" value="load">Export cache</a>
<a class="btn btn-default" id="load-from-cache" title="Load cached data from previous sessions" type="button" >Load cache</a>
<a class="btn btn-default" id="export-from-cache" title="Export cached data from previous sessions as a json file" type="button">Export cache</a>
<a class="btn btn-default" id="clear-cache" title="Delete cached data" type="button">Delete cache</a>
<div class="form-group">
<label for="service">Service:</label>
@@ -340,7 +345,7 @@ lying internet</textarea>
</select>
</div>
<div class="form-group">
<label for="lang">Lang code (google):</label>
<label for="lang">Lang code (google & yandex):</label>
<select class="form-control" title="Lang code. Two letters. Only works for google for now" class="form-control" id="lang" value="en" >
<option value=""></option>
<option value="en" >English (default) (en)</option>
@@ -393,18 +398,18 @@ lying internet</textarea>
<textarea type="text" rows="2" title="These values are added after words to prompt the search suggestions" class="form-control" id="suffixes"> ,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,y,x,y,z,like,for,without,with,versus,vs,to,near,except,has</textarea>
</div>
<div class="form-group">
<div class="form-group" style="display: none">
<label for="filter-positive" >Positive filter:</label>
<textarea disabled id="filter-positive" name="filter-positive" class="form-control" rows="3"
<textarea disabled id="filter-positive" name="filter-positive" class="form-control" rows="2"
placeholder="Positive Filter"></textarea>
</div>
<div class="form-group">
<div class="form-group" style="display: none">
<label for="filter-negative">Negative filter:</label>
<textarea disabled id="filter-negative" name="filter-negative" class="form-control" rows="3"placeholder="Negative Filter"></textarea>
<textarea disabled id="filter-negative" name="filter-negative" class="form-control" rows="2"placeholder="Negative Filter"></textarea>
</div>
<div class="form-group">
<div class="form-group" style="display: none">
<label for="rate-limit">Rate limit (for experts):</label>
<input type="text" class="form-control" id="rate-limit" value="2000" name="rate-limit" title="Value between searches in milliseconds only change if you know what you are doing. This could get your ip banned, or place an unfair burden on the suggest servers." disabled>
<input type="text" class="form-control" id="rate-limit" value="750" name="rate-limit" title="Value between searches in milliseconds only change if you know what you are doing. This could get your ip banned, or place an unfair burden on the suggest servers." disabled>
</div>
<div class="checkbox">
@@ -433,15 +438,16 @@ lying internet</textarea>
<div class="row">
<div class="col-sm-12">
<hr>
<hr id="progress1">
<br id="progress2">
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div id="results" class="col-sm-12">
<h2>Results</h2>
<!-- <div class="table-responsive"> -->
<table id="outtable" class=" table table-condensed compact dt-responsive hover" cellspacing="0" width="100%">
<table id="outtable" class=" table table-condensed compact dt-responsive" cellspacing="0" width="100%">
<thead>
<tr>
<th>id</th>
@@ -470,6 +476,8 @@ lying internet</textarea>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/4.2.0/lodash.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2014-11-29/FileSaver.min.js"></script>
<!-- <script src="//cdnjs.cloudflare.com/ajax/libs/localforage/1.3.3/localforage.js"></script> -->
<script src="//cdnjs.cloudflare.com/ajax/libs/progress.js/0.1.0/progress.min.js"></script>
+87 -48
View File
@@ -173,7 +173,10 @@ var KWS = function(){
this.FilterAndDisplay();
this.doWork = true;
this.progress1.start();
// $('#input').hide();
// $('#advanced').collapse("hide");
} else {
@@ -189,6 +192,7 @@ var KWS = function(){
this.table.columns.adjust();
this.saveSettings();
this.FilterAndDisplay();
this.progress1.end();
}
},
@@ -205,6 +209,10 @@ var KWS = function(){
this.DoJob();
}
var prog = parseInt(this.keywordsToQueryIndex/this.numOfInitialKeywords*100);
this.progress1.set(prog);
this.FilterAndDisplay();
} else {
if (this.options.keepRunning) {
console.log('finish initial queue');
@@ -267,7 +275,7 @@ var KWS = function(){
}, []);
// add to queue
this.keywordsToQuery.push.apply(this.keywordsToQuery,newInputs);
this.keywordsToQuery=_.concat(this.keywordsToQuery,newInputs);
return newInputs;
},
@@ -285,13 +293,20 @@ var KWS = function(){
var timeStamp = (new Date()).toISOString().replace(/[:\.]/g,'_').slice(0,-5);
name = 'keywordshitter_'+timeStamp+'_r'+e.target.result.length+'.json';
saveAs(blob,name);
if (success) success(blob);
if (success instanceof Function) success(blob);
}
return blob;
};
return reqObj;
},
clearDB: function(){
this.db.transaction(["suggestions"], "readwrite")
.objectStore("suggestions")
.clear();
console.warn('cleared all indexedDB data');
},
/** Display data from db upon pressing load button **/
loadFromDB: function(){
var self = this;
@@ -303,19 +318,10 @@ var KWS = function(){
/// grab the fields we want
var data =[];
for (var i = 0; i < e.target.result.length; i++) {
var d = e.target.result[i];
var da = [
d.id,
d.keyword,
d.length,
d.volume,
d.cpc,
d.search,
d.domain
];
var da = e.target.result[i];
// also remove undefined so datatables doesn't bring up alerts
da = da.map(function(v){return v===undefined ? null: v;});
da = _.mapValues(da, function(v){return v===undefined ? null: v;});
// parse nums
// da = da.map(v => /^[\d+\.]+$/.test(v) ? Number(v): v);
@@ -339,19 +345,28 @@ var KWS = function(){
// url might be in retlist
if (url===undefined) url=data[i].url;
var da = [
this.table.rows()[0].length+i,
cleanKw,
cleanKw.length,
null,
null,
search,
this.extractDomain(url)
];
//
// var da = [
// this.table.rows()[0].length+i,
// cleanKw,
// cleanKw.length,
// null,
// null,
// search,
// this.extractDomain(url)
// ];
var da = {
id: this.table.rows()[0].length+i,
keyword: cleanKw,
length: cleanKw.length,
volume: null,
cpc: null,
search: search,
domain: this.extractDomain(url)
};
// remove undefined values to avoid datatable alerts
da = da.map(function(v){return v===undefined ? null: v;});
da = _.mapValues(da, function(v){return v===undefined ? null: v;});
// TODO Check if suggestion is already displayed before adding
// var matches = table.data().filter(function(v){return v[1]===cleanKw && v[5]==search;}).count();
@@ -359,7 +374,8 @@ var KWS = function(){
rows.push(da);
}
this.table.rows.add(rows);
if (!dontDisplay) this.table.draw(false);
// if table is large lets defer rending to end to speed it up
if (!dontDisplay && this.table.data().length<this.options.deferTableUpdatesAtRows) this.table.draw(false);
},
/** Takes url string and returns domain e.g. www.google.com or google.com
@@ -616,8 +632,9 @@ var KWS = function(){
/** overrides default with dom options with arguments options **/
getOptions: function(argOptions){
var defaultOptions={
deferTableUpdatesAtRows: 5000,
keepRunning: false,
maxQueueDisplay: 10000,
maxQueueDisplay: 5000,
country: "",
filterNegative: "",
filterPositive: "",
@@ -710,16 +727,21 @@ var KWS = function(){
window.setInterval(this.DoJob.bind(this), this.options.rateLimit);
$('#progress1').addClass('progressjs-progress');
this.progress1 = progressJs("#progress1");
$('#startjob').on('click',this.toggleWork.bind(this));
$('#reset').on('click',this.reset.bind(this));
$('#load-from-cache').on('click',this.loadFromDB.bind(this));
$('#export-from-cache').on('click',this.exportDB.bind(this));
$('#clear-cache').on('click',this.clearDB.bind(this));
// $('#filter-positive').on('click',this.FilterIfNotWorking.bind(this));
// $('#filter-negative').on('click',this.FilterIfNotWorking.bind(this));
this.table = $('#outtable').DataTable({
pageLength: 50,
pageLength: 25,
"lengthMenu": [ 10, 25, 50, 75, 100,800],
dom:
"<'row'<'col-sm-5'B><'col-sm-7'<'pull-right'p>>>" +
@@ -734,53 +756,64 @@ var KWS = function(){
buttons: [
'copyHtml5',
'csvHtml5',
{
extend: 'csvHtml5',
fieldBoundary: "",
text: 'Copy keywords',
// 'customize': function(data,options){return data.split('\n').join(',');},
header: false,
exportOptions: {
stripNewlines: true,
stripHtml: true,
decodeEntities: true,
columns: 1,
// format:{
// body: function(html,i){console.log(html);return html}
// }
}
},
]
}
// {
// extend: 'csvHtml5',
// fieldBoundary: "",
// text: 'Copy keywords',
// // 'customize': function(data,options){return data.split('\n').join(',');},
// header: false,
// exportOptions: {
// stripNewlines: true,
// stripHtml: true,
// decodeEntities: true,
// columns: 1,
// // format:{
// // body: function(html,i){console.log(html);return html}
// // }
// }
// },
},
],
"columnDefs": [
{
"name": "id",
"data": "id",
"targets": 0,
"visible": false,
}, {
"responsivePriority": 1,
"name": "keyword",
"targets": 1
"data": "keyword",
"responsivePriority": 1,
"targets": 1,
}, {
"name": "length",
"data": "length",
"targets": 2,
"visible": false,
"type": "num"
}, {
"name": "volume",
"data": "volume",
"targets": 3,
"visible": false,
"type": "num"
}, {
"name": "cpc",
"data": "cpc",
"targets": 4,
"visible": false,
"type": "num"
}, {
"name": "search",
"data": "search",
"responsivePriority": 3,
"targets": 5,
"visible": false,
}, {
"name": "domain",
"data": "domain",
"responsivePriority": 2,
"targets": 6,
"visible": false,
@@ -788,8 +821,14 @@ var KWS = function(){
order: [[ 0, 'desc' ]],
// colReorder: {},
stateSave: true,
fixedHeader: true,
// responsive: true,
"bDeferRender": true,
// fixedHeader: true,
// responsive: {
// details: {
// type: 'column',
// target: 'tr'
// },
// },
// scrollY: 500,
// deferRender: true,
// scroller: true
+1 -1
View File
@@ -12,7 +12,7 @@
// clean minimalist tables
.table.dataTable {
min-height: 150px;
min-height: 600px;
}
.table {
// Cells