Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/whitemagicsoftware.com.git

Null checks

AuthorDave Jarvis <email>
Date2022-08-21 18:32:02 GMT-0700
Commit6495ab44b8d7b7f80819c1ce8e59819469a5c35c
Parent1604e9d
keenquotes/index.php
var copyButton = document.getElementById( 'copy-button' );
-copyButton.addEventListener( 'click', function( event ) {
- var output = document.getElementById( 'output' );
- var oldClass = output.className;
+if( copyButton ) {
+ copyButton.addEventListener( 'click', function( event ) {
+ var output = document.getElementById( 'output' );
+ var oldClass = output.className;
- output.className = 'newlines';
- var text = output.innerText || output.textContent;
- setClipboard( text );
+ output.className = 'newlines';
+ var text = output.innerText || output.textContent;
+ setClipboard( text );
- output.className = oldClass;
-});
+ output.className = oldClass;
+ });
+}
var sampleButton = document.getElementById( 'sample-button' );
-sampleButton.addEventListener( 'click', function( event ) {
- var source = document.getElementById( 'source' );
- source.value = "''E's got a 'ittle box 'n a big 'un,' she said, 'wit' th' 'ittle 'un 'bout 2'×6\". An' no, y'ain't cryin' on th' \"soap box\" to me no mo, y'hear. 'Cause it 'tweren't ever a spec o' fun!' I says to my frien'.";
-});
+if( sampleButton ) {
+ sampleButton.addEventListener( 'click', function( event ) {
+ var source = document.getElementById( 'source' );
+ source.value = "''E's got a 'ittle box 'n a big 'un,' she said, 'wit' th' 'ittle 'un 'bout 2'×6\". An' no, y'ain't cryin' on th' \"soap box\" to me no mo, y'hear. 'Cause it 'tweren't ever a spec o' fun!' I says to my frien'.";
+ });
+}
</script>
</body>
Delta16 lines added, 12 lines removed, 4-line increase