1
0
mirror of https://github.com/fHDHR/fHDHR_NextPVR.git synced 2025-12-06 09:06:59 -05:00

Compare commits

..

4 Commits

Author SHA1 Message Date
Deathbybandaid
e3d8f64c5c
Merge pull request #131 from deathbybandaid/dev
Make Universal Brython Functions
2021-01-13 11:15:35 -05:00
deathbybandaid
28383d89ec Make Universal Brython Functions 2021-01-13 11:12:20 -05:00
Deathbybandaid
d915e4cbed
Merge pull request #130 from deathbybandaid/dev
Repair Tab/Space issues in Templates
2021-01-13 10:15:20 -05:00
deathbybandaid
51b9a85597 Repair Tab/Space issues in Templates 2021-01-13 10:10:10 -05:00
10 changed files with 109 additions and 83 deletions

View File

@ -3,6 +3,8 @@
from .brython import Brython from .brython import Brython
from .brython_stdlib import Brython_stdlib from .brython_stdlib import Brython_stdlib
from .brython_bry import Brython_bry
class fHDHR_Brython(): class fHDHR_Brython():
@ -11,3 +13,5 @@ class fHDHR_Brython():
self.brython = Brython(fhdhr) self.brython = Brython(fhdhr)
self.brython_stdlib = Brython_stdlib(fhdhr) self.brython_stdlib = Brython_stdlib(fhdhr)
self.brython_bry = Brython_bry(fhdhr)

View File

@ -2,6 +2,7 @@ from flask import send_from_directory
import pathlib import pathlib
class Brython(): class Brython():
endpoints = ["/brython.js"] endpoints = ["/brython.js"]
endpoint_name = "file_brython_js" endpoint_name = "file_brython_js"

View File

@ -0,0 +1,19 @@
from flask import send_from_directory
import pathlib
class Brython_bry():
endpoints = ["/brython.bry"]
endpoint_name = "file_brython_bry"
def __init__(self, fhdhr):
self.fhdhr = fhdhr
self.brython_path = pathlib.Path(self.fhdhr.config.internal["paths"]["fHDHR_web_dir"]).joinpath('brython')
def __call__(self, *args):
return self.get(*args)
def get(self, *args):
return send_from_directory(self.brython_path, 'brython_code.py')

View File

@ -0,0 +1,60 @@
from browser import document, bind # alert, window
@bind("#enable_button", "click")
def enable_all(event):
for element in document.get(selector='input[type="checkbox"]'):
if element.name.endswith("enabled"):
if document["enable_button"].value == "0":
element.checked = False
element.value = False
else:
element.checked = True
element.value = True
if document["enable_button"].value == "0":
document["enable_button"].value = "1"
document["enable_button"].text = "Enable All"
else:
document["enable_button"].value = "0"
document["enable_button"].text = "Disable All"
@bind("#chanSubmit", "submit")
def submit_fixup(evt):
for element in document.get(selector='input[type="checkbox"]'):
if element.name.endswith("enabled"):
if element.checked is False:
element.checked = True
element.value = False
if element.name.endswith("favorite"):
if element.checked is False:
element.checked = True
element.value = 0
items = document.select(".channels")
chanlist = []
chandict = {}
for element in items:
if element.name == "id":
if len(chandict.keys()):
chanlist.append(chandict)
chandict = {}
chandict[element.name] = element.value
element.clear()
postForm = document.createElement('form')
postData = document.createElement('input')
postForm.method = "POST"
postForm.action = "/api/channels?method=modify&redirect=/channels_editor"
postForm.setRequestHeader = "('Content-Type', 'application/json')"
postData.name = "channels"
postData.value = chanlist
postForm.appendChild(postData)
document.body.appendChild(postForm)
postForm.submit()
evt.preventDefault()

View File

