mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-06 06:26:57 -05:00
Compare commits
4 Commits
051fb87add
...
e3d8f64c5c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3d8f64c5c | ||
|
|
28383d89ec | ||
|
|
d915e4cbed | ||
|
|
51b9a85597 |
@ -3,6 +3,8 @@
|
||||
from .brython import Brython
|
||||
from .brython_stdlib import Brython_stdlib
|
||||
|
||||
from .brython_bry import Brython_bry
|
||||
|
||||
|
||||
class fHDHR_Brython():
|
||||
|
||||
@ -11,3 +13,5 @@ class fHDHR_Brython():
|
||||
|
||||
self.brython = Brython(fhdhr)
|
||||
self.brython_stdlib = Brython_stdlib(fhdhr)
|
||||
|
||||
self.brython_bry = Brython_bry(fhdhr)
|
||||
|
||||
@ -2,6 +2,7 @@ from flask import send_from_directory
|
||||
|
||||
import pathlib
|
||||
|
||||
|
||||
class Brython():
|
||||
endpoints = ["/brython.js"]
|
||||
endpoint_name = "file_brython_js"
|
||||
|
||||
19
fHDHR_web/brython/brython_bry.py
Normal file
19
fHDHR_web/brython/brython_bry.py
Normal 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')
|
||||
60
fHDHR_web/brython/brython_code.py
Normal file
60
fHDHR_web/brython/brython_code.py
Normal 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()
|
||||
@ -2,6 +2,7 @@ from flask import send_from_directory
|
||||
|
||||
import pathlib
|
||||
|
||||
|
||||
class Brython_stdlib():
|
||||
endpoints = ["/brython_stdlib.js"]
|
||||
endpoint_name = "file_brython_stdlib_js"
|
||||
|
||||
@ -5,9 +5,14 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<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>
|
||||
|
||||
<body>
|
||||
<body onload="brython({debug: 1, indexedDB: false})">
|
||||
|
||||
<h1 class="center" style="text-align:center">
|
||||
<span style="text-decoration: underline;"><strong><em>{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }}</em></strong>
|
||||
</span>
|
||||
|
||||
@ -1,70 +1,6 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% 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>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user