kgena_ua,
seriousstas, с новым годом и с наступающим Рождеством Христовым!
Буду отвечать без цитат. Эту тему пора уже закрывать)))
kgena_ua, это мы ещё обсуждали с самых первых версий БИО. Вспомните ,я тогда писал про включение
Grab Focus и т.д. и т.п.(это обсуждение есть в теме, не буду искать сейчас). И никто не спорит что текст увеличивался при зажатой кнопке Shift, но не совсем правильно как по мне, о чём написал в предыдущих сообщениях. Что такое "Клацать шифтом" ? Тут всё просто: Вы пробовали сразу за один присест увеличить шрифт от 16 до 96(мой вариант)? Уверен что нет! Так у вас этот зазор (по умолчанию) 16 - 12 = 4. И при такой регулировке подобные артефакты конечно не заметны! Поэтому высказал свою идею о разделении функций, а сам уже давно эту проблему решил. Об этом ниже.
seriousstas, ну опять))) Я же тебя не заставляю что-то там исправлять! Сам это заметил когда специально твой мод включил(нужны были подсказки) Раньше тоже не замечал (когда тестировал), так как кнопками всё делал как и ты (так удобнее)!
Вынудили меня в четыре утра скриншоты делать и сообщения писать))) Сейчас устаю сильно, помогаю дочке с проектом в
Unity, приходится вспоминать то что уже не только забыл, но и не знал совсем. Вчера в
Skype конференции больше восьми часов - это для меня очень тяжело.
Выкладываю вашу
Biography Text && Picture. www.last.fm by kgena_ua от
"14112016" в моей редакции для всех(DUI & CUI & всё остальное)
- Код: Выделить всё
Что добавил:
1. Авто компенсация жирного шрифта при увеличении.
2. Авто отключение теней на тексте в зависимости от фона. По умолчанию цвет тени равен цвету фона.
3. Для WSH Panel Mod v1.5.6 отключение из меню свойства пункта контекстного меню "Reload"
4. Увеличение шрифта с шагом 1: минимальный 11, максимальный 48. Если настроить то можно получить замену шрифта "BIO" на "Artist" при увеличении.
5. Всякие мелочи (уже не помню) для удобства.
Установка: 1. В настройках WSH Panel Mod:
Menu\File\Preferences\Tools\WSH Panel Mod --> Safe Mode Снять галочку!
2. В окне
Configure...:
Grab Focus включён(стоит галочка)
Управление: Левая кнопка мыши - зажата на тексте: Перетаскивание текста по экрану.
Левая кнопка мыши - двойной щелчок на тексте: Смена языка вывода текста RU / EN
Левая кнопка мыши - двойной щелчок на картинке: Смена изображений Артист/ Альбом
Зажатая клавиша Ctrl + колесо мыши на картинке: Установка/Отключение интервала показа картинок в секундах
Зажатая клавиша Shift + колесо мыши на тексте: Изменение размера отображаемого текста
Колесо мыши на картинке, если нет изображения, меняет логотип last.fm (появятся после первой перезагрузки плеера)
Правая кнопка мыши выбор из контекстного меню:
Заголовок "Артист" Включение / Отключение: "Artist header"
Смена языка вывода текста RU / EN: "en text" ; "ru text"
Показ картинок проигрываемый трек / выбранный трек: "Prefer now playing" ; "Follow selected track"
Отображение обложек Артист / Альбом: "Artist pictures" ; "Albums pictures"
Переход на страницу артиста LAST.FM: "last.fm Artist"
Включение эффекта затухания при смене картинок: "Fade effect"
Пропорции картинок: Align : "adjust", "adjust top - center", "adjust top - left", "centre", "centre - top", "stretch"
Количество загружаемых картинок: Download limit: 0 - без картинок; 1, 2, 3, 4, 5, 10, 15, 20 - лимит загрузки;
Качество загружаемых картинок: Download quality: Low - 170x170; Medium - 300x300; High - 500x500; Original - 770x0;
Копировать в папку с файлом: "Copy to folder containing track..."
Открытие программы показа картинок по умолчанию: "Open image"
Сохранять текст и картинки: "Save images and text"
Перезагрузить скрипт: "Reload"
Меню
Properties: download limit: настройка лимита загружаемых изображений. По умолчанию 5
scrollbar: false/ true Включение/ Отключение полосы прокрутки
scrollbar width: Ширина полосы прокрутки. По умолчанию 6
- Код: Выделить всё
// ==PREPROCESSOR==
// @name "Biography Text && Picture. www.last.fm"
// @author "kgena_ua ""modified AHAPXICT for all"""
// @version "14112016"
// @feature "v1.4"
// @feature "watch-metadb"
// ==/PREPROCESSOR==
function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }
function RGBA(r,g,b,a) { return ((a << 24) | (r << 16) | (g << 8) | (b)); }
function getRed(color) {return ((color >> 16) & 0xff);};
function getGreen(color) {return ((color >> 8) & 0xff);};
function getBlue(color) {return (color & 0xff);};
DT_LEFT = 0x00000000;
DT_RIGHT = 0x00000002;
DT_CENTER = 0x00000001;
DT_VCENTER = 0x00000004;
DT_SINGLELINE = 0x00000020;
DT_WORD_ELLIPSIS = 0x00040000;
DT_WORDBREAK = 0x00000010;
DT_CALCRECT = 0x00000400;
DT_NOPREFIX = 0x00000800;
MF_ENABLED = 0x00000000;
MF_GRAYED = 0x00000001;
MF_SEPARATOR = 0x00000800;
var ww = 200, wh = 200;
var a_header = window.GetProperty(" artist header: on/off", true);
var menu_reload = window.GetProperty("reload (context menu): on/off", true);
var font_name_a = window.GetProperty(" font name: artist", "Arial");
var font_name_b = window.GetProperty(" font name: biography", "Arial");
var font_size_a_d = window.GetProperty(" font size: artist (delta)", 0);
var font_size_b = window.GetProperty(" font size: biography", 12);
var a_font_style = window.GetProperty(" font style: artist", 1);
var b_font_style = window.GetProperty(" font style: biography", 0);
var min_font_size = 11;
var max_font_size = 48;
var a_font, b_font;
get_font();
function get_font(){
var font_name_c = font_name_b;
font_name_c = font_size_b > 48 ? font_name_a : font_name_b; // Auto Change: Font Name VS Font Size
var c_font_style = b_font_style;
if (b_font_style == 1){c_font_style = font_size_b > 17 ? 0 : 1;} // Auto Change: Font Style VS Font Size
if (a_header){
a_font = gdi.Font(font_name_a, font_size_b + font_size_a_d, a_font_style);
} else{
a_font = gdi.Font(font_name_a, font_size_b - font_size_b / 2 - 1, a_font_style);
}
b_font = gdi.Font(font_name_c, font_size_b, c_font_style);
}
ColorTypeCUI = {
text: 0,
selection_text: 1,
inactive_selection_text: 2,
background: 3,
selection_background: 4,
inactive_selection_background: 5,
active_item_frame: 6
};
ColorTypeDUI = {
text: 0,
background: 1,
highlight: 2,
selection: 3
};
function get_color(){
if (window.InstanceType == 0){
bgcolor = window.GetColorCUI(ColorTypeCUI.background);
a_color = window.GetColorCUI(ColorTypeCUI.inactive_selection_text);
b_color = window.GetColorCUI(ColorTypeCUI.text);
} else if (window.InstanceType == 1) {
bgcolor = window.GetColorDUI(ColorTypeDUI.background);
a_color = window.GetColorDUI(ColorTypeDUI.highlight);
b_color = window.GetColorDUI(ColorTypeDUI.text);
}
window.Repaint();
};
get_color();
function on_colors_changed(){
get_color();
}
var fso = new ActiveXObject("Scripting.FileSystemObject");
var tmp_b_path = fb.ProfilePath + "\\tmp_Biography\\";
if (!fso.FolderExists(tmp_b_path)) {fso.CreateFolder(tmp_b_path)};
var script_path = tmp_b_path + "_download\\";
if (!fso.FolderExists(script_path)) {fso.CreateFolder(script_path)};
if (!fso.FileExists(script_path + "download.vbs")) {create_download_file()};
var doc = new ActiveXObject("htmlfile");
var WshShell = new ActiveXObject("WScript.Shell");
var vbs = "cscript //nologo \"" + script_path + "download.vbs\"";
var default_img_path = window.GetProperty(" default img path",".\\tmp_Biography\\_download\\last_fm_logo.png");
var default_img = window.GetProperty(" default img", false);
var default_img_transparent = window.GetProperty(" default img transparent (0-255)", 255);
var default_logo = window.GetProperty(" default last.fm logo (0-5) 6-off", 1);
load_last_fm_logo();
var l_arr = [];
l_arr[0] = gdi.Image(script_path + "Lastfm_logo.png");
l_arr[1] = gdi.Image(script_path + "Lastfm_logo.png");
l_arr[2] = gdi.Image(script_path + "last_fm_logo.png");
l_arr[3] = gdi.Image(script_path + "last_fm_logo.png");
l_arr[4] = gdi.Image(script_path + "logo_static.png");
l_arr[5] = gdi.Image(script_path + "footer_logo.png");
var logo_img = l_arr[default_logo];
var artist, old_artist;
var path, directory_path;
function clean_name(n) {
if (!n) return;
return n.replace(/[\/\\|:]/g, "-").replace(/\*/g, "x").replace(/"/g, "''").replace(/[<>]/g, "_").replace(/\?/g, "").replace(/^\./, "_").replace(/\.+$/, "").substr(0,50);
}
function artist_folder_path(n) {
return tmp_b_path + n;
}
function check_folder(n) {
if (!n) return;
try {
if(!fso.FolderExists(n)) {fso.CreateFolder(n)};
} catch(e) {}
}
String.prototype.repeat = function(n) {
return new Array(n + 1).join(this);
}
window.SetProperty(" ------------ User Settings ------------ ", "");
if (window.GetProperty(" ------------ User Settings ------------ ") != "" ) window.SetProperty(" ------------ User Settings ------------ ", "");
window.SetProperty("-".repeat(50), "");
if (window.GetProperty("-".repeat(50)) != "" ) window.SetProperty("-".repeat(50), "");
var g_img = null;
var p_margin = window.GetProperty(" margin: picture", 0);
var align_mode_a = new Array("adjust", "adjust top - center", "adjust top - left", "centre", "centre - top", "stretch");
var align_mode = window.GetProperty("align mode", 1);
var selected = 0;
var files = [];
var images = [];
var save_images = window.GetProperty("save images", false);
var limit = window.GetProperty(" download limit",5);
var cycle = window.GetProperty("auto cycle (sec)", 0);
if (cycle > 0) set_cycle_timer();
var fader = 255;
var fade_effect = window.GetProperty("fade effect", false);
var fade_step = window.GetProperty("fade step", 25);
var on_pic = false;
var download_quality = window.GetProperty("download quality", 1);
var quality = [
[ "low", "avatar170s" , "avatar300s"],
[ "medium", "300x300" , "300x300"],
[ "high", "500x500" , "600x600"],
[ "original", "770x0" , ""]
];
var scrollbar = window.GetProperty(" scrollbar", true);
var scrollbar_w = window.GetProperty(" scrollbar width ", 6);
var scrollbar_k;
var sb_x = 0;
var sb_posy = 0;
var on_sb = false;
var on_sb_down = false;
var sb_color;
var b_file;
var bg_transparent = window.GetProperty(" bg transparent (0-255)", 220);
var t_margin = window.GetProperty(" margin: text", 5);
var txt_x = window.GetProperty("txt_x", 0); //window.Width / 2
var old_txt_x = 0;
var txt_y = window.GetProperty("txt_y", window.Width); //window.Height / 2
var delta_x, delta_y;
var a_x, a_y, b_x, b_y;
var text = "";
var text_not_found = new Array(". . .", ". . .");
var s_text = 0;
var a_text_row_height = 0;
var b_text_row_height = 0;
var b_text_rows = 0;
var b_text_visable_rows = 0;
var b_text_visable_height = 0;
var b_text_array = [];
var on_artist = false;
var on_text = false;
var on_text_down = false;
var refresh_txt = true;
var lang_query = new Array("", "ru/");
var lang_text = new Array("en", "ru");
var lang = window.GetProperty("lang", 1);
var select_p_a = window.GetProperty("pictures/albums", 0);
var p_a = new Array("images", "albums");
var panel_on = true;
var selection_mode = window.GetProperty("selection mode", 0);
var metadb;
on_item_focus_change();
function on_paint(gr){
!window.IsTransparent && gr.FillSolidRect(0, 0, ww, wh, bgcolor);
draw_image(gr);
if(set_cycle){
gr.FillSolidRect(0, 0, ww, wh, RGBA(getRed(bgcolor),getGreen(bgcolor),getBlue(bgcolor),bg_transparent));
var txt_cycle = cycle == 0 ? "off" : cycle + " sec";
set_cycle && gr.GdiDrawText("AUTO CYCLE: " + txt_cycle, b_font, a_color, 0, 20, ww, wh, DT_CENTER | DT_WORD_ELLIPSIS );
} else{
gr.FillSolidRect(txt_x, txt_y, ww - txt_x, wh - txt_y, RGBA(getRed(bgcolor),getGreen(bgcolor),getBlue(bgcolor),bg_transparent));
}
draw_scrollbar(gr);
if(a_header){
gr.GdiDrawText( tf_artist, a_font, bgcolor, a_x + 1, a_y + 2, ww - a_x - t_margin, wh, DT_LEFT | DT_WORD_ELLIPSIS | DT_NOPREFIX );
gr.GdiDrawText( tf_artist, a_font, a_color, a_x, a_y, ww - a_x - t_margin, wh, DT_LEFT | DT_WORD_ELLIPSIS | DT_NOPREFIX );
} else{
gr.GdiDrawText( "||||", a_font, bgcolor, a_x + 1, a_y + 2, ww - a_x - t_margin, wh, DT_CENTER );
gr.GdiDrawText( "||||", a_font, b_color, a_x, a_y, ww - a_x - t_margin, wh, DT_CENTER );
}
for (var i = 0; i < b_text_visable_rows * 2; i += 2) {
try {
if (b_color > bgcolor) {
gr.GdiDrawText( b_text_array[i + s_text * 2].replace(/^\s+|\s+$/g, ""), b_font, bgcolor, b_x + 1, b_y + b_text_row_height * i / 2 - 11, ww, wh, DT_LEFT | DT_NOPREFIX );
}
gr.GdiDrawText( b_text_array[i + s_text * 2].replace(/^\s+|\s+$/g, ""), b_font, b_color, b_x, b_y + b_text_row_height * i / 2 - 12 , ww, wh, DT_LEFT | DT_NOPREFIX );
} catch(e) {}
}
}
function draw_image(gr){
if (g_img && images.length > 0){
var size = calc_img_size(g_img);
gr.DrawRect(size.x, size.y, size.width, size.height, 1, RGBA(getRed(bgcolor),getGreen(bgcolor),getBlue(bgcolor),fader));
gr.DrawImage(g_img, size.x, size.y, size.width, size.height, size.cx, size.cy, size.cwidth, size.cheight, 0, fader);
}
if (logo_img && images.length == 0 && !default_img){
var w, h, x, y;
var logo_angle = 0;
var l_margin = ww / 8;
if (default_logo == 0){logo_angle = 320};
if (ww <= wh && logo_angle > 0 || default_logo == 2){l_margin = 0
}else if (default_logo == 3){l_margin = ww / 2};
if (logo_img.Width || logo_img.Height) {
var logo_scale = Math.min((ww - p_margin * 2 - l_margin) / logo_img.Width, (wh - p_margin * 2) / logo_img.Height);
w = logo_img.Width * logo_scale;
h = logo_img.Height * logo_scale;
x = (ww - w) / 2;
if(ww < wh){
if(default_logo < 2){
y = h + p_margin;
} else if(default_logo == 2){
y = 0 + p_margin;
} else if(default_logo == 3){
y = wh / 3 * logo_scale + p_margin;
}
} else {
if(default_logo == 0 || default_logo == 3){
w = logo_img.Width * logo_scale / (ww/wh);
h = logo_img.Height * logo_scale / (ww/wh);
}
x = (ww - w) / 2;
y = (wh - h) / 3.5;
}
}
if (default_logo < 2){
gr.DrawImage(logo_img, x, y, w, h, 0, 0, logo_img.Width, logo_img.Height, logo_angle, 85); // 709px-Lastfm_logo.svg.png
} else if (default_logo < 4){
gr.DrawImage(logo_img, x, y, w, h, 0, 0, logo_img.Width, logo_img.Height, 0, 150); // Last_fm_logo.png 512x512
} else if (default_logo == 4){
gr.DrawImage(logo_img, p_margin + 1, p_margin + 1, logo_img.Width * 0.9, logo_img.Height * 0.9, 0, 0, logo_img.Width, logo_img.Height, 0, 255); // logo_static.png
} else if (default_logo == 5){
gr.DrawImage(logo_img, p_margin + 10, p_margin + 12, logo_img.Width, logo_img.Height, 0, 0, logo_img.Width, logo_img.Height, 0, 120); // footer_logo.png
}
}
if (images.length == 0 && default_img){
try {
nc_img = gdi.Image(default_img_path);
var size = calc_img_size(nc_img);
gr.DrawImage(nc_img, size.x, size.y, size.width, size.height, size.cx, size.cy, size.cwidth, size.cheight, 0, default_img_transparent);
} catch(e) {};
}
}
function draw_scrollbar(gr){
scrollbar_h = b_text_rows > b_text_visable_rows ? b_text_visable_height * (b_text_visable_rows / b_text_rows) + b_text_row_height : 0;
if (b_text_rows > b_text_visable_rows){ scrollbar_h = Math.max(20, scrollbar_h)}
scrollbar_y = s_text > 0 ? s_text * scrollbar_k : 0;
b_scrollbar_h = b_text_rows > b_text_visable_rows ? 1 : 0;
// sb_x = ww - t_margin - scrollbar_w;
sb_x = ww - scrollbar_w;
sb_t = on_sb || on_sb_down ? 150 : 50;
sb_color = RGBA(getRed(a_color), getGreen(a_color), getBlue(a_color), sb_t);
bg_color = RGBA(getRed(b_color), getGreen(b_color), getBlue(b_color), sb_t/2);
scrollbar && gr.FillSolidRect(sb_x, b_y, scrollbar_w, (wh - b_y - 1) * b_scrollbar_h, bg_color);
scrollbar && gr.FillSolidRect(sb_x, b_y + scrollbar_y, scrollbar_w, scrollbar_h, sb_color);
/*
sb_t = on_sb || on_sb_down ? 220 : 120;
scrollbar && gr.FillSolidRect(sb_x, b_y, scrollbar_w, (wh - b_y - 1)*b_scrollbar_h, RGBA(63, 100, 127, sb_t/4));
scrollbar && gr.FillSolidRect(sb_x, b_y + scrollbar_y, scrollbar_w, scrollbar_h, RGBA(63, 100, 127, sb_t));
*/
}
function on_playlist_switch() {
on_item_focus_change();
}
function on_playback_new_track() {
on_item_focus_change();
}
function on_playback_dynamic_info_track() {
on_item_focus_change();
}
function on_playback_stop() {
on_item_focus_change();
}
function on_selection_changed(metadb) {
on_item_focus_change();
}
function on_item_focus_change() {
switch (selection_mode) {
case 0:
metadb = fb.IsPlaying ? fb.GetNowPlaying() : fb.GetFocusItem();
break;
case 1:
metadb = fb.GetFocusItem();
break;
}
if (metadb) on_metadb_changed();
}
function Eval(field) {
if (!metadb) return;
path = fb.Titleformat("%path%").EvalWithMetadb(metadb);
directory_path = fb.Titleformat("$directory_path(%path%)").EvalWithMetadb(metadb);
return path.indexOf('://') > 0 ? fb.TitleFormat("[" + field + "]").Eval(true) : fb.TitleFormat("[" + field + "]").EvalWithMetadb(metadb);
}
function on_metadb_changed() {
if (!panel_on) return;
if (!metadb) return;
artist = Eval("%artist%");
if (artist) {artist = clean_name(artist); tf_artist = Eval("%artist%")} else {artist = ""; tf_artist = ""};
if (artist != old_artist){
if (!save_images) del_folders(artist);
get_pic();
old_artist = artist;
}
}
function get_pic() {
images = [];
files = [];
selected = 0;
g_img = null;
window.Repaint();
check_folder(artist_folder_path(artist));
if (fso.FolderExists(artist_folder_path(artist))){
get_files_from_dir(artist_folder_path(artist));
if (!g_img && images.length > 0) {
next_image(0);
get_text();
} else {
get_lastFM_pic(artist_folder_path(artist));
}
}
}
function get_lastFM_pic(p){
xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP");
url1 = ("http://www.last.fm/music/" + encodeURIComponent(artist) + "/+" + p_a[select_p_a]);
xmlhttp1.open("GET", url1, true );
xmlhttp1.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
xmlhttp1.send(null);
xmlhttp1.onreadystatechange = function () {
if (xmlhttp1.readyState == 4) {
if (xmlhttp1.status == 200) {
doc.open();
var div = doc.createElement("div");
div.innerHTML = xmlhttp1.responsetext;
var data = div.getElementsByTagName("img");
var urls = [];
for (i = 0; i < data.length; i++) {
if (data[i].className == "image-list-image" && select_p_a == 0){
if (data[i].src.indexOf("http://img2-ak.lst.fm/i/u/avatar170s") == 0 || data[i].src.indexOf("https://lastfm-img2.akamaized.net/i/u/avatar170s") == 0) {
urls.push(data[i].src.replace("avatar170s", quality[download_quality][1]));
}
}
if (data[i].className == "album-grid-album-art" && select_p_a == 1){
if ((data[i].src.indexOf("http://img2-ak.lst.fm/i/u/300") == 0 || data[i].src.indexOf("https://lastfm-img2.akamaized.net/i/u/300") == 0) && data[i].src.indexOf("c6f59c1e5e7240a4c0d427abd71f3dbb") < 0) {
urls.push(data[i].src.replace("300x300", quality[download_quality][2]))
}
}
}
var found = urls.length;
for (i = 0; i < Math.min(urls.length, limit); i++) {
var file = "\"" + p + "\\" + artist + "_" + i + "_" + p_a[select_p_a] + ".jpg" + "\"";
WshShell.Run(vbs + " " + urls[i] + " " + file, 0, false);
}
doc.close();
if (found > 0) get_files_if_loaded(p);
}
}
get_text();
}
}
function get_files_from_dir(p) {
if (!artist) return;
files = utils.Glob(p + "\\" + artist + "*" + p_a[select_p_a] + ".jpg").toArray();
if (files.length > images.length){
images = [];
for (var i = 0; i < files.length; i += 1) {
try {
images.push(resize_image(gdi.Image(files[i])));
} catch(e) {}
}
}
}
function next_image(d){
fader = fade_effect ? 0 : 255;
if (d < 0) {selected = selected <= 0 ? images.length - 1 : selected = selected - 1};
if (d > 0) {selected = selected >= images.length - 1 ? 0 : selected = selected + 1};
g_img = images[selected];
if (g_img && fade_effect) fader_timer();
window.Repaint();
}
function resize_image(img){
if (!img) return;
var scale_w = (window.Width - p_margin * 2) / img.Width;
var scale_h = (window.Height - p_margin * 2) / img.Height;
var scale = Math.min(scale_w, scale_h);
var nww = img.Width * scale;
var nwh = img.Height * scale
var temp_bmp = gdi.CreateImage(nww, nwh);
var temp_gr = temp_bmp.GetGraphics();
temp_gr.SetSmoothingMode(2);
temp_gr.SetInterpolationMode(7);
temp_gr.DrawImage(img, 0, 0, nww, nwh, 0, 0, img.width, img.height);
temp_bmp.ReleaseGraphics(temp_gr);
CollectGarbage();
return temp_bmp;
temp_bmp.Dispose();
temp_gr = null;
temp_bmp = null;
}
function clear_text_var() {
s_text = 0;
text = "";
b_text_array = [];
}
function get_text() {
clear_text_var();
b_text_file = artist_folder_path(artist) + "\\" + artist + "_biography_" + lang_text[lang] + ".txt";
refresh_txt = true;
if (artist && fso.FileExists(b_text_file)){
text = utils.ReadTextFile(b_text_file);
get_b_text_array();
} else{
get_lastFM_b_text(b_text_file);
}
}
function get_lastFM_b_text(p){
xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP");
url2 = ("http://www.last.fm/" + lang_query[lang] + "music/" + encodeURIComponent(artist) + "/+wiki");
xmlhttp2.open("GET", url2, true);
xmlhttp2.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
xmlhttp2.send(null);
xmlhttp2.onreadystatechange = function () {
if (xmlhttp2.readyState == 4) {
if (xmlhttp2.status == 200) {
doc.open();
var div = doc.createElement("div");
div.innerHTML = xmlhttp2.responsetext;
var data = div.getElementsByTagName("div");
for (i = 0; i < data.length; i++) {
if (data[i].className == "wiki-content") {
text = strip_tags(data[i].innerHTML).replace(/^\s+|\s+$/g,"");
break;
}
}
doc.close();
}
if (text != "") save_biography_file(text, p);
if (text == "") text = text_not_found[lang];
get_b_text_array();
}
}
}
function strip_tags(t) {
doc.open();
var div = doc.createElement("div");
div.innerHTML = t.replace(/<[Pp][^>]*>/g, "").replace(/<\/[Pp]>/g, "<br>").replace(/\n/g, "<br>");
var text = div.innerText;
doc.close();
return text;
}
function get_b_text_array() {
a_x = txt_x + t_margin;
a_y = txt_y + t_margin;
temp_bmp = gdi.CreateImage(1, 1);
temp_gr = temp_bmp.GetGraphics();
a_text_row_height = temp_gr.CalcTextHeight("text", a_font);
b_text_row_height = temp_gr.CalcTextHeight("text", b_font);
b_x = txt_x + t_margin;
b_y = a_y + a_text_row_height + b_text_row_height;
string_width = scrollbar ? Math.max(ww - b_x - t_margin - scrollbar_w - 2, 0) : Math.max(ww - b_x - t_margin, 0);
if (Math.abs(txt_x - old_txt_x) > 5 || refresh_txt){
b_text_array = [];
if (text) b_text_array = temp_gr.EstimateLineWrap(text.replace(/^\s+|\s+$/g,""), b_font, string_width).toArray();
old_txt_x = txt_x;
refresh_txt = false;
}
b_text_rows = b_text_array.length / 2;
b_text_visable_area = Math.floor(Math.max(0, window.Height - t_margin - b_y));
b_text_visable_rows = Math.floor(b_text_visable_area / b_text_row_height);
b_text_visable_height = b_text_visable_rows * b_text_row_height;
if (b_text_visable_rows + s_text > b_text_rows && s_text > 0) {
s_text = (b_text_rows - b_text_visable_rows);
}
scrollbar_k = b_text_visable_height / b_text_rows;
temp_bmp.ReleaseGraphics(temp_gr);
temp_bmp.Dispose();
temp_gr = null;
temp_bmp = null;
window.Repaint();
}
function save_biography_file(t, p){
if (!artist) return;
try {
file = fso.OpenTextFile( p, 2, true, -1)
file.WriteLine(t);
file.Close();
} catch(e) {
return;
}
}
function on_mouse_rbtn_up (x, y){
var _menu = window.CreatePopupMenu();
_menu.AppendMenuItem(MF_ENABLED, 1, "Artist header");
_menu.CheckMenuItem(1, a_header);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 10, lang_text[0] + " text");
_menu.AppendMenuItem(MF_ENABLED, 11, lang_text[1] + " text");
_menu.CheckMenuRadioItem(10, 11, lang + 10);
_menu.EnableMenuItem(lang + 10, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 12, "Prefer now playing");
_menu.AppendMenuItem(MF_ENABLED, 13, "Follow selected track");
_menu.CheckMenuRadioItem(12, 13 , selection_mode + 12);
_menu.EnableMenuItem(selection_mode + 12, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 14, "Artist pictures");
_menu.AppendMenuItem(MF_ENABLED, 15, "Albums pictures");
_menu.CheckMenuRadioItem(14, 15 , select_p_a + 14);
_menu.EnableMenuItem(select_p_a + 14, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
IS_ARTIST = artist ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(IS_ARTIST, 16, "last.fm Artist");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 17, "Fade effect");
_menu.CheckMenuItem(17, fade_effect);
_firstgroup = window.CreatePopupMenu();
_firstgroup.AppendTo(_menu,MF_ENABLED, "Align : " + align_mode_a[align_mode]);
_firstgroup.AppendMenuItem(MF_ENABLED, 20, align_mode_a[0]);
_firstgroup.AppendMenuItem(MF_ENABLED, 21, align_mode_a[1]);
_firstgroup.AppendMenuItem(MF_ENABLED, 22, align_mode_a[2]);
_firstgroup.AppendMenuItem(MF_ENABLED, 23, align_mode_a[3]);
_firstgroup.AppendMenuItem(MF_ENABLED, 24, align_mode_a[4]);
_firstgroup.AppendMenuItem(MF_ENABLED, 25, align_mode_a[5]);
_firstgroup.CheckMenuRadioItem(20, 25, align_mode + 20);
_firstgroup.EnableMenuItem(align_mode + 20, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_secondgroup = window.CreatePopupMenu();
_secondgroup.AppendTo(_menu,MF_ENABLED, "Download limit : " + limit);
_secondgroup.AppendMenuItem(MF_ENABLED, 30, "0");
_secondgroup.AppendMenuItem(MF_ENABLED, 31, "1");
_secondgroup.AppendMenuItem(MF_ENABLED, 32, "2");
_secondgroup.AppendMenuItem(MF_ENABLED, 33, "3");
_secondgroup.AppendMenuItem(MF_ENABLED, 34, "4");
_secondgroup.AppendMenuItem(MF_ENABLED, 35, "5");
_secondgroup.AppendMenuItem(MF_ENABLED, 40, "10");
_secondgroup.AppendMenuItem(MF_ENABLED, 45, "15");
_secondgroup.AppendMenuItem(MF_ENABLED, 50, "20");
_secondgroup.CheckMenuRadioItem(30, 50, limit + 30);
_secondgroup.EnableMenuItem(limit + 30, 1);
_thirdgroup = window.CreatePopupMenu();
_thirdgroup.AppendTo(_menu,MF_ENABLED, "Download quality : " + quality[download_quality][0]);
_thirdgroup.AppendMenuItem(MF_ENABLED, 60, "Low");
_thirdgroup.AppendMenuItem(MF_ENABLED, 61, "Medium");
_thirdgroup.AppendMenuItem(MF_ENABLED, 62, "High");
_thirdgroup.AppendMenuItem(MF_ENABLED, 63, "Original");
_thirdgroup.CheckMenuRadioItem(60, 63, download_quality + 60);
_thirdgroup.EnableMenuItem(download_quality + 60, 1);
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
MF_STRING = images.length > 0 ? MF_ENABLED : MF_GRAYED;
_menu.AppendMenuItem(MF_STRING, 70, "Copy to folder containing track...");
_menu.AppendMenuItem(MF_STRING, 80, "Open image");
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 90, "Save images and text");
_menu.CheckMenuItem(90, save_images);
if (menu_reload){
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 100, "Reload");
}
_menu.AppendMenuItem(MF_SEPARATOR, 0, 0);
_menu.AppendMenuItem(MF_ENABLED, 110, "Properties");
_menu.AppendMenuItem(MF_ENABLED, 120, "Configure ...");
ret = _menu.TrackPopupMenu(x,y);
switch (ret) {
case 1:
window.SetProperty(" artist header: on/off", !a_header);
a_header = window.GetProperty(" artist header: on/off");
get_font();
get_text();
window.Repaint();
break;
case 10:
lang = 0;
window.SetProperty("lang", lang);
get_text();
break;
case 11:
lang = 1;
window.SetProperty("lang", lang);
get_text();
break;
case 12:
selection_mode = 0;
window.SetProperty("selection mode", selection_mode);
on_item_focus_change();
break;
case 13:
selection_mode = 1;
window.SetProperty("selection mode", selection_mode);
on_item_focus_change();
break;
case 14:
select_p_a = 0;
window.SetProperty("pictures/albums", select_p_a);
get_pic();
break;
case 15:
select_p_a = 1;
window.SetProperty("pictures/albums", select_p_a);
get_pic();
break;
case 16:
WshShell.run("http://www.last.fm/" + lang_query[lang] + "music/" + encodeURIComponent(artist));
break;
case 17:
window.SetProperty("fade effect", !fade_effect);
fade_effect = window.GetProperty("fade effect");
break;
case 20:
case 21:
case 22:
case 23:
case 24:
case 25:
align_mode = ret - 20;
window.SetProperty("align mode", align_mode);
window.Repaint();
break;
case 30:
case 31:
case 32:
case 33:
case 34:
case 35:
case 40:
case 45:
case 50:
limit = ret - 30;
window.SetProperty(" download limit", limit);
del_folders();
delay_timer = window.SetTimeout(function () {
window.ClearTimeout(delay_timer);
get_pic();
old_artist = artist;
step = 0;
window.Repaint();
}, 3000);
break;
case 60:
case 61:
case 62:
case 63:
download_quality = ret - 60;
window.SetProperty("download quality", download_quality);
del_folders();
delay_timer = window.SetTimeout(function () {
window.ClearTimeout(delay_timer);
get_pic();
old_artist = artist;
step = 0;
window.Repaint();
}, 3000);
break;
case 70:
copy_files();
break;
case 80:
try {
if (images[selected]) WshShell.run( '"' + artist_folder_path(artist)+ "\\" + artist + "_" + selected + "_" + p_a[select_p_a] + ".jpg" + '"' );
} catch(e) {}
break;
case 90:
window.SetProperty("Save images", !save_images);
save_images = window.GetProperty("Save images");
break;
case 100:
window.Reload();
break;
case 110:
window.ShowProperties();
break;
case 120:
window.ShowConfigure();
break;
}
_menu.Dispose();
return true;
}
var timer;
function get_files_if_loaded(p){
timer && window.ClearInterval(timer);
timer = window.SetInterval(function() {
get_files_from_dir(p);
if (images.length > 0) {
next_image(0);
window.ClearInterval(timer);
}
}, 500 );
}
var set_cycle = false;
function on_key_down(vkey) {
if (vkey == 17){
set_cycle = true;
dis_set();
window.Repaint();
}
}
var cycle_timer, step = 0;
function set_cycle_timer(){
cycle_timer && window.ClearInterval(cycle_timer);
cycle_timer = window.SetInterval(function() {
step = set_cycle ? 0 : step + 1;
if (cycle > 0 && step >= cycle){
get_files_from_dir(artist_folder_path(artist));
if (images.length > 1){
next_image(1);
step = 0;
}
}
window.Repaint();
}, 1000 );
}
var dis_timer, dis = 0;
function dis_set(){
dis = 0;
dis_timer && window.ClearInterval(dis_timer);
dis_timer = window.SetInterval(function() {
if (set_cycle) {
dis++;
if(dis == 1) {
set_cycle = false;
if (cycle > 0) set_cycle_timer();
if (cycle == 0) window.ClearInterval(cycle_timer);
window.ClearInterval(dis_timer)
window.Repaint();
};
}
}, 1000 );
}
var delay = false;
function fdelay(){
var delay_timer = window.SetTimeout(function() {
delay = false;
window.ClearTimeout(delay_timer);
}, 200);
}
var ftimer;
function fader_timer(){
fader = 0;
ftimer && window.ClearInterval(ftimer);
ftimer = window.SetInterval(function() {
fader = fader + fade_step;
if (fader >= 255) {
fader= 255;
window.ClearInterval(ftimer);
}
window.Repaint();
}, 42 );
}
function load_last_fm_logo(){
if(!fso.FileExists(script_path + "logo_static.png")) {
var url = "http://static-web.last.fm/static/images/footer_logo.ddcfd65712a6.png"
var file = "\"" + script_path + "footer_logo.png" + "\"";
WshShell.Run(vbs + " " + url + " " + file, false);
var url = "http://static-web.last.fm/static/images/favicon.702b239b6194.ico"
var file = "\"" + script_path + "last_fm_ico.ico" + "\"";
WshShell.Run(vbs + " " + url + " " + file, false);
var url = "http://vignette3.wikia.nocookie.net/logopedia/images/1/1d/Last_fm_logo.png/revision/latest?cb=20130411230808"
var file = "\"" + script_path + "Last_fm_logo.png" + "\"";
WshShell.Run(vbs + " " + url + " " + file, false);
var url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d4/Lastfm_logo.svg/709px-Lastfm_logo.svg.png"
var file = "\"" + script_path + "Lastfm_logo.png" + "\"";
WshShell.Run(vbs + " " + url + " " + file, false);
var url = "http://www.last.fm/static/images/logo_static.png?5b6b42188c40"
var file = "\"" + script_path + "logo_static.png" + "\"";
WshShell.Run(vbs + " " + url + " " + file, false);
}
}
function create_download_file() {
try {
file = fso.CreateTextFile(script_path + "download.vbs" )
var text =
"If (WScript.Arguments.Count <> 2) Then" + "\n\r" +
" WScript.Quit" + "\n\r" +
"End If" + "\n\r" + "\n\r" +
"url = WScript.Arguments(0)" + "\n\r" +
"file = WScript.Arguments(1)" + "\n\r" + "\n\r" +
"Set objFSO = Createobject(" + '"Scripting.FileSystemObject"' + ")" + "\n\r" +
"If objFSO.Fileexists(file) Then" + "\n\r" +
" Set objFSO = Nothing" + "\n\r" +
" WScript.Quit" + "\n\r" +
"End If" + "\n\r" + "\n\r" +
"Set objXMLHTTP = CreateObject(" + '"MSXML2.XMLHTTP"' + ")" + "\n\r" +
"objXMLHTTP.open " + '"GET"' + ", url,false" + "\n\r" +
"objXMLHTTP.send()" + "\n\r" + "\n\r" +
"If objXMLHTTP.Status = 200 Then" + "\n\r" +
" Set objADOStream = CreateObject(" + '"ADODB.Stream"' + ")" + "\n\r" +
" objADOStream.Open" + "\n\r" +
" objADOStream.Type = 1" + "\n\r" +
" objADOStream.Write objXMLHTTP.ResponseBody" + "\n\r" +
" objADOStream.Position = 0" + "\n\r" +
" objADOStream.SaveToFile file" + "\n\r" +
" objADOStream.Close" + "\n\r" +
" Set objADOStream = Nothing" + "\n\r" +
"End If" + "\n\r" + "\n\r" +
"Set objFSO = Nothing" + "\n\r" +
"Set objXMLHTTP = Nothing"
;
file.WriteLine(text);
file.Close();
} catch(e) {};
}
function on_mouse_move(x, y) {
window.SetCursor(32649);
on_text = x >= txt_x && x < sb_x && y >= txt_y ? true : false;
on_sb = x >= sb_x && x < ww && y >= txt_y && y < wh ? true : false;
on_pic = !on_text && !on_sb ? true : false;
if (on_text_down){
txt_x = x - delta_x;
txt_y = y - delta_y;
txt_x = txt_x <= 0 ? 0 : txt_x >= ww - (a_text_row_height + t_margin * 2) ? ww - (a_text_row_height + t_margin * 2) : txt_x;
txt_y = txt_y <= 0 ? 0 : txt_y >= wh - (a_text_row_height + t_margin * 2) ? wh - (a_text_row_height + t_margin * 2) : txt_y;
get_b_text_array();
}
if (on_sb_down && scrollbar && b_text_rows > b_text_visable_rows){
sb_posy = y + delta_y;
s_text = y + delta_y >= 0 ? y + delta_y <= (b_text_rows - b_text_visable_rows) * scrollbar_k ? Math.round(sb_posy / scrollbar_k) : b_text_rows - b_text_visable_rows : 0;
//window.Repaint();
window.RepaintRect(txt_x, txt_y, ww - txt_x, wh - txt_y);
}
window.RepaintRect(sb_x, txt_y, ww, wh);
}
function on_mouse_wheel(delta) {
ShiftDown = utils.IsKeyPressed(0x10) ? true : false;
CtrlDown = utils.IsKeyPressed(0x11) ? true : false;
if (on_pic && !CtrlDown && !delay){
get_files_from_dir(artist_folder_path(artist));
if (files.length > 1){
delay = true;
fdelay();
next_image(delta);
if (cycle > 0) step = 0;
} else if (logo_img && images.length == 0 && !default_img){
if (delta < 0) {default_logo = default_logo <= 0 ? 0 : default_logo - 1;};
if (delta > 0) {default_logo = default_logo >= 5 ? 5 : default_logo + 1;};
window.SetProperty(" default last.fm logo (0-5) 6-off", default_logo);
logo_img = l_arr[default_logo];
window.Repaint();
}
}
if (on_text && !ShiftDown){
if (b_text_rows > b_text_visable_rows){
if (delta < 0) {s_text = b_text_rows - s_text <= b_text_visable_rows ? b_text_rows - b_text_visable_rows : s_text += 1}
if (delta > 0) {s_text = s_text <= 0 ? 0 : s_text -= 1}
}
window.RepaintRect(txt_x, txt_y, ww - txt_x, wh - txt_y);
}
if (on_text && ShiftDown && !delay){
delay = true;
fdelay();
if (delta < 0) {font_size_b = font_size_b <= min_font_size ? min_font_size : font_size_b - 1;};
if (delta > 0) {font_size_b = font_size_b >= max_font_size ? max_font_size : font_size_b + 1;};
window.SetProperty(" font size: biography", font_size_b);
get_font();
refresh_txt = true;
get_b_text_array();
}
if (set_cycle && on_pic) {
if (delta < 0) {cycle = cycle <= 0 ? 0 : cycle - 5;};
if (delta > 0) {cycle = cycle >= 60 ? 60 : cycle + 5;};
window.SetProperty("auto cycle (sec)", cycle);
window.Repaint();
}
}
function on_mouse_lbtn_down(x,y){
if (on_text){
on_text_down = true;
delta_x = x - txt_x;
delta_y = y - txt_y;
}
if (on_sb){
on_sb_down = true;
sb_posy = s_text * scrollbar_k;
delta_y = sb_posy - y;
}
}
function on_mouse_lbtn_up(x,y){
window.SetProperty("txt_x", txt_x);
window.SetProperty("txt_y", txt_y);
on_text_down = false;
on_sb_down = false;
}
function on_mouse_lbtn_dblclk (x,y){
if (on_text){
lang = lang == 1 ? 0 : 1;
window.SetProperty("lang", lang);
get_text();
}
if (on_pic){
select_p_a = select_p_a == 1 ? 0 : 1;
window.SetProperty("pictures/albums", select_p_a);
get_pic();
}
}
function on_mouse_leave() {
window.SetCursor(32512);
on_sb = false;
window.Repaint();
}
function on_size(){
ww = window.Width;
wh = window.Height;
txt_x = window.GetProperty("txt_x");
txt_y = window.GetProperty("txt_y");
txt_x = txt_x >= ww - (a_text_row_height + t_margin * 2) && txt_x >= 0 ? ww - (a_text_row_height + t_margin * 2) : txt_x;
txt_y = txt_y >= wh - (a_text_row_height + t_margin * 2) && txt_y >= 0 ? wh - (a_text_row_height + t_margin * 2) : txt_y;
refresh_txt = true;
get_b_text_array();
}
function del_folders(n){
var dir = fso.GetFolder(tmp_b_path);
var e = new Enumerator( dir.SubFolders );
try {
for(; !e.atEnd(); e.moveNext() ) {
var name = e.item().Name;
if (name.indexOf("_download") < 0){
if (name.indexOf(n) < 0){
fso.deleteFolder(tmp_b_path + name, true);
}
}
}
} catch(e) {};
}
function calc_img_size(img){
if(!img) return;
var size = {x:0, y:0, width:0, height:0, cx:0, cy:0, cwidth:0, cheight:0};
switch(align_mode) {
case 0: // adjust
var sw = ww / img.Width;
var sh = wh / img.Height;
var s = Math.min(sw, sh);
var x = 0;
var y = 0;
if (sw > sh) x = (ww - img.Width * s) / 2;
else if (sw < sh) y = (wh - img.height * s) / 2;
var width = img.Width * s;
var height = img.Height * s;
var cx = 0;
var cy = 0;
var cwidth = img.Width;
var cheight = img.Height;
break;
case 1: // adjust top - center
var sw = ww / img.Width;
var sh = wh / img.Height;
var s = Math.min(sw, sh);
var x = 0;
if (sw > sh) x = (ww - img.Width * s) / 2;
var y = 0;
var width = img.Width * s;
var height = img.Height * s;
var cx = 0;
var cy = 0;
var cwidth = img.Width;
var cheight = img.Height;
break;
case 2: // adjust top - left
var sw = ww / img.Width;
var sh = wh / img.Height;
var s = Math.min(sw, sh);
var x = 0;
var y = 0;
var width = img.Width * s;
var height = img.Height * s;
var cx = 0;
var cy = 0;
var cwidth = img.Width;
var cheight = img.Height;
break;
case 3: // centre
var sr = img.Width / img.Height;
var dr = ww / wh;
if (sr < dr) {
var r = img.Width / ww;
var cheight = wh * r;
var cy = Math.round((img.Height - cheight) / 2);
var cwidth = img.Width;
var cx = 0;
} else {
var r = img.Height / wh;
var cwidth = ww * r;
var cx = Math.round((img.Width - cwidth) / 2);
var cheight = img.Height;
var cy = 0;
}
var x = 0;
var y = 0;
var width = ww;
var height = wh;
break;
case 4: // centre - top
var sr = img.Width / img.Height;
var dr = ww / wh;
if (sr < dr) {
var r = img.Width / ww;
var cheight = wh * r;
var cy = 0;
var cwidth = img.Width;
var cx = 0;
} else {
var r = img.Height / wh;
var cwidth = ww * r;
var cx = Math.round((img.Width - cwidth) / 2);
var cheight = img.Height;
var cy = 0;
}
var x = 0;
var y = 0;
var width = ww;
var height = wh;
break;
case 5: // stretch
var x = 0;
var y = 0;
var width = ww;
var height = wh;
var cx = 0;
var cy = 0;
var cwidth = img.Width;
var cheight = img.Height;
break;
}
size.x = x + p_margin;
size.y = y + p_margin;
size.width = width - p_margin * 2;
size.height = height - p_margin * 2;
size.cx = cx;
size.cy = cy;
size.cwidth = cwidth;
size.cheight = cheight;
return size;
}
function copy_files(){
var save_images_state = save_images;
if (!save_images_state) save_images = true;
var destination_path;
var tmp_files = files;
var tmp_artist = artist;
var tmp_p_a = p_a[select_p_a];
var tmp_directory_path;
if (path.indexOf('://') > 0 || path.indexOf('youtube') == 0 || path.indexOf('cdda') == 0) {
tmp_directory_path = fb.ProfilePath + tmp_p_a + "\\";
} else {
tmp_directory_path = directory_path + "\\" + tmp_p_a + "\\";
}
var nl = "\" + chr(10) + \"";
var input_box_text = "Copy " + nl + nl + tmp_artist + " " + tmp_p_a + ".jpg" + nl + "files to";
var string = input_box(input_box_text, tmp_directory_path, "Foobar 2000");
if (string){
destination_path = folder_exists(string);
if (!destination_path) {
copy_files();
} else{
copy_files_to_folder(destination_path, tmp_files, tmp_p_a);
}
}
save_images = save_images_state;
}
function copy_files_to_folder(p, f, pa){
if (p.length != "\\"){p = p + "\\"}
for (i in f) {
if (f[i].indexOf(pa) > 0){
try {
fso.CopyFile (f[i], p , 1 );
} catch(e) {}
}
}
}
function input_box(p_text, d_text, w_title){
vbe = new ActiveXObject('ScriptControl');
vbe.Language = 'VBScript';
return vbe.eval( "InputBox(\"" + p_text + "\",\"" + w_title + "\",\"" + d_text + "\")");
}
function clean_path_name(n) {
if (!n) return;
return n.replace(/[\/\:\*\?\"\<\>\|]/g,'');
}
function folder_exists(n) {
var driver = fso.GetDriveName(n);
if (!fso.DriveExists(driver)) {
return "";
} else {
var p = "";
var split_string = [];
split_string = n.replace(/\\$/g, "").split("\\");
for (var i = 1; i < split_string.length; i += 1) {
p = p + clean_path_name(split_string[i]) + "\\";
try {
if(!fso.FolderExists(driver + "\\" + p)) fso.CreateFolder(driver + "\\" + p);
} catch(e) {};
}
return driver + "\\" + p;
}
}