Skip to content

Commit

Permalink
add title templates
Browse files Browse the repository at this point in the history
  • Loading branch information
reaby committed Apr 16, 2020
1 parent 0028d94 commit 96df74c
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 56 deletions.
39 changes: 34 additions & 5 deletions public/javascripts/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,37 @@ $(function () {
}
});

$('#loadTitle1').dropdown({
direction: "downward",
action: function (text, value) {
$("#title1").val(text);
$('#loadTitle1').dropdown("hide");
}
});

$('#loadTitle2').dropdown({
direction: "downward",
action: function (text, value) {
$("#title2").val(text);
$('#loadTitle2').dropdown("hide");
}
});

$('#loadSub1').dropdown({
direction: "downward",
action: function (text, value) {
$("#sub1").val(text);
$('#loadSub1').dropdown("hide");
}
});

$('#loadSub2').dropdown({
direction: "downward",
action: function (text, value) {
$("#sub2").val(text);
$('#loadSub2').dropdown("hide");
}
});

/* $('#file').dropdown({
direction: "downward",
Expand All @@ -34,13 +65,11 @@ $(function () {
if (this.resizeTO)
clearTimeout(this.resizeTO);



this.resizeTO = setTimeout(function () {
$(this).trigger('viewportResize');
}, 250);
});

$(window).on('viewportResize', function () {
$("#col1").css("height", ($(window).height() - (40 + $("#preview iframe").height() + $(".menu").height() * 2)) + "px")
$("#col2").css("height", ($(window).height() - (20 + $(".menu").height() * 2)) + "px")
Expand Down Expand Up @@ -80,7 +109,7 @@ socket.on('obs.scenelist', data => {
let output = "";
obsScenes = data.scenes;
serverOptions.obs.currentScene = data.currentScene;

let idx = 0;
for (var scene of data.scenes) {
let action = "";
Expand All @@ -101,7 +130,7 @@ socket.on('obs.scenelist', data => {
});

socket.on('obs.update', data => {
serverOptions = data;
serverOptions = data;
renderUI();
});

Expand Down
17 changes: 12 additions & 5 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ var router = express.Router();
var fs = require('fs');

router.get('/', function (req, res, next) {
let titleData = fs.readFileSync("./public/images/titles.svg").toString();
res.render('display', { titles: titleData });
let titles = fs.readFileSync("./public/images/titles.svg").toString();
res.render('display', { titles: titles });
});

router.get('/admin', function (req, res, next) {
res.render('admin', { title: '' });
let data = "{}";
if (fs.existsSync("./data/titles.json")) {
data = JSON.parse(fs.readFileSync("./data/titles.json").toString());
}
res.render('admin', { titleData: data });
});

router.get('/admin/editsong', function (req, res, next) {
Expand All @@ -33,8 +37,11 @@ router.get('/ajax/song/:uuid', function (req, res, next) {

router.post('/ajax/song', function (req, res, next) {
let file = './data/songs/' + req.body.filename + ".json";
fs.writeFileSync(file, req.body.data || "[]");

try {
fs.writeFileSync(file, req.body.data || "[]");
} catch (e) {
console.log("Error while saving file: " + e);
}
res.sendStatus(200);
});

Expand Down
156 changes: 110 additions & 46 deletions views/admin.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,115 @@
<div class="ui primary top attached pointing menu">
<a class="header item" href="/admin">LoistoTxt</a>

<!-- <div id="file" class="ui dropdown item">
<div class="text">Show</div>
<i class="dropdown icon"></i>
<div class="menu">
<div class="item" data-value="new">New</div>
<div class="item" data-value="open">
Open...
</div>
<div class="item" data-value="save">
Save...
</div>
</div>
</div> -->
<!-- <div id="file" class="ui dropdown item">
<div class="text">Show</div>
<i class="dropdown icon"></i>
<div class="menu">
<div class="item" data-value="new">New</div>
<div class="item" data-value="open">
Open...
</div>
<div class="item" data-value="save">
Save...
</div>
</div>
</div> -->

<a class="browse item">
Titles
Create titles
<i class="dropdown icon"></i>
</a>
<div class="ui popup">
<div style="width: 60vw;" class="ui three column divided grid">
<div class="column">
<h4 class="ui header">Left</h4>
<div class="ui form list">
<input id="title1" class="ui input item" type="text"/>
<input id="sub1" class="ui input item" type="text"/>
<div style="width: 70vw;" class="ui two column divided grid">
<div class="row">
<div class="column">
<div class="ui form list">
<div class="ui right action left icon fluid input">
<i class="user icon"></i>
<input id="title1" type="text" placeholder="">
{% if titleData.titles %}
<div id="loadTitle1" class="ui basic floating dropdown button">
<div class="text">Load</div>
<i class="dropdown icon"></i>
<div class="menu">
{% for item in titleData.titles %}
<div class="item">{{item}}</div>
{% endfor %}
</div>
</div>
{% endif %}
<button class="ui icon button" onclick="$('#title1').val('');">
<i class="delete icon"></i>
</button>
</div>
<div class="ui right action left icon fluid input">
<i class="info icon"></i>
<input id="sub1" type="text" placeholder="">
{% if titleData.subs %}
<div id="loadSub1" class="ui basic floating dropdown button">
<div class="text">Load</div>
<i class="dropdown icon"></i>
<div class="menu">
{% for item in titleData.subs %}
<div class="item">{{item}}</div>
{% endfor %}
</div>
</div>
{% endif %}
<button class="ui icon button" onclick="$('#sub1').val('');">
<i class="delete icon"></i>
</button>
</div>
</div>
</div>
</div>
<div class="column">
<h4 class="ui header">Right</h4>
<div class="ui form list">
<input id="title2" class="ui input item" type="text"/>
<input id="sub2" class="ui input item" type="text"/>
<div class="column">
<div class="ui form list">
<div class="ui right action left icon fluid input">
<i class="user icon"></i>
<input id="title2" type="text" placeholder="">
{% if titleData.titles %}
<div id="loadTitle2" class="ui basic floating dropdown button">
<div class="text">Load</div>
<i class="dropdown icon"></i>
<div class="menu">
{% for item in titleData.titles %}
<div class="item">{{item}}</div>
{% endfor %}
</div>
</div>
{% endif %}
<button class="ui icon button" onclick="$('#title2').val('');">
<i class="delete icon"></i>
</button>
</div>
<div class="ui right action left icon fluid input">
<i class="info icon"></i>
<input id="sub2" type="text" placeholder="">
{% if titleData.subs %}
<div id="loadSub2" class="ui basic floating dropdown button">
<div class="text">Load</div>
<i class="dropdown icon"></i>
<div class="menu">
{% for item in titleData.subs %}
<div class="item">{{item}}</div>
{% endfor %}
</div>
</div>
{% endif %}
<button class="ui icon button" onclick="$('#sub2').val('');">
<i class="delete icon"></i>
</button>
</div>
</div>
<div style="text-align: right">
<div id="toggleTitlesButton" class="ui inverted green button" onclick="toggleTitles();">Show Title</div>
</div>
</div>
</div>
<div class="column">
<h4 class="ui header">Actions</h4>
<div class="ui list">
<div id="toggleTitlesButton" class="ui inverted green button" onclick="toggleTitles();">Show Title</div>
</div>
</div>

</div>
</div>

<!-- right menu -->
<div class="right menu">
<div class="item">
<div class="ui inverted buttons">
Expand All @@ -70,12 +135,13 @@
</div>
</div>
</div>
<!-- menu -->


<!-- Grids -->

<!-- <div class="ui three column grid" id="content" > -->
<div class="ui two column grid" id="content">
<div class="ui eight wide column">
<div class="ui two column grid" id="content"> <div class="ui eight wide column">
<div class="row">
<div class="ui inverted basic segment" style="overflow-y: none">
<div id="preview" data-url="/" class="ui 16:9 embed" style="background: gray; border: 1px solid black;"></div>
Expand Down Expand Up @@ -113,17 +179,15 @@
<div
class="ui small primary bottom fixed pointing menu">
<!--
<div class="item" style="width: fit-content;">
<div class="ui text">Teksti ruudulle</div>
<form class="ui fluid action input" onsubmit="return update(event);">
<input style="width: 400px !important;" id="text" type="text" value="">
<button type="submit" class="ui small basic green button">Go</button>
</form>
</div> -->

<div id="sceneList" class="item">

</div>
<div class="item" style="width: fit-content;">
<div class="ui text">Teksti ruudulle</div>
<form class="ui fluid action input" onsubmit="return update(event);">
<input style="width: 400px !important;" id="text" type="text" value="">
<button type="submit" class="ui small basic green button">Go</button>
</form>
</div> -->

<div id="sceneList" class="item"></div>

<div class="right menu">
<div class="item">
Expand Down

0 comments on commit 96df74c

Please sign in to comment.