@ -2,6 +2,7 @@ from flask import send_from_directory
import pathlib import pathlib
class Brython_stdlib(): class Brython_stdlib():
endpoints = ["/brython_stdlib.js"] endpoints = ["/brython_stdlib.js"]
endpoint_name = "file_brython_stdlib_js" endpoint_name = "file_brython_stdlib_js"

View File

@ -5,9 +5,14 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="style.css" rel="stylesheet"> <link href="style.css" rel="stylesheet">
<script type="text/javascript" src="/brython.js"></script>
<script type="text/javascript" src="/brython_stdlib.js"></script>
<script type="text/python" src="brython.bry"></script>
</head> </head>
<body> <body onload="brython({debug: 1, indexedDB: false})">
<h1 class="center" style="text-align:center"> <h1 class="center" style="text-align:center">
<span style="text-decoration: underline;"><strong><em>{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }}</em></strong> <span style="text-decoration: underline;"><strong><em>{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }}</em></strong>
</span> </span>

View File

@ -49,8 +49,8 @@
<td> <td>
{% if chan_dict["enabled"] %} {% if chan_dict["enabled"] %}
<a href="{{ chan_dict["m3u_url"] }}">Play</a> <a href="{{ chan_dict["m3u_url"] }}">Play</a>
{% else %} {% else %}
<a href="{{ chan_dict["m3u_url"] }}" style="visibility:hidden">Play</a> <a href="{{ chan_dict["m3u_url"] }}" style="visibility:hidden">Play</a>
{% endif %} {% endif %}
</td> </td>

View File

@ -1,70 +1,6 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block content %} {% block content %}
<body onload="brython({debug: 1, indexedDB: false})">
<script type="text/javascript" src="/brython.js"></script>
<script type="text/javascript" src="/brython_stdlib.js"></script>
<script type="text/python" id="enable0">
from browser import document, alert, window, bind
@bind("#enable_button", "click")
def enable_all(event):
for element in document.get(selector='input[type="checkbox"]'):
if element.name.endswith("enabled"):
if document["enable_button"].value == "0":
element.checked = False
element.value = False
else:
element.checked = True
element.value = True
if document["enable_button"].value == "0":
document["enable_button"].value = "1"
document["enable_button"].text = "Enable All"
else:
document["enable_button"].value = "0"
document["enable_button"].text = "Disable All"
@bind("#chanSubmit", "submit")
def submit_fixup(evt):
for element in document.get(selector='input[type="checkbox"]'):
if element.name.endswith("enabled"):
if element.checked == False:
element.checked = True
element.value = False
if element.name.endswith("favorite"):
if element.checked == False:
element.checked = True
element.value = 0
items = document.select(".channels")
chanlist = []
chandict = {}
for element in items:
if element.name == "id":
if len(chandict.keys()):
chanlist.append(chandict)
chandict = {}
chandict[element.name] = element.value
element.clear()
postForm = document.createElement('form')
postData = document.createElement('input')
postForm.method = "POST"
postForm.action = "/api/channels?method=modify&redirect=/channels_editor"
postForm.setRequestHeader = "('Content-Type', 'application/json')"
postData.name = "channels"
postData.value = chanlist
postForm.appendChild(postData)
document.body.appendChild(postForm)
postForm.submit()
evt.preventDefault()
</script>
<h4 style="text-align: center;">{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }} Channels Editor</h4> <h4 style="text-align: center;">{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }} Channels Editor</h4>
@ -100,16 +36,16 @@
<td><input type="text" class="channels" name="number" value="{{ chan_dict["number"] }}"></td> <td><input type="text" class="channels" name="number" value="{{ chan_dict["number"] }}"></td>
<td><input type="text" class="channels" name="thumbnail" value="{{ chan_dict["thumbnail"] }}"></td> <td><input type="text" class="channels" name="thumbnail" value="{{ chan_dict["thumbnail"] }}"></td>
{% if chan_dict["enabled"] %} {% if chan_dict["enabled"] %}
<td><input type="checkbox" class="channels" name="enabled" value=True checked></td> <td><input type="checkbox" class="channels" name="enabled" value=True checked></td>
{% else %} {% else %}
<td><input type="checkbox" class="channels" name="enabled" value=True ></td> <td><input type="checkbox" class="channels" name="enabled" value=True ></td>
{% endif %} {% endif %}
{% if chan_dict["favorite"] %} {% if chan_dict["favorite"] %}
<td><input type="checkbox" class="channels" name="favorite" value=1 checked></td> <td><input type="checkbox" class="channels" name="favorite" value=1 checked></td>
{% else %} {% else %}
<td><input type="checkbox" class="channels" name="favorite" value=1 ></td> <td><input type="checkbox" class="channels" name="favorite" value=1 ></td>
{% endif %} {% endif %}
<td> <td>
<form method="post" action="/api/channels?method=update&redirect=/channels_editor"> <form method="post" action="/api/channels?method=update&redirect=/channels_editor">
<input type="hidden" class="reset" name="id" value="{{ chan_dict["id"] }}"> <input type="hidden" class="reset" name="id" value="{{ chan_dict["id"] }}">
<input type="hidden" class="reset" name="name" value="{{ chan_dict["origin_name"] }}"> <input type="hidden" class="reset" name="name" value="{{ chan_dict["origin_name"] }}">
@ -119,7 +55,7 @@
<input type="hidden" class="reset" name="enabled" value=True> <input type="hidden" class="reset" name="enabled" value=True>
<input type="submit" value="Reset"> <input type="submit" value="Reset">
</form> </form>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

