from js import document from datetime import datetime # 文字列のカウントを更新する関数 def update_text_counts(): text_input = document.getElementById('text_area').value # 空白ありの文字数を取得 length_with_spaces = len(text_input.replace("\n", "")) # 空白なしの文字数を取得 length_without_spaces = len(text_input.replace(" ", "").replace("\n", "")) # 行数の取得 lines = text_input.split("\n") line_count = len(lines) # 要素を取得して,内容を更新 document.getElementById('length_display').innerText = f"文字数(空白含む)  : {length_with_spaces}" document.getElementById('length_display_no_spaces').innerText = f"文字数(空白含まない): {length_without_spaces}" document.getElementById('line_count_display').innerText = f"行数         : {line_count}" # 今年の残り日数を計算する関数 def update_days_left(): today = datetime.today() end_of_year = datetime(today.year, 12, 31) start_of_year = datetime(today.year, 1, 1) days_left = (end_of_year - today).days days_total = (end_of_year - start_of_year).days + 1 document.getElementById('days_left_display').innerText = f"今年の残り日数    : {days_left}" document.getElementById('days_total_display').innerText = f"今年の全日数    : {days_total}" # ページ読み込み時に残り日数を表示 update_days_left() # 数字のカウントを更新する関数 def update_num_counts(): num_input = document.getElementById('text_area_num').value today = datetime.today() end_of_year = datetime(today.year, 12, 31) start_of_year = datetime(today.year, 1, 1) days_left = (end_of_year - today).days days_total = (end_of_year - start_of_year).days + 1 try: num_value = int(num_input) * days_total/(days_total-days_left) except ValueError: num_value = 0 document.getElementById('num_output_display').innerText = f"数字         : {num_value}"

今年の今日までの達成した数字を入力してください:

今年の全日数    : 0

今年の残り日数    : 0

年末までに達成できると予想される数字         : 0