1
0
mirror of https://github.com/fHDHR/fHDHR_NextPVR.git synced 2025-12-06 13:26:57 -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

@ -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>