View File

@ -36,7 +36,7 @@
<tr> <tr>
<td>{{ config_item }}</td> <td>{{ config_item }}</td>
<td>{{ web_settings_dict[config_section][config_item]["value_default"] }}</td> <td>{{ web_settings_dict[config_section][config_item]["value_default"] }}</td>
<td> <td>
<form method="post" action="/api/settings?method=update&redirect=/settings"> <form method="post" action="/api/settings?method=update&redirect=/settings">
<input type="hidden" name="config_section" value="{{ config_section }}"> <input type="hidden" name="config_section" value="{{ config_section }}">
<input type="hidden" name="config_name" value="{{ config_item }}"> <input type="hidden" name="config_name" value="{{ config_item }}">
@ -47,17 +47,17 @@
<input type="text" size="25" name="config_value" value="{{ web_settings_dict[config_section][config_item]["value"] }}"> <input type="text" size="25" name="config_value" value="{{ web_settings_dict[config_section][config_item]["value"] }}">
{% endif %} {% endif %}
</td> </td>
<td style="display:flex;"> <td style="display:flex;">
<span style="margin:auto"> <span style="margin:auto">
<input type="submit" value="Update"> <input type="submit" value="Update">
</form> </form>
</span> </span>
<form style="margin:auto"> <form style="margin:auto">
<input type="hidden" name="config_section" value="{{ config_section }}"> <input type="hidden" name="config_section" value="{{ config_section }}">
<input type="hidden" name="config_name" value="{{ config_item }}"> <input type="hidden" name="config_name" value="{{ config_item }}">
<input type="hidden" name="config_value" value="{{ web_settings_dict[config_section][config_item]["value_default"] }}"> <input type="hidden" name="config_value" value="{{ web_settings_dict[config_section][config_item]["value_default"] }}">
<input type="hidden" name="config_default" value="{{ web_settings_dict[config_section][config_item]["value_default"] }}"> <input type="hidden" name="config_default" value="{{ web_settings_dict[config_section][config_item]["value_default"] }}">
<input type="submit" value="Reset"> <input type="submit" value="Reset">
</form> </form>
</td> </td>
</tr> </tr>

View File

@ -7,7 +7,7 @@
<div class="container"> <div class="container">
<table class="table-medium center action-col"> <table class="table-medium center action-col">
<tbody> <tbody>
<tr> <tr>
<th>Status</th> <th>Status</th>
<th>Channel</th> <th>Channel</th>
<th>Method</th> <th>Method</th>