├── .github └── workflows │ └── publish.yml ├── CHANGELOG.md ├── LICENSE ├── README.assets ├── attrsetting.png ├── clickhelp.png ├── clickhelp_en.png ├── setattrhint2.png └── taskListId.png ├── README.md ├── README_en_US.md ├── icon.png ├── index.html ├── preview.png ├── release.py ├── src ├── API.js ├── common.js ├── config.js ├── progressMain.js └── uncommon.js ├── static ├── holiday.json ├── icon.png ├── iconSetting.png ├── jquery-3.6.0.min.js ├── jscolor.js ├── layDate-v5.3.1 │ ├── laydate.js │ └── theme │ │ └── default │ │ ├── font │ │ ├── iconfont.eot │ │ ├── iconfont.svg │ │ ├── iconfont.ttf │ │ └── iconfont.woff │ │ └── laydate.css └── progressbar.css └── widget.json /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Create Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - 'v*' 7 | 8 | permissions: 9 | contents: write 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout code 16 | uses: actions/checkout@v2 17 | 18 | - name: Generate Package.zip 19 | run: find . -not -path '*/\.*' -print | xargs zip package.zip 20 | 21 | 22 | - name: Set up Python 23 | uses: actions/setup-python@v2 24 | with: 25 | python-version: '3.8' 26 | 27 | - name: Get CHANGELOGS 28 | run: python release.py 29 | 30 | - name: Pre Release 31 | uses: softprops/action-gh-release@v1 32 | if: contains(github.ref, 'beta') || contains(github.ref, 'alpha') 33 | with: 34 | body_path: ./result.txt 35 | files: package.zip 36 | prerelease: true 37 | token: ${{ secrets.GITHUB_TOKEN }} 38 | 39 | - name: Release 40 | uses: softprops/action-gh-release@v1 41 | if: ${{ ! contains(github.ref, 'beta') && ! contains(github.ref, 'alpha') }} 42 | with: 43 | body_path: ./result.txt 44 | files: package.zip 45 | prerelease: false 46 | token: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 更新日志 2 | 3 | ### v0.2.1 (2024年12月3日) 4 | 5 | - 改进:同步2025年法定节假日安排; 6 | - 改进:修改了部分由相对字体大小指定的宽度、高度; 7 | 8 | ### v0.2.0 (2024年7月10日) 9 | 10 | - 新增:删除其他挂件; 11 | 如果不再使用挂件,可快速移除位于当前工作空间的其他“任务进度条”挂件; 12 | - 新增:仅工作日(计算剩余时间时,跳过法定节假日与周末(补班除外)); 13 | - 改进:周进度的周数计算:改为调API获得ISOWeek; 14 | - 改进:使用临近的任务列表块id快速填充“任务列表块id”; 15 | - 改进:使用快捷键打开设置(`Ctrl+I`),刷新/保存(`F5`); 16 | 17 | ### v0.1.7 (2024年3月13日) 18 | - 修复:自动模式在换用API计算进度时,错误地展开了设置区的问题; 19 | - 修复:减少错误日志输出; 20 | 21 | ### v0.1.6 22 | - 改进:避免fetch error错误输出; 23 | 24 | ### v0.1.4 (2023年5月24日) 25 | - 修复: 手动模式无法使用的问题; 26 | - 修复: 设定不显示按钮后,载入时闪现按钮的问题; 27 | 28 | ### v0.1.3 (2023年5月23日) 29 | 30 | - 改进:时间模式改进: 31 | - 时间模式显示; 32 | - 剩余天数颜色变化; 33 | - 开始结束时间选择控件([layDate](https://layuiweb.com/laydate/index.htm)); 34 | - 时间设置为日期时,以天为单位计算进度; 35 | - 时间模式预设:天进度、周进度、月进度、年进度; 36 | - 改进:自动模式显示截止日期和剩余天数; 37 | - 改进:支持手动重设挂件高度; 38 | 39 | ### v0.1.2 (2022年12月22日) 40 | 41 | - 改进:时间模式时间段输出显示文案,支持显示相隔日期; 42 | - 新增:(beta)支持从`widgets/custom.js`导入用户设置,避免升级后设置丢失; 43 | - 改进:默认隐藏右侧的刷新和设置按钮; 44 | - 改进:除首次插入外,不再重设挂件宽高; 45 | 46 | ### v0.1.1 (2022年10月17日) 47 | 48 | - 修复:子项包括无序列表时,错误计算任务总数的问题;[#5](https://github.com/OpaqueGlass/progressBarT-sywidget/issues/5) 49 | 50 | ### v0.1.0 (2022年10月2日) 51 | 52 | - 新增:支持自动定位紧邻的任务列表块; 53 | - 改进:支持在挂件中设置属性、外观; 54 | - 改进:外观变更,将提示词移动至设置区(时间模式除外),减少视觉干扰; 55 | - 修复:进度条内部#process溢出问题; 56 | 57 | ### v0.0.1 58 | 59 | 从这里开始。 60 | 61 | - 自动模式 62 | - DOM模式支持观察任务列表变化,当任务列表发生新增、删除时自动计算进度;(在未来的软件更新中可能不再适用) 63 | - 支持Fn按钮设定任务全为未完成; 64 | - 手动模式 65 | - 支持点击、拖拽设定进度; 66 | - 时间模式 67 | - 支持计算时间进度; -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /README.assets/attrsetting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpaqueGlass/progressBarT-sywidget/29b19d6e42ad288a8e046c3601804dafd0471719/README.assets/attrsetting.png -------------------------------------------------------------------------------- /README.assets/clickhelp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpaqueGlass/progressBarT-sywidget/29b19d6e42ad288a8e046c3601804dafd0471719/README.assets/clickhelp.png -------------------------------------------------------------------------------- /README.assets/clickhelp_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpaqueGlass/progressBarT-sywidget/29b19d6e42ad288a8e046c3601804dafd0471719/README.assets/clickhelp_en.png -------------------------------------------------------------------------------- /README.assets/setattrhint2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpaqueGlass/progressBarT-sywidget/29b19d6e42ad288a8e046c3601804dafd0471719/README.assets/setattrhint2.png -------------------------------------------------------------------------------- /README.assets/taskListId.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpaqueGlass/progressBarT-sywidget/29b19d6e42ad288a8e046c3601804dafd0471719/README.assets/taskListId.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## progress Bar T 进度条 2 | 3 | > 展示进度条的思源笔记挂件。 4 | 5 | - “自动”模式:绑定任务列表,计算任务列表第一层级完成进度;[^1] 6 | - 手动模式:鼠标拖拽/点击设定进度; 7 | - 时间模式:显示时间段进度; 8 | 9 | > 当前版本: v0.2.1 10 | > **改进**:“仅工作日”功能更新2025年法定节假日安排; 11 | > **改进**:修改了部分由相对字体大小指定的宽度、高度,保证编辑器字号非默认时的挂件宽高; 12 | > 13 | > 详见更新日志CHANGELOG.md;[更新日志](CHANGELOG.md) ; 14 | 15 | > 挂件最初在2022年9月发布,感谢陪伴!现已进入维护阶段,停止功能新增;如遇bug缺陷请反馈。 16 | 17 | ## 快速开始(必读) 18 | 19 | - 操作: 20 | - 单击进度条右侧的文字:刷新/手动模式保存; 21 | - 双击进度条右侧的文字:显示或隐藏设置; 22 | - 自动模式仅能统计挂件紧邻的列表或手动设定的列表; 23 | - (隐藏进度条右侧文字时,请点击显示进度百分比的文字); 24 | 25 | ![click help](./README.assets/clickhelp.png) 26 | 27 | ![click help](/widgets/progressBarT/README.assets/clickhelp.png) 28 | - 操作成功提示: 29 | - 成功刷新时,进度百分比将显示上划线; 30 | - 成功保存时,进度百分比将显示下划线; 31 | - 时间模式: 32 | - 点击日历图标可使用日历选择器选择日期; 33 | - 手动输入时间模式日期时,需要满足`年月日时分之间用非数字的字符隔开`的条件,例:`2023年4月14日`、`23:23`; 34 | - 其他常见问题: 35 | - 文档打开时挂件高度由长变短,影响体验? 36 | 点击“重设挂件高度”按钮或手动拖拽保存一下高度; 37 | 38 | > 强烈建议完整阅读此文档 39 | 40 | ## 设置&使用方式 41 | 42 | ### 模式说明 43 | 44 | #### 自动模式 45 | 46 | 默认情况下(任务列表块id为空时),挂件将自动获取**下方紧邻的**任务列表块并计算其进度。(若下方没有任务列表块,则获取挂件上方紧邻的任务列表块) 47 | 48 | > (非必需,仅在浮窗等情况下需要)使用左侧的填充图标可以快速填充临近的任务列表块id; 49 | 50 | 您也可以复制已经存在的任务列表块id(不是列表项块)到设置->任务列表块id中,点击“保存设置”按钮在挂件中应用更改。 51 | 52 | ![复制任务列表容器块id](README.assets/taskListId.png) 53 | 54 | ![复制任务列表容器块id](/widgets/progressBarT/README.assets/taskListId.png) 55 | 56 | 自动模式下,双击`Fn`按钮(需要点开设置才能看到):取消/完成块id对应的**全部**任务列表项。 57 | 58 | > 鼠标悬停在刷新按钮上,有`(API)`标注时,无法在修改任务列表块后自动刷新,需要手动点击刷新按钮计算进度。 59 | 60 | #### 手动模式 61 | 62 | 点击进度条对应位置设定进度,然后点击刷新按钮保存进度,默认将在手动更改后0.5秒自动保存。 63 | 64 | 进度百分比下方出现下划线并随后消失,表明已经成功保存设定,请确定保存成功后再关闭文档。 65 | 66 | #### 时间模式 67 | 68 | 设置开始时间、结束时间,然后点击“保存设置”按钮。 69 | 70 | **挂件接受的时间字符串格式**为:(年、月、日、时、分之间需要使用任意的非数字字符隔开,小时为24小时制) 71 | 72 | - `yyyy MM dd`(年 月 日),例如`2020.1.1` `2020年1月1日` 73 | - `yyyy MM dd HH mm` (年 月 日 时 分),例如`2020.1.1 12.20` 74 | - `HH mm`(将在计算进度时自动补全为挂件运行时当天对应时间,用于展示当天进度),例如`12.20` `12:20` 75 | 76 | > 若为20xx年,年份数字可只写后两位。 77 | 78 | 请注意:时间模式下,进度刷新频率由`config.js`设定(请参考自定义设置),默认10分钟刷新一次; 79 | 80 | ### 自定义设置 81 | 82 | 打开`${思源data目录}/widgets/progressBarT/static/progressbar.css`,可编辑进度条显示样式,例如: 83 | 84 | - ~~进度条默认颜色;~~ 请注意,进度条颜色设定迁移至config.js设置; 85 | - 按钮样式,等; 86 | 87 | #### 在`config.js`中直接更改设置 88 | 89 | 打开`${思源data目录}/widgets/progressBarT/src/config.js`,可进行自定义设置,请参考设置项旁边的说明。以下是一些可能常用的设置项: 90 | 91 | - 手动模式操作后自动保存延迟`saveAttrTimeout`; 92 | - 自动模式API统计时自动计算间隔`refreshInterval`; 93 | - 自定义挂件属性名称`manualAttrName`、`autoTargetAttrName`、`startTimeAttrName`、`endTimeAttrName`等; 94 | - 自动模式:如果块不存在则创建块`createBlock`; 95 | - 时间模式:定时刷新间隔`timeModeRefreshInterval`; 96 | - 显示进度条右侧的刷新和设置按钮`showButtons`; 97 | - 挂件在各种情况下的宽高`widgetTimeModeHeight`、`widgetAutoModeWithTimeRemainHeight`、`widgetTimeModeHeight`、`widgetHeight`; 98 | 99 | #### 在`custom.js`中覆盖设置 100 | 101 | > 测试中,可能存在缺陷。 102 | 103 | 创建或编辑`${思源data目录}/widgets/custom.js`,仅支持`config.js`文件中defaultAttr(创建挂件时的默认设置)、setting(全局设置)下的设置项,以下是一个示例。 104 | 105 | ```javascript 106 | /*方案1:若之前有config,需要添加progressBarT的部分*/ 107 | export const config = { 108 | token: "", 109 | progressBarT:{/*若之前有config,则只加入progressBarT的部分*/ 110 | setting: { // 和config.js中setting对应 111 | showButtons: true 112 | }, 113 | defaultAttr: {// 和config.js 中 defaultAttr对应 114 | frontColor: "rgba(255, 255, 255, 1)", //前景色更改 115 | barWidth: 12, //进度条宽度 116 | frontColorSelector: {//前景色颜色选择器配置(jscolor),像这样复杂的设置项,如果有更改,必须重新自定义全部属性,不能只自定义部分属性 117 | value: 'rgba(51,153,255,0.5)', 118 | position: 'bottom', 119 | height: 80, 120 | backgroundColor: '#333', 121 | palette: 'rgba(0,0,0,0) #2da44eff #f1993eff #0080cfff #cb406cff #ff5454ff #af481bff #269affff',//预设颜色组 122 | paletteCols: 11, 123 | hideOnPaletteClick: true 124 | }, 125 | } 126 | } 127 | /*...其他挂件的自定义设置*/ 128 | }; 129 | ``` 130 | 131 | ```javascript 132 | /*方案2 单独配置export*/ 133 | export const progressBarT = { 134 | setting: { // 和config.js中setting对应 135 | showButtons: true 136 | }, 137 | defaultAttr: {// 和config.js 中 defaultAttr对应 138 | frontColor: "rgba(255, 255, 255, 1)", //前景色更改 139 | barWidth: 12 //进度条宽度 140 | } 141 | } 142 | ``` 143 | 144 | #### 节假日信息 145 | 146 | v0.2.0新增了在计算任务进度时“智能”地跳过中国法定节假日以及周末,目前挂件使用的法定节假日数据请悬停在“仅工作日”处查看,或直接参考:`./static/holiday.json`。 147 | 148 | 如果节假日未能涵盖实际假期,又或者需要使用其他地区的节假日信息,请创建`思源工作空间目录/data/storage/progressBarT/holiday.json`(优先生效),具体格式请参考`./static/holiday.json`。 149 | 150 | 大致说明如下: 151 | 152 | - `holidays`:节假日,这一天将会被记为假期,不统计在剩余时间中; 153 | - `workdays`:工作日,这一天将会被记为工作日,即使是周六或周日; 154 | - 值均为`yyyy-MM-dd`的字符串数组; 155 | 156 | > 请注意计算方式(未在这里列出的情况,可能存在计算问题): 157 | > 158 | > 开始至结束日期间,计算开始日,但不计算结束日,即在结束日当天,将会显示当天(或 还剩0天);(如果结束日为假日,则结束日视为最后一个工作日) 159 | > 160 | > 例1 2024-06-30周日~2024-07-01周一,共1天,0工作日; 161 | > 162 | > 这种情况下,在6月30日便会显示当天,且进度为NaN,这是因为6月30日并不是工作日,则时间段总工作日为0,计算进度百分比时,将出现除以0的情况; 163 | > 164 | > 在已经超过截止日期的情况下,超过x天的计算方式如下:时间段内最后一个工作日至当前时间的全部天数(含假日); 165 | > 166 | > 例2 2024-07-04周四~2024-07-08周一,共4天,2工作日; 167 | > 168 | > 在这种情况下,周四显示“还有2天”,周五显示“还有1天”,周六日一均会显示当天(因为到截止日,已无工作日); 169 | 170 | #### 隐藏进度百分比 171 | 172 | 开发者不推荐隐藏进度百分比,因为这未经过测试,且隐藏后不能向用户反馈保存情况; 173 | 174 | 若要隐藏,可使用css自行实现,隐藏后,可以使用`Ctrl+I`打开关闭设置界面,使用`F5`刷新/保存进度; 175 | 176 | 177 | ## ⚠️注意 178 | 179 | > 由于开发者能力有限,挂件还存在一些问题。 180 | 181 | - 理论上,自动模式通过页面直接计算任务进度,但有些情况将切换为API统计,需手动点击刷新按钮更新进度。例如: 182 | - 任务列表和进度条不在同一页面; 183 | - 任务列表和进度条相距较远; 184 | - 因为挂件未更新而在新版本失效; 185 | - 没有设置界面,需要自行设定挂件属性; 186 | - 任务完成/取消完成勾选的变动,通过MutationObserver获取对应任务节点的class属性变化实现,频繁高亮、选中任务列表块可能导致卡顿; 187 | - 关于`7alltask`统计子任务功能: 188 | - 上一层级任务(父任务)完成,其下子任务不会被认为完成,父任务、子任务统计时权重相同; 189 | - 在进行大量任务节点增删时,会反复触发MutaionObserver(节点变动监视)重设,可能导致卡顿; 190 | 191 | ## 反馈bug 192 | 193 | (推荐)请到github仓库[新建issue](https://github.com/OpaqueGlass/progressBarT-sywidget/issues/new); 194 | 195 | 如您无法访问github仓库,请[点击这里填写问卷](https://wj.qq.com/s2/12395364/b69f/)。 196 | 197 | ## 参考&感谢 198 | 199 | 开发过程中参考了以下网络博客: 200 | 201 | | 博客原文-作者 | 备注 | 202 | | ------------------------------------------------------------ | -------------- | 203 | | https://blog.csdn.net/m0_47214030/article/details/117911609 作者:[☆*往事随風*☆](https://blog.csdn.net/m0_47214030) | 进度条鼠标拖拽 | 204 | 205 | 开发过程中参考了以下大佬的项目: 206 | 207 | | github仓库 / 开发者 | 开源协议 | 备注 | 208 | | ----------------| --------| --------------| 209 | | [widget-query](https://github.com/Zuoqiu-Yingyi/widget-query) / [Zuoqiu-Yingyi](https://github.com/Zuoqiu-Yingyi) | AGPL-3.0 | 从custom.js导入自定义设置 | 210 | 211 | 212 | 213 | ### 依赖 214 | 215 | 1. [jQuery](https://jquery.com/) (本项目中通过jQuery选择页面元素); 216 | 217 | ``` 218 | jQuery JavaScript Library v3.6.0 https://jquery.com/ 219 | Copyright OpenJS Foundation and other contributors 220 | Released under the MIT license https://jquery.org/license 221 | ``` 222 | 223 | 2. jsColor 224 | 225 | 开源协议:[GNU GPL v3](http://www.gnu.org/licenses/gpl-3.0.txt) 226 | 227 | 官方网站:[https://jscolor.com/download/](https://jscolor.com/download/) 228 | 229 | 3. [layDate](http://www.layui.com/laydate/) 230 | 231 | ``` 232 | http://www.layui.com/laydate/ 233 | https://github.com/layui/laydate 234 | MIT license 235 | ``` 236 | 237 | 238 | 239 | ### 图标 240 | 241 | 1. [刷新按钮图标](https://www.iconfinder.com/icons/5402417/refresh_rotate_sync_update_reload_repeat_icon),作者:[amoghdesign](https://www.iconfinder.com/amoghdesign),许可协议:[CC3.0 BY-NC](http://creativecommons.org/licenses/by-nc/3.0/); 242 | 243 | 2. [设置按钮图标](https://www.iconfinder.com/icons/5925600/control_options_settings_icon),作者:[IconPai](https://www.iconfinder.com/iconpai),许可说明:Free for commercial use (Include link to authors website); 244 | 245 | 246 | 247 | [^1]: 计算默认使用DOM统计任务列表进度、配合MutationObserver在任务列表变化时触发重新统计,但在一些条件下无法使用,详见“注意”一节; 248 | -------------------------------------------------------------------------------- /README_en_US.md: -------------------------------------------------------------------------------- 1 | ## progress Bar T 2 | 3 | > This document was translated by Google Translate. 4 | > 5 | > Note that some text (such as date) is not internationalized. 6 | 7 | > Siyuan note widget showing the progress bar. 8 | 9 | - "Automatic" mode: bind the task list and calculate the completion progress; [^1] 10 | - Manual mode: drag/click to set the progress; 11 | - Time mode: display the progress of the time period; 12 | 13 | ## Quick start (At least read this section) 14 | 15 | - operation: 16 | - Double-click the text on the right side of the progress bar: show or hide settings; 17 | - Automatic mode can only count the list next to the widget or the list set manually; 18 | - (When hiding the text on the right side of the progress bar, please click the text showing the progress percentage); 19 | 20 | ![click help](./README.assets/clickhelp_en.png) 21 | 22 | - Tips for successful operation: 23 | - When successfully refreshed, the progress percentage will be overlined; 24 | - When saving successfully, the progress percentage will be underlined; 25 | - modes: 26 | - Click the text on the right side of the progress bar: Refresh/Save in manual mode; 27 | - When manually entering the date in the time mode, it is necessary to meet the condition of "year, month, day, hour and minute separated by non-numeric characters", for example: `2023-1-1`, `23:23`; 28 | - other: 29 | - When the document is opened, the widget changes from long to short, which affects the experience? Click the "Reset Widget Height" button or manually drag and drop to save the height; 30 | 31 | > It is strongly recommended to read this document in its entirety; 32 | 33 | ## Setup & Usage 34 | 35 | ### Mode Description 36 | 37 | #### Automatic Mode 38 | 39 | By default (when the task list block id is empty), the widget will automatically get the **task list block immediately below and calculate its progress. (If there is no task list block below, get the task list block immediately above the widget) 40 | 41 | > (Optional, only necessary in the case of pop-up windows, etc.) Using the padding icon on the left, you can quickly fill in the adjacent task list block IDs. 42 | 43 | You can also copy an existing task list block id (not a list item block) to Settings->Task List block id, click the "Save Settings" button to apply the changes in the widget. 44 | 45 | ![Copy task list container block id](README.assets/taskListId.png) 46 | 47 | ![Copy task list container block id](/widgets/progressBarT/README.assets/taskListId.png) 48 | 49 | In automatic mode, double-click the `Fn` button (you need to open the settings to see it): cancel/complete **all** task list items corresponding to the block id. 50 | 51 | > When the mouse hovers on the refresh button, when there is `(API)` marked, it cannot be automatically refreshed after modifying the task list block, and you need to manually click the refresh button to calculate the progress. 52 | 53 | #### Manual mode 54 | 55 | Click the corresponding position of the progress bar to set the progress, and then click the refresh button to save the progress. By default, it will be automatically saved 0.5 seconds after the manual change. 56 | 57 | An underline appears under the progress percentage and then disappears, indicating that the settings have been successfully saved. Please confirm that the save is successful before closing the document. 58 | 59 | #### Time Mode 60 | 61 | Set the start time, end time, and click the "Save Settings" button. 62 | 63 | **The time string format accepted by the widget** is: (year, month, day, hour, and minute need to be separated by any non-numeric characters, and the hour is in 24-hour format) 64 | 65 | - `yyyy MM dd` (year month day), such as `2020.1.1` `2020.1.1` 66 | - `yyyy MM dd HH mm` (year month day hour minute), for example `2020.1.1 12.20` 67 | - `HH mm` (will be automatically completed when calculating the progress as the corresponding time of the widget running day, used to display the progress of the day), such as `12.20` `12:20` 68 | 69 | > If it is 20xx, only the last two digits of the year number can be written. 70 | 71 | Please note: In the time mode, the progress refresh frequency is set by `config.js` (please refer to the custom settings), and the default is to refresh once every 10 minutes; 72 | 73 | 74 | ### Custom settings 75 | 76 | Open `${Siyuan data directory}/widgets/progressBarT/static/progressbar.css` to edit the display style of the progress bar, for example: 77 | 78 | - ~~ The default color of the progress bar; ~~ Please note that the color setting of the progress bar is migrated to the config.js setting; 79 | - button styles, etc.; 80 | 81 | #### Changing settings directly in `config.js` 82 | 83 | Open `${Siyuan data directory}/widgets/progressBarT/src/config.js` for custom settings, please refer to the description next to the setting items. Here are some settings that may be commonly used: 84 | 85 | - Automatic save delay `saveAttrTimeout` after manual mode operation; 86 | - Automatic calculation interval `refreshInterval` when API statistics in automatic mode; 87 | - Custom widget attribute names `manualAttrName`, `autoTargetAttrName`, `startTimeAttrName`, `endTimeAttrName`, etc.; 88 | - automatic mode: create block `createBlock` if block does not exist; 89 | - Time mode: timed refresh interval `timeModeRefreshInterval`; 90 | - Show refresh and set button `showButtons` to the right of the progress bar; 91 | 92 | #### Override settings in `custom.js` 93 | 94 | > During testing, there may be bugs. 95 | 96 | Create or edit `${Siyuan data directory}/widgets/custom.js`, only support the setting items under defaultAttr (the default setting when creating widgets) and setting (global settings) in the `config.js` file, the following is a example. 97 | 98 | ```javascript 99 | /*Scheme 1: If there is config before, you need to add the part of progressBarT*/ 100 | export const config = { 101 | token: "", 102 | progressBarT:{/*If there is config before, only add the part of progressBarT*/ 103 | setting: { // corresponds to setting in config.js 104 | showButtons: true 105 | }, 106 | defaultAttr: {// corresponds to defaultAttr in config.js 107 | frontColor: "rgba(255, 255, 255, 1)", // change the front color 108 | barWidth: 12, // progress bar width 109 | frontColorSelector: {//Foreground color color selector configuration (jscolor), if such a complex setting item is changed, all attributes must be re-customized, not only some attributes 110 | value: 'rgba(51,153,255,0.5)', 111 | position: 'bottom', 112 | height: 80, 113 | backgroundColor: '#333', 114 | palette: 'rgba(0,0,0,0) #2da44eff #f1993eff #0080cfff #cb406cff #ff5454ff #af481bff #269affff',//preset color group 115 | paletteCols: 11, 116 | hideOnPaletteClick: true 117 | }, 118 | } 119 | } 120 | /*...custom settings for other widgets*/ 121 | }; 122 | ``` 123 | 124 | ```javascript 125 | /*Scheme 2 configure export separately*/ 126 | export const progressBarT = { 127 | setting: { // corresponds to setting in config.js 128 | showButtons: true 129 | }, 130 | defaultAttr: {// corresponds to defaultAttr in config.js 131 | frontColor: "rgba(255, 255, 255, 1)", // change the front color 132 | barWidth: 12 //Progress bar width 133 | } 134 | } 135 | ``` 136 | 137 | #### Holiday Information (Only Workdays ) 138 | 139 | In version v0.2.0, we are happy to introduce the "Only Workday" feature to automatically ignore weekends while calculating remaining days. 140 | 141 | If you need to use holiday information in your region, please create `${Work space}/data/storage/progressBarT/holiday.json` and refer to the format in `./static/holiday.json`. 142 | 143 | Briefly: 144 | 145 | - `holidays`: These days will not count in 'Remaining days'; 146 | - `workdays`: These days will count in 'Remaining days' even if they are weekends; 147 | 148 | Values should be an array of strings with the date format `yyyy-MM-dd`. 149 | 150 | 151 | #### Hide Progress Percentage 152 | 153 | Developers do not recommend hiding the progress percentage as this has not been tested and, once hidden, it cannot provide feedback to the user about the saving status. 154 | 155 | If you wish to hide it, you can achieve this using CSS. After hiding, you can use Ctrl+I to open and close the settings interface, and use F5 to refresh/save progress. 156 | 157 | ## ⚠️ Note 158 | 159 | > Due to the limited ability of developers, there are still some problems in the widget. 160 | 161 | - In theory, the automatic mode calculates the task progress directly through the page, but in some cases, it will switch to API statistics, and you need to manually click the refresh button to update the progress. For example: 162 | - Task list and progress bar are not on the same page; 163 | - The task list and the progress bar are far apart; 164 | - Invalid in the new version because the widget has not been updated; 165 | - There is no setting interface, you need to set the widget properties by yourself; 166 | - The change of task completion/cancellation is achieved by obtaining the change of the class attribute of the corresponding task node through MutationObserver. Frequent highlighting and selection of task list blocks may cause freezes; 167 | - About `7alltask` statistical subtask function: 168 | - When the task of the previous level (parent task) is completed, the sub-tasks below it will not be considered as completed, and the weight of the parent task and sub-tasks is the same when counting; 169 | - When a large number of task nodes are added or deleted, the MutaionObserver (node change monitoring) reset will be triggered repeatedly, which may cause freezes; 170 | 171 | ## Feedback bugs 172 | 173 | Please go to the github repository and [create a new issue](https://github.com/OpaqueGlass/progressBarT-sywidget/issues/new); 174 | 175 | ## References & Thanks 176 | 177 | The following web blogs were referenced during the development process: 178 | 179 | | Original Blog - Author | Remarks | 180 | | -------------------------------------------------- ----------- | -------------- | 181 | | https://blog.csdn.net/m0_47214030/article/details/117911609 Author: [☆*The past follows the wind*☆](https://blog.csdn.net/m0_47214030) | Progress bar mouse drag | 182 | 183 | During the development process, the following projects (created by awesome developer) were referred to: 184 | 185 | | github warehouse / developer | Open source agreement | Remarks | 186 | | ----------------| --------| --------------| 187 | | [widget-query](https://github.com/Zuoqiu-Yingyi/widget-query) / [Zuoqiu-Yingyi](https://github.com/Zuoqiu-Yingyi) | AGPL-3.0 | From custom. js import custom settings | 188 | 189 | 190 | 191 | ### Dependencies 192 | 193 | 1. jQuery (select page elements through jQuery in this project); 194 | 195 | ``` 196 | jQuery JavaScript Library v3.6.0 https://jquery.com/ 197 | Copyright OpenJS Foundation and other contributors 198 | Released under the MIT license https://jquery.org/license 199 | ``` 200 | 201 | 2. jsColor 202 | 203 | Open source license: [GNU GPL v3](http://www.gnu.org/licenses/gpl-3.0.txt) 204 | 205 | Official website: [https://jscolor.com/download/](https://jscolor.com/download/) 206 | 207 | 3. [layDate](http://www.layui.com/laydate/) 208 | 209 | ``` 210 | http://www.layui.com/laydate/ 211 | https://github.com/layui/laydate 212 | MIT license 213 | ``` 214 | 215 | ### icon 216 | 217 | 1. [Refresh button icon](https://www.iconfinder.com/icons/5402417/refresh_rotate_sync_update_reload_repeat_icon), author: [amoghdesign](https://www.iconfinder.com/amoghdesign), license agreement: [CC3. 0 BY-NC](http://creativecommons.org/licenses/by-nc/3.0/); 218 | 219 | 2. [Settings button icon](https://www.iconfinder.com/icons/5925600/control_options_settings_icon), author: [IconPai](https://www.iconfinder.com/iconpai), license description: Free for commercial use (Include link to authors website); 220 | 221 | 222 | 223 | [^1]: The calculation uses DOM to count the progress of the task list by default, and cooperates with MutationObserver to trigger re-statistics when the task list changes, but it cannot be used under some conditions, see the "Note" section for details; -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpaqueGlass/progressBarT-sywidget/29b19d6e42ad288a8e046c3601804dafd0471719/icon.png -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | progress bar for sy 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 |
20 | 21 |
22 |
23 | 24 |
25 | 26 |
N/A
27 | 28 | 31 |
32 | 33 |
34 |
35 | 38 | 181 | 182 | 183 | 184 | 185 | 186 | -------------------------------------------------------------------------------- /preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpaqueGlass/progressBarT-sywidget/29b19d6e42ad288a8e046c3601804dafd0471719/preview.png -------------------------------------------------------------------------------- /release.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | with open('CHANGELOG.md', 'r', encoding='utf-8') as f: 4 | readme_str = f.read() 5 | 6 | match_obj = re.search(r'(?<=### )[\s\S]*?(?=#)', readme_str, re.DOTALL) 7 | if match_obj: 8 | h3_title = match_obj.group(0) 9 | with open('result.txt', 'w') as f: 10 | f.write(h3_title) 11 | else: 12 | with open('result.txt', 'w') as f: 13 | f.write("") 14 | -------------------------------------------------------------------------------- /src/API.js: -------------------------------------------------------------------------------- 1 | import { warnPush } from "./common.js"; 2 | import {token, includeOs} from "./config.js"; 3 | //向思源api发送请求 4 | export async function postRequest(data, url){ 5 | let result; 6 | await fetch(url, { 7 | body: JSON.stringify(data), 8 | method: 'POST', 9 | headers: { 10 | "Authorization": "Token "+token, 11 | "Content-Type": "application/json" 12 | } 13 | }).then((response) => { 14 | result = response.json(); 15 | }); 16 | return result; 17 | } 18 | 19 | export async function checkResponse4Result(response){ 20 | if (response.code != 0 || response.data == null){ 21 | return null; 22 | }else{ 23 | return response; 24 | } 25 | } 26 | 27 | export async function checkResponse(response){ 28 | if (response.code == 0){ 29 | return 0; 30 | }else{ 31 | return -1; 32 | } 33 | } 34 | 35 | //SQL(api) 36 | export async function queryAPI(sqlstmt){ 37 | let url = "/api/query/sql"; 38 | let response = await postRequest({stmt: sqlstmt},url); 39 | if (response.code == 0 && response.data != null){ 40 | return response.data; 41 | } 42 | return null; 43 | } 44 | 45 | //列出子文件(api) 46 | export async function getSubDocsAPI(notebookId, path){ 47 | let url = "/api/filetree/listDocsByPath"; 48 | let response = await postRequest({notebook: notebookId, path: path}, url); 49 | if (response.code != 0 || response.data == null){ 50 | return new Array(); 51 | } 52 | return response.data.files; 53 | } 54 | 55 | /** 56 | * 添加属性(API) 57 | * @param attrs 属性对象 58 | * @blockid 挂件id 59 | * */ 60 | export async function addblockAttrAPI(attrs, blockid = thisWidgetId){ 61 | let url = "/api/attr/setBlockAttrs"; 62 | let attr = { 63 | id: blockid, 64 | attrs: attrs 65 | } 66 | let result = await postRequest(attr, url); 67 | return checkResponse(result); 68 | } 69 | 70 | //获取挂件块参数(API) 71 | export async function getblockAttrAPI(blockid = thisWidgetId){ 72 | let url = "/api/attr/getBlockAttrs"; 73 | let response = await postRequest({id: blockid}, url); 74 | if (response.code != 0){ 75 | throw Error("获取挂件块参数失败"); 76 | } 77 | return response; 78 | } 79 | 80 | /** 81 | * 更新块(返回值有删减) 82 | * @param {String} text 更新写入的文本 83 | * @param {String} blockid 更新的块id 84 | * @param {String} textType 文本类型,markdown、dom可选 85 | * @returns 被更新的块id,为null则未知失败,为空字符串则写入失败 86 | */ 87 | export async function updateBlockAPI(text, blockid, textType = "markdown"){ 88 | let url = "/api/block/updateBlock"; 89 | let data = {dataType: textType, data: text, id: blockid}; 90 | let response = await postRequest(data, url); 91 | try{ 92 | if (response.code == 0 && response.data != null && isValidStr(response.data[0].doOperations[0].id)){ 93 | return response.data[0].doOperations[0].id; 94 | } 95 | if (response.code == -1){ 96 | console.warn("更新块失败", response.msg); 97 | return ""; 98 | } 99 | }catch(err){ 100 | console.error(err); 101 | console.warn(response.msg); 102 | } 103 | return null; 104 | } 105 | 106 | /** 107 | * 插入块(返回值有删减) 108 | * @param {*} text 文本 109 | * @param {*} blockid 创建的块将平级插入于该块之后 110 | * @param {*} textType 插入的文本类型,"markdown" or "dom" 111 | * @return 创建的块id,为null则未知失败,为空字符串则写入失败,错误提示信息将输出在 112 | */ 113 | export async function insertBlockAPI(text, blockid, textType = "markdown"){ 114 | let url = "/api/block/insertBlock"; 115 | let data = {dataType: textType, data: text, previousID: blockid}; 116 | let response = await postRequest(data, url); 117 | try{ 118 | if (response.code == 0 && response.data != null && isValidStr(response.data[0].doOperations[0].id)){ 119 | return response.data[0].doOperations[0].id; 120 | } 121 | if (response.code == -1){ 122 | console.warn("插入块失败", response.msg); 123 | return ""; 124 | } 125 | }catch(err){ 126 | console.error(err); 127 | console.warn(response.msg); 128 | } 129 | return null; 130 | 131 | } 132 | 133 | /** 134 | * 判断字符串是否为空 135 | * 警告"null"也会被视为空 136 | * @param {*} s 137 | * @returns 非空字符串true,空字符串false 138 | */ 139 | export function isValidStr(s){ 140 | if (s == undefined || s == null || s === '' || s === "null") { 141 | return false; 142 | } 143 | return true; 144 | } 145 | 146 | /** 147 | * 渲染sprig 148 | */ 149 | export async function renderSprig(template){ 150 | let url = "/api/template/renderSprig"; 151 | let data = {template: template}; 152 | let response = await postRequest(data, url); 153 | if (response == null || response.code != 0 || response.data == null){ 154 | warnPush("API响应错误", response?.msg); 155 | return null; 156 | } 157 | return response.data; 158 | } 159 | 160 | /** 161 | * 推送普通消息 162 | * @param {*} msgText 推送的内容 163 | * @param {*} timeout 显示时间,单位毫秒 164 | * @return 0正常推送 -1 推送失败 165 | */ 166 | export async function pushMsgAPI(msgText, timeout){ 167 | let url = "/api/notification/pushMsg"; 168 | let response = await postRequest({msg: msgText, timeout: timeout}, url); 169 | if (response.code != 0 || response.data == null || !isValidStr(response.data.id)){ 170 | return -1; 171 | } 172 | return 0; 173 | } 174 | 175 | export async function getJSONFile(path) { 176 | const url = "/api/file/getFile"; 177 | let response = await postRequest({"path": path}, url); 178 | if (response.code == 404) { 179 | return null; 180 | } 181 | return response; 182 | } 183 | 184 | /** 185 | * 获取当前文档id(伪api) 186 | * 优先使用jquery查询 187 | */ 188 | export async function getCurrentDocIdF(){ 189 | let thisDocId; 190 | let thisWidgetId = getCurrentWidgetId(); 191 | //依靠widgetId sql查,运行时最稳定方案(但挂件刚插入时查询不到!) 192 | if (isValidStr(thisWidgetId)){ 193 | let queryResult = await queryAPI("SELECT root_id as parentId FROM blocks WHERE id = '" + thisWidgetId + "'"); 194 | console.assert(queryResult != null && queryResult.length == 1, "SQL查询失败", queryResult); 195 | if (queryResult!= null && queryResult.length >= 1){ 196 | console.log("获取当前文档idBy方案A"+queryResult[0].parentId); 197 | return queryResult[0].parentId; 198 | } 199 | } 200 | 201 | try{ 202 | if (isValidStr(thisWidgetId)){ 203 | //通过获取挂件所在页面题头图的data-node-id获取文档id【安卓下跳转返回有问题,原因未知】 204 | let thisDocId = $(window.parent.document).find(`div.protyle-content:has(.iframe[data-node-id="${thisWidgetId}"])`) 205 | .find(`.protyle-background`).attr("data-node-id"); 206 | if (isValidStr(thisDocId)){ 207 | console.log("获取当前文档idBy方案B" + thisDocId); 208 | return thisDocId; 209 | } 210 | } 211 | 212 | }catch(err){ 213 | console.warn(err); 214 | } 215 | 216 | //widgetId不存在,则使用老方法(存在bug:获取当前展示的页面id(可能不是挂件所在的id)) 217 | if (!isValidStr(thisWidgetId)){ 218 | thisDocId = $(window.parent.document).find(".layout__wnd--active .protyle.fn__flex-1:not(.fn__none) .protyle-background").attr("data-node-id"); 219 | console.log("获取当前文档idBy方案C" + thisDocId); 220 | return thisDocId; 221 | } 222 | return null; 223 | } 224 | 225 | /** 226 | * 获取当前挂件id 227 | * @returns 228 | */ 229 | export function getCurrentWidgetId(){ 230 | try{ 231 | return window.frameElement.parentElement.parentElement.dataset.nodeId; 232 | }catch(err){ 233 | console.warn("getCurrentWidgetId window...nodeId方法失效"); 234 | return null; 235 | } 236 | } 237 | 238 | /** 239 | * 检查运行的操作系统 240 | * @return true 可以运行,当前os在允许列表中 241 | */ 242 | export function checkOs(){ 243 | try{ 244 | if (includeOs.indexOf(window.top.siyuan.config.system.os.toLowerCase()) != -1){ 245 | return true; 246 | } 247 | }catch(err){ 248 | console.error(err); 249 | console.warn("检查操作系统失败"); 250 | } 251 | 252 | return false; 253 | } 254 | /** 255 | * 删除块 256 | * @param {*} blockid 257 | * @returns 258 | */ 259 | export async function removeBlockAPI(blockid){ 260 | let url = "/api/block/deleteBlock"; 261 | let response = await postRequest({id: blockid}, url); 262 | if (response.code == 0){ 263 | return true; 264 | } 265 | warnPush("删除块失败", response); 266 | return false; 267 | } 268 | 269 | /** 270 | * 获取块kramdown源码 271 | * @param {*} blockid 272 | * @returns 273 | */ 274 | export async function getKramdown(blockid){ 275 | let url = "/api/block/getBlockKramdown"; 276 | let response = await postRequest({id: blockid}, url); 277 | if (response.code == 0 && response.data != null && "kramdown" in response.data){ 278 | return response.data.kramdown; 279 | } 280 | return null; 281 | } 282 | 283 | export function isDarkMode() { 284 | return window.top.siyuan.config.appearance.mode == 1 ? true : false; 285 | } -------------------------------------------------------------------------------- /src/common.js: -------------------------------------------------------------------------------- 1 | 2 | // debug push 3 | let g_DEBUG = 2; 4 | const g_NAME = "progress"; 5 | const g_FULLNAME = "进度条T"; 6 | 7 | function pushDebug(text) { 8 | let areaElem = document.getElementById("debugArea"); 9 | if (areaElem) { 10 | areaElem.value = areaElem.value + `\n${new Date().toLocaleTimeString()}` + text; 11 | areaElem.scrollTop = areaElem.scrollHeight; 12 | } 13 | } 14 | 15 | /* 16 | LEVEL 0 忽略所有 17 | LEVEL 1 仅Error 18 | LEVEL 2 Err + Warn 19 | LEVEL 3 Err + Warn + Info 20 | LEVEL 4 Err + Warn + Info + Log 21 | LEVEL 5 Err + Warn + Info + Log + Debug 22 | */ 23 | function commonPushCheck() { 24 | if (window.top["OpaqueGlassDebugV2"] == undefined || window.top["OpaqueGlassDebugV2"][g_NAME] == undefined) { 25 | return g_DEBUG; 26 | } 27 | return window.top["OpaqueGlassDebugV2"][g_NAME]; 28 | } 29 | 30 | export function debugPush(str, ...args) { 31 | pushDebug(str); 32 | if (commonPushCheck() >= 5) { 33 | console.debug(`${g_FULLNAME}[D] ${new Date().toLocaleString()} ${str}`, ...args); 34 | } 35 | } 36 | 37 | export function logPush(str, ...args) { 38 | pushDebug(str); 39 | if (commonPushCheck() >= 4) { 40 | console.log(`${g_FULLNAME}[L] ${new Date().toLocaleString()} ${str}`, ...args); 41 | } 42 | } 43 | 44 | export function errorPush(str, ... args) { 45 | if (commonPushCheck() >= 1) { 46 | console.error(`${g_FULLNAME}[E] ${new Date().toLocaleString()} ${str}`, ...args); 47 | } 48 | } 49 | 50 | export function warnPush(str, ... args) { 51 | if (commonPushCheck() >= 2) { 52 | console.warn(`${g_FULLNAME}[W] ${new Date().toLocaleString()} ${str}`, ...args); 53 | } 54 | } -------------------------------------------------------------------------------- /src/config.js: -------------------------------------------------------------------------------- 1 | export { 2 | token, includeOs, setting, language, defaultAttr, attrName, attrSetting, holidayInfo 3 | }; 4 | let token = "";//api鉴权token 5 | let includeOs = [];//目前没用 6 | let defaultAttr = {//挂件创建时默认属性设定 7 | percentage: -1, //挂件被创建时默认的模式。-2时间模式 -1自动模式 >=0手动模式 8 | targetid: "null",//更改此设定无意义,请勿修改 9 | start: "null",// 开始时间默认值,更改此项可能意义不大 10 | end: "null",// 结束时间默认值,更改此项可能意义不大 11 | frontColor: "rgba(45, 164, 78, 1)",//进度条前景色对应的属性默认值 12 | backColor: "rgba(175, 184, 193, 0.2)",//进度条背景色对应的属性默认值 13 | alltask: false,//计算子任务进度默认值。认为所有任务(包括子任务)的权重相同,统计所有任务完成的进度,而不只是第一层级 14 | barWidth: 10,//进度条高度,单位px像素 15 | frontColorSelector: {//前景色颜色选择器配置(jscolor)(若在custom.js中设置此项,需包含其下的所有设置) 16 | value: 'rgba(51,153,255,0.5)',//好像实际上没用到 17 | position: 'bottom', 18 | height: 80, 19 | backgroundColor: '#333', 20 | palette: 'rgba(0,0,0,0) #2da44eff #f1993eff #0080cfff #cb406cff #ff5454ff #af481bff #269affff',//预设颜色组 21 | paletteCols: 11, 22 | hideOnPaletteClick: true 23 | }, 24 | backColorSelector: {//背景色颜色选择器配置(若在custom.js中设置此项,需包含其下的所有设置) 25 | value: 'rgba(51,153,255,0.5)', 26 | position: 'bottom', 27 | height: 80, 28 | backgroundColor: '#333', 29 | palette: 'rgba(176,176,176,0.2) #e9d7c740 #dbe4e540 rgba(175,184,193,0.2) rgba(255, 231, 231, 0.25) #ffe438 #88dd20 #22e0cd #269aff #bb1cd4',//预设颜色组 30 | paletteCols: 11, hideOnPaletteClick: true 31 | } 32 | } 33 | //在此自定义属性名称(只接受英文(最好是小写)、数字,后面会补充custom-这里不用写) 34 | let attrName = { 35 | manual: "1progress",//百分比/模式对应的属性名称 36 | autoTarget: "2targetid", //任务列表块id对应的属性名称 37 | startTime: "3start",//开始时间对应的属性名称 38 | endTime: "4end",//结束时间对应的属性名称 39 | frontColor: "5frontcolor",//进度条前景色对应的属性名称 40 | backColor: "6backcolor",//进度条背景色对应的属性名称 41 | taskCalculateMode: "7alltask",//自动模式统计任务范围对应的属性名称 42 | barWidth: "6width", //进度条高度 43 | basicSetting: "pgbtconfig", //进度条基础设定 44 | barTitle: "71title", // 进度条标题(时间模式) 45 | } 46 | let attrSetting = { 47 | timeModeMode: 0, 48 | onlyWorkDay: false, 49 | } 50 | let holidayInfo = null; 51 | let setting = { 52 | widgetWidth: "50em",//挂件的宽 53 | widgetHeight: "68.8px",//挂件的高4.3em 54 | widgetBarOnlyHeight: "48px",//只显示进度条和刷新按钮时,挂件的高3em 55 | widgetAutoModeWithTimeRemainHeight: "68.8px", // 自动模式显示时间时挂件高度4.3em 56 | widgetTimeModeHeight: "80px", // 时间模式挂件高度5em 57 | refreshInterval: 90000,//自动模式自动刷新间隔(单位:毫秒),由于请求api,请勿设定的时间过短;为0禁用 58 | onstart: true, //在挂件被加载时同步一次进度 59 | saveAttrTimeout: 1000 * 0.5, //手动模式:在操作进度条后自动保存百分比的延迟时间,单位毫秒,为0则禁用自动保存 60 | timeModeRefreshInterval: 1000 * 60 * 10,//时间模式定时刷新间隔,单位毫秒,请勿设定的时间过短;为0则禁用 61 | createBlock: false, //如果块不存在,则创建块 62 | updateForSubNode: true,//在子任务增删时更新进度(beta),此选项开启后,可能出现性能问题,建议关闭 63 | showGapDay: true, // 时间模式显示日期间隔天数 64 | showButtons: false, // 在进度条右侧展示刷新和设置按钮 65 | saveDefaultHeight: true, // 挂件默认高度记忆(插入后第二次加载将默认宽高写入文档,以减少载入文档时挂件高度变化) 66 | 67 | // 自动、时间模式时间提示词覆盖,请参考zh_CN中同名属性 68 | countDay_dayLeft: undefined, // 时间段:剩余天数显示模板,其中%%将替换为天数 69 | countDay_today: undefined,//时间段:当前为结束日 70 | countDay_exceed: undefined, //时间段 当前已超期,超过多少天,其中%%将替换为天数 71 | countDay_auto_modeinfo: undefined, //自动模式截止时间提示前缀,其中%2%将替换为截止日日期,%1%将被替换为剩余天数模板,%0%将被替换为完成进度百分比 72 | 73 | /* 时间倒数日颜色渐变控制 */ 74 | // 【颜色骤变/渐变基准色】,数组,从左至右为倒数日由近至远; 75 | // 数组元素格式不仅限于#十六进制、也可以是rgb(255,255,255)类型,值直接填入css color 76 | // 橙色#ff7f27 #EB7323 77 | colorGradient_baseColor: ["#f94144", "#FF6E34", "#B88B06", "#2DA44E", "#2571BF"],//["#f94144", "#6a4c93", "#f3722c", "#1982c4", "#43aa8b"], 78 | colorGradient_baseColor_night: ["#f94144", "#FF6E34", "#B88B06", "#2DA44E", "#3292F5"],//["#f94144", "#A853ED", "#f3722c", "#4cc9f0", "#43aa8b"], 79 | // 颜色骤变触发天数,数组,从左至右逐渐变大 80 | // 在天数小于等于对应位置天数值时,选用上面对应位置的颜色,和上面数组长度必须相同 81 | colorGradient_triggerDay: [1, 4, 7, 14, 21], 82 | // 【颜色骤变触发百分比】,数组,从左至右逐渐变小; 83 | // 当时间进度大于对应位置进度时,选用colorGradient_baseColor对应位置的颜色,和上面数组长度必须相同 84 | colorGradient_triggerPercentage: [90, 70, 50, 30, 0], 85 | // 【暂不支持】控制是否使用颜色渐变【注意:渐变使用RGB各色线性变化实现,可能出现不期望的颜色】 86 | //colorGradient_gradient: false, 87 | 88 | // 在年份相同时,省略年份提示,使用 dateFormat_simp 模板格式化日期 89 | dateSimplize: true, 90 | 91 | // 隐藏右侧进度百分比(仅自动模式且显示倒数日) 92 | hideRightPercentage: false, 93 | // 时间模式开始结束时间显示格式 94 | // dateFormat: "MM月dd日", 95 | 96 | // 周开始日(周日为0,周一为1) 97 | weekStartDay: 1, 98 | // 时间模式开始、结束时间文字占用空间最小化(多个进度条连续显示时可能无法对齐) 99 | timeTextMinimize: false, 100 | }; 101 | let zh_CN = { 102 | "notTaskList": "不是任务列表块,或块id填写错误。(若为无序、任务混合列表,请勾选统计子任务后再试)", 103 | "getKramdownFailed": "通过API获取块失败,请检查块ID是否正确:", 104 | "unknownIdAtDom": "页面内未找到对应块,正尝试API获取。", 105 | "cantObserve": "页面内未找到对应块,无法自动触发进度计算", 106 | "setObserveErr": "内部错误,无法自动触发进度计算", 107 | "autoModeFailed": "由于API或DOM处理错误,未能展示进度。", 108 | "autoMode": "当前:自动模式", 109 | "manualMode": "当前:手动模式", 110 | "needSetAttr": `未设置目标块id且未在紧邻块发现列表,请创建任务列表或设定id。`, 111 | "saved": "已保存", 112 | "writeAttrFailed": "保存失败,写入属性失败", 113 | "writeHeightInfoFailed": "记忆挂件宽高设定失败", 114 | "timeMode": "当前:时间模式", 115 | "timeModeSetError": "时间设定错误,开始时间晚于或等于结束时间", 116 | "timeSetIllegal": "时间设定错误,时间格式请参考说明文档README.md", 117 | "timeNotSet": `未设定开始时间或结束时间`, 118 | "timeRepeatSetError": "时间模式重复方式设定错误,请重新设定", 119 | "earlyThanStart": "当前时间早于开始时间", 120 | "startTime": "", 121 | "endTime": "", 122 | "noTimeAttr": `读取挂件属性时发生错误`, 123 | "autoModeAPI": `当前:自动模式(API)`,// 124 | "usingAPI": `当前正在使用API自动计算。若未设置间隔刷新,则必须手动点击刷新。`, 125 | "autoModeFnBtn": "[双击] 取消全部/完成全部", 126 | "autoDetectId": "已自动定位临近的列表", 127 | "frontColorText": "前景色设定:", 128 | "backColorText": "背景色设定:", 129 | "barWidthText": "进度条高度:", 130 | "saveBtnText": "保存外观", 131 | "saveSettingText": "保存设置", 132 | "deleteAndGoodByeText": "删除其他挂件", 133 | "startTimeText": "开始时间:", 134 | "endTimeText": "结束时间:", 135 | "allTaskText": "统计子任务:", 136 | "blockIdText": "任务列表块id:", 137 | "barTitleText": "时间模式标题:", 138 | "changeModeText": "切换模式", 139 | "resetHeightText": "重设挂件高度", 140 | "resetHeightHint": "修复打开文档时挂件高度突变问题", 141 | "refreshed": "已刷新", 142 | "ui_percentage_hint": "进度百分比\n出现下划线=>已保存", 143 | "ui_percentage_btn_hint": "进度百分比\n[单击] 刷新/(手动模式)保存\n[双击] 显示/隐藏设置\n出现下划线=>已保存\n出现上划线=>已刷新", 144 | "ui_refresh_btn_hint": "\n[单击] 刷新/(手动模式)保存\n[双击] 切换模式", 145 | "ui_setting_btn_hint": "显示/隐藏设置", 146 | "countDay_dayLeft": "还有%%天", 147 | "countDay_today": `当天`, 148 | "countDay_exceed": `已过%%天`, 149 | "countDay_hour": `还有%%小时`, 150 | "countDay_dayLeft_sim": "还有%%天", 151 | "countDay_today_sim": `截止日`, 152 | "countDay_exceed_sim": `超%%天`, 153 | "countDay_auto_modeinfo": `完成%0%,%2%截止,%1%`, 154 | "ui_select_all": "全部完成/全部取消", 155 | "gradient_error": "提示词颜色变化设置错误,请检查", 156 | "colorCardExample": "色卡示例: ", 157 | "dateFormat": "yyyy年MM月dd日", 158 | "dateFormat_simp": "MM月dd日", 159 | "timeFormat": "HH:mm", 160 | "timeModeSelectText": "时间模式预设:", 161 | "timeModeArray": ["自定义", "天进度", "周进度", "月进度", "年进度"],//通过数组下标区分模式 162 | "color_cards": "█剩余时间少于%0%%(或%1%天)", 163 | "color_cards_error": "倒数日颜色设定错误", 164 | "calendar_lang": "cn", 165 | "weekOfDay": ["周日","周一","周二","周三","周四","周五","周六"], 166 | "months": ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'], 167 | "yearFormat": "yyyy年", 168 | "weekFormat": "第%0%周", 169 | "monthFormat": "%0%", 170 | "cannot_observe": "错误:无法获取任务列表变化", 171 | "deleteAndGoodByeConfirm": "“删除其他挂件”用于删除当前工作空间下存在的其他任务进度条挂件。
但功能测试有限,可能错误删除其他挂件或不应删除的内容。(具体实现可查看开源代码)
继续即代表您已经了解了相关风险并已经做好了笔记历史备份。
感谢陪伴,期待下次相遇。", 172 | "removeOtherSuccess": "成功删除%1%个挂件", 173 | "removeOtherFailed": "成功删除%1%个挂件,失败%2%个。失败的挂件id分别是:%3%", 174 | "onlyWorkDayText": "仅工作日beta:", 175 | "onlyWorkDayHoverInfo": "并不智能的计算剩余天数(不计法定节假日),默认实现不支持中国大陆以外的地区以及2022~2024以外的节假日,请参考README.md", 176 | "goodbye_confirmBtn": "确认删除", 177 | "goodbye_cancelBtn": "取消", 178 | } 179 | let en_UK = { 180 | "notTaskList": "Not a task list block, or the block id was filled in incorrectly. (If it is an unordered, mixed list of tasks, please tick the statistics subtask and try again)", 181 | "getKramdownFailed": "Failed to get the block via API, please check if the block id is correct:", 182 | "unknownIdAtDom": "The corresponding block was not found within the page, trying to get it via the API." , 183 | "cantObserve": "The corresponding block was not found within the page and the progress calculation could not be triggered automatically.", 184 | "setObserveErr": "Internal error, unable to automatically trigger progress calculation", 185 | "autoModeFailed": "Failure to show progress due to API or DOM handling errors.", 186 | "autoMode": "Current: auto mode", 187 | "manualMode": "Current: manual mode", 188 | "needSetAttr": `No target block id set and no list found in immediate block, create task list or set id. `, 189 | "saved": "Saved", 190 | "writeAttrFailed": "Failed to save, failed to write attribute", 191 | "writeHeightInfoFailed": "Failed to set the width and height of the memory pendant", 192 | "timeMode": "Current: time mode", 193 | "timeModeSetError": "Time setting error, start time is later than or equal to end time", 194 | "timeSetIllegal": "Time setting error, please refer to the documentation README.md for the time format", 195 | "timeNotSet": `Start time or end time not set`, 196 | "earlyThanStart": "The current time is earlier than the start time", 197 | "timeRepeatSetError": "(Time mode) Repetiton preset type illeagal, please reset it.", 198 | "startTime": "", 199 | "endTime": "", 200 | "noTimeAttr": `Error occurred while reading pendant attributes`, 201 | "autoModeAPI": `Current: auto mode (API)`, 202 | "usingAPI": `The API is currently being used for automatic calculations. If the interval refresh is not set, you must click refresh manually. `, 203 | "autoModeFnBtn": "[double-click] Cancel All / Finish All", 204 | "autoDetectId": "Has automatically positioned the adjacent list", 205 | "frontColorText": "Front colour setting:", 206 | "backColorText": "Background colour setting:", 207 | "barWidthText": "Progress bar height:", 208 | "saveBtnText": "Save appearance", 209 | "saveSettingText": "Save settings", 210 | "deleteAndGoodByeText": "Delete Other Widgets", 211 | "startTimeText": "Start time:", 212 | "endTimeText": "End time:", 213 | "allTaskText": "Count subtasks in:", 214 | "blockIdText": "Task list block id:", 215 | "barTitleText": "Time Mode Title:", 216 | "changeModeText": "Switch modes", 217 | "resetHeightText": "Reset the height of the widget", 218 | "resetHeightHint": "Fix a problem with the pendant height changing abruptly when opening a document", 219 | "refreshed": "Refreshed", 220 | "ui_percentage_hint": "Progress percentage \n with underline => Saved", 221 | "ui_percentage_btn_hint": "Progress percentage \n[click] Refresh/(manual mode) Save \n[double click] Show/hide settings \nUnderline appears => Saved \nOverline appears => Refreshed", 222 | "ui_refresh_btn_hint": "\n[click] Refresh/(manual mode) Save \n[double click] Switch mode", 223 | "ui_setting_btn_hint": "Show/hide settings", 224 | "countDay_dayLeft": "%% day(s) left", 225 | "countDay_today": `On the day`, 226 | "countDay_exceed": `%% day(s) passed`, 227 | "countDay_hour": `%% hour(s) left`, 228 | "countDay_dayLeft_sim": "%% day(s) left", 229 | "countDay_today_sim": `Deadline`, 230 | "countDay_exceed_sim": `%% days passed`, 231 | "countDay_auto_modeinfo": `%0% of tasks completed, Deadline %2%, %1%`, 232 | "ui_select_all": "All done/all cancelled", 233 | "gradient_error": "Cue word colour change is set incorrectly, please check it.", 234 | "colorCardExample": "Example of colours ", 235 | "dateFormat": "yyyy-MM-dd", 236 | "dateFormat_simp": "MM-dd", 237 | "timeFormat": "HH:mm", 238 | "timeModeSelectText": "Time Mode Preset: ", 239 | "timeModeArray": ["Custom", "Current day", "Current week", "Current month", "Current year"],//通过数组下标区分模式 240 | "color_cards": "█Less than %0%% time left (or %1% days) ", 241 | "color_cards_error": "Wrong colour setting for the countdown day", 242 | "calendar_lang": "en", 243 | "weekOfDay": ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"], 244 | "months": ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], 245 | "yearFormat": "yyyy", 246 | "weekFormat": "%0%", 247 | "monthFormat": "%0% (%1%)", 248 | "cannot_observe": "ERROR: Unable to observe changes in the task list.", 249 | "deleteAndGoodByeConfirm": "This feature is used to delete other progreeBarT widgets, typically for no longer in use and want to clean up the widget content in bulk.
This feature has limited testing and may incorrectly match other widgets or content that should not be deleted. (Please refer our open-source code)
Proceeding means you have understood the relevant risks and have made a backup of all note in Siyuan.
Thank you for your company. Maybe it's time to say goodbye.", 250 | "removeOtherFailed": "Successfully deleted %1% widgets, failed %2%. Failed widget ids are: %3%", 251 | "removeOtherSuccess": "Successfully deleted %1% widgets", 252 | "onlyWorkDayText": "Only Workdays(beta): ", 253 | "onlyWorkDayHoverInfo": "Due to regional differences, the default implementation only skips Saturdays and Sundays. If you want to customize holiday information, please refer to the README.", 254 | "goodbye_confirmBtn": "Confirm", 255 | "goodbye_cancelBtn": "Cancel", 256 | } 257 | 258 | let language = zh_CN; 259 | let lang = window.top.siyuan.config.lang; 260 | // 测试中的外部json语言配置文件读入,但再开个语言文件意义不大,废弃中 261 | if (lang != "zh_CN") { 262 | language = en_UK; 263 | } 264 | // language = await getLanguageFile(`/widgets/progress-dev/lang/${lang}.json`).catch(async(error)=>{ 265 | // language = await getLanguageFile("/widgets/progress-dev/lang/zh_CN.json") 266 | // }); 267 | 268 | //补充属性名的custom- 269 | for (let attr in attrName){ 270 | attrName[attr] = "custom-" + attrName[attr]; 271 | } 272 | 273 | // 导入外部config.js 测试功能 274 | try { 275 | do { 276 | // 先通过思源API判断文件是否存在,否则就别找了 277 | if (await getJSONFile("/data/widgets/custom.js") == null) { 278 | break; 279 | } 280 | let allCustomConfig = await import('/widgets/custom.js'); 281 | let customConfig = null; 282 | let customConfigName = "progressBarT"; 283 | if (allCustomConfig[customConfigName] != undefined) { 284 | customConfig = allCustomConfig[customConfigName]; 285 | }else if (allCustomConfig.config != undefined && allCustomConfig.config[customConfigName] != undefined) { 286 | customConfig = allCustomConfig.config[customConfigName]; 287 | } 288 | // 导入token 289 | if (allCustomConfig.token != undefined) { 290 | token = allCustomConfig.token; 291 | }else if (allCustomConfig.config != undefined && allCustomConfig.config.token != undefined) { 292 | token = allCustomConfig.config.token; 293 | } 294 | 295 | // 仅限于config.setting/config.defaultAttr下一级属性存在则替换,深层对象属性将完全覆盖 296 | if (customConfig != null) { 297 | if ("setting" in customConfig) { 298 | for (let key in customConfig.setting) { 299 | if (key in setting) { 300 | setting[key] = customConfig.setting[key]; 301 | } 302 | } 303 | } 304 | 305 | if ("defaultAttr" in customConfig) { 306 | for (let key in customConfig.defaultAttr) { 307 | if (key in defaultAttr) { 308 | defaultAttr[key] = customConfig.defaultAttr[key]; 309 | } 310 | } 311 | } 312 | 313 | } 314 | } while (false); 315 | }catch (err) { 316 | console.warn("导入用户自定义设置时出现错误", err); 317 | } 318 | 319 | try { 320 | do { 321 | let holidayInfoFile = await getJSONFile("/data/storage/progressBarT/holiday.json"); 322 | if (holidayInfoFile != null) { 323 | holidayInfo = holidayInfoFile; 324 | break; 325 | } 326 | if (lang != "zh_CN") { 327 | break; 328 | } 329 | holidayInfoFile = await getJSONFile("/data/widgets/progressBarT/static/holiday.json"); 330 | if (holidayInfoFile == null) { 331 | break; 332 | } else { 333 | holidayInfo = holidayInfoFile; 334 | break; 335 | } 336 | } while(false); 337 | } catch(err) { 338 | console.warn("解析节假日信息时出错", err); 339 | } finally { 340 | console.log("holida", holidayInfo) 341 | } 342 | 343 | async function getLanguageFile(url) { 344 | let result; 345 | await fetch(url).then((response) => { 346 | result = response.json(); 347 | }); 348 | return result; 349 | } 350 | 351 | async function getJSONFile(path) { 352 | const url = "/api/file/getFile"; 353 | let response = await postRequest({"path": path}, url); 354 | if (response.code == 404) { 355 | return null; 356 | } 357 | return response; 358 | } 359 | 360 | async function postRequest(data, url){ 361 | let result; 362 | await fetch(url, { 363 | body: JSON.stringify(data), 364 | method: 'POST', 365 | headers: { 366 | "Authorization": "Token "+token, 367 | "Content-Type": "application/json" 368 | } 369 | }).then((response) => { 370 | result = response.json(); 371 | }); 372 | return result; 373 | } 374 | -------------------------------------------------------------------------------- /src/uncommon.js: -------------------------------------------------------------------------------- 1 | /** 2 | * common.js 可能可以应用到其他项目的操作函数 3 | */ 4 | import { isValidStr, isDarkMode } from "./API.js"; 5 | import { debugPush, logPush } from "./common.js"; 6 | import { language, setting, holidayInfo } from "./config.js"; 7 | 8 | /** 9 | * 解析符合以下条件的字符串为日期: 10 | * 年月日时分,之间用任意非数字字符隔开;支持只输入时、分 11 | * @returns [int, Date, Str] 解析是否成功(0失败,1成功为日期,2成功为时间);若成功,对应的Date时间;若成功,对应的时间字符串 12 | */ 13 | export function parseTimeString(timeStr, format = "") { 14 | let resultDate; 15 | let resultDateStr; 16 | let resultCode; 17 | // 非字符串、空字符串、“null”字符串 18 | if (!isValidStr(timeStr) || timeStr == "null") { 19 | return [0, null, ""]; 20 | } 21 | // 拆分连续的数字(string) 22 | let timeNums = timeStr.match(/[0-9]+/gm); 23 | // 无数字的情况 24 | if (!timeNums || timeNums.length <= 1) { 25 | return [0, null, ""]; 26 | } 27 | // 处理yy MM dd的情况 28 | if (timeNums.length != 2) { 29 | if (timeNums[0].length == 2) { 30 | timeNums[0] = "20" + timeNums[0]; 31 | } 32 | } 33 | resultCode = 1; 34 | switch (timeNums.length) { 35 | case 3: {//输入格式yyyy MM dd 36 | resultDate = new Date(timeNums[0], timeNums[1] - 1, timeNums[2]); 37 | resultDateStr = formatDateString(resultDate, format); 38 | break; 39 | } 40 | case 5: {//输入格式yyyy MM dd HH mm 41 | resultDate = new Date(timeNums[0], timeNums[1] - 1, timeNums[2], timeNums[3], timeNums[4]); 42 | resultDateStr = formatDateString(resultDate, format) + " " + resultDate.toLocaleTimeString(); 43 | break; 44 | } 45 | case 2: {//输入格式HH mm 46 | resultDate = new Date(); 47 | resultDate.setHours(timeNums[0]); 48 | resultDate.setMinutes(timeNums[1]); 49 | resultDate.setSeconds(0); 50 | resultDateStr = formatDateString(resultDate, useUserTemplate("timeFormat")); 51 | resultCode = 2; 52 | break; 53 | } 54 | default: { 55 | console.warn("时间设定非法", this.times[i]); 56 | return [0, null, ""]; 57 | } 58 | } 59 | return [resultCode, resultDate, resultDateStr]; 60 | } 61 | 62 | export function formatDateString(date, format) { 63 | let result = format; 64 | if (!isValidStr(format)) { 65 | return date.toLocaleDateString(); 66 | } 67 | result = result.replace(new RegExp("yyyy", "g"), date.getFullYear()); 68 | result = result.replace(new RegExp("yy", "g"), date.getFullYear() % 100); 69 | result = result.replace(new RegExp("MM", "g"), date.getMonth() + 1); 70 | result = result.replace(new RegExp("dd", "g"), date.getDate()); 71 | result = result.replace(new RegExp("HH", "g"), date.getHours() > 9 ? date.getHours() : "0" + date.getHours()); 72 | result = result.replace(new RegExp("mm", "g"), date.getMinutes() > 9 ? date.getMinutes() : "0" + date.getMinutes()); 73 | return result; 74 | } 75 | 76 | /** 77 | * 计算两个日期相差的天数,返回天数 78 | * end - start 79 | * @param {Date} start 80 | * @param {Date} end 81 | * @param {boolean} onlyWorkDay 是否只计算工作日(跳过法定节假日) 82 | * @return {int} 正数:start距离end还有x天 83 | */ 84 | export function calculateDateGapByDay(start, end, onlyWorkDay) { 85 | let from = Date.parse(start.toDateString()); 86 | let to = Date.parse(end.toDateString()); 87 | let result; 88 | if (onlyWorkDay) { 89 | debugPush(">>>> 还剩天数") 90 | result = calculateDateGapByWorkDay({start, end, remain: true}); 91 | debugPush("剩余天数计算", result); 92 | return result; 93 | } 94 | return Math.ceil((to - from) / (1 * 24 * 60 * 60 * 1000)); 95 | } 96 | 97 | /** 98 | * 计算截止小时 99 | */ 100 | export function calculateDateGapByHour(start, end) { 101 | let from = Date.parse(start.toDateString()); 102 | let to = Date.parse(end.toDateString()); 103 | return Math.ceil((to - from) / (60 * 60 * 1000) * 10) / 10; 104 | } 105 | 106 | /** 107 | * 计算时间间隔内的法定工作日 108 | * 周一至周五(除法定节假日)+调休 109 | * @param {Date} start 110 | * @param {Date} end 111 | * @param {boolean} remain 是否是在计算剩余时间(这将考虑已经结束等情况,否则将默认start < end) 112 | */ 113 | export function calculateDateGapByWorkDay({start, end, remain=false, gapEnd=null}) { 114 | start.setHours(0, 0, 0, 0); 115 | end.setHours(0, 0, 0, 0); 116 | // 时段判定应当返回最后一个工作日,即end应该是工作日 117 | debugPush("输入开始结束时间", start, end); 118 | // 总时间段才需要走这个逻辑 119 | let lastWorkdayEnd = getLastWorkingDay(holidayInfo?.workdays ?? [], holidayInfo?.holidays ?? [], start, end); 120 | debugPush("统计时段", start, end, lastWorkdayEnd); 121 | // 总时间段指示的区间中,必须包含工作日,否则无效 122 | if (remain == false && lastWorkdayEnd == null) { 123 | throw new Error("区间内无工作日"); 124 | } 125 | if (lastWorkdayEnd == null) { 126 | lastWorkdayEnd = getLastWorkingDay(holidayInfo?.workdays ?? [], holidayInfo?.holidays ?? [], new Date(0), end);; 127 | } 128 | debugPush("过滤后结束时间v2", lastWorkdayEnd); 129 | let overFlag = lastWorkdayEnd != null && start >= lastWorkdayEnd; 130 | debugPush("时段已过判定", overFlag, remain); 131 | if (overFlag && remain) { 132 | debugPush("时段已过,fallback到默认实现", start, lastWorkdayEnd); 133 | return Math.floor((lastWorkdayEnd - start) / (1 * 24 * 60 * 60 * 1000)); 134 | } 135 | const holidayCount = getRangeHolidayCount(start, lastWorkdayEnd); 136 | const weekdaysCount = getRangeWeekDayCount(start, lastWorkdayEnd); 137 | const workdaysCount = getRangeWorkDayCount(start, lastWorkdayEnd); 138 | let result = weekdaysCount - holidayCount + workdaysCount; 139 | debugPush("周一至周五总计", weekdaysCount, "减去假日", holidayCount, "调休日", workdaysCount, "Res", result); 140 | // 在计算时段时,出现工作日时段结果为0,但是设置的结束时间还未到达的情况,例如: 141 | // 班 休 休 班 142 | // Now ^结束 143 | // 回退一天,计算正确的结束工作日 144 | // if (result <= 0 && (lastWorkdayEnd - start) > 0 && remain) { 145 | // end.setDate(end.getDate() - 1); 146 | // lastWorkdayEnd = getLastWorkingDay(holidayInfo?.workdays ?? [], holidayInfo?.holidays ?? [], new Date(0), end); 147 | // debugPush("工作日计算出现0,调整后日期", lastWorkdayEnd); 148 | // return Math.floor((lastWorkdayEnd - start) / (1 * 24 * 60 * 60 * 1000)); 149 | // } 150 | return result; 151 | } 152 | 153 | 154 | /** 155 | * 获取区间假日天数 156 | * @param {Date} start 时间段开始 157 | * @param {Date} end 时间段结束 158 | * @returns 区间范围内法定节假日天数(以发布为准,不含正常周末,不含节日周末) 159 | */ 160 | function getRangeHolidayCount(start, end) { 161 | // dateArray为休息日Array 162 | const dateArray = holidayInfo?.holidays ?? []; 163 | debugPush("休息日数组", dateArray.length); 164 | const filteredDates = dateArray.filter(dateStr => { 165 | const date = new Date(dateStr); 166 | return date >= start && date < end && date.getDay() !== 0 && date.getDay() !== 6; 167 | }); 168 | 169 | return filteredDates.length; 170 | } 171 | /** 172 | * 获取区间调休上班天数 173 | * @param {Date} start 174 | * @param {Date} end 175 | * @returns 区间内调休上班日,仅含周末 176 | */ 177 | function getRangeWorkDayCount(start, end) { 178 | // dateArray为工作日Array 179 | const dateArray = holidayInfo?.workdays ?? []; 180 | debugPush("工作日数组", dateArray.length); 181 | const filteredDates = dateArray.filter(dateStr => { 182 | const date = new Date(dateStr); 183 | // debugPush("调休工作日", "输入日期", dateStr, "转换日期", date, date.getDay(), date >= start && date < end && (date.getDay() == 0 || date.getDay() == 6)); 184 | return date >= start && date < end && (date.getDay() == 0 || date.getDay() == 6); 185 | }); 186 | 187 | return filteredDates.length; 188 | } 189 | 190 | function getRangeWeekDayCount(start, end) { 191 | // 计算两个日期之间的总天数差(不包括结束日期) 192 | const totalDays = Math.floor((end - start) / (1000 * 60 * 60 * 24)); 193 | 194 | // 计算完整的周数 195 | const fullWeeks = Math.floor(totalDays / 7); 196 | let weekdaysCount = fullWeeks * 5; // 每周有 5 个工作日 197 | 198 | // 计算剩余的天数 199 | let remainingDays = totalDays % 7; 200 | 201 | // 获取开始日期的星期几(0 是星期天,1 是星期一,依此类推) 202 | let startDay = start.getDay(); 203 | // 计算剩余天数中的工作日 204 | for (let i = 0; i < remainingDays; i++) { 205 | let currentDay = (startDay + i) % 7; 206 | if (currentDay !== 0 && currentDay !== 6) { // 排除周六和周日 207 | weekdaysCount++; 208 | } 209 | } 210 | 211 | return weekdaysCount; 212 | } 213 | 214 | function getLastWorkingDay(workDays, holidays, startDate, endDate) { 215 | // 将上班日和节假日数组转换为 Set 对象,便于查找 216 | const workDaySet = new Set(workDays); 217 | const holidaySet = new Set(holidays); 218 | 219 | let lastWorkingDay = null; 220 | let currentDate = new Date(endDate); 221 | // 遍历时间段内的每一天,从结束日期向前 222 | while (currentDate >= startDate) { 223 | const year = currentDate.getFullYear(); 224 | const month = String(currentDate.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始,需要加 1 225 | const day = String(currentDate.getDate()).padStart(2, '0'); 226 | const dateString = `${year}-${month}-${day}`; 227 | 228 | // 检查是否为工作日且不在节假日列表中 229 | if ((currentDate.getDay() !== 0 && currentDate.getDay() !== 6) || workDaySet.has(dateString)) { 230 | if (!holidaySet.has(dateString)) { 231 | lastWorkingDay = new Date(currentDate); 232 | break; // 找到最近的工作日后跳出循环 233 | } 234 | } 235 | // 移动到前一天 236 | currentDate.setDate(currentDate.getDate() - 1); 237 | } 238 | return lastWorkingDay; 239 | } 240 | 241 | async function parseHolidayInfo() { 242 | const response = await fetch('https://raw.githubusercontent.com/lanceliao/china-holiday-calender/master/holidayAPI.json'); 243 | const data = await response.json(); 244 | const parseDates = (data) => { 245 | const holidays = []; 246 | const workdays = []; 247 | 248 | const addDates = (start, end) => { 249 | let currentDate = new Date(start); 250 | const endDate = new Date(end); 251 | while (currentDate <= endDate) { 252 | holidays.push(currentDate.toISOString().split('T')[0]); 253 | currentDate.setDate(currentDate.getDate() + 1); 254 | } 255 | }; 256 | 257 | for (const year in data.Years) { 258 | data.Years[year].forEach(holiday => { 259 | addDates(holiday.StartDate, holiday.EndDate); 260 | holiday.CompDays.forEach(compDay => { 261 | workdays.push(compDay); 262 | }); 263 | }); 264 | } 265 | 266 | holidays.sort(); 267 | workdays.sort(); 268 | 269 | return { holidays, workdays }; 270 | }; 271 | 272 | const { holidays, workdays } = parseDates(data); 273 | logPush("holiday", JSON.stringify(holidays)); 274 | logPush("workdays", JSON.stringify(workdays)); 275 | return { holidays, workdays }; 276 | } 277 | 278 | /** 279 | * 载入用户设定的输出模板 280 | * @param {*} attrName 281 | * @param {...any} args 282 | * @returns 283 | */ 284 | export function useUserTemplate(attrName, ...args) { 285 | let result; 286 | if (isValidStr(setting[attrName])) { 287 | result = setting[attrName]; 288 | } else { 289 | result = language[attrName]; 290 | } 291 | if (args.length == 0) { 292 | return result; 293 | } else if (args.length == 1) { 294 | return result.replace(new RegExp("%%", "g"), args[0]); 295 | } else { 296 | for (let i = 0; i < args.length; i++) { 297 | result = result.replace(new RegExp(`%${i}%`, "g"), args[i]); 298 | } 299 | return result; 300 | } 301 | } 302 | 303 | /** 304 | * 格式化语言模板 305 | * @param {*} attrName 306 | * @param {...any} args 307 | * @returns 308 | */ 309 | export function formatLanguageTemplate(attrName, ...args) { 310 | let result; 311 | result = language[attrName]; 312 | if (args.length == 0) { 313 | return result; 314 | } else if (args.length == 1) { 315 | return result.replace(new RegExp("%%", "g"), args[0]); 316 | } else { 317 | for (let i = 0; i < args.length; i++) { 318 | result = result.replace(new RegExp(`%${i}%`, "g"), args[i]); 319 | } 320 | return result; 321 | } 322 | } 323 | 324 | /** 325 | * 返回当前时间距离输入参数endTime 326 | * @param {*} endTime 327 | * @param {boolean} simplify 简化输出(用于自动模式) 328 | * @returns 329 | */ 330 | export function getDayGapString({ endTime, simplify = false, percentage = null, onlyWorkDay = false }) { 331 | // 计算还有多少天 332 | let gapDay = calculateDateGapByDay(new Date(), endTime, onlyWorkDay); 333 | let dateGapString = ""; 334 | if (gapDay > 0) { 335 | dateGapString = useUserTemplate(simplify ? "countDay_dayLeft_sim" : "countDay_dayLeft", gapDay); 336 | } else if (gapDay == 0) { 337 | dateGapString = useUserTemplate(simplify ? "countDay_today_sim" : "countDay_today"); 338 | } else { 339 | dateGapString = useUserTemplate(simplify ? "countDay_exceed_sim" : "countDay_exceed", -gapDay); 340 | } 341 | // 旧代码:时间段折合 342 | // let gradientColors = generateGradientColor("#FF0000", "#00FF00", 30); 343 | // let gradientColors = generateGradientColors(7); 344 | // let ratio = Math.floor(gapDay / 30 * 7); 345 | // console.log(gradientColors); 346 | // if (gapDay <= 0) gapDay = 0; 347 | // if (gapDay >= gradientColors.length) gapDay = gradientColors.length - 1; 348 | // 处理并返回时间颜色 349 | let colorStr = getCorrespondingColor(gapDay, percentage); 350 | if (isValidStr(colorStr)) { 351 | dateGapString = `${dateGapString}`; 352 | } else { 353 | dateGapString = `${dateGapString}`; 354 | } 355 | return dateGapString; 356 | } 357 | /** 358 | * 两段渐变色生成 359 | * @param {*} startColor 360 | * @param {*} endColor 361 | * @param {*} steps 362 | * @returns 颜色数组 363 | */ 364 | function generateGradientColor(startColor, endColor, steps) { 365 | const start = { 366 | red: parseInt(startColor.slice(1, 3), 16), 367 | green: parseInt(startColor.slice(3, 5), 16), 368 | blue: parseInt(startColor.slice(5, 7), 16), 369 | }; 370 | const end = { 371 | red: parseInt(endColor.slice(1, 3), 16), 372 | green: parseInt(endColor.slice(3, 5), 16), 373 | blue: parseInt(endColor.slice(5, 7), 16), 374 | }; 375 | const diff = { 376 | red: end.red - start.red, 377 | green: end.green - start.green, 378 | blue: end.blue - start.blue, 379 | }; 380 | const gradientColors = []; 381 | for (let i = 0; i < steps; i++) { 382 | const ratio = i / (steps - 1); 383 | const color = { 384 | red: Math.round(start.red + diff.red * ratio), 385 | green: Math.round(start.green + diff.green * ratio), 386 | blue: Math.round(start.blue + diff.blue * ratio), 387 | }; 388 | const hex = `#${color.red.toString(16).padStart(2, '0')}${color.green.toString(16).padStart(2, '0')}${color.blue.toString(16).padStart(2, '0')}`; 389 | gradientColors.push(hex); 390 | } 391 | return gradientColors; 392 | } 393 | /** 394 | * 多段渐变色生成 395 | * @returns 颜色数组 396 | */ 397 | function generateGradientColors(colors, n) { 398 | // const colors = ['#FF0000', '#FFA500', '#008000', '#00FFFF', '#0000FF', '#800080']; 399 | // const colors = ["#FF0000", "#FF3300", "#FF6600", "#FFA500", "#CCFF00", "#66FF00", "#00FF00 "]; 400 | const gradientColors = []; 401 | const colorCount = colors.length - 1; 402 | const colorStep = 1 / (n - 1); 403 | for (let i = 0; i < n; i++) { 404 | const colorIndex1 = Math.floor(i * colorStep * colorCount); 405 | const colorIndex2 = Math.ceil(i * colorStep * colorCount); 406 | const color1 = colors[colorIndex1]; 407 | const color2 = colors[colorIndex2]; 408 | const ratio = i * colorStep * colorCount - colorIndex1; 409 | const r1 = parseInt(color1.substring(1, 3), 16); 410 | const g1 = parseInt(color1.substring(3, 5), 16); 411 | const b1 = parseInt(color1.substring(5, 7), 16); 412 | const r2 = parseInt(color2.substring(1, 3), 16); 413 | const g2 = parseInt(color2.substring(3, 5), 16); 414 | const b2 = parseInt(color2.substring(5, 7), 16); 415 | const r = Math.floor(r1 * (1 - ratio) + r2 * ratio); 416 | const g = Math.floor(g1 * (1 - ratio) + g2 * ratio); 417 | const b = Math.floor(b1 * (1 - ratio) + b2 * ratio); 418 | const color = `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`; 419 | gradientColors.push(color); 420 | } 421 | return gradientColors; 422 | } 423 | /** 424 | * 通过config获取颜色配置,并选择颜色 425 | * @param {*} remainDay 426 | * @param {*} gapPercentage 百分比(已经乘以100) 427 | */ 428 | function getCorrespondingColor(remainDay, gapPercentage = null) { 429 | // 安全检查 430 | if (setting.colorGradient_baseColor.length != setting.colorGradient_triggerDay.length 431 | || setting.colorGradient_baseColor_night.length != setting.colorGradient_baseColor.length 432 | || setting.colorGradient_triggerDay.length != setting.colorGradient_triggerPercentage.length) { 433 | console.warn("设置中数组长度不匹配,无法应用颜色"); 434 | $("#color-test").html(language["color_cards_error"]); 435 | return null; 436 | } 437 | // debug 颜色设定方格 438 | $("#color-test").html(generateColorBlocksPlus( 439 | isDarkMode() ? setting.colorGradient_baseColor_night : setting.colorGradient_baseColor, 440 | setting.colorGradient_triggerDay, setting.colorGradient_triggerPercentage)); 441 | 442 | if (!isValidStr(gapPercentage)) { 443 | for (let i = 0; i < setting.colorGradient_baseColor.length; i++) { 444 | if (remainDay <= setting.colorGradient_triggerDay[i]) { 445 | if (isDarkMode()) { 446 | return setting.colorGradient_baseColor_night[i]; 447 | } 448 | return setting.colorGradient_baseColor[i]; 449 | } 450 | } 451 | } else { 452 | for (let i = 0; i < setting.colorGradient_baseColor.length; i++) { 453 | if (gapPercentage >= setting.colorGradient_triggerPercentage[i]) { 454 | if (isDarkMode()) { 455 | return setting.colorGradient_baseColor_night[i]; 456 | } 457 | return setting.colorGradient_baseColor[i]; 458 | } 459 | } 460 | } 461 | 462 | return undefined; 463 | } 464 | 465 | /** 466 | * 横排生成颜色预览 467 | * @param {*} colors 468 | * @param {*} numbers 469 | * @param {*} percentages 470 | * @returns html 471 | */ 472 | function generateColorBlocksPlus(colors, numbers, percentages) { 473 | let html = language["colorCardExample"]; 474 | if (!isValidStr(colors) || !isValidStr(numbers) || colors.length != numbers.length) { 475 | return language["gradient_error"]; 476 | } 477 | for (let i = 0; i < colors.length; i++) { 478 | // html += `
${numbers[i]}
`; 479 | html += `${formatLanguageTemplate("color_cards", 100 - percentages[i], numbers[i])}` 480 | } 481 | return html; 482 | } 483 | 484 | /** 485 | * 计算经过百分比(已经*100) 486 | * @param {*} startTime 487 | * @param {*} endTime 488 | * @param {*} scale 单位(例:1单位毫秒) 489 | * @returns 490 | */ 491 | export function calculateTimePercentage(startTime, endTime, scale = 1, onlyWorkDay = false) { 492 | let totalGap = endTime - startTime; 493 | if (totalGap <= 0) { 494 | console.warn(language["timeModeSetError"]); 495 | throw new Error(language["timeModeSetError"]); 496 | } 497 | let nowDate = new Date(); 498 | let passed = Math.floor((nowDate - startTime) / scale) * scale; 499 | let result = passed / totalGap * 100.0; 500 | if (result < 0) { 501 | console.warn(language["earlyThanStart"]); 502 | throw new Error(language["earlyThanStart"]); 503 | } 504 | if (onlyWorkDay) { 505 | // 无论如何,我们会将结束时间调整到合适的最后一个工作日(没有的报错) 506 | debugPush(">>>> 全组时段") 507 | let workDayCount = calculateDateGapByWorkDay({start: startTime, end: endTime}); 508 | debugPush(">>>> 还剩时段时段") 509 | let remainCount = calculateDateGapByWorkDay({start: nowDate, end: endTime, remain: true}); 510 | debugPush("时间段进度百分比", workDayCount, remainCount); 511 | result = 100.0 * (workDayCount - remainCount) / workDayCount; 512 | } 513 | if (result === NaN) { 514 | logPush("进度计算出现NaN,总时段为0,转换为100%"); 515 | result = 100.0; 516 | } 517 | return result; 518 | } 519 | 520 | export const SCALE = { 521 | MS: 1, 522 | SECOND: 1000, 523 | MIN: 1000 * 60, 524 | HOUR: 1000 * 60 * 60, 525 | DAY: 1000 * 60 * 60 * 24, 526 | WEEK: 1000 * 60 * 60 * 24 * 7, 527 | } -------------------------------------------------------------------------------- /static/holiday.json: -------------------------------------------------------------------------------- 1 | { 2 | "holidays": ["2022-01-01","2022-01-02","2022-01-03","2022-01-31","2022-02-01","2022-02-02","2022-02-03","2022-02-04","2022-02-05","2022-02-06","2022-04-03","2022-04-04","2022-04-05","2022-04-30","2022-05-01","2022-05-02","2022-05-03","2022-05-04","2022-06-03","2022-06-04","2022-06-05","2022-09-10","2022-09-11","2022-09-12","2022-10-01","2022-10-02","2022-10-03","2022-10-04","2022-10-05","2022-10-06","2022-10-07","2022-12-31","2023-01-01","2023-01-02","2023-01-21","2023-01-22","2023-01-23","2023-01-24","2023-01-25","2023-01-26","2023-01-27","2023-04-05","2023-04-29","2023-04-30","2023-05-01","2023-05-02","2023-05-03","2023-06-22","2023-06-23","2023-06-24","2023-09-29","2023-09-30","2023-10-01","2023-10-02","2023-10-03","2023-10-04","2023-10-05","2023-10-06","2024-01-01","2024-02-10","2024-02-11","2024-02-12","2024-02-13","2024-02-14","2024-02-15","2024-02-16","2024-02-17","2024-04-04","2024-04-05","2024-04-06","2024-05-01","2024-05-02","2024-05-03","2024-05-04","2024-05-05","2024-06-10","2024-09-15","2024-09-16","2024-09-17","2024-10-01","2024-10-02","2024-10-03","2024-10-04","2024-10-05","2024-10-06","2024-10-07","2025-01-01","2025-01-28","2025-01-29","2025-01-30","2025-01-31","2025-02-01","2025-02-02","2025-02-03","2025-02-04","2025-04-04","2025-04-05","2025-04-06","2025-05-01","2025-05-02","2025-05-03","2025-05-04","2025-05-05","2025-05-31","2025-06-01","2025-06-02","2025-10-01","2025-10-02","2025-10-03","2025-10-04","2025-10-05","2025-10-06","2025-10-07","2025-10-08"], 3 | "workdays": ["2022-01-29","2022-01-30","2022-04-02","2022-04-24","2022-05-07","2022-10-08","2022-10-09","2023-01-28","2023-01-29","2023-04-23","2023-05-06","2023-06-25","2023-10-07","2023-10-08","2024-02-04","2024-02-18","2024-04-07","2024-04-28","2024-05-11","2024-09-14","2024-09-29","2024-10-12","2025-01-26","2025-02-08","2025-04-27","2025-09-28","2025-10-11"] 4 | } -------------------------------------------------------------------------------- /static/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpaqueGlass/progressBarT-sywidget/29b19d6e42ad288a8e046c3601804dafd0471719/static/icon.png -------------------------------------------------------------------------------- /static/iconSetting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpaqueGlass/progressBarT-sywidget/29b19d6e42ad288a8e046c3601804dafd0471719/static/iconSetting.png -------------------------------------------------------------------------------- /static/layDate-v5.3.1/laydate.js: -------------------------------------------------------------------------------- 1 | /*! layDate v5.3.1 | 日期与时间组件 | MIT Licensed */ 2 | ;!function(e){"use strict";var t=e.document,n={modules:{},status:{},timeout:10,event:{}},a=function(){this.v="2.6.7"},r=e.LAYUI_GLOBAL||{},i=function(){var e=t.currentScript?t.currentScript.src:function(){for(var e,n=t.scripts,a=n.length-1,r=a;r>0;r--)if("interactive"===n[r].readyState){e=n[r].src;break}return e||n[a].src}();return n.dir=r.dir||e.substring(0,e.lastIndexOf("/")+1)}(),o=function(t,n){n=n||"log",e.console&&console[n]&&console[n]("layui error hint: "+t)},l="undefined"!=typeof opera&&"[object Opera]"===opera.toString(),s=n.builtin={lay:"lay",layer:"layer",laydate:"laydate",laypage:"laypage",laytpl:"laytpl",layedit:"layedit",form:"form",upload:"upload",dropdown:"dropdown",transfer:"transfer",tree:"tree",table:"table",element:"element",rate:"rate",colorpicker:"colorpicker",slider:"slider",carousel:"carousel",flow:"flow",util:"util",code:"code",jquery:"jquery",all:"all","layui.all":"layui.all"};a.prototype.cache=n,a.prototype.define=function(e,t){var a=this,r="function"==typeof e,i=function(){var e=function(e,t){u[e]=t,n.status[e]=!0};return"function"==typeof t&&t(function(a,r){e(a,r),n.callback[a]=function(){t(e)}}),this};return r&&(t=e,e=[]),a.use(e,i,null,"define"),a},a.prototype.use=function(a,r,c,y){function d(e,t){var a="PLaySTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/;("load"===e.type||a.test((e.currentTarget||e.srcElement).readyState))&&(n.modules[g]=t,p.removeChild(w),function r(){return++v>1e3*n.timeout/4?o(g+" is not a valid module","error"):void(n.status[g]?m():setTimeout(r,4))}())}function m(){c.push(u[g]),a.length>1?f.use(a.slice(1),r,c,y):"function"==typeof r&&function(){return u.jquery&&"function"==typeof u.jquery&&"define"!==y?u.jquery(function(){r.apply(u,c)}):void r.apply(u,c)}()}var f=this,h=n.dir=n.dir?n.dir:i,p=t.getElementsByTagName("head")[0];a=function(){return"string"==typeof a?[a]:"function"==typeof a?(r=a,["all"]):a}(),e.jQuery&&jQuery.fn.on&&(f.each(a,function(e,t){"jquery"===t&&a.splice(e,1)}),u.jquery=u.$=jQuery);var g=a[0],v=0;if(c=c||[],n.host=n.host||(h.match(/\/\/([\s\S]+?)\//)||["//"+location.host+"/"])[0],0===a.length||u["layui.all"]&&s[g])return m(),f;var T=(s[g]?h+"modules/":/^\{\/\}/.test(f.modules[g])?"":n.base||"")+(f.modules[g]||g)+".js";if(T=T.replace(/^\{\/\}/,""),!n.modules[g]&&u[g]&&(n.modules[g]=T),n.modules[g])!function D(){return++v>1e3*n.timeout/4?o(g+" is not a valid module","error"):void("string"==typeof n.modules[g]&&n.status[g]?m():setTimeout(D,4))}();else{var w=t.createElement("script");w.async=!0,w.charset="utf-8",w.src=T+function(){var e=n.version===!0?n.v||(new Date).getTime():n.version||"";return e?"?v="+e:""}(),p.appendChild(w),!w.attachEvent||w.attachEvent.toString&&w.attachEvent.toString().indexOf("[native code")<0||l?w.addEventListener("load",function(e){d(e,T)},!1):w.attachEvent("onreadystatechange",function(e){d(e,T)}),n.modules[g]=T}return f},a.prototype.getStyle=function(t,n){var a=t.currentStyle?t.currentStyle:e.getComputedStyle(t,null);return a[a.getPropertyValue?"getPropertyValue":"getAttribute"](n)},a.prototype.link=function(e,a,r){var i=this,l=t.getElementsByTagName("head")[0],s=t.createElement("link");"string"==typeof a&&(r=a);var c=(r||e).replace(/\.|\//g,""),u=s.id="layuicss-"+c,y="creating",d=0;return s.rel="stylesheet",s.href=e+(n.debug?"?v="+(new Date).getTime():""),s.media="all",t.getElementById(u)||l.appendChild(s),"function"!=typeof a?i:(function m(r){var l=100,s=t.getElementById(u);return++d>1e3*n.timeout/l?o(e+" timeout"):void(1989===parseInt(i.getStyle(s,"width"))?(r===y&&s.removeAttribute("lay-status"),s.getAttribute("lay-status")===y?setTimeout(m,l):a()):(s.setAttribute("lay-status",y),setTimeout(function(){m(y)},l)))}(),i)},a.prototype.addcss=function(e,t,a){return u.link(n.dir+"css/"+e,t,a)},n.callback={},a.prototype.factory=function(e){if(u[e])return"function"==typeof n.callback[e]?n.callback[e]:null},a.prototype.img=function(e,t,n){var a=new Image;return a.src=e,a.complete?t(a):(a.onload=function(){a.onload=null,"function"==typeof t&&t(a)},void(a.onerror=function(e){a.onerror=null,"function"==typeof n&&n(e)}))},a.prototype.config=function(e){e=e||{};for(var t in e)n[t]=e[t];return this},a.prototype.modules=function(){var e={};for(var t in s)e[t]=s[t];return e}(),a.prototype.extend=function(e){var t=this;e=e||{};for(var n in e)t[n]||t.modules[n]?o(n+" Module already exists","error"):t.modules[n]=e[n];return t},a.prototype.router=function(e){var t=this,e=e||location.hash,n={path:[],search:{},hash:(e.match(/[^#](#.*$)/)||[])[1]||""};return/^#\//.test(e)?(e=e.replace(/^#\//,""),n.href="/"+e,e=e.replace(/([^#])(#.*$)/,"$1").split("/")||[],t.each(e,function(e,t){/^\w+=/.test(t)?function(){t=t.split("="),n.search[t[0]]=t[1]}():n.path.push(t)}),n):n},a.prototype.url=function(e){var t=this,n={pathname:function(){var t=e?function(){var t=(e.match(/\.[^.]+?\/.+/)||[])[0]||"";return t.replace(/^[^\/]+/,"").replace(/\?.+/,"")}():location.pathname;return t.replace(/^\//,"").split("/")}(),search:function(){var n={},a=(e?function(){var t=(e.match(/\?.+/)||[])[0]||"";return t.replace(/\#.+/,"")}():location.search).replace(/^\?+/,"").split("&");return t.each(a,function(e,t){var a=t.indexOf("="),r=function(){return a<0?t.substr(0,t.length):0!==a&&t.substr(0,a)}();r&&(n[r]=a>0?t.substr(a+1):null)}),n}(),hash:t.router(function(){return e?(e.match(/#.+/)||[])[0]||"/":location.hash}())};return n},a.prototype.data=function(t,n,a){if(t=t||"layui",a=a||localStorage,e.JSON&&e.JSON.parse){if(null===n)return delete a[t];n="object"==typeof n?n:{key:n};try{var r=JSON.parse(a[t])}catch(i){var r={}}return"value"in n&&(r[n.key]=n.value),n.remove&&delete r[n.key],a[t]=JSON.stringify(r),n.key?r[n.key]:r}},a.prototype.sessionData=function(e,t){return this.data(e,t,sessionStorage)},a.prototype.device=function(t){var n=navigator.userAgent.toLowerCase(),a=function(e){var t=new RegExp(e+"/([^\\s\\_\\-]+)");return e=(n.match(t)||[])[1],e||!1},r={os:function(){return/windows/.test(n)?"windows":/linux/.test(n)?"linux":/iphone|ipod|ipad|ios/.test(n)?"ios":/mac/.test(n)?"mac":void 0}(),ie:function(){return!!(e.ActiveXObject||"ActiveXObject"in e)&&((n.match(/msie\s(\d+)/)||[])[1]||"11")}(),weixin:a("micromessenger")};return t&&!r[t]&&(r[t]=a(t)),r.android=/android/.test(n),r.ios="ios"===r.os,r.mobile=!(!r.android&&!r.ios),r},a.prototype.hint=function(){return{error:o}},a.prototype._typeof=function(e){return null===e?String(e):"object"==typeof e||"function"==typeof e?function(){var t=Object.prototype.toString.call(e).match(/\s(.+)\]$/)||[],n="Function|Array|Date|RegExp|Object|Error|Symbol";return t=t[1]||"Object",new RegExp("\\b("+n+")\\b").test(t)?t.toLowerCase():"object"}():typeof e},a.prototype._isArray=function(t){var n,a=this,r=a._typeof(t);return!(!t||"object"!=typeof t||t===e)&&(n="length"in t&&t.length,"array"===r||0===n||"number"==typeof n&&n>0&&n-1 in t)},a.prototype.each=function(e,t){var n,a=this,r=function(e,n){return t.call(n[e],e,n[e])};if("function"!=typeof t)return a;if(e=e||[],a._isArray(e))for(n=0;n(window.innerHeight||d.documentElement.clientHeight)},m.position=function(e,t,n){if(t){n=n||{},e!==d&&e!==m("body")[0]||(n.clickType="right");var a="right"===n.clickType?function(){var e=n.e||window.event||{};return{left:e.clientX,top:e.clientY,right:e.clientX,bottom:e.clientY}}():e.getBoundingClientRect(),r=t.offsetWidth,i=t.offsetHeight,o=function(e){return e=e?"scrollLeft":"scrollTop",d.body[e]|d.documentElement[e]},l=function(e){return d.documentElement[e?"clientWidth":"clientHeight"]},s=5,c=a.left,u=a.bottom;c+r+s>l("width")&&(c=l("width")-r-s),u+i+s>l()&&(a.top>i+s?u=a.top-i-2*s:"right"===n.clickType&&(u=l()-i-2*s,u<0&&(u=0)));var y=n.position;if(y&&(t.style.position=y),t.style.left=c+("fixed"===y?0:o(1))+"px",t.style.top=u+("fixed"===y?0:o())+"px",!m.hasScrollbar()){var f=t.getBoundingClientRect();!n.SYSTEM_RELOAD&&f.bottom+s>l()&&(n.SYSTEM_RELOAD=!0,setTimeout(function(){m.position(e,t,n)},50))}}},m.options=function(e,t){var n=m(e),a=t||"lay-options";try{return new Function("return "+(n.attr(a)||"{}"))()}catch(r){return hint.error("parseerror\uff1a"+r,"error"),{}}},m.isTopElem=function(e){var t=[d,m("body")[0]],n=!1;return m.each(t,function(t,a){if(a===e)return n=!0}),n},f.addStr=function(e,t){return e=e.replace(/\s+/," "),t=t.replace(/\s+/," ").split(" "),m.each(t,function(t,n){new RegExp("\\b"+n+"\\b").test(e)||(e=e+" "+n)}),e.replace(/^\s|\s$/,"")},f.removeStr=function(e,t){return e=e.replace(/\s+/," "),t=t.replace(/\s+/," ").split(" "),m.each(t,function(t,n){var a=new RegExp("\\b"+n+"\\b");a.test(e)&&(e=e.replace(a,""))}),e.replace(/\s+/," ").replace(/^\s|\s$/,"")},f.prototype.find=function(e){var t=this,n=0,a=[],r="object"==typeof e;return this.each(function(i,o){for(var l=r?o.contains(e):o.querySelectorAll(e||null);n0)return n[0].style[e]}():n.each(function(n,r){"object"==typeof e?m.each(e,function(e,t){r.style[e]=a(t)}):r.style[e]=a(t)})},f.prototype.width=function(e){var t=this;return void 0===e?function(){if(t.length>0)return t[0].offsetWidth}():t.each(function(n,a){t.css("width",e)})},f.prototype.height=function(e){var t=this;return void 0===e?function(){if(t.length>0)return t[0].offsetHeight}():t.each(function(n,a){t.css("height",e)})},f.prototype.attr=function(e,t){var n=this;return void 0===t?function(){if(n.length>0)return n[0].getAttribute(e)}():n.each(function(n,a){a.setAttribute(e,t)})},f.prototype.removeAttr=function(e){return this.each(function(t,n){n.removeAttribute(e)})},f.prototype.html=function(e){var t=this;return void 0===e?function(){if(t.length>0)return t[0].innerHTML}():this.each(function(t,n){n.innerHTML=e})},f.prototype.val=function(e){var t=this;return void 0===e?function(){if(t.length>0)return t[0].value}():this.each(function(t,n){n.value=e})},f.prototype.append=function(e){return this.each(function(t,n){"object"==typeof e?n.appendChild(e):n.innerHTML=n.innerHTML+e})},f.prototype.remove=function(e){return this.each(function(t,n){e?n.removeChild(e):n.parentNode.removeChild(n)})},f.prototype.on=function(e,t){return this.each(function(n,a){a.attachEvent?a.attachEvent("on"+e,function(e){e.target=e.srcElement,t.call(a,e)}):a.addEventListener(e,t,!1)})},f.prototype.off=function(e,t){return this.each(function(n,a){a.detachEvent?a.detachEvent("on"+e,t):a.removeEventListener(e,t,!1)})},window.lay=m,window.layui&&u.define&&u.define(function(e){e(y,m)})}(window,window.document),!function(e,t){"use strict";var n=e.layui&&layui.define,a={getPath:e.lay&&lay.getPath?lay.getPath:"",link:function(t,n,a){i.path&&e.lay&&lay.layui&&lay.layui.link(i.path+t,n,a)}},r=e.LAYUI_GLOBAL||{},i={v:"5.3.1",config:{},index:e.laydate&&e.laydate.v?1e5:0,path:r.laydate_dir||a.getPath,set:function(e){var t=this;return t.config=lay.extend({},t.config,e),t},ready:function(e){var t="laydate",r="",o=(n?"modules/laydate/":"theme/")+"default/laydate.css?v="+i.v+r;return n?layui.addcss(o,e,t):a.link(o,e,t),this}},o=function(){var e=this,t=e.config,n=t.id;return o.that[n]=e,{hint:function(t){e.hint.call(e,t)},config:e.config}},l="laydate",s=".layui-laydate",c="layui-this",u="laydate-disabled",y=[100,2e5],d="layui-laydate-static",m="layui-laydate-list",f="layui-laydate-hint",h="layui-laydate-footer",p=".laydate-btns-confirm",g="laydate-time-text",v="laydate-btns-time",T="layui-laydate-preview",w=function(e){var t=this;t.index=++i.index,t.config=lay.extend({},t.config,i.config,e),e=t.config,e.id="id"in e?e.id:t.index,i.ready(function(){t.init()})},D="yyyy|y|MM|M|dd|d|HH|H|mm|m|ss|s";o.formatArr=function(e){return(e||"").match(new RegExp(D+"|.","g"))||[]},w.isLeapYear=function(e){return e%4===0&&e%100!==0||e%400===0},w.prototype.config={type:"date",range:!1,format:"yyyy-MM-dd",value:null,isInitValue:!0,min:"1900-1-1",max:"2099-12-31",trigger:"click",show:!1,showBottom:!0,isPreview:!0,btns:["clear","now","confirm"],lang:"cn",theme:"default",position:null,calendar:!1,mark:{},zIndex:null,done:null,change:null},w.prototype.lang=function(){var e=this,t=e.config,n={cn:{weeks:["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d"],time:["\u65f6","\u5206","\u79d2"],timeTips:"\u9009\u62e9\u65f6\u95f4",startTime:"\u5f00\u59cb\u65f6\u95f4",endTime:"\u7ed3\u675f\u65f6\u95f4",dateTips:"\u8fd4\u56de\u65e5\u671f",month:["\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341","\u5341\u4e00","\u5341\u4e8c"],tools:{confirm:"\u786e\u5b9a",clear:"\u6e05\u7a7a",now:"\u73b0\u5728"},timeout:"\u7ed3\u675f\u65f6\u95f4\u4e0d\u80fd\u65e9\u4e8e\u5f00\u59cb\u65f6\u95f4
\u8bf7\u91cd\u65b0\u9009\u62e9",invalidDate:"\u4e0d\u5728\u6709\u6548\u65e5\u671f\u6216\u65f6\u95f4\u8303\u56f4\u5185",formatError:["\u65e5\u671f\u683c\u5f0f\u4e0d\u5408\u6cd5
\u5fc5\u987b\u9075\u5faa\u4e0b\u8ff0\u683c\u5f0f\uff1a
","
\u5df2\u4e3a\u4f60\u91cd\u7f6e"],preview:"\u5f53\u524d\u9009\u4e2d\u7684\u7ed3\u679c"},en:{weeks:["Su","Mo","Tu","We","Th","Fr","Sa"],time:["Hours","Minutes","Seconds"],timeTips:"Select Time",startTime:"Start Time",endTime:"End Time",dateTips:"Select Date",month:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],tools:{confirm:"Confirm",clear:"Clear",now:"Now"},timeout:"End time cannot be less than start Time
Please re-select",invalidDate:"Invalid date",formatError:["The date format error
Must be followed\uff1a
","
It has been reset"],preview:"The selected result"}};return n[t.lang]||n.cn},w.prototype.init=function(){var t=this,n=t.config,a="static"===n.position,r={year:"yyyy",month:"yyyy-MM",date:"yyyy-MM-dd",time:"HH:mm:ss",datetime:"yyyy-MM-dd HH:mm:ss"};n.elem=lay(n.elem),n.eventElem=lay(n.eventElem),n.elem[0]&&(t.rangeStr=n.range?"string"==typeof n.range?n.range:"-":"",n.range&&n.range.constructor===Array&&(t.rangeElem=[lay(n.range[0]),lay(n.range[1])]),r[n.type]||(e.console&&console.error&&console.error("laydate type error:'"+n.type+"' is not supported"),n.type="date"),n.format===r.date&&(n.format=r[n.type]||r.date),t.format=o.formatArr(n.format),t.EXP_IF="",t.EXP_SPLIT="",lay.each(t.format,function(e,n){var a=new RegExp(D).test(n)?"\\d{"+function(){return new RegExp(D).test(t.format[0===e?e+1:e-1]||"")?/^yyyy|y$/.test(n)?4:n.length:/^yyyy$/.test(n)?"1,4":/^y$/.test(n)?"1,308":"1,2"}()+"}":"\\"+n;t.EXP_IF=t.EXP_IF+a,t.EXP_SPLIT=t.EXP_SPLIT+"("+a+")"}),t.EXP_IF_ONE=new RegExp("^"+t.EXP_IF+"$"),t.EXP_IF=new RegExp("^"+(n.range?t.EXP_IF+"\\s\\"+t.rangeStr+"\\s"+t.EXP_IF:t.EXP_IF)+"$"),t.EXP_SPLIT=new RegExp("^"+t.EXP_SPLIT+"$",""),t.isInput(n.elem[0])||"focus"===n.trigger&&(n.trigger="click"),n.elem.attr("lay-key")||(n.elem.attr("lay-key",t.index),n.eventElem.attr("lay-key",t.index)),n.mark=lay.extend({},n.calendar&&"cn"===n.lang?{"0-1-1":"\u5143\u65e6","0-2-14":"\u60c5\u4eba","0-3-8":"\u5987\u5973","0-3-12":"\u690d\u6811","0-4-1":"\u611a\u4eba","0-5-1":"\u52b3\u52a8","0-5-4":"\u9752\u5e74","0-6-1":"\u513f\u7ae5","0-9-10":"\u6559\u5e08","0-9-18":"\u56fd\u803b","0-10-1":"\u56fd\u5e86","0-12-25":"\u5723\u8bde"}:{},n.mark),lay.each(["min","max"],function(e,t){var a=[],r=[];if("number"==typeof n[t]){var i=n[t],o=(new Date).getTime(),l=864e5,s=new Date(i?i0)return!0;var t=lay.elem("div",{"class":"layui-laydate-header"}),r=[function(){var e=lay.elem("i",{"class":"layui-icon laydate-icon laydate-prev-y"});return e.innerHTML="",e}(),function(){var e=lay.elem("i",{"class":"layui-icon laydate-icon laydate-prev-m"});return e.innerHTML="",e}(),function(){var e=lay.elem("div",{"class":"laydate-set-ym"}),t=lay.elem("span"),n=lay.elem("span");return e.appendChild(t),e.appendChild(n),e}(),function(){var e=lay.elem("i",{"class":"layui-icon laydate-icon laydate-next-m"});return e.innerHTML="",e}(),function(){var e=lay.elem("i",{"class":"layui-icon laydate-icon laydate-next-y"});return e.innerHTML="",e}()],i=lay.elem("div",{"class":"layui-laydate-content"}),o=lay.elem("table"),y=lay.elem("thead"),d=lay.elem("tr");lay.each(r,function(e,n){t.appendChild(n)}),y.appendChild(d),lay.each(new Array(6),function(e){var t=o.insertRow(0);lay.each(new Array(7),function(n){if(0===e){var r=lay.elem("th");r.innerHTML=a.weeks[n],d.appendChild(r)}t.insertCell(n)})}),o.insertBefore(y,o.children[0]),i.appendChild(o),l[e]=lay.elem("div",{"class":"layui-laydate-main laydate-main-list-"+e}),l[e].appendChild(t),l[e].appendChild(i),s.push(r),c.push(i),u.push(o)}),lay(y).html(function(){var e=[],t=[];return"datetime"===n.type&&e.push(''+a.timeTips+""),(n.range||"datetime"!==n.type)&&e.push(''),lay.each(n.btns,function(e,i){var o=a.tools[i]||"btn";n.range&&"now"===i||(r&&"clear"===i&&(o="cn"===n.lang?"\u91cd\u7f6e":"Reset"),t.push(''+o+""))}),e.push('"),e.join("")}()),lay.each(l,function(e,t){o.appendChild(t)}),n.showBottom&&o.appendChild(y),/^#/.test(n.theme)){var m=lay.elem("style"),f=["#{{id}} .layui-laydate-header{background-color:{{theme}};}","#{{id}} .layui-this{background-color:{{theme}} !important;}"].join("").replace(/{{id}}/g,e.elemID).replace(/{{theme}}/g,n.theme);"styleSheet"in m?(m.setAttribute("type","text/css"),m.styleSheet.cssText=f):m.innerHTML=f,lay(o).addClass("laydate-theme-molv"),o.appendChild(m)}i.thisId=n.id,e.remove(w.thisElemDate),r?n.elem.append(o):(t.body.appendChild(o),e.position()),e.checkDate().calendar(null,0,"init"),e.changeEvent(),w.thisElemDate=e.elemID,"function"==typeof n.ready&&n.ready(lay.extend({},n.dateTime,{month:n.dateTime.month+1})),e.preview()},w.prototype.remove=function(e){var t=this,n=(t.config,lay("#"+(e||t.elemID)));return n[0]?(n.hasClass(d)||t.checkDate(function(){n.remove()}),t):t},w.prototype.position=function(){var e=this,t=e.config;return lay.position(e.bindElem||t.elem[0],e.elem,{position:t.position}),e},w.prototype.hint=function(e){var t=this,n=(t.config,lay.elem("div",{"class":f}));t.elem&&(n.innerHTML=e||"",lay(t.elem).find("."+f).remove(),t.elem.appendChild(n),clearTimeout(t.hinTimer),t.hinTimer=setTimeout(function(){lay(t.elem).find("."+f).remove()},3e3))},w.prototype.getAsYM=function(e,t,n){return n?t--:t++,t<0&&(t=11,e--),t>11&&(t=0,e++),[e,t]},w.prototype.systemDate=function(e){var t=e||new Date;return{year:t.getFullYear(),month:t.getMonth(),date:t.getDate(),hours:e?e.getHours():0,minutes:e?e.getMinutes():0,seconds:e?e.getSeconds():0}},w.prototype.checkDate=function(e){var t,n,a=this,r=(new Date,a.config),o=a.lang(),l=r.dateTime=r.dateTime||a.systemDate(),s=a.bindElem||r.elem[0],c=(a.isInput(s)?"val":"html",function(){if(a.rangeElem){var e=[a.rangeElem[0].val(),a.rangeElem[1].val()];if(e[0]&&e[1])return e.join(" "+a.rangeStr+" ")}return a.isInput(s)?s.value:"static"===r.position?"":lay(s).attr("lay-date")}()),u=function(e){e.year>y[1]&&(e.year=y[1],n=!0),e.month>11&&(e.month=11,n=!0),e.hours>23&&(e.hours=0,n=!0),e.minutes>59&&(e.minutes=0,e.hours++,n=!0),e.seconds>59&&(e.seconds=0,e.minutes++,n=!0),t=i.getEndDate(e.month+1,e.year),e.date>t&&(e.date=t,n=!0)},d=function(e,t,i){var o=["startTime","endTime"];t=(t.match(a.EXP_SPLIT)||[]).slice(1),i=i||0,r.range&&(a[o[i]]=a[o[i]]||{}),lay.each(a.format,function(l,s){var c=parseFloat(t[l]);t[l].lengthf(r.max)||f(l)f(r.max))&&(a.endDate=lay.extend({},r.max)),e&&e(),a},w.prototype.mark=function(e,t){var n,a=this,r=a.config;return lay.each(r.mark,function(e,a){var r=e.split("-");r[0]!=t[0]&&0!=r[0]||r[1]!=t[1]&&0!=r[1]||r[2]!=t[2]||(n=a||t[2])}),n&&e.html(''+n+""),a},w.prototype.limit=function(e,t,n,a){var r,i=this,o=i.config,l={},s=o[n>41?"endDate":"dateTime"],c=lay.extend({},s,t||{});return lay.each({now:c,min:o.min,max:o.max},function(e,t){l[e]=i.newDate(lay.extend({year:t.year,month:t.month,date:t.date},function(){var e={};return lay.each(a,function(n,a){e[a]=t[a]}),e}())).getTime()}),r=l.nowl.max,e&&e[r?"addClass":"removeClass"](u),r},w.prototype.thisDateTime=function(e){var t=this,n=t.config;return e?t.endDate:n.dateTime},w.prototype.calendar=function(e,t,n){var a,r,o,l=this,s=l.config,t=t?1:0,u=e||l.thisDateTime(t),d=new Date,m=l.lang(),f="date"!==s.type&&"datetime"!==s.type,h=lay(l.table[t]).find("td"),g=lay(l.elemHeader[t][2]).find("span");return u.yeary[1]&&(u.year=y[1],l.hint(m.invalidDate)),l.firstDate||(l.firstDate=lay.extend({},u)),d.setFullYear(u.year,u.month,1),a=d.getDay(),r=i.getEndDate(u.month||12,u.year),o=i.getEndDate(u.month+1,u.year),lay.each(h,function(e,t){var n=[u.year,u.month],i=0;t=lay(t),t.removeAttr("class"),e=a&&e=n.firstDate.year&&(i.month=a.max.month,i.date=a.max.date),n.limit(lay(r),i,t),E++}),lay(y[h?0:1]).attr("lay-ym",E-8+"-"+w[1]).html(x+T+" - "+(E-1+T))}else if("month"===e)lay.each(new Array(12),function(e){var r=lay.elem("li",{"lay-ym":e}),o={year:w[0],month:e};e+1==w[1]&&lay(r).addClass(c),r.innerHTML=i.month[e]+(h?"\u6708":""),l.appendChild(r),w[0]=n.firstDate.year&&(o.date=a.max.date),n.limit(lay(r),o,t)}),lay(y[h?0:1]).attr("lay-ym",w[0]+"-"+w[1]).html(w[0]+T);else if("time"===e){var C=function(){lay(l).find("ol").each(function(e,a){lay(a).find("li").each(function(a,r){n.limit(lay(r),[{hours:a},{hours:n[b].hours,minutes:a},{hours:n[b].hours,minutes:n[b].minutes,seconds:a}][e],t,[["hours"],["hours","minutes"],["hours","minutes","seconds"]][e])})}),a.range||n.limit(lay(n.footer).find(p),n[b],0,["hours","minutes","seconds"])};a.range?n[b]||(n[b]="startTime"===b?r:n.endDate):n[b]=r,lay.each([24,60,60],function(e,t){var a=lay.elem("li"),r=["

"+i.time[e]+"

    "];lay.each(new Array(t),function(t){r.push(""+lay.digit(t,2)+"")}),a.innerHTML=r.join("")+"
",l.appendChild(a)}),C()}if(f&&d.removeChild(f),d.appendChild(l),"year"===e||"month"===e)lay(n.elemMain[t]).addClass("laydate-ym-show"),lay(l).find("li").on("click",function(){var i=0|lay(this).attr("lay-ym");if(!lay(this).hasClass(u)){0===t?(r[e]=i,n.limit(lay(n.footer).find(p),null,0)):n.endDate[e]=i;var s="year"===a.type||"month"===a.type;s?(lay(l).find("."+c).removeClass(c),lay(this).addClass(c),"month"===a.type&&"year"===e&&(n.listYM[t][0]=i,o&&((t?n.endDate:r).year=i),n.list("month",t))):(n.checkDate("limit").calendar(null,t),n.closeList()),n.setBtnStatus(),a.range||("month"===a.type&&"month"===e||"year"===a.type&&"year"===e)&&n.setValue(n.parse()).remove().done(),n.done(null,"change"),lay(n.footer).find("."+v).removeClass(u)}});else{var M=lay.elem("span",{"class":g}),S=function(){lay(l).find("ol").each(function(e){var t=this,a=lay(t).find("li");t.scrollTop=30*(n[b][D[e]]-2),t.scrollTop<=0&&a.each(function(e,n){if(!lay(this).hasClass(u))return t.scrollTop=30*(e-2),!0})})},k=lay(s[2]).find("."+g);S(),M.innerHTML=a.range?[i.startTime,i.endTime][t]:i.timeTips,lay(n.elemMain[t]).addClass("laydate-time-show"),k[0]&&k.remove(),s[2].appendChild(M),lay(l).find("ol").each(function(e){var t=this;lay(t).find("li").on("click",function(){var i=0|this.innerHTML;lay(this).hasClass(u)||(a.range?n[b][D[e]]=i:r[D[e]]=i,lay(t).find("."+c).removeClass(c),lay(this).addClass(c),C(),S(),(n.endDate||"time"===a.type)&&n.done(null,"change"),n.setBtnStatus())})})}return n},w.prototype.listYM=[],w.prototype.closeList=function(){var e=this;e.config;lay.each(e.elemCont,function(t,n){lay(this).find("."+m).remove(),lay(e.elemMain[t]).removeClass("laydate-ym-show laydate-time-show")}),lay(e.elem).find("."+g).remove()},w.prototype.setBtnStatus=function(e,t,n){var a,r=this,i=r.config,o=r.lang(),l=lay(r.footer).find(p);i.range&&"time"!==i.type&&(t=t||i.dateTime,n=n||r.endDate,a=r.newDate(t).getTime()>r.newDate(n).getTime(),r.limit(null,t)||r.limit(null,n)?l.addClass(u):l[a?"addClass":"removeClass"](u),e&&a&&r.hint("string"==typeof e?o.timeout.replace(/\u65e5\u671f/g,e):o.timeout))},w.prototype.parse=function(e,t){var n=this,a=n.config,r=t||("end"==e?lay.extend({},n.endDate,n.endTime):a.range?lay.extend({},a.dateTime,n.startTime):a.dateTime),o=i.parse(r,n.format,1);return a.range&&void 0===e?o+" "+n.rangeStr+" "+n.parse("end"):o},w.prototype.newDate=function(e){return e=e||{},new Date(e.year||1,e.month||0,e.date||1,e.hours||0,e.minutes||0,e.seconds||0)},w.prototype.setValue=function(e){var t=this,n=t.config,a=t.bindElem||n.elem[0];return"static"===n.position?t:(e=e||"",t.isInput(a)?lay(a).val(e):t.rangeElem?(t.rangeElem[0].val(e?t.parse("start"):""),t.rangeElem[1].val(e?t.parse("end"):"")):(0===lay(a).find("*").length&&lay(a).html(e),lay(a).attr("lay-date",e)),t)},w.prototype.preview=function(){var e=this,t=e.config;if(t.isPreview){var n=lay(e.elem).find("."+T),a=t.range?e.endDate?e.parse():"":e.parse();n.html(a).css({color:"#5FB878","font-size":"14px;"}),setTimeout(function(){ 3 | n.css({color:"#666","font-size":"12px;"})},300)}},w.prototype.done=function(e,t){var n=this,a=n.config,r=lay.extend({},lay.extend(a.dateTime,n.startTime)),i=lay.extend({},lay.extend(n.endDate,n.endTime));return lay.each([r,i],function(e,t){"month"in t&&lay.extend(t,{month:t.month+1})}),n.preview(),e=e||[n.parse(),r,i],"function"==typeof a[t||"done"]&&a[t||"done"].apply(a,e),n},w.prototype.choose=function(e,t){var n=this,a=n.config,r=n.thisDateTime(t),i=(lay(n.elem).find("td"),e.attr("lay-ymd").split("-"));i={year:0|i[0],month:(0|i[1])-1,date:0|i[2]},e.hasClass(u)||(lay.extend(r,i),a.range?(lay.each(["startTime","endTime"],function(e,t){n[t]=n[t]||{hours:0,minutes:0,seconds:0}}),n.calendar(null,t).done(null,"change")):"static"===a.position?n.calendar().done().done(null,"change"):"date"===a.type?n.setValue(n.parse()).remove().done():"datetime"===a.type&&n.calendar().done(null,"change"))},w.prototype.tool=function(e,t){var n=this,a=n.config,r=n.lang(),i=a.dateTime,o="static"===a.position,l={datetime:function(){lay(e).hasClass(u)||(n.list("time",0),a.range&&n.list("time",1),lay(e).attr("lay-type","date").html(n.lang().dateTips))},date:function(){n.closeList(),lay(e).attr("lay-type","datetime").html(n.lang().timeTips)},clear:function(){o&&(lay.extend(i,n.firstDate),n.calendar()),a.range&&(delete a.dateTime,delete n.endDate,delete n.startTime,delete n.endTime),n.setValue("").remove(),n.done(["",{},{}])},now:function(){var e=new Date;lay.extend(i,n.systemDate(),{hours:e.getHours(),minutes:e.getMinutes(),seconds:e.getSeconds()}),n.setValue(n.parse()).remove(),o&&n.calendar(),n.done()},confirm:function(){if(a.range){if(lay(e).hasClass(u))return n.hint("time"===a.type?r.timeout.replace(/\u65e5\u671f/g,"\u65f6\u95f4"):r.timeout)}else if(lay(e).hasClass(u))return n.hint(r.invalidDate);n.done(),n.setValue(n.parse()).remove()}};l[t]&&l[t]()},w.prototype.change=function(e){var t=this,n=t.config,a=t.thisDateTime(e),r=n.range&&("year"===n.type||"month"===n.type),i=t.elemCont[e||0],o=t.listYM[e],l=function(l){var s=lay(i).find(".laydate-year-list")[0],c=lay(i).find(".laydate-month-list")[0];return s&&(o[0]=l?o[0]-15:o[0]+15,t.list("year",e)),c&&(l?o[0]--:o[0]++,t.list("month",e)),(s||c)&&(lay.extend(a,{year:o[0]}),r&&(a.year=o[0]),n.range||t.done(null,"change"),n.range||t.limit(lay(t.footer).find(p),{year:o[0]})),t.setBtnStatus(),s||c};return{prevYear:function(){l("sub")||(a.year--,t.checkDate("limit").calendar(null,e),t.done(null,"change"))},prevMonth:function(){var n=t.getAsYM(a.year,a.month,"sub");lay.extend(a,{year:n[0],month:n[1]}),t.checkDate("limit").calendar(null,e),t.done(null,"change")},nextMonth:function(){var n=t.getAsYM(a.year,a.month);lay.extend(a,{year:n[0],month:n[1]}),t.checkDate("limit").calendar(null,e),t.done(null,"change")},nextYear:function(){l()||(a.year++,t.checkDate("limit").calendar(null,e),t.done(null,"change"))}}},w.prototype.changeEvent=function(){var e=this;e.config;lay(e.elem).on("click",function(e){lay.stope(e)}).on("mousedown",function(e){lay.stope(e)}),lay.each(e.elemHeader,function(t,n){lay(n[0]).on("click",function(n){e.change(t).prevYear()}),lay(n[1]).on("click",function(n){e.change(t).prevMonth()}),lay(n[2]).find("span").on("click",function(n){var a=lay(this),r=a.attr("lay-ym"),i=a.attr("lay-type");r&&(r=r.split("-"),e.listYM[t]=[0|r[0],0|r[1]],e.list(i,t),lay(e.footer).find("."+v).addClass(u))}),lay(n[3]).on("click",function(n){e.change(t).nextMonth()}),lay(n[4]).on("click",function(n){e.change(t).nextYear()})}),lay.each(e.table,function(t,n){var a=lay(n).find("td");a.on("click",function(){e.choose(lay(this),t)})}),lay(e.footer).find("span").on("click",function(){var t=lay(this).attr("lay-type");e.tool(this,t)})},w.prototype.isInput=function(e){return/input|textarea/.test(e.tagName.toLocaleLowerCase())},w.prototype.events=function(){var e=this,t=e.config,n=function(n,a){n.on(t.trigger,function(){a&&(e.bindElem=this),e.render()})};t.elem[0]&&!t.elem[0].eventHandler&&(n(t.elem,"bind"),n(t.eventElem),t.elem[0].eventHandler=!0)},o.that={},o.getThis=function(e){var t=o.that[e];return t||hint.error(e?l+" instance with ID '"+e+"' not found":"ID argument required"),t},a.run=function(n){n(t).on("mousedown",function(e){if(i.thisId){var t=o.getThis(i.thisId);if(t){var a=t.config;e.target!==a.elem[0]&&e.target!==a.eventElem[0]&&e.target!==n(a.closeStop)[0]&&t.remove()}}}).on("keydown",function(e){if(i.thisId){var t=o.getThis(i.thisId);t&&13===e.keyCode&&n("#"+t.elemID)[0]&&t.elemID===w.thisElemDate&&(e.preventDefault(),n(t.footer).find(p)[0].click())}}),n(e).on("resize",function(){if(i.thisId){var e=o.getThis(i.thisId);if(e)return!(!e.elem||!n(s)[0])&&void e.position()}})},i.render=function(e){var t=new w(e);return o.call(t)},i.parse=function(e,t,n){return e=e||{},"string"==typeof t&&(t=o.formatArr(t)),t=(t||[]).concat(),lay.each(t,function(a,r){/yyyy|y/.test(r)?t[a]=lay.digit(e.year,r.length):/MM|M/.test(r)?t[a]=lay.digit(e.month+(n||0),r.length):/dd|d/.test(r)?t[a]=lay.digit(e.date,r.length):/HH|H/.test(r)?t[a]=lay.digit(e.hours,r.length):/mm|m/.test(r)?t[a]=lay.digit(e.minutes,r.length):/ss|s/.test(r)&&(t[a]=lay.digit(e.seconds,r.length))}),t.join("")},i.getEndDate=function(e,t){var n=new Date;return n.setFullYear(t||n.getFullYear(),e||n.getMonth()+1,1),new Date(n.getTime()-864e5).getDate()},n?(i.ready(),layui.define("lay",function(e){i.path=layui.cache.dir,a.run(lay),e(l,i)})):"function"==typeof define&&define.amd?define(function(){return a.run(lay),i}):function(){i.ready(),a.run(e.lay),e.laydate=i}()}(window,window.document); -------------------------------------------------------------------------------- /static/layDate-v5.3.1/theme/default/font/iconfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpaqueGlass/progressBarT-sywidget/29b19d6e42ad288a8e046c3601804dafd0471719/static/layDate-v5.3.1/theme/default/font/iconfont.eot -------------------------------------------------------------------------------- /static/layDate-v5.3.1/theme/default/font/iconfont.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | Created by iconfont 9 | 10 | 11 | 12 | 13 | 21 | 22 | 23 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /static/layDate-v5.3.1/theme/default/font/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpaqueGlass/progressBarT-sywidget/29b19d6e42ad288a8e046c3601804dafd0471719/static/layDate-v5.3.1/theme/default/font/iconfont.ttf -------------------------------------------------------------------------------- /static/layDate-v5.3.1/theme/default/font/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpaqueGlass/progressBarT-sywidget/29b19d6e42ad288a8e046c3601804dafd0471719/static/layDate-v5.3.1/theme/default/font/iconfont.woff -------------------------------------------------------------------------------- /static/layDate-v5.3.1/theme/default/laydate.css: -------------------------------------------------------------------------------- 1 | .laydate-set-ym,.layui-laydate,.layui-laydate *,.layui-laydate-list{box-sizing:border-box}@font-face{font-family:laydate-icon;src:url(font/iconfont.eot);src:url(font/iconfont.eot#iefix) format('embedded-opentype'),url(font/iconfont.svg#iconfont) format('svg'),url(font/iconfont.woff) format('woff'),url(font/iconfont.ttf) format('truetype')}.laydate-icon{font-family:laydate-icon!important;font-size:16px;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}html #layuicss-laydate{display:none;position:absolute;width:1989px}.layui-laydate *{margin:0;padding:0}.layui-laydate{position:absolute;z-index:66666666;margin:5px 0;border-radius:2px;font-size:14px;-webkit-animation-duration:.2s;animation-duration:.2s;-webkit-animation-fill-mode:both;animation-fill-mode:both;animation-name:laydate-downbit}.layui-laydate-main{width:272px}.layui-laydate-content td,.layui-laydate-header *,.layui-laydate-list li{transition-duration:.3s;-webkit-transition-duration:.3s}@keyframes laydate-downbit{0%{opacity:.3;transform:translate3d(0,-5px,0)}100%{opacity:1;transform:translate3d(0,0,0)}}.layui-laydate-static{position:relative;z-index:0;display:inline-block;margin:0;-webkit-animation:none;animation:none}.laydate-ym-show .laydate-next-m,.laydate-ym-show .laydate-prev-m{display:none!important}.laydate-ym-show .laydate-next-y,.laydate-ym-show .laydate-prev-y{display:inline-block!important}.laydate-time-show .laydate-set-ym span[lay-type=month],.laydate-time-show .laydate-set-ym span[lay-type=year],.laydate-time-show .layui-laydate-header .layui-icon,.laydate-ym-show .laydate-set-ym span[lay-type=month]{display:none!important}.layui-laydate-header{position:relative;line-height:30px;padding:10px 70px 5px}.layui-laydate-header *{display:inline-block;vertical-align:bottom}.layui-laydate-header i{position:absolute;top:10px;padding:0 5px;color:#999;font-size:18px;cursor:pointer}.layui-laydate-header i.laydate-prev-y{left:15px}.layui-laydate-header i.laydate-prev-m{left:45px}.layui-laydate-header i.laydate-next-y{right:15px}.layui-laydate-header i.laydate-next-m{right:45px}.laydate-set-ym{width:100%;text-align:center;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.laydate-set-ym span{padding:0 10px;cursor:pointer}.laydate-time-text{cursor:default!important}.layui-laydate-content{position:relative;padding:10px;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none}.layui-laydate-content table{border-collapse:collapse;border-spacing:0}.layui-laydate-content td,.layui-laydate-content th{width:36px;height:30px;padding:5px;text-align:center}.layui-laydate-content td{position:relative;cursor:pointer}.laydate-day-mark{position:absolute;left:0;top:0;width:100%;line-height:30px;font-size:12px;overflow:hidden}.laydate-day-mark::after{position:absolute;content:'';right:2px;top:2px;width:5px;height:5px;border-radius:50%}.layui-laydate-footer{position:relative;height:46px;line-height:26px;padding:10px}.layui-laydate-footer span{display:inline-block;vertical-align:top;height:26px;line-height:24px;padding:0 10px;border:1px solid #C9C9C9;border-radius:2px;background-color:#fff;font-size:12px;cursor:pointer;white-space:nowrap;transition:all .3s}.layui-laydate-list>li,.layui-laydate-range .layui-laydate-main{display:inline-block;vertical-align:middle}.layui-laydate-footer span:hover{color:#5FB878}.layui-laydate-footer span.layui-laydate-preview{cursor:default;border-color:transparent!important}.layui-laydate-footer span.layui-laydate-preview:hover{color:#666}.layui-laydate-footer span:first-child.layui-laydate-preview{padding-left:0}.laydate-footer-btns{position:absolute;right:10px;top:10px}.laydate-footer-btns span{margin:0 0 0 -1px}.layui-laydate-list{position:absolute;left:0;top:0;width:100%;height:100%;padding:10px;background-color:#fff}.layui-laydate-list>li{position:relative;width:33.3%;height:36px;line-height:36px;margin:3px 0;text-align:center;cursor:pointer}.laydate-month-list>li{width:25%;margin:17px 0}.laydate-time-list>li{height:100%;margin:0;line-height:normal;cursor:default}.laydate-time-list p{position:relative;top:-4px;line-height:29px}.laydate-time-list ol{height:181px;overflow:hidden}.laydate-time-list>li:hover ol{overflow-y:auto}.laydate-time-list ol li{width:130%;padding-left:33px;height:30px;line-height:30px;text-align:left;cursor:pointer}.layui-laydate-hint{position:absolute;top:115px;left:50%;width:250px;margin-left:-125px;line-height:20px;padding:15px;text-align:center;font-size:12px}.layui-laydate-range{width:546px}.layui-laydate-range .laydate-main-list-1 .layui-laydate-content,.layui-laydate-range .laydate-main-list-1 .layui-laydate-header{border-left:1px solid #e2e2e2}.layui-laydate,.layui-laydate-hint{border:1px solid #d2d2d2;box-shadow:0 2px 4px rgba(0,0,0,.12);background-color:#fff;color:#666}.layui-laydate-header{border-bottom:1px solid #e2e2e2}.layui-laydate-header i:hover,.layui-laydate-header span:hover{color:#5FB878}.layui-laydate-content{border-top:none 0;border-bottom:none 0}.layui-laydate-content th{font-weight:400;color:#333}.layui-laydate-content td{color:#666}.layui-laydate-content td.laydate-selected{background-color:#B5FFF8}.laydate-selected:hover{background-color:#00F7DE!important}.layui-laydate-content td:hover,.layui-laydate-list li:hover{background-color:#eee;color:#333}.laydate-time-list li ol{margin:0;padding:0;border:1px solid #e2e2e2;border-left-width:0}.laydate-time-list li:first-child ol{border-left-width:1px}.laydate-time-list>li:hover{background:0 0}.layui-laydate-content .laydate-day-next,.layui-laydate-content .laydate-day-prev{color:#d2d2d2}.laydate-selected.laydate-day-next,.laydate-selected.laydate-day-prev{background-color:#f8f8f8!important}.layui-laydate-footer{border-top:1px solid #e2e2e2}.layui-laydate-hint{color:#FF5722}.laydate-day-mark::after{background-color:#5FB878}.layui-laydate-content td.layui-this .laydate-day-mark::after{display:none}.layui-laydate-footer span[lay-type=date]{color:#5FB878}.layui-laydate .layui-this{background-color:#009688!important;color:#fff!important}.layui-laydate .laydate-disabled,.layui-laydate .laydate-disabled:hover{background:0 0!important;color:#d2d2d2!important;cursor:not-allowed!important;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none}.laydate-theme-molv{border:none}.laydate-theme-molv.layui-laydate-range{width:548px}.laydate-theme-molv .layui-laydate-main{width:274px}.laydate-theme-molv .layui-laydate-header{border:none;background-color:#009688}.laydate-theme-molv .layui-laydate-header i,.laydate-theme-molv .layui-laydate-header span{color:#f6f6f6}.laydate-theme-molv .layui-laydate-header i:hover,.laydate-theme-molv .layui-laydate-header span:hover{color:#fff}.laydate-theme-molv .layui-laydate-content{border:1px solid #e2e2e2;border-top:none;border-bottom:none}.laydate-theme-molv .laydate-main-list-1 .layui-laydate-content{border-left:none}.laydate-theme-grid .laydate-month-list>li,.laydate-theme-grid .laydate-year-list>li,.laydate-theme-grid .layui-laydate-content td,.laydate-theme-grid .layui-laydate-content thead,.laydate-theme-molv .layui-laydate-footer{border:1px solid #e2e2e2}.laydate-theme-grid .laydate-selected,.laydate-theme-grid .laydate-selected:hover{background-color:#f2f2f2!important;color:#009688!important}.laydate-theme-grid .laydate-selected.laydate-day-next,.laydate-theme-grid .laydate-selected.laydate-day-prev{color:#d2d2d2!important}.laydate-theme-grid .laydate-month-list,.laydate-theme-grid .laydate-year-list{margin:1px 0 0 1px}.laydate-theme-grid .laydate-month-list>li,.laydate-theme-grid .laydate-year-list>li{margin:0 -1px -1px 0}.laydate-theme-grid .laydate-year-list>li{height:43px;line-height:43px}.laydate-theme-grid .laydate-month-list>li{height:71px;line-height:71px} -------------------------------------------------------------------------------- /static/progressbar.css: -------------------------------------------------------------------------------- 1 | :root { 2 | /* v0.0.1->v0.1.0升级提示 3 | 进度条颜色已经纳入config.js管理,手动更改css将会被config.js设定覆盖 */ 4 | /* 进度条背景色(未达到部分)*/ 5 | /* --container-color: ; */ 6 | /* 进度条前景色(已达到部分)*/ 7 | /* --progress-color: ; */ 8 | 9 | /* 进度条背景色(已达到部分-黑夜模式*/ 10 | --container-dark-color: rgba(175, 184, 193, 0.2); 11 | /* 进度条前景色(未达到部分-黑夜模式 */ 12 | --progress-dark: rgb(45, 164, 255); 13 | 14 | /* 进度百分比文字-黑夜模式 */ 15 | --text-dark: rgb(201, 209, 217); 16 | --bar-radius: 5px; 17 | } 18 | 19 | button.calendar_btn { 20 | border: 0px; 21 | /* font-weight: 300; */ 22 | width: 25px; 23 | height: 25px; 24 | border-radius: 3px; 25 | box-sizing: border-box; 26 | /* color: white; */ 27 | padding: 0px; 28 | /* text-align: center; 29 | text-decoration: none; */ 30 | display: inline-block; 31 | /* font-size: 16px; */ 32 | /* min-width: 15px; */ 33 | background-color: #f0f0f022; 34 | cursor: pointer; 35 | } 36 | 37 | /* 除alltask\showButtonCheckBox外的用户输入 */ 38 | .settings input:not(#allTask, #showButtonCheckBox, #onlyWorkDay) { 39 | border: 1px solid rgb(45, 164, 255); 40 | font-weight: 300; 41 | background-size: auto 1.5em; 42 | background-repeat: no-repeat; 43 | background-position: center; 44 | width: 12em; 45 | height: 1.5em; 46 | border-radius: 0.3em; 47 | box-sizing: border-box; 48 | /* color: white; */ 49 | /* padding: 15px 32px; */ 50 | text-decoration: none; 51 | display: inline-block; 52 | font-size: 16px; 53 | min-width: 15px; 54 | background-color: #f0f0f022; 55 | /* background-color:darkslategray; 56 | color: white; */ 57 | } 58 | 59 | /* 60 | 61 | td{ 62 | width: 96px; 63 | height: 26px; 64 | } */ 65 | 66 | #refresh { 67 | background-image: url("./icon.png"); 68 | } 69 | 70 | #settingBtn { 71 | background-image: url("./iconSetting.png"); 72 | fill: currentColor; 73 | width: 1.4em; 74 | background-size: auto 1.4em; 75 | height: 1.4em; 76 | border: 0px; 77 | margin-left: 2px; 78 | padding: 1px 6px; 79 | } 80 | 81 | #barWidth { 82 | width: 40px; 83 | } 84 | 85 | /* 左侧栏 */ 86 | .linel { 87 | text-align: right; 88 | min-width: 4em; 89 | } 90 | 91 | /* 右侧栏 */ 92 | .liner { 93 | text-align: left; 94 | } 95 | 96 | .btnline { 97 | text-align: center; 98 | } 99 | 100 | 101 | /* 主界面刷新按钮 */ 102 | .btn > button { 103 | border-width: 0px; 104 | /*自动模式按钮边框*/ 105 | font-weight: 300; 106 | background-size: auto 1.5em; 107 | background-repeat: no-repeat; 108 | background-position: center; 109 | width: 1.5em; 110 | height: 1.5em; 111 | border-radius: 0.3em; 112 | box-sizing: border-box; 113 | text-align: center; 114 | text-decoration: none; 115 | display: inline-block; 116 | font-size: 14px; 117 | background-color: #f0f0f000; 118 | cursor: pointer; 119 | } 120 | 121 | /* 提示区功能按钮 */ 122 | .infos>button { 123 | width: 2em; 124 | height: 1.5em; 125 | border-width: 1px; 126 | text-align: center; 127 | text-decoration: none; 128 | display: inline-block; 129 | } 130 | 131 | .innerinfos { 132 | height: 47px; 133 | } 134 | 135 | .settingTable { 136 | width: 50%; 137 | } 138 | 139 | .btn { 140 | height: 1.5em; 141 | } 142 | 143 | .canClick { 144 | cursor: pointer; 145 | } 146 | 147 | /* 进度条主体 */ 148 | #container { 149 | width: 100%; 150 | /*进度条宽度*/ 151 | height: 10px; 152 | /*进度条高度*/ 153 | border-radius: var(--bar-radius); 154 | /*进度条圆角*/ 155 | align-self: center; 156 | /* 禁止子元素溢出 */ 157 | overflow: hidden; 158 | /* float: right; */ 159 | } 160 | 161 | /* 提示词子项间隔 */ 162 | .infos>* { 163 | margin-left: 3px; 164 | } 165 | 166 | /* 设置项保存按钮 */ 167 | .settings .text_btn { 168 | border: 1px dotted; 169 | border-radius: 3px; 170 | } 171 | 172 | #progress, #progress2 { 173 | width: 0%; 174 | /*初始值,刷新后由js控制*/ 175 | height: inherit; 176 | /*请勿修改*/ 177 | border-radius: var(--bar-radius) 0 0 var(--bar-radius); 178 | /*进度条已加载部分颜色*/ 179 | transition-property: width; 180 | transition-duration: 200ms; 181 | } 182 | 183 | /* 黑夜模式下进度条已完成颜色 */ 184 | .progress_dark { 185 | background: var(--progress-dark); 186 | } 187 | 188 | /* 黑夜模式下进度条未完成颜色 */ 189 | .container_dark { 190 | background: var(--container-dark-color); 191 | } 192 | 193 | #percentage { 194 | text-align: center; 195 | width: 50px; 196 | /* flex: right; */ 197 | } 198 | 199 | /* 黑夜模式下百分比文字 */ 200 | .text_dark { 201 | color: var(--text-dark); 202 | } 203 | 204 | #errorInfo { 205 | color: red; 206 | } 207 | 208 | #infoInfo { 209 | color: cornflowerblue; 210 | } 211 | 212 | .app { 213 | display: flex; 214 | white-space: nowrap; 215 | 216 | } 217 | 218 | .input_dark { 219 | color: var(--text-dark); 220 | background-color: #f0f0f000; 221 | } 222 | 223 | .btn_dark { 224 | color: var(--text-dark); 225 | background-color: #1259536e; 226 | } 227 | 228 | /* 日期选择控件 深色模式适配*/ 229 | 230 | [dark_mode] .layui-laydate-header, 231 | [dark_mode] .layui-laydate-content, 232 | [dark_mode] .layui-laydate-footer, 233 | [dark_mode] .layui-laydate, 234 | [dark_mode] .layui-laydate-footer span, 235 | [dark_mode] .laydate-footer-btns, 236 | [dark_mode] .layui-laydate-list { 237 | border-color: rgb(56, 61, 63) !important; 238 | background-color: #181a1b !important; 239 | } 240 | 241 | [dark_mode] .layui-laydate-list li:hover, 242 | [dark_mode] .layui-laydate-main td:hover { 243 | color: rgb(200, 195, 188); 244 | background-color: #383c3f; 245 | } 246 | 247 | [dark_mode] .layui-icon { 248 | color: #a8a095; 249 | } 250 | 251 | [dark_mode] .layui-laydate-main td, 252 | [dark_mode] .layui-laydate-main th, 253 | [dark_mode] .layui-laydate-footer * , 254 | [dark_mode] .laydate-set-ym, 255 | [dark_mode] .layui-laydate-list li, 256 | [dark_mode] .layui-laydate-preview { 257 | color: rgb(200, 195, 188); 258 | } 259 | 260 | [dark_mode] .laydate-day-prev, 261 | [dark_mode] .laydate-day-next { 262 | color: rgb(168, 160, 149) !important; 263 | } 264 | 265 | .time-warn { 266 | color: red; 267 | } 268 | 269 | [dark_mode] .time-warn { 270 | color: #FF0000; 271 | } 272 | 273 | [dark_mode] #color-test { 274 | color:rgb(201, 209, 217); 275 | } 276 | 277 | #header { 278 | display: flex; 279 | justify-content: space-between; 280 | margin-bottom: 10px; 281 | } 282 | 283 | /* .time-mode-a { 284 | display: none !important; 285 | } */ 286 | 287 | [dark_mode] * { 288 | color: rgb(201, 209, 217); 289 | } 290 | 291 | #outerInfos { 292 | text-align: center; 293 | } 294 | 295 | #header { 296 | margin-bottom: 5px; 297 | } 298 | 299 | #header-left-info > *, #end-time-display { 300 | 301 | user-select: none; 302 | cursor: pointer; 303 | } 304 | 305 | /* #progress2 { 306 | width: 0%; 307 | position: relative; 308 | left: 0px; 309 | top: -12px; 310 | z-index: -1; 311 | background-color: rgba(255, 0, 0, 0.15); 312 | } 313 | 314 | #progress { 315 | z-index: 0; 316 | } */ 317 | 318 | #container { 319 | /* z-index: -255; 存在手动模式无法触发的问题*/ 320 | margin: 0px 3px; 321 | } 322 | 323 | /* 时间模式左右两侧的时间文本 */ 324 | #start-time-display, #end-time-display { 325 | /* 326 | 这里使用flex布局以使得开始/结束时间元素宽度相同,min-width决定他们实际所占的宽度; 327 | 进度条则占据所有剩余位置 328 | 英文用户或使用其他日期格式的用户需要另外调整 329 | */ 330 | min-width: 4.7em; 331 | flex: 1; 332 | } 333 | 334 | #start-time-display { 335 | text-align: center; 336 | margin-right: 3px; 337 | } 338 | 339 | #end-time-display { 340 | text-align: center; 341 | margin-left: 3px; 342 | } 343 | 344 | #outerInfos{ 345 | margin-top: 3px; 346 | } -------------------------------------------------------------------------------- /widget.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "progressBarT", 3 | "author": "OpaqueGlass", 4 | "url": "https://github.com/OpaqueGlass/progressBarT-sywidget", 5 | "version": "0.2.1", 6 | "displayName": { 7 | "default": "progressBarT", 8 | "zh_CN": "任务进度条", 9 | "en_US": "progressBarT" 10 | }, 11 | "description": { 12 | "default": "Show a progress bar in widget. [English is not fully supported]", 13 | "zh_CN": "显示进度条的挂件,另有时间模式和手动模式", 14 | "en_US": "Show a progress bar in widget. [English is not fully supported]" 15 | }, 16 | "readme": { 17 | "default": "README_en_US.md", 18 | "zh_CN": "README.md", 19 | "en_US": "README_en_US.md" 20 | }, 21 | "i18n": [ 22 | "zh_CN", 23 | "en_US" 24 | ], 25 | "funding": { 26 | "openCollective": "", 27 | "patreon": "", 28 | "github": "", 29 | "custom": [ 30 | "https://wj.qq.com/s2/12395364/b69f/" 31 | ] 32 | } 33 | } 34 | --------------------------------------------------------------------------------