]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
VentoyPlugson Update:
authorlongpanda <admin@ventoy.net>
Fri, 21 Oct 2022 08:06:13 +0000 (16:06 +0800)
committerlongpanda <admin@ventoy.net>
Fri, 21 Oct 2022 08:06:13 +0000 (16:06 +0800)
1. Add preview json feature
2. Add reset button
3. Add configuration active identifier for each tab
4. Bug fix

25 files changed:
Plugson/build.sh
Plugson/src/Core/ventoy_disk_linux.c
Plugson/src/Core/ventoy_json.h
Plugson/src/Core/ventoy_util.c
Plugson/src/Core/ventoy_util.h
Plugson/src/Core/ventoy_util_linux.c
Plugson/src/Web/ventoy_http.c
Plugson/src/Web/ventoy_http.h
Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe
Plugson/www/buildtime
Plugson/www/index.html
Plugson/www/plugson_auto_install.html
Plugson/www/plugson_auto_memdisk.html
Plugson/www/plugson_conf_replace.html
Plugson/www/plugson_control.html
Plugson/www/plugson_dud.html
Plugson/www/plugson_image_list.html
Plugson/www/plugson_injection.html
Plugson/www/plugson_menu_alias.html
Plugson/www/plugson_menu_class.html
Plugson/www/plugson_menu_tip.html
Plugson/www/plugson_password.html
Plugson/www/plugson_persistence.html
Plugson/www/plugson_theme.html
Plugson/www/static/js/vtoy.js

index 095d07094615c7bcbcb391aceee5633546ef7b12..af159b90054d58a005fff716680879a50b8dae8c 100644 (file)
@@ -8,14 +8,14 @@ build_func() {
     libsuffix=$2
     toolDir=$3
     
-    XXFLAG='-std=gnu99 -D_FILE_OFFSET_BITS=64'
+    XXFLAG='-std=gnu99 -D_FILE_OFFSET_BITS=64 -O2'
     XXLIB=""
     
     echo "CC=$1 libsuffix=$libsuffix toolDir=$toolDir"    
     
     echo "CC civetweb.o"
     $1 $XXFLAG -c -Wall -Wextra -Wshadow -Wformat-security -Winit-self \
-        -Wmissing-prototypes -O2 -DLINUX \
+        -Wmissing-prototypes -DLINUX \
         -I./src/Lib/libhttp/include \
         -DNDEBUG -DNO_CGI -DNO_CACHING -DNO_SSL -DSQLITE_DISABLE_LFS -DSSL_ALREADY_INITIALIZED \
         -DUSE_STACK_SIZE=102400 -DNDEBUG -fPIC \
@@ -23,7 +23,7 @@ build_func() {
         -o ./civetweb.o
 
     echo "CC plugson.o"
-    $1 $XXFLAG -O2 $exopt -Wall -Wno-unused-function -DSTATIC=static -DINIT= \
+    $1 $XXFLAG $exopt -Wall -Wno-unused-function -DSTATIC=static -DINIT= \
         -I./src \
         -I./src/Core \
         -I./src/Web \
@@ -71,7 +71,6 @@ build_func() {
 }
 
 build_func "gcc" '64' 'x86_64'
-
 build_func "gcc -m32" '32' 'i386'
 build_func "aarch64-linux-gnu-gcc" 'aa64' 'aarch64'
 build_func "mips-linux-gnu-gcc -mips64r2 -mabi=64" 'm64e' 'mips64el'
index 1a081592e9197043ccb87190ee0ba1b13686c28f..f4ec853ce261696818047c03191a199435332560 100644 (file)
@@ -311,12 +311,24 @@ uint64_t ventoy_get_disk_size_in_byte(const char *disk)
 
 int ventoy_get_disk_vendor(const char *name, char *vendorbuf, int bufsize)
 {
-    return ventoy_get_sys_file_line(vendorbuf, bufsize, "/sys/block/%s/device/vendor", name);
+    if (strncmp(name, "loop", 4) == 0)
+    {
+        scnprintf(vendorbuf, bufsize, "Local");
+        return 0;
+    }
+    
+    return ventoy_get_sys_file_line(vendorbuf, bufsize, "/sys/block/%s/device/vendor", name);        
 }
 
 int ventoy_get_disk_model(const char *name, char *modelbuf, int bufsize)
 {
-    return ventoy_get_sys_file_line(modelbuf, bufsize, "/sys/block/%s/device/model", name);
+    if (strncmp(name, "loop", 4) == 0)
+    {
+        scnprintf(modelbuf, bufsize, "Loop Device");
+        return 0;
+    }
+
+    return ventoy_get_sys_file_line(modelbuf, bufsize, "/sys/block/%s/device/model", name);  
 }
 
 static int fatlib_media_sector_read(uint32 sector, uint8 *buffer, uint32 sector_count)
@@ -576,9 +588,9 @@ int ventoy_get_disk_info(char **argv)
     char model[128];
     char *disk = argv[4];
 
-    if (strncmp(argv[4], "/dev/", 4) == 0)
+    if (strncmp(argv[4], "/dev/", 5) == 0)
     {
-        disk += 4;
+        disk += 5;
     }
     ventoy_get_disk_vendor(disk, vendor, sizeof(vendor));
     ventoy_get_disk_model(disk, model, sizeof(model));
index bccd3a2483246f98bdbed760616f0eec591fb99f..ad130b97228fdd39e9e710a1e96cca0e041a3315 100644 (file)
@@ -152,6 +152,9 @@ typedef struct tagVTOY_JSON
 #define VTOY_JSON_FMT_ITEM_LN(P, Item)  ssprintf(__uiCurPos, __pcBuf, __uiBufLen, "%s\"%s\",\n", P, (Item))
 #define VTOY_JSON_FMT_ITEM_PATH_LN(P, Item)  ssprintf(__uiCurPos, __pcBuf, __uiBufLen, "%s\"%s\",\n", P, ventoy_real_path(Item))
 
+#define VTOY_JSON_FMT_ITEM_INT(Item)  ssprintf(__uiCurPos, __pcBuf, __uiBufLen, "%d,", (Item))
+
+
 #define VTOY_JSON_FMT_COMA()  ssprintf(__uiCurPos, __pcBuf, __uiBufLen, ",")
 #define VTOY_JSON_FMT_COMA_N(cnt)  ssprintf(__uiCurPos, __pcBuf, __uiBufLen, ",\n")
 #define VTOY_JSON_FMT_COMA_N_CNT(cnt) if ((cnt) > 0)  ssprintf(__uiCurPos, __pcBuf, __uiBufLen, ",\n")
index 2a0043393922cc00203d18ed034d615dbfb91b44..6d3d9e738713adfb91f6ae3e71d380240566b1de 100644 (file)
@@ -257,4 +257,48 @@ if (backup)
 #endif    
 }
 
+static const char g_encoding_table[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
+                                'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
+                                'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
+                                'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
+                                'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
+                                'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
+                                'w', 'x', 'y', 'z', '0', '1', '2', '3',
+                                '4', '5', '6', '7', '8', '9', '+', '/'};
+
+char * ventoy_base64_encode(const char *data, int input_length, int *output_length) 
+{
+    int i = 0;
+    int j = 0;
+    char *encoded_data = NULL;
+    int mod_table[] = {0, 2, 1};
+    
+    *output_length = 4 * ((input_length + 2) / 3);
+    encoded_data = malloc(*output_length + 4);
+    if (!encoded_data)
+    {
+        return NULL;
+    }
+
+    while (i < input_length) 
+    {
+        unsigned int octet_a = i < input_length ? (unsigned char)data[i++] : 0;
+        unsigned int octet_b = i < input_length ? (unsigned char)data[i++] : 0;
+        unsigned int octet_c = i < input_length ? (unsigned char)data[i++] : 0;
+
+        unsigned int triple = (octet_a << 0x10) + (octet_b << 0x08) + octet_c;
+
+        encoded_data[j++] = g_encoding_table[(triple >> 3 * 6) & 0x3F];
+        encoded_data[j++] = g_encoding_table[(triple >> 2 * 6) & 0x3F];
+        encoded_data[j++] = g_encoding_table[(triple >> 1 * 6) & 0x3F];
+        encoded_data[j++] = g_encoding_table[(triple >> 0 * 6) & 0x3F];
+    }
+
+    for (i = 0; i < mod_table[input_length % 3]; i++)
+    {
+        encoded_data[*output_length - 1 - i] = '=';        
+    }
+
+    return encoded_data;
+}
 
index 7eadfc0a9d4d7feb5b3d1dfe7e7ea70d9f822faa..0ca1632d7eb5eea4d5a33aa45e8041ad0fb5dbc4 100644 (file)
@@ -199,6 +199,7 @@ extern unsigned char *g_unxz_buffer;
 extern int g_unxz_len;
 void unxz_error(char *x);
 int unxz_flush(void *src, unsigned int size);
+char * ventoy_base64_encode(const char *data, int input_length, int *output_length);
 
 #endif /* __VENTOY_UTIL_H__ */
 
index c432f084fc6f507acf432499954bef45886cfec6..c5bf838d68ec68f5ea43d2b5a621adba08d1a1f5 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/fs.h>
 #include <dirent.h>
 #include <time.h>
+#include <semaphore.h>
 #include <ventoy_define.h>
 #include <ventoy_util.h>
 
@@ -234,30 +235,18 @@ int ventoy_write_buf_to_file(const char *FileName, void *Bufer, int BufLen)
     return 0;
 }
 
-
+static sem_t g_writeback_sem;
 static volatile int g_thread_stop = 0;
 static pthread_t g_writeback_thread;
