Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample
@extends('layouts.admin.main')
@section('content')
<div class="row">
<div class="col-md-12">
<!-- Domain Search form starts -->
<form class="form-horizontal" method="GET" action="{{ route('projects.create') }}" id="projectForm">
<div class="form-group{{ $errors->has('domain_name') ? ' has-error' : '' }}">
<label for="domain_name" class="col-md-4 control-label">Project Name</label>
<div class="col-md-6">
<input id="domain_name" type="text" class="form-control" name="domain_name" value="{{ $domainName = $domain ?? '' }}" required autofocus>
@if ($errors->has('domain_name'))
<span class="help-block">
<strong>{{ $errors->first('domain_name') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group">
<div class="col-md-8 col-md-offset-4">
<button type="submit" class="btn btn-primary">Search</button>
</div>
</div>
</form>
<!-- Domain Search form ends -->
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading"><h3>Linked Domains</h3></div>
<div class="panel-body">
@if(count($domains) > 0)
<table id="domain_table" class="table table-bordered table-striped">
<thead>
<tr>
<th><input type="checkbox" id="checkAllDomains" checked></th>
<th>#</th>
<th>Domain From</th>
<th>Domain To</th>
<th>Total Links</th>
<th>Unique Pages</th>
<th>Domain to rating</th>
<th>Domain to ahrefs top</th>
</tr>
</thead>
<tbody>
@forelse($domains as $key => $domain)
<tr>
<td><input type="checkbox" checked></td>
<td>{{ $key + 1 }}</td>
<td>{{ $domain->domain_from }}</td>
<td>{{ $domain->domain_to }}</td>
<td>{{ $domain->links }}</td>
<td>{{ $domain->unique_pages }}</td>
<td>{{ $domain->domain_to_rating }}</td>
<td>{{ $domain->domain_to_ahrefs_top }}</td>
</tr>
@empty
<tr>
<td colspan="7" style="text-align: center;font-size: 20px;padding-top: 30px;"> No Domains Found.</td>
</tr>
@endforelse
</tbody>
</table>
@else
@if($domainName)
<p class="__msg">No Linked domains found for <code>{{ $domainName }}</code></p>
@else
<p class="__msg">All Linked domains will be displayed here.</p>
@endif
@endif
</div>
@if(count($domains) > 0)
<button type="button" id="addToMasterList" class="btn btn-primary pull-right">Add to master list</button>
@endif
</div>
</div>
</div>
<script>
$(document).ready(function(){
$('#projectForm').validate({
rules : {
domain_name : {
required : true
}
},
messages : {
domain_name : {
required : 'Please enter a domain name.'
}
}
});
$('#checkAllDomains').click(function(){
var table= $("#domain_table");
$('td input:checkbox', table).prop('checked', this.checked);
});
$('#addToMasterList').click(function(){
var el = $(this);
el.text('Please wait..');
el.addClass('disabled');
$(".loading").show();
var domains = $('#domain_table tr:has(td)').map(function(i, v) {
var $td = $('td', this);
isChecked = $(v).first().find('input[type="checkbox"]').is(':checked');
if(isChecked === true)
{
return {
domain_from: $.trim($td.eq(2).text()),
domain_to: $.trim($td.eq(3).text()),
links: $.trim($td.eq(4).text()),
unique_pages: $.trim($td.eq(5).text()),
domain_to_rating: $.trim($td.eq(6).text()),
domain_to_ahrefs_top: $.trim($td.eq(7).text())
};
}
}).get();
//Add Domains
$.ajax({
url : '{{ route('projects.store') }}',
method : 'POST',
data : {
project_name : '{{ $domainName }}',
domains : JSON.stringify(domains)
},
success : function(res, status){
if(res.success === true) {
var site_url = $('meta[name="site_url"]').attr('content');
return window.location = site_url + '/admin/projects/' + res.id;
} else if (res.success === false) {
swal({
title: "",
text: res.val_error,
type: "error"
});
el.text('Add to master list');
el.removeClass('disabled');
$(".loading").hide();
return;
}
},
error : function(err, s){
console.log('An error occurred.');
console.log(err, s);
}
});
});
});
</script>
@endsection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.