danoniplus 42.0.0 → 42.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/js/danoni_main.js +41 -10
- package/package.json +1 -1
package/js/danoni_main.js
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Source by tickle
|
|
6
6
|
* Created : 2018/10/08
|
|
7
|
-
* Revised : 2025/
|
|
7
|
+
* Revised : 2025/06/08
|
|
8
8
|
*
|
|
9
9
|
* https://github.com/cwtickle/danoniplus
|
|
10
10
|
*/
|
|
11
|
-
const g_version = `Ver 42.
|
|
12
|
-
const g_revisedDate = `2025/
|
|
11
|
+
const g_version = `Ver 42.1.1`;
|
|
12
|
+
const g_revisedDate = `2025/06/08`;
|
|
13
13
|
|
|
14
14
|
// カスタム用バージョン (danoni_custom.js 等で指定可)
|
|
15
15
|
let g_localVersion = ``;
|
|
@@ -66,7 +66,7 @@ const g_referenceDomains = [
|
|
|
66
66
|
Object.freeze(g_referenceDomains);
|
|
67
67
|
|
|
68
68
|
const g_rootPath = current().match(/(^.*\/)/)[0];
|
|
69
|
-
|
|
69
|
+
let g_workPath;
|
|
70
70
|
const hasRemoteDomain = _path => g_referenceDomains.some(domain => _path.match(`^https://${domain}/`) !== null);
|
|
71
71
|
const g_remoteFlg = hasRemoteDomain(g_rootPath);
|
|
72
72
|
|
|
@@ -821,6 +821,26 @@ const unEscapeHtml = _str => unEscapeEmoji(replaceStr(_str, g_escapeStr.unEscape
|
|
|
821
821
|
*/
|
|
822
822
|
const escapeHtmlForArray = _array => _array.map(str => escapeHtml(str));
|
|
823
823
|
|
|
824
|
+
/**
|
|
825
|
+
* URLのパスを検証し、絶対URLまたは相対パスであればその値を返す
|
|
826
|
+
* @param {string} _input
|
|
827
|
+
* @param {string} _defaultUrl
|
|
828
|
+
* @returns {string}
|
|
829
|
+
*/
|
|
830
|
+
const validatePath = (_input, _defaultUrl = ``) => {
|
|
831
|
+
// 絶対 URL(http, https, ftp, fileなど)
|
|
832
|
+
const absoluteUrlPattern = /^(https?:\/\/|ftp:\/\/|file:\/\/)/;
|
|
833
|
+
|
|
834
|
+
// 相対パス(ルート相対 `/path/to/file` もしくは `./file`, `../file` )
|
|
835
|
+
const relativePathPattern = /^\/|^\.{1,2}\//;
|
|
836
|
+
|
|
837
|
+
const raw = _input && (absoluteUrlPattern.test(_input) || relativePathPattern.test(_input))
|
|
838
|
+
? encodeURI(_input) : _defaultUrl;
|
|
839
|
+
|
|
840
|
+
// URL または相対パスが合致すればその値を返し、そうでなければデフォルト URL を返す
|
|
841
|
+
return raw.endsWith(`/`) ? raw : raw + `/`;
|
|
842
|
+
};
|
|
843
|
+
|
|
824
844
|
/**
|
|
825
845
|
* 次のカーソルへ移動
|
|
826
846
|
* @param {number} _basePos
|
|
@@ -2454,6 +2474,8 @@ const initialControl = async () => {
|
|
|
2454
2474
|
|
|
2455
2475
|
const stage = document.getElementById(`canvas-frame`);
|
|
2456
2476
|
const divRoot = createEmptySprite(stage, `divRoot`, g_windowObj.divRoot);
|
|
2477
|
+
g_workPath = validatePath(document.getElementById(`jsRootUrl`)?.value,
|
|
2478
|
+
new URL(location.href).href.match(/(^.*\/)/)[0]);
|
|
2457
2479
|
|
|
2458
2480
|
// 背景の表示
|
|
2459
2481
|
if (document.getElementById(`layer0`) !== null) {
|
|
@@ -2994,13 +3016,22 @@ const getMusicUrl = _scoreId =>
|
|
|
2994
3016
|
* @returns {string}
|
|
2995
3017
|
*/
|
|
2996
3018
|
const getFullMusicUrl = (_musicUrl = ``) => {
|
|
2997
|
-
let
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3019
|
+
let baseMusicUrl = _musicUrl;
|
|
3020
|
+
let baseDir = `../${g_headerObj.musicFolder}/`;
|
|
3021
|
+
|
|
3022
|
+
if (_musicUrl.includes(C_MRK_CURRENT_DIRECTORY)) {
|
|
3023
|
+
// musicUrl, musicFolder両方にカレントパス指定がある場合は、musicUrlの値を優先
|
|
3024
|
+
|
|
3025
|
+
} else if (g_headerObj.musicFolder.includes(C_MRK_CURRENT_DIRECTORY)) {
|
|
3026
|
+
// musicFolderにカレントパス指定がある場合は、ファイル名にmusicFolderの値も含める
|
|
3027
|
+
baseMusicUrl = `${g_headerObj.musicFolder}/${_musicUrl}`;
|
|
3028
|
+
}
|
|
3029
|
+
if (g_headerObj.musicFolder.includes(C_MRK_CURRENT_DIRECTORY)) {
|
|
3030
|
+
// musicFolderにカレントパス指定がある場合は、ディレクトリは指定しない
|
|
3031
|
+
baseDir = ``;
|
|
3002
3032
|
}
|
|
3003
|
-
|
|
3033
|
+
const [musicFile, musicPath] = getFilePath(baseMusicUrl, baseDir);
|
|
3034
|
+
return `${musicPath}${musicFile}`;
|
|
3004
3035
|
}
|
|
3005
3036
|
|
|
3006
3037
|
/**
|