-static pthread_mutex_t g_writeback_mutex;
-static pthread_cond_t g_writeback_cond;
+
 static void * ventoy_local_thread_run(void* data)
 {
     ventoy_http_writeback_pf callback = (ventoy_http_writeback_pf)data;
 
-    while (1)
+    while (0 == g_thread_stop)
     {
-        pthread_mutex_lock(&g_writeback_mutex);
-        pthread_cond_wait(&g_writeback_cond, &g_writeback_mutex);
-        
-        if (g_thread_stop)
-        {
-            pthread_mutex_unlock(&g_writeback_mutex);
-            break;
-        }
-        else
-        {
-            callback();
-            pthread_mutex_unlock(&g_writeback_mutex);
-        }
+        sem_wait(&g_writeback_sem);
+        callback();
     }    
 
     return NULL;
@@ -265,15 +254,14 @@ static void * ventoy_local_thread_run(void* data)
 
 void ventoy_set_writeback_event(void)
 {
-    pthread_cond_signal(&g_writeback_cond);
+    sem_post(&g_writeback_sem);
 }
 
 int ventoy_start_writeback_thread(ventoy_http_writeback_pf callback)
 {
     g_thread_stop = 0;
-    pthread_mutex_init(&g_writeback_mutex, NULL);
-    pthread_cond_init(&g_writeback_cond, NULL);
 
+    sem_init(&g_writeback_sem, 0, 0);
     pthread_create(&g_writeback_thread, NULL, ventoy_local_thread_run, callback);
 
     return 0;
@@ -282,13 +270,10 @@ int ventoy_start_writeback_thread(ventoy_http_writeback_pf callback)
 void ventoy_stop_writeback_thread(void)
 {
     g_thread_stop = 1;
-    pthread_cond_signal(&g_writeback_cond);
-    
-    pthread_join(g_writeback_thread, NULL);
 
-
-    pthread_cond_destroy(&g_writeback_cond);
-    pthread_mutex_destroy(&g_writeback_mutex);
+    sem_post(&g_writeback_sem);
+    pthread_join(g_writeback_thread, NULL);
+    sem_destroy(&g_writeback_sem);
 }
 
 
index 1fbc1c975db66c796e6bf74d97c708f330d10574..be9639192c54897020d52da157ae3dbc6f5b8cd0 100644 (file)
@@ -60,6 +60,17 @@ static const char *g_ventoy_kbd_layout[] =
     NULL
 };
 
+#define VTOY_DEL_ALL_PATH   "4119ae33-98ea-448e-b9c0-569aafcf1fb4"
+
+static int g_json_exist[plugin_type_max][bios_max];
+static const char *g_plugin_name[plugin_type_max] = 
+{
+    "control", "theme", "menu_alias", "menu_tip", 
+    "menu_class", "auto_install", "persistence", "injection", 
+    "conf_replace", "password", "image_list", 
+    "auto_memdisk", "dud"
+};
+
 static char g_ventoy_help_lang[MAX_LANGUAGE][8];
 
 static char g_pub_path[2 * MAX_PATH];
@@ -341,7 +352,10 @@ static int ventoy_api_sysinfo(struct mg_connection *conn, VTOY_JSON *json)
 
 static int ventoy_api_handshake(struct mg_connection *conn, VTOY_JSON *json)
 {
+    int i = 0;
+    int j = 0;
     int pos = 0;
+    char key[128];
     
     (void)json;
 
@@ -350,6 +364,19 @@ static int ventoy_api_handshake(struct mg_connection *conn, VTOY_JSON *json)
     VTOY_JSON_FMT_SINT("status", 0);
     VTOY_JSON_FMT_SINT("save_error", g_sysinfo.config_save_error);
     g_sysinfo.config_save_error = 0;
+
+    for (i = 0; i < plugin_type_max; i++)
+    {
+        scnprintf(key, sizeof(key), "exist_%s", g_plugin_name[i]);
+        VTOY_JSON_FMT_KEY(key);
+        VTOY_JSON_FMT_ARY_BEGIN();
+        for (j = 0; j < bios_max; j++)
+        {
+            VTOY_JSON_FMT_ITEM_INT(g_json_exist[i][j]);
+        }
+        VTOY_JSON_FMT_ARY_ENDEX();
+    }
+    
     VTOY_JSON_FMT_OBJ_END();
     VTOY_JSON_FMT_END(pos);
 
@@ -718,7 +745,7 @@ int ventoy_data_cmp_theme(data_theme *data1, data_theme *data2)
     {
         return 1;
     }
-    
+
     if (ventoy_path_list_cmp(data1->fontslist, data2->fontslist))
     {
         return 1;
@@ -927,7 +954,14 @@ static int ventoy_api_theme_del_file(struct mg_connection *conn, VTOY_JSON *json
     path = VTOY_JSON_STR_EX("path");
     if (path)
     {
-        vtoy_list_del(last, node, data->filelist, path);
+        if (strcmp(path, VTOY_DEL_ALL_PATH) == 0)
+        {
+            vtoy_list_free(path_node, data->filelist);
+        }
+        else
+        {
+            vtoy_list_del(last, node, data->filelist, path);
+        }    
     }
 
     ret = ventoy_data_save_all();
@@ -982,7 +1016,14 @@ static int ventoy_api_theme_del_font(struct mg_connection *conn, VTOY_JSON *json
     path = VTOY_JSON_STR_EX("path");
     if (path)
     {
-        vtoy_list_del(last, node, data->fontslist, path);
+        if (strcmp(path, VTOY_DEL_ALL_PATH) == 0)
+        {
+            vtoy_list_free(path_node, data->fontslist);
+        }
+        else
+        {
+            vtoy_list_del(last, node, data->fontslist, path);            
+        }    
     }
 
     ret = ventoy_data_save_all();
@@ -1179,7 +1220,14 @@ static int ventoy_api_alias_del(struct mg_connection *conn, VTOY_JSON *json)
     path = VTOY_JSON_STR_EX("path");
     if (path)
     {
-        vtoy_list_del(last, node, data->list, path);
+        if (strcmp(path, VTOY_DEL_ALL_PATH) == 0)
+        {
+            vtoy_list_free(data_alias_node, data->list);          
+        }
+        else
+        {
+            vtoy_list_del(last, node, data->list, path);            
+        }
     }
 
     ret = ventoy_data_save_all();
@@ -1417,7 +1465,14 @@ static int ventoy_api_tip_del(struct mg_connection *conn, VTOY_JSON *json)
     path = VTOY_JSON_STR_EX("path");
     if (path)
     {
-        vtoy_list_del(last, node, data->list, path);
+        if (strcmp(path, VTOY_DEL_ALL_PATH) == 0)
+        {
+            vtoy_list_free(data_tip_node, data->list);          
+        }
+        else
+        {
+            vtoy_list_del(last, node, data->list, path);  
+        }
     }
 
     ret = ventoy_data_save_all();
@@ -1620,7 +1675,14 @@ static int ventoy_api_class_del(struct mg_connection *conn, VTOY_JSON *json)
     path = VTOY_JSON_STR_EX("path");
     if (path)
     {
-        vtoy_list_del(last, node, data->list, path);
+        if (strcmp(path, VTOY_DEL_ALL_PATH) == 0)
+        {
+            vtoy_list_free(data_class_node, data->list);
+        }
+        else
+        {
+            vtoy_list_del(last, node, data->list, path);            
+        }
     }
 
     ret = ventoy_data_save_all();
@@ -1749,7 +1811,14 @@ static int ventoy_api_auto_memdisk_del(struct mg_connection *conn, VTOY_JSON *js
     path = VTOY_JSON_STR_EX("path");
     if (path)
     {
-        vtoy_list_del(last, node, data->list, path);
+        if (strcmp(path, VTOY_DEL_ALL_PATH) == 0)
+        {
+            vtoy_list_free(path_node, data->list);
+        }
+        else
+        {
+            vtoy_list_del(last, node, data->list, path);            
+        }
     }
 
     ret = ventoy_data_save_all();
@@ -1924,7 +1993,14 @@ static int ventoy_api_image_list_del(struct mg_connection *conn, VTOY_JSON *json
     path = VTOY_JSON_STR_EX("path");
     if (path)
     {
-        vtoy_list_del(last, node, data->list, path);
+        if (strcmp(path, VTOY_DEL_ALL_PATH) == 0)
+        {
+            vtoy_list_free(path_node, data->list);
+        }
+        else
+        {
+            vtoy_list_del(last, node, data->list, path);            
+        }
     }
 
     ret = ventoy_data_save_all();
@@ -2175,7 +2251,14 @@ static int ventoy_api_password_del(struct mg_connection *conn, VTOY_JSON *json)
     path = VTOY_JSON_STR_EX("path");
     if (path)
     {
-        vtoy_list_del(last, node, data->list, path);
+        if (strcmp(path, VTOY_DEL_ALL_PATH) == 0)
+        {
+            vtoy_list_free(menu_password, data->list);
+        }
+        else
+        {
+            vtoy_list_del(last, node, data->list, path);            
+        }
     }
 
     ret = ventoy_data_save_all();
@@ -2366,7 +2449,14 @@ static int ventoy_api_conf_replace_del(struct mg_connection *conn, VTOY_JSON *js
     path = VTOY_JSON_STR_EX("path");
     if (path)
     {
-        vtoy_list_del(last, node, data->list, path);
+        if (strcmp(path, VTOY_DEL_ALL_PATH) == 0)
+        {
+            vtoy_list_free(conf_replace_node, data->list);
+        }
+        else
+        {
+            vtoy_list_del(last, node, data->list, path);            
+        }
     }
 
     ret = ventoy_data_save_all();
@@ -2555,6 +2645,7 @@ static int ventoy_api_dud_del(struct mg_connection *conn, VTOY_JSON *json)
     int ret;
     int index = 0;
     const char *path = NULL;
+    dud_node *next = NULL;
     dud_node *last = NULL;
     dud_node *node = NULL;
     data_dud *data = NULL;
@@ -2565,7 +2656,20 @@ static int ventoy_api_dud_del(struct mg_connection *conn, VTOY_JSON *json)
     path = VTOY_JSON_STR_EX("path");
     if (path)
     {
-        vtoy_list_del_ex(last, node, data->list, path, ventoy_free_path_node_list);
+        if (strcmp(path, VTOY_DEL_ALL_PATH) == 0)
+        {
+            for (node = data->list; node; node = next)
+            {
+                next = node->next;
+                ventoy_free_path_node_list(node->list);
+                free(node);
+            }
+            data->list = NULL;
+        }
+        else
+        {
+            vtoy_list_del_ex(last, node, data->list, path, ventoy_free_path_node_list);
+        }
     }
 
     ret = ventoy_data_save_all();
@@ -2902,6 +3006,7 @@ static int ventoy_api_auto_install_del(struct mg_connection *conn, VTOY_JSON *js
     int index = 0;
     const char *path = NULL;
     auto_install_node *last = NULL;
+    auto_install_node *next = NULL;
     auto_install_node *node = NULL;
     data_auto_install *data = NULL;
     
@@ -2911,7 +3016,20 @@ static int ventoy_api_auto_install_del(struct mg_connection *conn, VTOY_JSON *js
     path = VTOY_JSON_STR_EX("path");
     if (path)
     {
-        vtoy_list_del_ex(last, node, data->list, path, ventoy_free_path_node_list);
+        if (strcmp(path, VTOY_DEL_ALL_PATH) == 0)
+        {
+            for (node = data->list; node; node = next)
+            {
+                next = node->next;
+                ventoy_free_path_node_list(node->list);
+                free(node);
+            }
+            data->list = NULL;
+        }
+        else
+        {
+            vtoy_list_del_ex(last, node, data->list, path, ventoy_free_path_node_list);            
+        }
     }
 
     ret = ventoy_data_save_all();
@@ -3229,6 +3347,7 @@ static int ventoy_api_persistence_del(struct mg_connection *conn, VTOY_JSON *jso
     int index = 0;
     const char *path = NULL;
     persistence_node *last = NULL;
+    persistence_node *next = NULL;
     persistence_node *node = NULL;
     data_persistence *data = NULL;
     
@@ -3238,7 +3357,20 @@ static int ventoy_api_persistence_del(struct mg_connection *conn, VTOY_JSON *jso
     path = VTOY_JSON_STR_EX("path");
     if (path)
     {
-        vtoy_list_del_ex(last, node, data->list, path, ventoy_free_path_node_list);
+        if (strcmp(path, VTOY_DEL_ALL_PATH) == 0)
+        {
+            for (node = data->list; node; node = next)
+            {
+                next = node->next;
+                ventoy_free_path_node_list(node->list);
+                free(node);
+            }
+            data->list = NULL;
+        }
+        else
+        {
+            vtoy_list_del_ex(last, node, data->list, path, ventoy_free_path_node_list);            
+        }    
     }
 
     ret = ventoy_data_save_all();
@@ -3515,7 +3647,14 @@ static int ventoy_api_injection_del(struct mg_connection *conn, VTOY_JSON *json)
     path = VTOY_JSON_STR_EX("path");
     if (path)
     {
-        vtoy_list_del(last, node, data->list, path);
+        if (strcmp(path, VTOY_DEL_ALL_PATH) == 0)
+        {
+            vtoy_list_free(injection_node, data->list);
+        }
+        else
+        {
+            vtoy_list_del(last, node, data->list, path);            
+        }
     }
 
     ret = ventoy_data_save_all();
@@ -3524,6 +3663,34 @@ static int ventoy_api_injection_del(struct mg_connection *conn, VTOY_JSON *json)
     return 0;
 }
 
+#if 0
+#endif
+
+static int ventoy_api_preview_json(struct mg_connection *conn, VTOY_JSON *json)
+{
+    int pos = 0;
+    int len = 0;
+    int encodelen = 0;
+    char *encodebuf = NULL;
+    
+    (void)json;
+
+    len = ventoy_data_real_save_all(0);
+    encodebuf = ventoy_base64_encode(JSON_SAVE_BUFFER, len, &encodelen);
+    encodebuf[encodelen] = 0;
+
+    VTOY_JSON_FMT_BEGIN(pos, JSON_BUFFER, JSON_BUF_MAX);
+    VTOY_JSON_FMT_OBJ_BEGIN();
+    VTOY_JSON_FMT_STRN("json", encodebuf);
+    VTOY_JSON_FMT_OBJ_END();
+    VTOY_JSON_FMT_END(pos);
+
+    free(encodebuf);
+
+    ventoy_json_buffer(conn, JSON_BUFFER, pos);
+    return 0;
+}
+
 
 #if 0
 #endif
@@ -3534,14 +3701,17 @@ int ventoy_data_save_all(void)
     return 0;
 }
 
-int ventoy_data_real_save_all(void)
+int ventoy_data_real_save_all(int apilock)
 {
     int i = 0;
     int pos = 0;
     char title[64];
 
-    pthread_mutex_lock(&g_api_mutex);
-    
+    if (apilock)
+    {
+        pthread_mutex_lock(&g_api_mutex);        
+    }
+
     ssprintf(pos, JSON_SAVE_BUFFER, JSON_BUF_MAX, "{\n");
 
     ventoy_save_plug(control);
@@ -3565,7 +3735,10 @@ int ventoy_data_real_save_all(void)
     }
     ssprintf(pos, JSON_SAVE_BUFFER, JSON_BUF_MAX, "}\n");
 
-    pthread_mutex_unlock(&g_api_mutex);
+    if (apilock)
+    {
+        pthread_mutex_unlock(&g_api_mutex);        
+    }
 
     return pos;
 }
@@ -3578,7 +3751,7 @@ int ventoy_http_writeback(void)
 
     ventoy_get_json_path(filename, NULL);
 
-    pos = ventoy_data_real_save_all();
+    pos = ventoy_data_real_save_all(1);
         
     #ifdef VENTOY_SIM
     printf("%s", JSON_SAVE_BUFFER);
@@ -3675,11 +3848,11 @@ static JSON_CB g_ventoy_json_cb[] =
     { "save_injection",     ventoy_api_save_injection     },   
     { "injection_add",      ventoy_api_injection_add      },
     { "injection_del",      ventoy_api_injection_del      },
-
+    { "preview_json",       ventoy_api_preview_json       },
     
 };
 
-static int ventoy_json_handler(struct mg_connection *conn, VTOY_JSON *json)
+static int ventoy_json_handler(struct mg_connection *conn, VTOY_JSON *json, char *jsonstr)
 {
     int i;
     const char *method = NULL;
@@ -3696,7 +3869,7 @@ static int ventoy_json_handler(struct mg_connection *conn, VTOY_JSON *json)
         ventoy_api_handshake(conn, json);
         return 0;
     }
-    
+
     for (i = 0; i < (int)(sizeof(g_ventoy_json_cb) / sizeof(g_ventoy_json_cb[0])); i++)
     {
         if (strcmp(method, g_ventoy_json_cb[i].method) == 0)
@@ -3740,7 +3913,7 @@ static int ventoy_request_handler(struct mg_connection *conn)
         if (JSON_SUCCESS == vtoy_json_parse(json, post_data_buf))
         {
             pthread_mutex_lock(&g_api_mutex);
-            ventoy_json_handler(conn, json->pstChild);
+            ventoy_json_handler(conn, json->pstChild, post_data_buf);
             pthread_mutex_unlock(&g_api_mutex);
         }
         else
@@ -5026,7 +5199,8 @@ end:
 
 int ventoy_http_start(const char *ip, const char *port)
 {
-    int i;
+    int i = 0;
+    int ret = 0;
     char addr[128];
     char filename[128];
     char backupname[128];
@@ -5063,10 +5237,13 @@ int ventoy_http_start(const char *ip, const char *port)
     if (ventoy_is_file_exist("%s", filename))
     {
         ventoy_copy_file(filename, backupname);
-        ventoy_load_old_json(filename);
+        ret = ventoy_load_old_json(filename);
+        if (ret == 0)
+        {
+            ventoy_data_real_save_all(0);
+        }
     }
 
-
     /* option */
     scnprintf(addr, sizeof(addr), "%s:%s", ip, port);
     options[1] = addr;
index 18447c165a5ff69374c5f5dba6083f373284561e..4a75196d1eebfc64a9c43ddc065ba052744c1b8c 100644 (file)
@@ -41,6 +41,24 @@ typedef enum bios_mode
     bios_max
 }bios_mode;
 
+typedef enum plugin_type
+{
+    plugin_type_control = 0,
+    plugin_type_theme,
+    plugin_type_menu_alias,
+    plugin_type_menu_tip,
+    plugin_type_menu_class,
+    plugin_type_auto_install,
+    plugin_type_persistence,
+    plugin_type_injection,
+    plugin_type_conf_replace,
+    plugin_type_password,
+    plugin_type_image_list,
+    plugin_type_auto_memdisk,
+    plugin_type_dud,
+
+    plugin_type_max
+}plugin_type;
 
 typedef struct data_control
 {
@@ -260,8 +278,10 @@ typedef struct data_persistence
     for (i = 0; i < bios_max; i++) \
     {\
         scnprintf(title, sizeof(title), "%s%s", #plug, g_json_title_postfix[i]);\
+        g_json_exist[plugin_type_##plug][i] = 0;\
         if (ventoy_data_cmp_##plug(g_data_##plug + i, g_data_##plug + bios_max))\
         {\
+            g_json_exist[plugin_type_##plug][i] = 1;\
             pos += ventoy_data_save_##plug(g_data_##plug + i, title, JSON_SAVE_BUFFER + pos, JSON_BUF_MAX - pos);\
         }\
     }\
@@ -302,6 +322,7 @@ typedef struct data_persistence
         free(__node);\
         __node = __next;\
     }\
+    (list) = NULL;\
 }
 
 #define vtoy_list_del(last, node, LIST, field) \
@@ -401,6 +422,7 @@ void ventoy_http_exit(void);
 int ventoy_http_start(const char *ip, const char *port);
 int ventoy_http_stop(void);
 int ventoy_data_save_all(void);
+int ventoy_data_real_save_all(int apilock);
 
 #endif /* __VENTOY_HTTP_H__ */
 
index 1aa6483f3f7ecef92ba52022efd7102ddfa4ad8d..c01dec7df7397052c6087c054608dc75d4c0c7c7 100644 (file)
Binary files a/Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe and b/Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe differ
index fb13048de0d0a3db299cd3eb3b45987ee3d981e1..e2f77da3118c9d6dbedaa76d25dfd2abc6d11e7c 100644 (file)
@@ -1 +1 @@
-20220921 18:42:35
\ No newline at end of file
+20221021 14:42:35
\ No newline at end of file
index b0cdca85357f1822cfea732ea62c2f1b8bc160c8..74dccdec89a5e76aa11b1a9e0cddfeebf1b65f38 100644 (file)
                 \r
                 <div class="navbar-custom-menu">\r
                     <ul class="nav navbar-nav">\r
+                        <li class="dropdown user user-menu">\r
+                            <a href="javascript:void(0)" id="id_a_preview">\r
+                                <span class="fa fa-file-code-o"></span>&nbsp;&nbsp;\r
+                                <span id="id_span_preview" class="hidden-xs">Preview</span>\r
+                                <span class="hidden-xs">&nbsp;&nbsp;&nbsp;</span>\r
+                            </a>                        \r
+                        </li>\r
+                    \r
                         <li class="dropdown user user-menu">\r
                             <a href="javascript:void(0)" id="id_a_language">\r
                                 <span class="fa fa-language"></span>&nbsp;&nbsp;\r
                 </div>\r
             </div>\r
         </div>\r
+        \r
+        \r
+        <div class="modal" id="JsonPreviewModal">\r
+            <div class="modal-dialog" style="width: 80%;">\r
+                <div class="modal-content">\r
+                    <form id="JsonPeviewForm" class="form-horizontal">   \r
+                        <div class="modal-header">\r
+                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">\r
+                                <span aria-hidden="true">&times;</span>\r
+                            </button>\r
+                            <h4>\r
+                                <b id="JsonPreviewForm_lang_1">JSON</b>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r
+                                <button type="button" id="id_btn_json_copy" class="btn btn-primary"><span class="fa fa-copy">&nbsp;&nbsp;</span><span id="id_span_copy">Copy</span></button>\r
+                            </h4>\r
+                            \r
+                        </div>\r
+                        <div class="modal-body">\r
+                            <textarea id="pre_json_preview" class="form-control" rows="30" style="font-family:Menlo,Monaco,Consolas,'Courier New',monospace"></textarea>\r
+                        </div>\r
+                        <div class="modal-footer">\r
+                            <button id="PrewForm_lang_2" type="button" class="btn btn-primary btn-flat" data-dismiss="modal">确定</button>\r
+                        </div>\r
+                    </form>\r
+                </div>\r
+            </div>        \r
+        </div>\r
 \r
 \r
         <!-- Content Wrapper. Contains page content -->\r
 \r
         <footer class="main-footer">\r
             <div class="pull-right hidden-xs">\r
-                <b id="plugson_build_date">20220921 18:42:35</b>
+                <b id="plugson_build_date">20221021 14:42:35</b>
             </div>\r
             <strong><a href="https://www.ventoy.net" target="_blank">https://www.ventoy.net</a></strong>\r
         </footer>\r
     <script src="/static/js/jquery.validate.min.js"></script>    \r
     <script src="/static/js/jquery.validate.vtoymethods.js?v=100"></script>\r
 \r
-    <script src="/static/js/vtoy.js?v=100"></script>\r
     <script src="/static/js/jquery.vtoy.alert.js?v=100"></script>\r
+    <script src="/static/js/vtoy.js?v=100"></script>\r
     <script src="/static/js/md5.min.js"></script>\r
 \r
     <!-- Bootstrap 3.3.5 -->\r
     \r
     <script type="text/javascript">\r
 \r
+    function VtoyJsonCopyClick() {\r
+        var copyText = document.getElementById("pre_json_preview");\r
+        copyText.select();\r
+        copyText.setSelectionRange(0, 99999); // For mobile devices\r
+\r
+        try {\r
+            var successful = document.execCommand('copy');\r
+            copyText.setSelectionRange(0, 0);\r
+            if (successful) {\r
+                Message.success(g_vtoy_cur_language.STR_JSON_COPY_SUCCESS);\r
+            } else {\r
+                Message.error(g_vtoy_cur_language.STR_JSON_COPY_FAILED);\r
+            }\r
+        } catch (err) {\r
+            Message.error(g_vtoy_cur_language.STR_JSON_COPY_FAILED);\r
+        }\r
+    }\r
+\r
+    function VtoyPreviewClick() {\r
+        callVtoySync({\r
+            method : 'preview_json'\r
+        }, function(data) {\r
+            $('#JsonPeviewForm #JsonPreviewForm_lang_1').text(g_vtoy_cur_language.STR_JSON_PREVIEW);\r
+            $('#JsonPeviewForm #PrewForm_lang_2').text(g_vtoy_cur_language.STR_BTN_OK);\r
+            \r
+            $('#pre_json_preview').text(atob(data.json));\r
+            $("#JsonPreviewModal").modal();\r
+        });\r
+    }\r
+    \r
     function VtoyLanguageClick() {\r
         var defaultPage = window.location.hash;\r
         \r
 \r
     });\r
  \r
+    $('#id_btn_json_copy').click(VtoyJsonCopyClick);\r
+    $('#id_a_preview').click(VtoyPreviewClick);\r
     $('#id_a_language').click(VtoyLanguageClick);\r
     \r
     $("#plugson-menu a").click(function() {\r
                 });\r
             }\r
 \r
+            if (typeof(UpdateTabTitleIcon)==='function') {\r
+                UpdateTabTitleIcon(data);\r
+            }\r
+\r
             setTimeout(function() {\r
                 ventoy_handshake();\r
-            }, 1000);\r
+            }, 200);\r
         },\r
 \r
         function(xmlHttpRequest, textStatus, errorThrown) {\r
index 4b3066c090fc83f60f32a7e92d9eb0c4b8bb4016..4014e101b892cdd642aaafc2aa09618d8e396561 100644 (file)
@@ -1,10 +1,12 @@
 <div class="box box-primary" id="control">\r
     <div class="box-header">\r
-        <div class="col-sm-10" style="padding-top:8px;">\r
+        <div class="col-sm-9" style="padding-top:8px;">\r
             <i class="fa fa-desktop">&nbsp;&nbsp;</i>\r
             <h1 class="box-title" style="font-weight:bold;" id="id_h1_page_title">x</h1>\r
         </div>\r
-        \r
+        <div class="col-sm-1" style="padding-top:2px;">\r
+          <button id="id_btn_reset" class="btn btn-sm btn-danger btn-del"><i class="fa fa-trash"></i><span id="id_btn_span_reset">Reset</span></button>\r
+        </div>\r
         <div class="col-sm-2" style="font-size:16px;padding-top:8px;">\r
             <a id="id_a_official_doc" target="_blank" href="https://www.ventoy.net/en/plugin_autoinstall.html"><span class="fa fa-link"></span><span id="id_span_official_doc">官网文档</span></a>\r
         </div>\r
   $('#id_tab_autoins a[href="#tab_3"]').click(OnClickMultiModeTab);\r
   $('#id_tab_autoins a[href="#tab_4"]').click(OnClickMultiModeTab);\r
   $('#id_tab_autoins a[href="#tab_5"]').click(OnClickMultiModeTab);\r
-\r
+  function UpdateTabTitleIcon(data) {\r
+    CommonUpdateTabTitleIcon(data.exist_auto_install, '#id_tab_autoins a[href="#tab_', 'auto_install');\r
+  }\r
+  $('#id_btn_reset').click(function() { \r
+    Modal.confirm({msg:GetResetTabConfigTipMsg(current_tab_index, 'auto_install')}).on(function(e) {\r
+        if (e) {            \r
+            callVtoySync({\r
+                method : 'auto_install_del',\r
+                index: current_tab_index,\r
+                path: g_del_all_path\r
+            }, function(data) {\r
+                \r
+            });\r
+            \r
+            m_data_autoins[current_tab_index].length = 0;\r
+            VtoyFillCurrentPageItem(m_data_autoins[g_vtoy_data_default_index]);\r
+            Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);        \r
+        }\r
+    });\r
+  });\r
+  \r
   $('#id_tab_autoins a[href="#tab_0"]').tab('show');\r
   VtoyFillCurrentPageItem(m_data_autoins[0]);\r
   VtoyPageLanguageChange(g_current_language);\r
index 82b07356df001f3de08750a7d7c18c3d3198cf47..14ed690d0581677c3126cf379457550de468e9fc 100644 (file)
@@ -1,10 +1,12 @@
 <div class="box box-primary" id="control">\r
     <div class="box-header">\r
-        <div class="col-sm-10" style="padding-top:8px;">\r
+        <div class="col-sm-9" style="padding-top:8px;">\r
             <i class="fa fa-floppy-o">&nbsp;&nbsp;</i>\r
             <h1 class="box-title" style="font-weight:bold;" id="id_h1_page_title"></h1>\r
         </div>\r
-        \r
+        <div class="col-sm-1" style="padding-top:2px;">\r
+          <button id="id_btn_reset" class="btn btn-sm btn-danger btn-del"><i class="fa fa-trash"></i><span id="id_btn_span_reset">Reset</span></button>\r
+        </div>\r
         <div class="col-sm-2" style="font-size:16px;padding-top:8px;">\r
             <a id="id_a_official_doc" target="_blank" href="https://www.ventoy.net/en/plugin_automemdisk.html"><span class="fa fa-link"></span><span id="id_span_official_doc">官网文档</span></a>\r
         </div>\r
   $('#id_tab_auto_memdisk a[href="#tab_3"]').click(OnClickMultiModeTab);\r
   $('#id_tab_auto_memdisk a[href="#tab_4"]').click(OnClickMultiModeTab);\r
   $('#id_tab_auto_memdisk a[href="#tab_5"]').click(OnClickMultiModeTab);\r
-\r
+  function UpdateTabTitleIcon(data) {\r
+    CommonUpdateTabTitleIcon(data.exist_auto_memdisk, '#id_tab_auto_memdisk a[href="#tab_', 'auto_memdisk');\r
+  }\r
+  $('#id_btn_reset').click(function() { \r
+    Modal.confirm({msg:GetResetTabConfigTipMsg(current_tab_index, 'auto_memdisk')}).on(function(e) {\r
+        if (e) {            \r
+            callVtoySync({\r
+                method : 'auto_memdisk_del',\r
+                index: current_tab_index,\r
+                path: g_del_all_path\r
+            }, function(data) {\r
+                \r
+            });\r
+            \r
+            m_data_memdisk[current_tab_index].length = 0;\r
+            VtoyFillCurrentPageItem(m_data_memdisk[g_vtoy_data_default_index]);\r
+            Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);        \r
+        }\r
+    });\r
+  });\r
+  \r
   $('#id_tab_auto_memdisk a[href="#tab_0"]').tab('show');\r
   VtoyFillCurrentPageItem(m_data_memdisk[0]);\r
   VtoyPageLanguageChange(g_current_language);\r
index 0561849f8275302a825ea71188d12fcd9651dff6..2e97523bedd7df89c28a4e5202da8a3829039fca 100644 (file)
@@ -1,10 +1,12 @@
 <div class="box box-primary" id="control">\r
     <div class="box-header">\r
-        <div class="col-sm-10" style="padding-top:8px;">\r
+        <div class="col-sm-9" style="padding-top:8px;">\r
             <i class="fa fa-retweet">&nbsp;&nbsp;</i>\r
             <h1 class="box-title" style="font-weight:bold;" id="id_h1_page_title">菜单别名插件</h1>\r
         </div>\r
-        \r
+        <div class="col-sm-1" style="padding-top:2px;">\r
+          <button id="id_btn_reset" class="btn btn-sm btn-danger btn-del"><i class="fa fa-trash"></i><span id="id_btn_span_reset">Reset</span></button>\r
+        </div>\r
         <div class="col-sm-2" style="font-size:16px;padding-top:8px;">\r
             <a id="id_a_official_doc" target="_blank" href="https://www.ventoy.net/en/plugin_bootconf_replace.html"><span class="fa fa-link"></span><span id="id_span_official_doc">官网文档</span></a>\r
         </div>\r
   $('#id_tab_conf_replace a[href="#tab_3"]').click(OnClickMultiModeTab);\r
   $('#id_tab_conf_replace a[href="#tab_4"]').click(OnClickMultiModeTab);\r
   $('#id_tab_conf_replace a[href="#tab_5"]').click(OnClickMultiModeTab);\r
-\r
+  function UpdateTabTitleIcon(data) {\r
+    CommonUpdateTabTitleIcon(data.exist_conf_replace, '#id_tab_conf_replace a[href="#tab_', 'conf_replace');\r
+  }\r
+  $('#id_btn_reset').click(function() { \r
+    Modal.confirm({msg:GetResetTabConfigTipMsg(current_tab_index, 'conf_replace')}).on(function(e) {\r
+        if (e) {            \r
+            callVtoySync({\r
+                method : 'conf_replace_del',\r
+                index: current_tab_index,\r
+                path: g_del_all_path\r
+            }, function(data) {\r
+                \r
+            });\r
+            \r
+            m_data_conf_replace[current_tab_index].length = 0;\r
+            VtoyFillCurrentPageItem(m_data_conf_replace[g_vtoy_data_default_index]);\r
+            Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);        \r
+        }\r
+    });\r
+  });\r
+  \r
   $('#id_tab_conf_replace a[href="#tab_0"]').tab('show');\r
   VtoyFillCurrentPageItem(m_data_conf_replace[0]);\r
   VtoyPageLanguageChange(g_current_language);\r
index 2452ac7cfb0de7e02cbc3c380c5fb89f80d18fc4..512872fd61dd67292abb4ed0b83ea731cba8afb2 100644 (file)
@@ -1,6 +1,6 @@
 <div class="box box-primary" id="control">\r
     <div class="box-header">\r
-        <div class="col-sm-8" style="padding-top:8px;">\r
+        <div class="col-sm-7" style="padding-top:8px;">\r
             <i class="fa fa-wrench">&nbsp;&nbsp;</i>\r
             <h1 class="box-title" style="font-weight:bold;" id="id_h1_page_title">全局控制插件</h1>\r
         </div>\r
           <button id="id_btn_expand" class="btn btn-sm btn-primary"><i style="font-size: 14px;" class="fa fa-plus"></i></button>\r
         </div>\r
 \r
+        <div class="col-sm-1" style="padding-top:2px;">\r
+          <button id="id_btn_reset" class="btn btn-sm btn-danger btn-del"><i class="fa fa-trash"></i><span id="id_btn_span_reset">Reset</span></button>\r
+        </div>\r
+\r
         <div class="col-sm-2" style="font-size:16px;padding-top:8px;">\r
             <a id="id_a_official_doc" target="_blank" href="https://www.ventoy.net/cn/plugin_control.html"><span class="fa fa-link"></span><span id="id_span_official_doc">官网文档</span></a>\r
         </div>\r
    \r
 </div>\r
 <script type="text/javascript">\r
+  \r
   function VtoyPageLanguageChange(newlang) {\r
     VtoyCommonChangeLanguage(newlang);\r
 \r
   $('#id_tab_control a[href="#tab_3"]').click(OnClickMultiModeTab);\r
   $('#id_tab_control a[href="#tab_4"]').click(OnClickMultiModeTab);\r
   $('#id_tab_control a[href="#tab_5"]').click(OnClickMultiModeTab);\r
+  \r
+  function UpdateTabTitleIcon(data) {\r
+    CommonUpdateTabTitleIcon(data.exist_control, '#id_tab_control a[href="#tab_', 'control');\r
+  }\r
+  $('#id_btn_reset').click(function() { \r
+    Modal.confirm({msg:GetResetTabConfigTipMsg(current_tab_index, 'control')}).on(function(e) {\r
+        if (e) {            \r
+            VtoyFillCurrentPageItem(m_data_control[g_vtoy_data_default_index]);\r
+            VtoySaveCurrentPage();\r
+        }\r
+    });\r
+  });\r
 \r
   $('#id_tab_control a[href="#tab_0"]').tab('show');\r
   VtoyFillCurrentPageItem(m_data_control[0]);\r
index 943343df4c88c5904b4b051a55878b7362653575..426400e716efe730323152096d7268c348aa4921 100644 (file)
@@ -1,10 +1,12 @@
 <div class="box box-primary" id="control">\r
     <div class="box-header">\r
-        <div class="col-sm-10" style="padding-top:8px;">\r
+        <div class="col-sm-9" style="padding-top:8px;">\r
             <i class="glyphicon glyphicon-cd">&nbsp;&nbsp;</i>\r
             <h1 class="box-title" style="font-weight:bold;" id="id_h1_page_title">x</h1>\r
         </div>\r
-        \r
+        <div class="col-sm-1" style="padding-top:2px;">\r
+          <button id="id_btn_reset" class="btn btn-sm btn-danger btn-del"><i class="fa fa-trash"></i><span id="id_btn_span_reset">Reset</span></button>\r
+        </div>\r
         <div class="col-sm-2" style="font-size:16px;padding-top:8px;">\r
             <a id="id_a_official_doc" target="_blank" href="https://www.ventoy.net/en/plugin_dud.html"><span class="fa fa-link"></span><span id="id_span_official_doc">官网文档</span></a>\r
         </div>\r
   $('#id_tab_dud a[href="#tab_3"]').click(OnClickMultiModeTab);\r
   $('#id_tab_dud a[href="#tab_4"]').click(OnClickMultiModeTab);\r
   $('#id_tab_dud a[href="#tab_5"]').click(OnClickMultiModeTab);\r
-\r
+  function UpdateTabTitleIcon(data) {\r
+    CommonUpdateTabTitleIcon(data.exist_dud, '#id_tab_dud a[href="#tab_', 'dud');\r
+  }\r
+  $('#id_btn_reset').click(function() { \r
+    Modal.confirm({msg:GetResetTabConfigTipMsg(current_tab_index, 'dud')}).on(function(e) {\r
+        if (e) {            \r
+            callVtoySync({\r
+                method : 'dud_del',\r
+                index: current_tab_index,\r
+                path: g_del_all_path\r
+            }, function(data) {\r
+                \r
+            });\r
+            \r
+            m_data_dud[current_tab_index].length = 0;\r
+            VtoyFillCurrentPageItem(m_data_dud[g_vtoy_data_default_index]);\r
+            Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);        \r
+        }\r
+    });\r
+  });\r
+  \r
   $('#id_tab_dud a[href="#tab_0"]').tab('show');\r
   VtoyFillCurrentPageItem(m_data_dud[0]);\r
   VtoyPageLanguageChange(g_current_language);\r
index ff538ba182b51a56013c87095e7c6939dd9be099..fbbcf07f5641a5ce9f6a90658312e79078a221cb 100644 (file)
@@ -1,10 +1,12 @@
 <div class="box box-primary" id="control">\r
     <div class="box-header">\r
-        <div class="col-sm-10" style="padding-top:8px;">\r
+        <div class="col-sm-9" style="padding-top:8px;">\r
             <i class="fa fa-list-alt">&nbsp;&nbsp;</i>\r
             <h1 class="box-title" style="font-weight:bold;" id="id_h1_page_title"></h1>\r
         </div>\r
-        \r
+        <div class="col-sm-1" style="padding-top:2px;">\r
+          <button id="id_btn_reset" class="btn btn-sm btn-danger btn-del"><i class="fa fa-trash"></i><span id="id_btn_span_reset">Reset</span></button>\r
+        </div>\r
         <div class="col-sm-2" style="font-size:16px;padding-top:8px;">\r
             <a id="id_a_official_doc" target="_blank" href="https://www.ventoy.net/en/plugin_imagelist.html"><span class="fa fa-link"></span><span id="id_span_official_doc">官网文档</span></a>\r
         </div>\r
   $('#id_tab_image_list a[href="#tab_3"]').click(OnClickMultiModeTab);\r
   $('#id_tab_image_list a[href="#tab_4"]').click(OnClickMultiModeTab);\r
   $('#id_tab_image_list a[href="#tab_5"]').click(OnClickMultiModeTab);\r
-\r
+  function UpdateTabTitleIcon(data) {\r
+    CommonUpdateTabTitleIcon(data.exist_image_list, '#id_tab_image_list a[href="#tab_', 'image_list');\r
+  }\r
+  $('#id_btn_reset').click(function() { \r
+    Modal.confirm({msg:GetResetTabConfigTipMsg(current_tab_index, 'image_list')}).on(function(e) {\r
+        if (e) {            \r
+            callVtoySync({\r
+                method : 'image_list_del',\r
+                index: current_tab_index,\r
+                path: g_del_all_path\r
+            }, function(data) {\r
+                \r
+            });\r
+            \r
+            m_data_imagelist[current_tab_index].list.length = 0;\r
+            VtoyFillCurrentPageItem(m_data_imagelist[g_vtoy_data_default_index]);\r
+            VtoySaveCurrentPage();\r
+        }\r
+    });\r
+  });\r
+  \r
   $('#id_tab_image_list a[href="#tab_0"]').tab('show');\r
   VtoyFillCurrentPageItem(m_data_imagelist[0]);\r
   VtoyPageLanguageChange(g_current_language);\r
index ce67093fdce67ea364966e43bac58db66fa84a5d..bd8e6d56400430dc426e9d92742b365cdbfb539e 100644 (file)
@@ -1,10 +1,12 @@
 <div class="box box-primary" id="control">\r
     <div class="box-header">\r
-        <div class="col-sm-10" style="padding-top:8px;">\r
+        <div class="col-sm-9" style="padding-top:8px;">\r
             <i class="fa fa-plus-circle">&nbsp;&nbsp;</i>\r
             <h1 class="box-title" style="font-weight:bold;" id="id_h1_page_title">x</h1>\r
         </div>\r
-        \r
+        <div class="col-sm-1" style="padding-top:2px;">\r
+          <button id="id_btn_reset" class="btn btn-sm btn-danger btn-del"><i class="fa fa-trash"></i><span id="id_btn_span_reset">Reset</span></button>\r
+        </div>\r
         <div class="col-sm-2" style="font-size:16px;padding-top:8px;">\r
             <a id="id_a_official_doc" target="_blank" href="https://www.ventoy.net/en/plugin_injection.html"><span class="fa fa-link"></span><span id="id_span_official_doc">官网文档</span></a>\r
         </div>\r
   $('#id_tab_injection a[href="#tab_3"]').click(OnClickMultiModeTab);\r
   $('#id_tab_injection a[href="#tab_4"]').click(OnClickMultiModeTab);\r
   $('#id_tab_injection a[href="#tab_5"]').click(OnClickMultiModeTab);\r
-\r
+  function UpdateTabTitleIcon(data) {\r
+    CommonUpdateTabTitleIcon(data.exist_injection, '#id_tab_injection a[href="#tab_', 'injection');\r
+  }\r
+  $('#id_btn_reset').click(function() { \r
+    Modal.confirm({msg:GetResetTabConfigTipMsg(current_tab_index, 'injection')}).on(function(e) {\r
+        if (e) {            \r
+            callVtoySync({\r
+                method : 'injection_del',\r
+                index: current_tab_index,\r
+                path: g_del_all_path\r
+            }, function(data) {\r
+                \r
+            });\r
+            \r
+            m_data_injection[current_tab_index].length = 0;            \r
+            VtoyFillCurrentPageItem(m_data_injection[g_vtoy_data_default_index]);\r
+            Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);    \r
+        }\r
+    });\r
+  });\r
+  \r
   $('#id_tab_injection a[href="#tab_0"]').tab('show');\r
   VtoyFillCurrentPageItem(m_data_injection[0]);\r
   VtoyPageLanguageChange(g_current_language);\r
index 5c75e155f2143791fea6eac0e598c189b0001a85..ed7d27bb24360957cb0477b326c3f1b2320b7163 100644 (file)
@@ -1,10 +1,12 @@
 <div class="box box-primary" id="control">\r
     <div class="box-header">\r
-        <div class="col-sm-10" style="padding-top:8px;">\r
+        <div class="col-sm-9" style="padding-top:8px;">\r
             <i class="fa fa-clone">&nbsp;&nbsp;</i>\r
             <h1 class="box-title" style="font-weight:bold;" id="id_h1_page_title">菜单别名插件</h1>\r
         </div>\r
-        \r
+        <div class="col-sm-1" style="padding-top:2px;">\r
+          <button id="id_btn_reset" class="btn btn-sm btn-danger btn-del"><i class="fa fa-trash"></i><span id="id_btn_span_reset">Reset</span></button>\r
+        </div>\r
         <div class="col-sm-2" style="font-size:16px;padding-top:8px;">\r
             <a id="id_a_official_doc" target="_blank" href="https://www.ventoy.net/en/plugin_menualias.html"><span class="fa fa-link"></span><span id="id_span_official_doc">官网文档</span></a>\r
         </div>\r
   $('#id_tab_menu_alias a[href="#tab_4"]').click(OnClickMultiModeTab);\r
   $('#id_tab_menu_alias a[href="#tab_5"]').click(OnClickMultiModeTab);\r
 \r
+  function UpdateTabTitleIcon(data) {\r
+    CommonUpdateTabTitleIcon(data.exist_menu_alias, '#id_tab_menu_alias a[href="#tab_', 'menu_alias');\r
+  }\r
+  $('#id_btn_reset').click(function() { \r
+    Modal.confirm({msg:GetResetTabConfigTipMsg(current_tab_index, 'menu_alias')}).on(function(e) {\r
+        if (e) {            \r
+            callVtoySync({\r
+                method : 'alias_del',\r
+                index: current_tab_index,\r
+                path: g_del_all_path\r
+            }, function(data) {\r
+                \r
+            });\r
+            \r
+            m_data_alias[current_tab_index].length = 0;\r
+            VtoyFillCurrentPageItem(m_data_alias[g_vtoy_data_default_index]);\r
+            Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);\r
+        }\r
+    });\r
+  });\r
+\r
   $('#id_tab_menu_alias a[href="#tab_0"]').tab('show');\r
   VtoyFillCurrentPageItem(m_data_alias[0]);\r
   VtoyPageLanguageChange(g_current_language);\r
index c451662c098d3c1bdcfd8d5eaccb4eb4f01af3af..f230935690df0107a7488e75c94e20fa1ec37239 100644 (file)
@@ -1,10 +1,12 @@
 <div class="box box-primary" id="control">\r
     <div class="box-header">\r
-        <div class="col-sm-10" style="padding-top:8px;">\r
+        <div class="col-sm-9" style="padding-top:8px;">\r
             <i class="fa fa-list-ul">&nbsp;&nbsp;</i>\r
             <h1 class="box-title" style="font-weight:bold;" id="id_h1_page_title">xx</h1>\r
         </div>\r
-        \r
+        <div class="col-sm-1" style="padding-top:2px;">\r
+          <button id="id_btn_reset" class="btn btn-sm btn-danger btn-del"><i class="fa fa-trash"></i><span id="id_btn_span_reset">Reset</span></button>\r
+        </div>\r
         <div class="col-sm-2" style="font-size:16px;padding-top:8px;">\r
             <a id="id_a_official_doc" target="_blank" href="https://www.ventoy.net/en/plugin_menuclass.html"><span class="fa fa-link"></span><span id="id_span_official_doc">官网文档</span></a>\r
         </div>\r
   $('#id_tab_menu_class a[href="#tab_3"]').click(OnClickMultiModeTab);\r
   $('#id_tab_menu_class a[href="#tab_4"]').click(OnClickMultiModeTab);\r
   $('#id_tab_menu_class a[href="#tab_5"]').click(OnClickMultiModeTab);\r
+  function UpdateTabTitleIcon(data) {\r
+    CommonUpdateTabTitleIcon(data.exist_menu_class, '#id_tab_menu_class a[href="#tab_', 'menu_class');\r
+  }\r
+  $('#id_btn_reset').click(function() { \r
+    Modal.confirm({msg:GetResetTabConfigTipMsg(current_tab_index, 'menu_class')}).on(function(e) {\r
+        if (e) {            \r
+            callVtoySync({\r
+                method : 'class_del',\r
+                index: current_tab_index,\r
+                path: g_del_all_path\r
+            }, function(data) {\r
+                \r
+            });\r
+            \r
+            m_data_class[current_tab_index].length = 0;\r
+            VtoyFillCurrentPageItem(m_data_class[g_vtoy_data_default_index]);\r
+            Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);        \r
+        }\r
+    });\r
+  });\r
 \r
   $('#id_tab_menu_class a[href="#tab_0"]').tab('show');\r
   VtoyFillCurrentPageItem(m_data_class[0]);\r
index f91b7c6c57f5c98caeda765a983ba57a4cb0108d..214a43eb147f624a2ff07c7865f4b2cb059ff710 100644 (file)
@@ -1,10 +1,12 @@
 <div class="box box-primary" id="control">\r
     <div class="box-header">\r
-        <div class="col-sm-10" style="padding-top:8px;">\r
+        <div class="col-sm-9" style="padding-top:8px;">\r
             <i class="fa fa-commenting">&nbsp;&nbsp;</i>\r
             <h1 class="box-title" style="font-weight:bold;" id="id_h1_page_title"></h1>\r
         </div>\r
-        \r
+        <div class="col-sm-1" style="padding-top:2px;">\r
+          <button id="id_btn_reset" class="btn btn-sm btn-danger btn-del"><i class="fa fa-trash"></i><span id="id_btn_span_reset">Reset</span></button>\r
+        </div>\r
         <div class="col-sm-2" style="font-size:16px;padding-top:8px;">\r
             <a id="id_a_official_doc" target="_blank" href="https://www.ventoy.net/en/plugin_menutip.html"><span class="fa fa-link"></span><span id="id_span_official_doc">官网文档</span></a>\r
         </div>\r
   $('#id_tab_menu_tip a[href="#tab_4"]').click(OnClickMultiModeTab);\r
   $('#id_tab_menu_tip a[href="#tab_5"]').click(OnClickMultiModeTab);\r
 \r
+  function UpdateTabTitleIcon(data) {\r
+    CommonUpdateTabTitleIcon(data.exist_menu_tip, '#id_tab_menu_tip a[href="#tab_', 'menu_tip');\r
+  }\r
+  $('#id_btn_reset').click(function() { \r
+    Modal.confirm({msg:GetResetTabConfigTipMsg(current_tab_index, 'menu_tip')}).on(function(e) {\r
+        if (e) {            \r
+            callVtoySync({\r
+                method : 'tip_del',\r
+                index: current_tab_index,\r
+                path: g_del_all_path\r
+            }, function(data) {\r
+                \r
+            });\r
+            \r
+            m_data_tip[current_tab_index].left = m_data_tip[g_vtoy_data_default_index].left;\r
+            m_data_tip[current_tab_index].top = m_data_tip[g_vtoy_data_default_index].top;\r
+            m_data_tip[current_tab_index].color = m_data_tip[g_vtoy_data_default_index].color;\r
+            m_data_tip[current_tab_index].tips.length = 0;            \r
+            VtoyFillCurrentPageItem(m_data_tip[g_vtoy_data_default_index]);\r
+            VtoySaveCurrentPage();\r
+        }\r
+    });\r
+  });\r
+  \r
   $('#id_tab_menu_tip a[href="#tab_0"]').tab('show');\r
   VtoyFillCurrentPageItem(m_data_tip[0]);\r
   VtoyPageLanguageChange(g_current_language);\r
index 0f25bddbdbeea083fe01ebbb020503ee96629483..97cdc68db0c58c0a4edfeac2785e54bda094d27d 100644 (file)
@@ -1,10 +1,12 @@
 <div class="box box-primary" id="control">\r
     <div class="box-header">\r
-        <div class="col-sm-10" style="padding-top:8px;">\r
+        <div class="col-sm-9" style="padding-top:8px;">\r
             <i class="glyphicon glyphicon-lock">&nbsp;</i>\r
             <h1 class="box-title" style="font-weight:bold;" id="id_h1_page_title"></h1>\r
         </div>\r
-        \r
+        <div class="col-sm-1" style="padding-top:2px;">\r
+          <button id="id_btn_reset" class="btn btn-sm btn-danger btn-del"><i class="fa fa-trash"></i><span id="id_btn_span_reset">Reset</span></button>\r
+        </div>\r
         <div class="col-sm-2" style="font-size:16px;padding-top:8px;">\r
             <a id="id_a_official_doc" target="_blank" href="https://www.ventoy.net/en/plugin_password.html"><span class="fa fa-link"></span><span id="id_span_official_doc">官网文档</span></a>\r
         </div>\r
     }\r
     \r
     current_tab_index = index;\r
-    VtoyFillCurrentPageItem(m_data_pwd[index].tips);\r
+    VtoyFillCurrentPageItem(m_data_pwd[index]);\r
   }\r
 \r
   function VtoyGetCurrentPageItem(data) {\r
@@ -557,6 +559,27 @@ function VtoySetPassword(common, type, cb, data) {
   $('#id_tab_password a[href="#tab_4"]').click(OnClickMultiModeTab);\r
   $('#id_tab_password a[href="#tab_5"]').click(OnClickMultiModeTab);\r
 \r
+  function UpdateTabTitleIcon(data) {\r
+    CommonUpdateTabTitleIcon(data.exist_password, '#id_tab_password a[href="#tab_', 'password');\r
+  }\r
+  $('#id_btn_reset').click(function() { \r
+    Modal.confirm({msg:GetResetTabConfigTipMsg(current_tab_index, 'password')}).on(function(e) {\r
+        if (e) {            \r
+            callVtoySync({\r
+                method : 'password_del',\r
+                index: current_tab_index,\r
+                path: g_del_all_path\r
+            }, function(data) {\r
+                \r
+            });\r
+            \r
+            m_data_pwd[current_tab_index].list.length = 0;\r
+            VtoyFillCurrentPageItem(m_data_pwd[g_vtoy_data_default_index]);\r
+            VtoySaveCurrentPage();\r
+        }\r
+    });\r
+  });\r
+\r
   $('#id_tab_password a[href="#tab_0"]').tab('show');\r
   VtoyFillCurrentPageItem(m_data_pwd[0]);\r
   VtoyPageLanguageChange(g_current_language);\r
index 6b8caf627c2629d4a5f5d78bbdea9432bdfc7c46..d5a4c076240d8ff9a2cd48ef520c00a6afcd223d 100644 (file)
@@ -1,10 +1,12 @@
 <div class="box box-primary" id="control">\r
     <div class="box-header">\r
-        <div class="col-sm-10" style="padding-top:8px;">\r
+        <div class="col-sm-9" style="padding-top:8px;">\r
             <i class="fa fa-database">&nbsp;&nbsp;</i>\r
             <h1 class="box-title" style="font-weight:bold;" id="id_h1_page_title">x</h1>\r
         </div>\r
-        \r
+        <div class="col-sm-1" style="padding-top:2px;">\r
+          <button id="id_btn_reset" class="btn btn-sm btn-danger btn-del"><i class="fa fa-trash"></i><span id="id_btn_span_reset">Reset</span></button>\r
+        </div>\r
         <div class="col-sm-2" style="font-size:16px;padding-top:8px;">\r
             <a id="id_a_official_doc" target="_blank" href="https://www.ventoy.net/en/plugin_persistence.html"><span class="fa fa-link"></span><span id="id_span_official_doc">官网文档</span></a>\r
         </div>\r
   $('#id_tab_persistence a[href="#tab_3"]').click(OnClickMultiModeTab);\r
   $('#id_tab_persistence a[href="#tab_4"]').click(OnClickMultiModeTab);\r
   $('#id_tab_persistence a[href="#tab_5"]').click(OnClickMultiModeTab);\r
-\r
+  function UpdateTabTitleIcon(data) {\r
+    CommonUpdateTabTitleIcon(data.exist_persistence, '#id_tab_persistence a[href="#tab_', 'persistence');\r
+  }\r
+  $('#id_btn_reset').click(function() { \r
+    Modal.confirm({msg:GetResetTabConfigTipMsg(current_tab_index, 'persistence')}).on(function(e) {\r
+        if (e) {            \r
+            callVtoySync({\r
+                method : 'persistence_del',\r
+                index: current_tab_index,\r
+                path: g_del_all_path\r
+            }, function(data) {\r
+                \r
+            });\r
+            \r
+            m_data_persistence[current_tab_index].length = 0;\r
+            VtoyFillCurrentPageItem(m_data_persistence[g_vtoy_data_default_index]);\r
+            Message.success(g_vtoy_cur_language.STR_SAVE_SUCCESS);\r
+        }\r
+    });\r
+  });\r
+  \r
   $('#id_tab_persistence a[href="#tab_0"]').tab('show');\r
   VtoyFillCurrentPageItem(m_data_persistence[0]);\r
   VtoyPageLanguageChange(g_current_language);\r
index b30d19a06fcc30567ffdaff71fdb654f9e90364d..e6f96a0226915ced5bbbc44acda03b09eb7e596a 100644 (file)
@@ -1,10 +1,12 @@
 <div class="box box-primary" id="control">\r
     <div class="box-header">\r
-        <div class="col-sm-10" style="padding-top:8px;">\r
+        <div class="col-sm-9" style="padding-top:8px;">\r
             <i class="fa fa-file-image-o">&nbsp;&nbsp;</i>\r
             <h1 class="box-title" style="font-weight:bold;" id="id_h1_page_title">主题插件</h1>\r
         </div>\r
-        \r
+        <div class="col-sm-1" style="padding-top:2px;">\r
+          <button id="id_btn_reset" class="btn btn-sm btn-danger btn-del"><i class="fa fa-trash"></i><span id="id_btn_span_reset">Reset</span></button>\r
+        </div>\r
         <div class="col-sm-2" style="font-size:16px;padding-top:8px;">\r
             <a id="id_a_official_doc" target="_blank" href="https://www.ventoy.net/cn/plugin_theme.html"><span class="fa fa-link"></span><span id="id_span_official_doc">官网文档</span></a>\r
         </div>\r
   $('#id_tab_theme a[href="#tab_4"]').click(OnClickMultiModeTab);\r
   $('#id_tab_theme a[href="#tab_5"]').click(OnClickMultiModeTab);\r
 \r
+  function UpdateTabTitleIcon(data) {\r
+    CommonUpdateTabTitleIcon(data.exist_theme, '#id_tab_theme a[href="#tab_', 'theme');\r
+  }\r
+  $('#id_btn_reset').click(function() { \r
+    Modal.confirm({msg:GetResetTabConfigTipMsg(current_tab_index, 'theme')}).on(function(e) {\r
+        if (e) {            \r
+            callVtoySync({\r
+                method : 'theme_del_file',\r
+                index: current_tab_index,\r
+                path: g_del_all_path\r
+            }, function(data) {\r
+                \r
+            });\r
+            \r
+            callVtoySync({\r
+                method : 'theme_del_font',\r
+                index: current_tab_index,\r
+                path: g_del_all_path\r
+            }, function(data) {\r
+                \r
+            });\r
+            \r
+            m_data_theme[current_tab_index].filelist.length = 0;\r
+            m_data_theme[current_tab_index].fontslist.length = 0;\r
+            VtoyFillCurrentPageItem(m_data_theme[g_vtoy_data_default_index]);\r
+            VtoySaveCurrentPage();\r
+        }\r
+    });\r
+  });\r
+  \r
   $('#id_tab_theme a[href="#tab_0"]').tab('show');\r
   VtoyFillCurrentPageItem(m_data_theme[0]);\r
   VtoyPageLanguageChange(g_current_language);\r
index 68719254a0c6d1ca4f08d15952b2927abd857fd1..e3f59acc0672c26270ab99f402e2963dd7425fe0 100644 (file)
@@ -288,71 +288,6 @@ String.prototype.endsWith = function(str) {
         return false;\r
 }\r
 \r
-window.Message = function() {\r
-    var _showMsg = function(type, msg, time) {\r
-        var o = {type : type, msg : msg };\r
-        if(time) {\r
-            o.time = time;\r
-        }\r
-        _show(o);\r
-    }\r
-    \r
-    var _show = function(options) {\r
-        var ops = {\r
-            msg : "提示内容",\r
-            type: 'S',\r
-            time: 3000\r
-        };\r
-        $.extend(ops, options);\r
-\r
-        var msg_class = 'alert-success';\r
-        if('S' === ops.type || 's' === ops.type) {\r
-            msg_class = 'alert-success';\r
-        } else if ('E' === ops.type || 'e' === ops.type) {\r
-            msg_class = 'alert-danger';\r
-        } else if ('W' === ops.type || 'w' === ops.type) {\r
-            msg_class = 'alert-warning';\r
-        } else if ('I' === ops.type || 'i' === ops.type) {\r
-            msg_class = 'alert-info';\r
-        } else {\r
-            alert("未知的类型,请使用: w-警告;s-成功;e-失败;i-提示");\r
-            return;\r
-        }\r
-        var $messageContainer = $("#fcss_message");\r
-        if($messageContainer.length === 0) {\r
-            $messageContainer = $('<div id="fcss_message" style="position:fixed; left: 20%; right: 20%; top:0px; z-index:99999999"></div>');\r
-            $messageContainer.appendTo($('body'));\r
-        }\r
-        var $div = $('<div class="alert ' + msg_class + ' alert-dismissible fade in" role="alert" style="margin-bottom: 0; padding-top:10px; padding-bottom: 10px;"></div>');\r
-        var $btn = $('<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>');\r
-        $div.append($btn).append(ops.msg).appendTo($messageContainer);\r
-        setTimeout(function() {\r
-            $div.remove();\r
-        }, ops.time);\r
-    }\r
-    \r
-    var _success = function(msg, time) {\r
-        _showMsg('s', msg, time);\r
-    }\r
-    var _error = function(msg, time) {        \r
-        _showMsg('e', msg, time || 5000);\r
-    }\r
-    var _warn = function(msg, time) {\r
-        _showMsg('w', msg, time);\r
-    }\r
-    var _info = function(msg, time) {\r
-        _showMsg('i', msg, time);\r
-    }\r
-    \r
-    return {\r
-        success : _success,\r
-        error  : _error,\r
-        warn   : _warn,\r
-        info    : _info,\r
-        show   : _show\r
-    }\r
-}();\r
-\r
 \r
 var g_vtoy_cur_language_en = \r
 {\r
@@ -376,6 +311,7 @@ var g_vtoy_cur_language_en =
     "STR_OPT_SETTING": "Option Setting",\r
     "STR_OPT_DESC": "Option Description",\r
     "STR_EDIT": "Edit",\r
+    "STR_RESET": "Reset",\r
     "STR_FILE": "File",\r
     "STR_DIR": "Dir",\r
     "STR_SAVE_TIP": "Data in current page has been modified. Do you want to save it?",\r
@@ -489,6 +425,10 @@ var g_vtoy_cur_language_en =
     "STR_INVALID_CONFIG_TIP": "Invalid configuration detected in ventoy.json, so the configuration is not loaded!",\r
     "STR_CONFIG_SAVE_ERROR_TIP": "Failed to write ventoy.json file. Check VentoyPlugson.log for more details!",\r
 \r
+    "STR_JSON_PREVIEW": "JSON Preview",\r
+    "STR_JSON_COPY_SUCCESS": "JSON Copy Success",\r
+    "STR_JSON_COPY_FAILED": "JSON Copy Failed",\r
+\r
     "STR_XXX": "xxx"\r
 };\r
 \r
@@ -514,6 +454,7 @@ var g_vtoy_cur_language_cn =
     "STR_OPT_SETTING": "选项设置",\r
     "STR_OPT_DESC": "选项说明",\r
     "STR_EDIT": "设置",\r
+    "STR_RESET": "重置",\r
     "STR_FILE": "文件",\r
     "STR_DIR": "目录",\r
     "STR_SAVE_TIP": "当前页面数据已经修改,是否保存?",\r
@@ -625,6 +566,9 @@ var g_vtoy_cur_language_cn =
     "STR_INVALID_CONFIG_TIP": "ventoy.json 文件中存在错误配置,配置未加载!",\r
     "STR_CONFIG_SAVE_ERROR_TIP": "ventoy.json 文件写入失败,详细信息请参考 VentoyPlugson.log 文件!",\r
 \r
+    "STR_JSON_PREVIEW": "JSON 预览",\r
+    "STR_JSON_COPY_SUCCESS": "JSON 内容复制成功",\r
+    "STR_JSON_COPY_FAILED": "JSON 内容复制失败",\r
 \r
     "STR_XXX": "xxx"\r
 };\r
@@ -635,12 +579,45 @@ var g_current_language = 'cn';
 var g_vtoy_cur_language = g_vtoy_cur_language_cn;\r
 var g_vtoy_data_default_index = 6;\r
 \r
+var g_bios_postfix = [ "", "_legacy", "_uefi", "_ia32", "_aa64", "_mips" ];\r
+var g_del_all_path = '4119ae33-98ea-448e-b9c0-569aafcf1fb4';\r
 var g_file_with_extra = false;\r
 var g_dir_with_extra = false;\r
 var g_file_fuzzy_match = 0;\r
 var g_file_modal_callback;\r
 var g_dir_modal_callback;\r
 \r
+function GetResetTabConfigTipMsg(index, name) {\r
+    var msgstr;\r
+    \r
+    if (g_current_language === 'en') {\r
+        msgstr = 'Are you sure to reset all the configurations on the <code>' + name + g_bios_postfix[index] + '</code> tab ?';\r
+    } else {\r
+        msgstr = '确认要重置 <code>' + name + g_bios_postfix[index] + '</code> 标签页下的所有配置?';\r
+    }\r
+    \r
+    return msgstr;\r
+}\r
+\r
+function CommonUpdateTabTitleIcon(exists, id, name) {\r
+    var exspan = " <span id='tab_0_icon' class='fa fa-circle' style='color:red;'></span>";\r
+    for (var i = 0; i < g_vtoy_data_default_index; i++) {\r
+        var fid = id + i + '"]';\r
+        var oldhtml = $(fid).html();\r
+        var newhtml;\r
+\r
+        if (exists[i]) {\r
+            newhtml = name + g_bios_postfix[i] + exspan;\r
+        } else {\r
+            newhtml = name + g_bios_postfix[i];\r
+        }\r
+        \r
+        if (newhtml != oldhtml) {\r
+            $(fid).html(newhtml);\r
+        }\r
+    }\r
+}\r
+\r
 function ventoy_file_submit(form, extra) {\r
     var filepath = $("#FilePath").val();\r
     var fileextra = $("#FileExtra").val();\r
@@ -920,6 +897,8 @@ function VtoyCommonChangeLanguage(newlang) {
             $(this).text(" Plugin Official Document");\r
         });\r
         \r
+        $('#id_span_copy').text("Copy");\r
+        $('#id_span_preview').text("Preview");\r
         $('#id_span_language').text("中文");\r
         \r
         $("tr[id=tr_title_desc_cn]").each(function(){\r
@@ -966,6 +945,8 @@ function VtoyCommonChangeLanguage(newlang) {
             $(this).text(" 插件官网文档");\r
         });\r
         \r
+        $('#id_span_copy').text("复制");\r
+        $('#id_span_preview').text("预览");\r
         $('#id_span_language').text("English");\r
         \r
         $("tr[id=tr_title_desc_cn]").each(function(){\r
@@ -1002,7 +983,10 @@ function VtoyCommonChangeLanguage(newlang) {
     $('#id_span_save').text(g_vtoy_cur_language.STR_SAVE);\r
     $('#id_span_reset').text(g_vtoy_cur_language.STR_RESET);\r
     $('#id_span_donation').text(g_vtoy_cur_language.STR_PLUG_DONATION);\r
-\r
+    \r
+    $('span[id=id_btn_span_reset]').each(function(){\r
+        $(this).text(' ' + g_vtoy_cur_language.STR_RESET);\r
+    });\r
     $("span[id=id_span_btn_add]").each(function(){\r
         $(this).text(g_vtoy_cur_language.STR_ADD);\r
     });\r