Setting generator init commit
Beta stage, but it should be bug free. Tested to work in Firefox and Chrome
This commit is contained in:
parent
fa91a84515
commit
8daa01419e
171
developers/setting-generator/index.html
Normal file
171
developers/setting-generator/index.html
Normal file
@ -0,0 +1,171 @@
|
||||
<html>
|
||||
<head>
|
||||
<script
|
||||
src="https://code.jquery.com/jquery-3.3.1.min.js"
|
||||
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
|
||||
crossorigin="anonymous"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tocas-ui/2.3.3/tocas.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/tocas-ui/2.3.3/tocas.js"></script>
|
||||
<style>
|
||||
body{
|
||||
background-color:#eaeaea;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<br><br>
|
||||
<div class="ts container">
|
||||
<div class="ts segment">
|
||||
<div class="ts header">
|
||||
Setting Generator
|
||||
<div class="sub header">For <a href="https://github.com/aceisace/E-Paper-Calendar-with-iCal-sync-and-live-weather">E-Paper-Calendar-with-iCal-sync-and-live-weather</a> Project<br>
|
||||
<ins>If no value is filled in for any of the row, the default value will be used.</ins>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<form class="ts form">
|
||||
<div class="field">
|
||||
<label>ical urls</label>
|
||||
<input id="ical_url" type="text" placeholder="https://calendar.google.com/calendar/ical/en.usa%23holiday%40group.v.calendar.google.com/public/basic.ics">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Events max range</label>
|
||||
<input id="events_max_range" type="text" placeholder="60">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>API Key</label>
|
||||
<input id="api_key" type="text" placeholder="">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Location</label>
|
||||
<input id="location" type="text" placeholder="Julich, DE">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Week Starts On</label>
|
||||
<input id="week_starts_on" type="text" placeholder="Monday">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Display Colors</label>
|
||||
<input id="display_colours" type="text" placeholder="bwr">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Language</label>
|
||||
<input id="language" type="text" placeholder="en">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Units</label>
|
||||
<input id="units" type="text" placeholder="metric">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Hours</label>
|
||||
<div class="ts checkboxes">
|
||||
<div class="ts radio checkbox">
|
||||
<input id="hour12" type="radio" name="hr">
|
||||
<label for="hour12">12</label>
|
||||
</div>
|
||||
<div class="ts radio checkbox">
|
||||
<input id="hour24" type="radio" name="hr">
|
||||
<label for="hour24">24</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<br>
|
||||
<button class="ts primary button" onClick="generate();">Generate</button>
|
||||
<br><br>
|
||||
<kbd>Developed by Toby Chui for E-Paper-Cal Project, Licensed under MIT</kbd>
|
||||
<details class="ts accordion">
|
||||
<summary>
|
||||
<i class="dropdown icon"></i> MIT License
|
||||
</summary>
|
||||
<div class="content">
|
||||
<p>Copyright 2019 Toby Chui <br>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<script>
|
||||
var template = 'ical_urls = [\n"{ics_url}"\n]\nevents_max_range = "{events_max_range}"\napi_key = "{api_key}"\nlocation = "{location}"\nweek_starts_on = "{weekStart}"\ndisplay_colours = "{display_colours}"\nlanguage = "{language}"\nunits = "{units}"\nhours = "{hours}"';
|
||||
|
||||
function generate(){
|
||||
var ics_url = $("#ical_url").val().trim();
|
||||
if (ics_url == ""){
|
||||
ics_url = $("#ical_url").attr("placeholder");
|
||||
}
|
||||
var events_max_range = $("#events_max_range").val().trim();
|
||||
if (events_max_range == ""){
|
||||
events_max_range = $("#events_max_range").attr("placeholder");
|
||||
}
|
||||
var api_key = $("#api_key").val().trim();
|
||||
if (api_key == ""){
|
||||
api_key = "";
|
||||
}
|
||||
var location = $("#location").val().trim();
|
||||
if (location == ""){
|
||||
location = $("#location").attr("placeholder");
|
||||
}
|
||||
var week_starts_on = $("#week_starts_on").val().trim();
|
||||
if (week_starts_on == ""){
|
||||
week_starts_on = $("#week_starts_on").attr("placeholder");
|
||||
}
|
||||
var display_colours = $("#display_colours").val().trim();
|
||||
if (display_colours == ""){
|
||||
display_colours = $("#display_colours").attr("placeholder");
|
||||
}
|
||||
var language = $("#language").val().trim();
|
||||
if (language == ""){
|
||||
language = $("#language").attr("placeholder");
|
||||
}
|
||||
var units = $("#units").val().trim();
|
||||
if (units == ""){
|
||||
units = $("#units").attr("placeholder");
|
||||
}
|
||||
var hours = "12";
|
||||
if ($('#hour24').is(':checked')){
|
||||
hours = "24";
|
||||
}
|
||||
//console.log(ics_url,events_max_range,api_key,location,week_starts_on,display_colours,language,units,hours);
|
||||
createPythonSetting(ics_url,events_max_range,api_key,location,week_starts_on,display_colours,language,units,hours);
|
||||
}
|
||||
|
||||
function rk(content,key,value){
|
||||
//Use to replace key-value pair in template string
|
||||
return content.split("{" + key + "}").join(value);
|
||||
}
|
||||
|
||||
function createPythonSetting(a,b,c,d,e,f,g,h,i){
|
||||
var box = template;
|
||||
box = rk(box,"ics_url",a);
|
||||
box = rk(box,"events_max_range",b);
|
||||
box = rk(box,"api_key",c);
|
||||
box = rk(box,"location",d);
|
||||
box = rk(box,"weekStart",e);
|
||||
box = rk(box,"display_colours",f);
|
||||
box = rk(box,"language",g);
|
||||
box = rk(box,"units",h);
|
||||
box = rk(box,"hours",i);
|
||||
var config = new Blob([box], {type : "text/plain"});
|
||||
var link = document.createElement('link');
|
||||
link.href = window.URL.createObjectURL(config);
|
||||
var a = document.createElement('A');
|
||||
a.href = link.href;
|
||||
a.download = link.href.substr(link.href.lastIndexOf('/') + 1);
|
||||
document.body.appendChild(a);
|
||||
$(a).attr('download','setting.py');
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
BIN
developers/setting-generator/screenshot.png
Normal file
BIN
developers/setting-generator/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
11
developers/setting-generator/setting.py
Normal file
11
developers/setting-generator/setting.py
Normal file
@ -0,0 +1,11 @@
|
||||
ical_urls = [
|
||||
"https://calendar.google.com/calendar/ical/en.usa%23holiday%40group.v.calendar.google.com/public/basic.ics"
|
||||
]
|
||||
events_max_range = "60"
|
||||
api_key = ""
|
||||
location = "Julich, DE"
|
||||
week_starts_on = "Monday"
|
||||
display_colours = "bwr"
|
||||
language = "en"
|
||||
units = "metric"
|
||||
hours = "12"
|
14
developers/setting-generator/settings.py.sample
Normal file
14
developers/setting-generator/settings.py.sample
Normal file
@ -0,0 +1,14 @@
|
||||
""" To quickly get started, fill in the following details:"""
|
||||
|
||||
ical_urls = [
|
||||
"https://calendar.google.com/calendar/ical/en.usa%23holiday%40group.v.calendar.google.com/public/basic.ics"
|
||||
]
|
||||
|
||||
events_max_range = "60"
|
||||
api_key = ""
|
||||
location = "Julich, DE"
|
||||
week_starts_on = "Monday"
|
||||
display_colours = "bwr"
|
||||
language = "en"
|
||||
units = "metric"
|
||||
hours = "24"
|
14
developers/setting-generator/settings.py_template
Normal file
14
developers/setting-generator/settings.py_template
Normal file
@ -0,0 +1,14 @@
|
||||
""" To quickly get started, fill in the following details:"""
|
||||
|
||||
ical_urls = [
|
||||
"{ics_url}"
|
||||
]
|
||||
|
||||
events_max_range = "{events_max_range}"
|
||||
api_key = "{api_key}"
|
||||
location = "{location}"
|
||||
week_starts_on = "{weekStart}"
|
||||
display_colours = "{display_colours}"
|
||||
language = "{language}"
|
||||
units = "{units}"
|
||||
hours = "{hours}"
|
Loading…
Reference in New Issue
Block a user