Browse Source

added button to add a random title to titles page

main
Simon Bowie 2 years ago
parent
commit
36cca1baa2
1 changed files with 21 additions and 0 deletions
  1. +21
    -0
      site/public/titles.php

+ 21
- 0
site/public/titles.php View File

@@ -11,6 +11,7 @@ include '../solr.php';

$core = 'all';
$random_titles = ten_random_titles($core);
$additional_titles = ten_random_titles($core);

?>

@@ -29,6 +30,8 @@ $random_titles = ten_random_titles($core);
<div class="container">

<button class="float-end btn btn-danger" onclick="removeRandomTitle()">-</button>
<button class="float-end btn btn-danger" onclick="addRandomTitle()">+</button>

<?php

foreach ($random_titles as $record_array):
@@ -56,8 +59,26 @@ foreach ($random_titles as $record_array):
<?php
endforeach;
?>
<span class="add_title">
</span>

</div>
<script>

var titles = <?php echo json_encode($additional_titles); ?>;

x = 0;

function addRandomTitle(){
var record_array = titles[x];
let title = "";
for (const id in record_array) {
title += record_array[id];
document.querySelector('.container').innerHTML += "<a href='id_search.php?id=" + id + "&core=all'><span class='title'>" + title + "</span></a><br><br><hr>";
x++;
}
}

function removeRandomTitle() {
var elts = document.getElementsByClassName("title");
var RandomSpan = elts[Math.floor(Math.random() * elts.length)];

Loading…
Cancel
Save