Skip to content

Commit

Permalink
Merge pull request #2 from infiniti008/serial_list
Browse files Browse the repository at this point in the history
Serial list
  • Loading branch information
infiniti008 authored Oct 10, 2016
2 parents 1f83c68 + aaba906 commit 8aa2a23
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 8 deletions.
30 changes: 30 additions & 0 deletions public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,33 @@
.div_page{
/*border: 2px solid red;*/
}

/*list page*/
.div_in_line{
vertical-align:top;;
display: inline-block;
/*border: 1px solid red;*/
width: 23%;
height: auto;
word-wrap:break-word;
font-family:monospace;
font-size: 15px;
}

.div_list{
margin-top: 5px;
border: 2px solid #7586AC;
border-radius: 5px;
background-color: #81A9A9;
padding-top: 3px;
padding-bottom: 3px;
}

.hr_list{
margin-top: 2px;
margin-bottom: 2px;
background-color: #273C3C; /* Цвет линии */
height: 2px; /* Толщина линии */
border: none; /* Убираем границу */
width: 98%;
}
12 changes: 8 additions & 4 deletions run.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ function startServer(){
});

app.get('/2', function(req, res) {
db.insert_from_base('', '', '', function(row){
console.log('Извлекли');
console.log(row);
});

var file = fs.readFileSync('./views/home.html').toString();
var first_page = fs.readFileSync('./views/first_page.html').toString();
file = file.replace('{{Title}}', 'Главная страница');
Expand All @@ -92,6 +89,13 @@ function startServer(){
res.end(file);
});

app.get('/get_list', function(req, res) {
db.insert_from_base('off', 'id', '1', function(row){
res.send(row)
console.log(row);
});
});

//Рабочий
// app.get('/send_url', function(req, res){
// console.log('XMLHttpRequest');
Expand Down
2 changes: 1 addition & 1 deletion views/first_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</script>
<div class="div_add">
<input type="button" value="Добавить сериал" class="btn_href" onclick="location.href='/add_page'"><br>
<input type="button" value="Список сериалов" class="btn_href" onclick="location.href='/list_page'"><br>
<input type="button" value="Удалить запись из базы" class="btn_href" onclick="location.href='/deleteFromBase_page'"><br>
<input type="button" value="Список сериалов" class="btn_href" onclick="location.href='/list_page'"><br>
<input type="button" value="2" class="btn_href" onclick="location.href='/2'"><br>
</div>
8 changes: 7 additions & 1 deletion views/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@
<link href="style.css" type="text/css" rel="stylesheet">
<title>{{Title}}</title>
</head>
<body class="body_home">
<body class="body_home" onLoad="load_page()">
<div class="div_page">
<div id="div_content">
{{content}}
</div>
</div>
</body>
</html>

<script type="text/javascript">
function load_page(){
load_curr_page();
}
</script>
78 changes: 76 additions & 2 deletions views/list_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,82 @@
var div_content_add = document.getElementById('div_content');
div_content_add.setAttribute("class", "div_content_list");
</script>
<div class="div_add">
<div class="div_add" id="div_add">
<input type="button" value="Главная страница" class="btn_href" onclick="location.href='/'"><br>
<hr class="hr">

<div class="div_list">
<div class="div_in_line">
Название сериала
</div>
<div class="div_in_line">
Следующая серия
</div>
<div class="div_in_line">
Дата выхода
</div>
<div class="div_in_line">
Название эпизода
</div>
</div>
</div>


<script>
function zapr(){
var x = new XMLHttpRequest();
x.open("GET", "/get_list", true);
x.onload = function (){
// alert(x.responseText);
// myFunction(x.responseText);
repla(x.responseText);
}
x.send(null);
}
function repla(response) {
// alert('dlfkjvgmdflkvg');
var tex = '<div class="div_in_line">\
{{name}}\
</div>\
<div class="div_in_line">\
{{next}}\
</div>\
<div class="div_in_line">\
{{date}}\
</div>\
<div class="div_in_line">\
{{episode}}\
</div>';
// alert(response);
var arr = JSON.parse(response);
// alert(arr[0]);
for (var i = 0; i < arr.length; i++) {
if (arr[i].SerialSeason < 10) {
arr[i].SerialSeason = '0' + arr[i].SerialSeason;
}
if (arr[i].NextEpNumber < 10) {
arr[i].NextEpNumber = '0' + arr[i].NextEpNumber;
}
if (arr[i].NextEpDay < 10) {
arr[i].NextEpDay = '0' + arr[i].NextEpDay;
}
if (arr[i].NextEpMonth < 10) {
arr[i].NextEpMonth = '0' + arr[i].NextEpMonth;
}
var newDiv = document.createElement('div');
newDiv.className = 'div_list';
newDiv.innerHTML = tex;
newDiv.innerHTML = newDiv.innerHTML.replace('{{name}}', arr[i].SerialName);
newDiv.innerHTML = newDiv.innerHTML.replace('{{next}}', 'S' + arr[i].SerialSeason + 'E' + arr[i].NextEpNumber);
newDiv.innerHTML = newDiv.innerHTML.replace('{{date}}', arr[i].NextEpDay + '-' + arr[i].NextEpMonth + '-' + arr[i].NextEpYear);
newDiv.innerHTML = newDiv.innerHTML.replace('{{episode}}', arr[i].NextEpName);
div_add.appendChild(newDiv);


}
}

function load_curr_page(){
zapr();
}

</script>

0 comments on commit 8aa2a23

Please sign in to comment.