config.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <!DOCTYPE html>
  2. <html lang="ja">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Settings - Startpage</title>
  7. <link rel="stylesheet" href="style.css">
  8. <style>
  9. .config-container {
  10. max-width: 600px;
  11. margin: 0 auto;
  12. padding: 40px 20px;
  13. }
  14. h1 {
  15. font-size: 2rem;
  16. margin-bottom: 40px;
  17. text-align: center;
  18. }
  19. .form-group {
  20. margin-bottom: 30px;
  21. }
  22. label {
  23. display: block;
  24. margin-bottom: 8px;
  25. font-size: 1rem;
  26. color: #aaa;
  27. }
  28. input[type="text"],
  29. input[type="color"] {
  30. width: 100%;
  31. padding: 12px;
  32. background-color: rgba(255, 255, 255, 0.05);
  33. border: 1px solid #333;
  34. color: #fff;
  35. font-family: 'Courier New', monospace;
  36. font-size: 1rem;
  37. border-radius: 4px;
  38. }
  39. input[type="color"] {
  40. width: 100px;
  41. height: 50px;
  42. cursor: pointer;
  43. }
  44. .button-group {
  45. display: flex;
  46. gap: 12px;
  47. margin-top: 40px;
  48. }
  49. button {
  50. flex: 1;
  51. padding: 14px;
  52. background-color: #4a9eff;
  53. border: none;
  54. color: #fff;
  55. font-family: 'Courier New', monospace;
  56. font-size: 1rem;
  57. cursor: pointer;
  58. border-radius: 4px;
  59. transition: background-color 0.2s;
  60. }
  61. button:hover {
  62. background-color: #3a8eef;
  63. }
  64. button.secondary {
  65. background-color: #333;
  66. }
  67. button.secondary:hover {
  68. background-color: #444;
  69. }
  70. .hint {
  71. font-size: 0.85rem;
  72. color: #666;
  73. margin-top: 4px;
  74. }
  75. .back-link {
  76. display: inline-block;
  77. margin-bottom: 20px;
  78. color: #4a9eff;
  79. text-decoration: none;
  80. }
  81. .back-link:hover {
  82. text-decoration: underline;
  83. }
  84. </style>
  85. </head>
  86. <body>
  87. <div class="config-container">
  88. <a href="index.html" class="back-link">← Back to Startpage</a>
  89. <h1>Settings</h1>
  90. <div class="form-group">
  91. <label for="backgroundColor">Background Color</label>
  92. <input type="color" id="backgroundColor" value="#000000">
  93. </div>
  94. <div class="form-group">
  95. <label for="textColor">Text Color</label>
  96. <input type="color" id="textColor" value="#ffffff">
  97. </div>
  98. <div class="form-group">
  99. <label for="accentColor">Accent Color</label>
  100. <input type="color" id="accentColor" value="#4a9eff">
  101. </div>
  102. <div class="form-group">
  103. <label for="searchEngine">Search Engine URL</label>
  104. <input type="text" id="searchEngine" value="https://kagi.com/search?q=" placeholder="https://kagi.com/search?q=">
  105. <div class="hint">Add search query parameter at the end (e.g., ?q=)</div>
  106. </div>
  107. <div class="form-group">
  108. <label for="backgroundImage">Background Image URL</label>
  109. <input type="text" id="backgroundImage" placeholder="background.jpg or https://..." value="">
  110. <div class="hint">Local file path or external URL</div>
  111. </div>
  112. <div class="form-group">
  113. <label for="backgroundBlur">Background Blur: <span id="blurValue">0</span>px</label>
  114. <input type="range" id="backgroundBlur" value="0" min="0" max="20" step="1">
  115. <div class="hint">Blur effect for background image (0-20px)</div>
  116. </div>
  117. <div class="form-group">
  118. <label for="maskColor">Mask Color</label>
  119. <input type="color" id="maskColor" value="#000000">
  120. <div class="hint">Color overlay on background image</div>
  121. </div>
  122. <div class="form-group">
  123. <label for="maskOpacity">Mask Opacity: <span id="opacityValue">60</span>%</label>
  124. <input type="range" id="maskOpacity" value="60" min="0" max="100" step="1">
  125. <div class="hint">Opacity of mask overlay (0-100%)</div>
  126. </div>
  127. </div>
  128. <script>
  129. const STORAGE_KEY = 'startpageConfig';
  130. const DEFAULT_CONFIG = {
  131. backgroundColor: '#000000',
  132. textColor: '#ffffff',
  133. accentColor: '#4a9eff',
  134. searchEngine: 'https://kagi.com/search?q=',
  135. backgroundImage: '',
  136. backgroundBlur: 0,
  137. maskColor: '#000000',
  138. maskOpacity: 60
  139. };
  140. const CONFIG_FIELDS = [
  141. 'backgroundColor',
  142. 'textColor',
  143. 'accentColor',
  144. 'searchEngine',
  145. 'backgroundImage',
  146. 'backgroundBlur',
  147. 'maskColor',
  148. 'maskOpacity'
  149. ];
  150. function getConfigFromInputs() {
  151. return CONFIG_FIELDS.reduce((config, field) => {
  152. config[field] = document.getElementById(field).value;
  153. return config;
  154. }, {});
  155. }
  156. function updateSliderValue(sliderId, valueId) {
  157. const slider = document.getElementById(sliderId);
  158. const valueDisplay = document.getElementById(valueId);
  159. valueDisplay.textContent = slider.value;
  160. }
  161. function setInputsFromConfig(config) {
  162. CONFIG_FIELDS.forEach(field => {
  163. document.getElementById(field).value = config[field];
  164. });
  165. updateSliderValue('backgroundBlur', 'blurValue');
  166. updateSliderValue('maskOpacity', 'opacityValue');
  167. }
  168. async function loadSettings() {
  169. const saved = localStorage.getItem(STORAGE_KEY);
  170. if (saved) {
  171. const config = JSON.parse(saved);
  172. setInputsFromConfig(config);
  173. applyTheme(config);
  174. } else {
  175. try {
  176. const response = await fetch('data.json');
  177. const data = await response.json();
  178. const config = data.config || DEFAULT_CONFIG;
  179. setInputsFromConfig(config);
  180. applyTheme(config);
  181. } catch (error) {
  182. console.error('Failed to load data.json:', error);
  183. setInputsFromConfig(DEFAULT_CONFIG);
  184. applyTheme(DEFAULT_CONFIG);
  185. }
  186. }
  187. }
  188. function applyTheme(config) {
  189. document.body.style.backgroundColor = config.backgroundColor;
  190. document.body.style.color = config.textColor;
  191. // Apply background image effects
  192. removeElementById('background-style');
  193. removeElementById('background-mask');
  194. const backgroundImage = config.backgroundImage;
  195. if (backgroundImage) {
  196. applyBackgroundImage(backgroundImage, config.backgroundBlur);
  197. applyMask(config.maskColor, config.maskOpacity);
  198. }
  199. }
  200. function removeElementById(id) {
  201. const element = document.getElementById(id);
  202. if (element) {
  203. element.remove();
  204. }
  205. }
  206. function applyBackgroundImage(backgroundImage, backgroundBlur) {
  207. const blur = backgroundBlur || 0;
  208. const filterValue = blur > 0 ? `blur(${blur}px)` : 'none';
  209. const bgStyle = document.createElement('style');
  210. bgStyle.id = 'background-style';
  211. bgStyle.textContent = `
  212. body::before {
  213. content: '';
  214. position: fixed;
  215. top: 0;
  216. left: 0;
  217. width: 100%;
  218. height: 100%;
  219. background-image: url('${backgroundImage}');
  220. background-size: cover;
  221. background-position: center;
  222. background-repeat: no-repeat;
  223. filter: ${filterValue};
  224. z-index: -2;
  225. }
  226. `;
  227. document.head.appendChild(bgStyle);
  228. document.body.style.backgroundImage = 'none';
  229. }
  230. function applyMask(maskColor, maskOpacity) {
  231. const opacity = (maskOpacity || 0) / 100;
  232. if (opacity > 0) {
  233. const mask = document.createElement('div');
  234. mask.id = 'background-mask';
  235. Object.assign(mask.style, {
  236. position: 'fixed',
  237. top: '0',
  238. left: '0',
  239. width: '100%',
  240. height: '100%',
  241. backgroundColor: maskColor || '#000000',
  242. opacity: opacity.toString(),
  243. zIndex: '-1',
  244. pointerEvents: 'none'
  245. });
  246. document.body.appendChild(mask);
  247. }
  248. }
  249. function autoSaveSettings() {
  250. const config = getConfigFromInputs();
  251. localStorage.setItem(STORAGE_KEY, JSON.stringify(config));
  252. applyTheme(config);
  253. }
  254. CONFIG_FIELDS.forEach(field => {
  255. const element = document.getElementById(field);
  256. element.addEventListener('input', autoSaveSettings);
  257. // Select all text on focus for text inputs
  258. if (element.type === 'text') {
  259. element.addEventListener('focus', function() {
  260. this.select();
  261. });
  262. }
  263. });
  264. document.getElementById('backgroundBlur').addEventListener('input', () => updateSliderValue('backgroundBlur', 'blurValue'));
  265. document.getElementById('maskOpacity').addEventListener('input', () => updateSliderValue('maskOpacity', 'opacityValue'));
  266. loadSettings();
  267. </script>
  268. </body>
  269. </html>