mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
update
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func mainPage(c *gin.Context) {
|
||||
c.HTML(200, "mainPage", nil)
|
||||
}
|
||||
17
src/server/web/pages/pages.go
Normal file
17
src/server/web/pages/pages.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func mainPage(c *gin.Context) {
|
||||
c.HTML(200, "mainPage", nil)
|
||||
}
|
||||
|
||||
func apijsPage(c *gin.Context) {
|
||||
c.HTML(200, "apijsPage", nil)
|
||||
}
|
||||
|
||||
func mainjsPage(c *gin.Context) {
|
||||
c.HTML(200, "mainjsPage", nil)
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"server/web/pages/template"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var temp *template.Template
|
||||
@@ -11,5 +12,6 @@ func SetupRoute(route *gin.Engine) {
|
||||
temp = template.InitTemplate(route)
|
||||
|
||||
route.GET("/", mainPage)
|
||||
|
||||
route.GET("/api.js", apijsPage)
|
||||
route.GET("/main.js", mainjsPage)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package template
|
||||
|
||||
const apijs = `
|
||||
const apiJS = `
|
||||
// Torrents
|
||||
function addTorrent(link, title, poster, save, done, fail){
|
||||
torrent("add",link,null,title,poster,save,done,fail);
|
||||
@@ -37,10 +37,34 @@ function torrent(action, link, hash, title, poster, save, done, fail){
|
||||
//
|
||||
|
||||
// Settings
|
||||
function getSettings(done, fail){
|
||||
sendApi("get",null,"/settings",done,fail);
|
||||
}
|
||||
|
||||
function setSettings(sets, done, fail){
|
||||
sendApi("set",sets,"/settings",done,fail);
|
||||
}
|
||||
//
|
||||
|
||||
// Viewed
|
||||
function listViewed(done, fail){
|
||||
sendApi("list",null,"/viewed",done,fail);
|
||||
}
|
||||
|
||||
function setViewed(hash, index, done, fail){
|
||||
var obj = {"hash":hash, "file_index":index};
|
||||
sendApi("set",obj,"/viewed",done,fail);
|
||||
}
|
||||
|
||||
function remViewed(hash, index, done, fail){
|
||||
var obj = {"hash":hash, "file_index":index};
|
||||
sendApi("rem",obj,"/viewed",done,fail);
|
||||
}
|
||||
//
|
||||
|
||||
function sendApi(action, obj, path, done, fail){
|
||||
if (obj==null)
|
||||
obj={};
|
||||
obj[action]=action;
|
||||
var req = JSON.stringify(obj);
|
||||
$.post(path,req)
|
||||
|
||||
@@ -12,7 +12,7 @@ const header = `
|
||||
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha256-4+XzXVhsDmqanXGHaHvgh1gMQKX40OUvDEBTu8JcmNs=" crossorigin="anonymous"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.5.1.min.js" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.5.4/umd/popper.min.js" crossorigin="anonymous"></script>
|
||||
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
|
||||
|
||||
@@ -13,7 +13,9 @@ const mainPage = `
|
||||
<html lang="ru">
|
||||
` + header + `
|
||||
<body>
|
||||
<script src="/api.js"></script>
|
||||
<script src="/main.js"></script>
|
||||
|
||||
<style>
|
||||
.wrap {
|
||||
white-space: normal;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package template
|
||||
|
||||
const mainjs = `
|
||||
const mainJS = `
|
||||
$(document).ready(function() {
|
||||
watchInfo();
|
||||
});
|
||||
@@ -8,13 +8,32 @@ $(document).ready(function() {
|
||||
var lastTorrHtml = '';
|
||||
|
||||
function watchInfo(){
|
||||
reloadTorrents();
|
||||
setInterval(function() {
|
||||
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function reloadTorretns(){
|
||||
var torrents = $("#torrents");
|
||||
torrents.empty();
|
||||
}
|
||||
|
||||
function loadTorrentInfoHtml(){
|
||||
|
||||
}
|
||||
|
||||
const torrElem =
|
||||
|
||||
|
||||
`
|
||||
|
||||
var torrElem = `"""
|
||||
<div class="btn-group d-flex" role="group">
|
||||
<button type="button" class="btn btn-secondary wrap w-100" data-toggle="collapse" data-target="#info_'+tor.Hash+'"></button>';
|
||||
<a role="button" class="btn btn-secondary" href="'+tor.Playlist+'"><i class="fas fa-th-list"></i> Плейлист</a>';
|
||||
<button type="button" class="btn btn-secondary"><i class="fas fa-info"></i></a>';
|
||||
<button type="button" class="btn btn-secondary"><i class="fas fa-trash-alt"></i> Удалить</button>';
|
||||
</div>
|
||||
"""
|
||||
`
|
||||
|
||||
@@ -33,10 +33,10 @@ type Template struct {
|
||||
func InitTemplate(c *gin.Engine) *Template {
|
||||
temp := new(Template)
|
||||
|
||||
temp.parseMainPage()
|
||||
// temp.parseSettingsPage()
|
||||
// temp.parseAboutPage()
|
||||
// temp.parseCachePage()
|
||||
temp.parsePage("mainPage", mainPage)
|
||||
temp.parsePage("apijsPage", apiJS)
|
||||
temp.parsePage("mainjsPage", mainJS)
|
||||
|
||||
c.SetHTMLTemplate(temp.templates)
|
||||
return temp
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user