浏览代码

added button to add a random title to titles page

main
Simon Bowie 2 年前
父节点
当前提交
36cca1baa2
共有 1 个文件被更改,包括 21 次插入0 次删除
  1. +21
    -0
      site/public/titles.php

+ 21
- 0
site/public/titles.php 查看文件

@@ -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)];

正在加载...
取消
保存