Skip to content

Commit

Permalink
Version 3
Browse files Browse the repository at this point in the history
Now handles HTML conversion.
  • Loading branch information
GrabzIt committed Oct 6, 2016
1 parent 81d89ec commit 639e7e2
Show file tree
Hide file tree
Showing 13 changed files with 1,330 additions and 164 deletions.
16 changes: 16 additions & 0 deletions ajax/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,30 @@ function zoomout()
function selectChanged(select) {
if ($(select).val() == 'gif') {
$('#spnGif').show();
$('#divURL').show();
$('#divHTML').hide();
$('#divConvert').hide();
$('#spnScreenshot').hide();
}
else {
$('#divConvert select').change();
$('#divConvert').show();
$('#spnScreenshot').show();
$('#spnGif').hide();
}
}

function selectConvertChanged(select) {
if ($(select).val() == 'url') {
$('#divURL').show();
$('#divHTML').hide();
}
else {
$('#divHTML').show();
$('#divURL').hide();
}
}

$(document).ready(function() {
checkForResults();
});
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "grabzit/grabzit",
"type": "library",
"keywords": ["screenshots","PDF","table","capture","PNG","JPG","BMP","TIFF","API","web","images","videos","animated gif","csv","xlsx","video conversion"],
"keywords": ["screenshots","PDF","HTML","table","capture","PNG","JPG","BMP","TIFF","API","web","images","videos","animated gif","csv","xlsx","video conversion"],
"homepage": "http://grabz.it/",
"description": "Use our API to integrate image and PDF screenshots into your website or application. Additionally GrabzIt allows you to convert online videos into animated GIF's or HTML tables into CSV's.",
"description": "Use our API to allow your app to create images and PDF's from URL's or raw HTML. Additionally GrabzIt allows you to convert online videos into animated GIF's or HTML tables into CSV's.",
"license": "MIT",
"version":"2.3.0",
"version":"3.0.0",
"support": {
"issues": "http://grabz.it/support/"
},
Expand Down
25 changes: 25 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,29 @@ h1
{
display:inline;
clear:none;
}

label
{
float:left;
font-weight:bold;
width:10em;
}

.Row
{
float:left;
clear:both;
margin-bottom:1em;
width:100%;
}

.Row input, .Row select, .Row textarea
{
width:15em;
}

.Row textarea
{
height:6em;
}
69 changes: 50 additions & 19 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,56 @@

if (count($_POST) > 0)
{
if (isset($_POST["delete"]) && $_POST["delete"] == 1)
{
$files = glob('results/*');
foreach($files as $file)
{
if(is_file($file))
unlink($file);
}
}
else
{
if (isset($_POST["delete"]) && $_POST["delete"] == 1)
{
$files = glob('results/*');
foreach($files as $file)
{
if(is_file($file))
unlink($file);
}
}
else
{
$url = $_POST["url"];
$html = $_POST["html"];
$format = $_POST["format"];
$convert = $_POST["convert"];

try
{
$grabzIt = new GrabzItClient($grabzItApplicationKey, $grabzItApplicationSecret);
if ($format == "pdf")
{
$grabzIt->SetPDFOptions($url);
if ($convert == 'html')
{
$grabzIt->HTMLToPDF($html);
}
else
{
$grabzIt->URLToPDF($url);
}
}
else if ($format == "gif")
{
$grabzIt->SetAnimationOptions($url);
$grabzIt->URLToAnimation($url);
}
else
{
$grabzIt->SetImageOptions($url);
if ($convert == 'html')
{
$grabzIt->HTMLToImage($html);
}
else
{
$grabzIt->URLToImage($url);
}
}
$grabzIt->Save($grabzItHandlerUrl);
}
catch (Exception $e)
{
$message = $e->getMessage();
$message = $e->getMessage();
}
}
}
Expand All @@ -54,11 +71,11 @@
<body>
<h1>GrabzIt Demo</h1>
<form method="post" action="index.php" class="inputForms">
<p><span id="spnScreenshot">Enter the URL of the website you want to take a screenshot of. The resulting screenshot</span><span class="hidden" id="spnGif">Enter the URL of the online video you want to convert into a animated GIF. The resulting animated GIF</span> should then be saved in the <a href="results/" target="_blank">results directory</a>. It may take a few seconds for it to appear! If nothing is happening check the <a href="http://grabz.it/account/diagnostics" target="_blank">diagnostics panel</a> to see if there is an error.</p>
<p><span id="spnScreenshot">Enter the HTML or URL you want to convert into a PDF or Image. The resulting capture</span><span class="hidden" id="spnGif">Enter the URL of the online video you want to convert into a animated GIF. The resulting animated GIF</span> should then be saved in the <a href="results/" target="_blank">results directory</a>. It may take a few seconds for it to appear! If nothing is happening check the <a href="http://grabz.it/account/diagnostics" target="_blank">diagnostics panel</a> to see if there is an error.</p>
<?php
if ($grabzItHandlerUrl == "URL OF YOUR handler.php FILE (http://www.example.com/grabzit/handler.php)")
{
?><p><span class="error">You must set your call back to a valid public URL.</span></p><?php
?><p><span class="error">Please update the $grabzItHandlerUrl variable found in config.php file to match the URL of the handler.php file found in this demo app.</span></p><?php
}
if (!is_writable("results"))
{
Expand All @@ -77,12 +94,26 @@
}
}
?>
<label style="font-weight:bold;margin-right:1em;">URL </label><input text="input" name="url"/> <select name="format" onchange="selectChanged(this)">
<div class="Row" id="divConvert">
<label>Convert </label><select name="convert" onchange="selectConvertChanged(this)">
<option value="url">URL</option>
<option value="html">HTML</option>
</select>
</div>
<div id="divHTML" class="Row hidden">
<label>HTML </label><textarea name="html"><html><body><h1>Hello world!</h1></body></html></textarea>
</div>
<div id="divURL" class="Row">
<label>URL </label><input text="input" name="url" placeholder="http://www.example.com"/>
</div>
<div class="Row">
<label>Format </label><select name="format" onchange="selectChanged(this)">
<option value="jpg">JPG</option>
<option value="pdf">PDF</option>
<option value="gif">GIF</option>
</select>
<input type="submit" value="Grabz It"></input>
</div>
<input type="submit" value="Grabz It" style="margin-left:12em"></input>
</form>
<form method="post" action="index.php" class="inputForms">
<input type="hidden" name="delete" value="1"></input>
Expand Down
Loading

0 comments on commit 639e7e2

Please sign in to comment.