scratch
/file.html |
@@ -87,6 +87,9 @@ |
<button id="btn-mailto" class="btn btn-default" type="button"><i class="glyphicon glyphicon-envelope"></i></button> |
</span> |
<span class="input-group-btn"> |
<button id="btn-facebook" class="btn btn-default" type="button" disabled="disabled"><i class="fa fa-facebook"></i></button> |
</span> |
<span class="input-group-btn"> |
<button id="btn-clipboard" class="btn btn-default" type="button"><i class="glyphicon glyphicon-paperclip"></i></button> |
</span> |
</div> |
@@ -300,6 +303,47 @@ |
encodeURIComponent("Can't scratch this!") + "&body=" + |
encodeURIComponent($('#' + boxURLID).val()); |
}); |
|
// Set the ID of the facebook button. |
const faceBookButtonID = '_' + Math |
.random() |
.toString(36) |
.substr(2, 9); |
|
file |
.previewElement |
.querySelector("#btn-facebook") |
.setAttribute('id', faceBookButtonID); |
|
switch(data.opengraph) { |
case true: |
// Enable the facebook button. |
file |
.previewElement |
.querySelector('#' + faceBookButtonID) |
.removeAttribute("disabled"); |
|
// Change the URL when the user clicks the button. |
$('#' + faceBookButtonID).on('click', () => { |
$('#' + boxURLID) |
.val( |
location.protocol.concat("//") |
.concat(window.location.hostname) |
.concat("/") |
.concat("og") |
.concat("/") |
.concat(data.hash) |
); |
}); |
break; |
default: |
// Disable the facebook button. |
file |
.previewElement |
.querySelector('#' + faceBookButtonID) |
.setAttribute("disabled", "disabled"); |
break; |
} |
}); |
|
document.querySelector("#actions .start").onclick = () => { |
/file.php |
@@ -80,12 +80,21 @@ |
#### Store the file. |
$timestamp = atomized_put_contents($userPath.'.'.$fileExtension, $data); |
|
### Hook for various file extensions. |
$opengraph = FALSE; |
switch(strtoupper($fileExtension)) { |
case 'GIF': |
$opengraph = TRUE; |
break; |
} |
|
### Return the URL to the file. |
header('Content-Type: text/plain; charset=utf-8'); |
echo json_encode( |
array( |
"hash" => $file, |
"timestamp" => $timestamp |
"timestamp" => $timestamp, |
"opengraph" => $opengraph |
) |
); |
break; |
/graph.php |
@@ -64,18 +64,19 @@ |
die('File not found.'); |
} |
|
list($width, $height) = getimagesize($userPath); |
$URL = $config['URL_PATH'].$_GET['hash']; |
|
$imagePath = $config['URL_PATH'].$_GET['hash']; |
|
echo <<<END |
switch(strtoupper($fileExtension)) { |
case 'GIF': |
list($width, $height) = getimagesize($userPath); |
echo <<<END |
<html> |
<head> |
<meta property="og:site_name" content="Scratch Copy"> |
<meta property="og:url" content="$imagePath"> |
<meta property="og:url" content="$URL"> |
<meta property="og:title" content="Scratch Copy"> |
<meta property="og:type" content="video.other"> |
<meta property="og:image" content="$imagePath"> |
<meta property="og:image" content="$URL"> |
<meta property="og:image:width" content="$width"> |
<meta property="og:image:height" content="$height"> |
</head> |
@@ -82,9 +83,14 @@ |
|
<body> |
<p> |
<img src="$imagePath"> |
<img src="$URL"> |
</p> |
</body> |
|
</html> |
END; |
break; |
} |
|
|
|