/*******************************************************************************
* Copyright (c) 2017 Genialist Software Ltd.
* All rights reserved.
******************************************************************************/
const m_settings = [ "user-device", /*'user-plugins',*/ "user-advanced", "audio", "video", 'user-movies', "user-books", "user-pictures", "user-homevideos", "user-radios", "youtube" ];
function doShow(name) {
if (!pString.isValid(name)) return false;
var x = pElement.x(name);
if (x) {
m_settings.forEach(function(i_setting) {
if (i_setting == name) {
if (pDocument.isShown(x)) {
pDocument.hideSmooth(x);
pElement.x("a.text."+name).className="listview-text";
pDocument.setHistoryState('view_device_'+i_setting, false);
}
else {
pDocument.showSmooth(x, null);
pElement.x("a.text."+name).className="listview-text-selected";
pDocument.setHistoryState('view_device_'+i_setting, true);
pDocument.setTimeout(x.id, function() { pDocument.scrollTo(x); }, 200);
}
}
else if (null!=pElement.x(i_setting)) {
pDocument.hideSmooth(i_setting);
pElement.x("a.text."+i_setting).className="listview-text";
pDocument.setHistoryState('view_device_'+i_setting, false);
}
});
return true;
}
return false;
}
function getVLCPlugin() {
return navigator.plugins['VLC Web Plugin'];
}
function getWMPPlugin() {
var L = navigator.plugins.length;
for(var i=0 ; i<L ; i++)
if (navigator.plugins[i].filename == 'np-mswmp.dll') {
return navigator.plugins[i];
}
return null;
}
function initCheckBox2(p_id, p_default) {
var i_element = null;
if (p_id.name!=null && p_id.type!=null && p_id.vdefault!=null) {
i_element = pElement.x(p_id.name);
pROSE.getProp(p_id);
}
else
i_element = pElement.x(p_id);
var i_value = pROSE.getProp(p_id);
if (null!=i_element)
i_element.checked = i_value;
if (typeof p_id=="string") {
pElement.n(p_id).forEach(function(x) {
x.checked = i_value;
});
/*var i_elements = document.getElementsByName(p_id);
for(var i=0 ; i<i_elements.length ; i++)
i_elements[i].checked = i_value;*/
}
}
function init() {
var h = '', x = navigator, yes = '<span class="ok">yes</span>', no = '<span class="warning">no</span>';
h += [
'App Code Name: ' + ((x.appCodeName)? x.appCodeName : '?'),
'App Name: ' + ((x.appName && x.appVersion)? x.appName+' '+x.appVersion : '?'),
'Platform: ' + x.platform,
'Product: ' + x.product,
'Cookies: ' + ((x.cookieEnabled)? yes:no),
'iOS Web-Application: ' + (x.standalone? 'yes':'no'),
'Online: ' + (pDevice.online? yes:no)
].join('<p>');
var c = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
if (c)
h += '<p>Connection: ' + c.type;
h += '<p>'+[
'Language: ' + x.language,
'Screen: ' + screen.width+'x'+screen.height + ' pixels',
'<div class="media200-192">High Pixel Resolution/Retina Display (Pixel-Ratio: 2, Resolution: 192dpi): yes</div>',
'<div class="media125-120">High Pixel Resolution/Retina Display (Pixel-Ratio: 1.25, Resolution: 120dpi): yes</div>',
'<div class="media130-124">High Pixel Resolution/Retina Display (Pixel-Ratio: 1.3, Resolution: 124.8dpi): yes</div>',
'<div class="media150-144">High Pixel Resolution/Retina Display (Pixel-Ratio: 1.5, Resolution: 144dpi): yes</div>',
'Window: ' + window.innerWidth+'x'+window.innerHeight + ' pixels'
].join('<p>');
h += '<p>Javascript/HTML features:<ul class="xcolumns2">';
h += '<li>Features<ul>';
[ 'localStorage', 'sessionStorage', 'File', 'FileReader', 'FileList', 'Blob' ].forEach(function(f) { h += '<li>window.'+f+': ' + (window[f]? yes:no) + '</li>'; });
h += '<li>date.toLocaleString: '+(pDate.ftoLocaleString? yes:no)+'</li>';
h += '<li>date.toLocaleDateString: '+(pDate.ftoLocaleDateString? yes:no)+'</li>';
h += '<li>date.toLocaleTimeString: '+(pDate.ftoLocaleTimeString? yes:no)+'</li>';
[ 'pushState', 'replaceState' ].forEach(function(f) { h += '<li>history.'+f+': ' + (history[f]? yes:no)+'</li>'; });
h += '</ul></li>';
h += '<li>Form Field Support<ul>';
[ 'text', 'password', 'checkbox', 'radio', 'search', 'number', 'date', 'datetime-local' ].forEach(function(f) {
h += '<li>html.input.type = '+f+': ';
var x = pElement.create('input'); x.type = f; h += (x.type == f)? yes:no;
h += '</li>';
});
h += '</ul></li>';
h += '<li>Image Support<ul>';
[ 'gif', 'jpeg', 'png', 'webp', 'bmp', 'tiff' ].forEach(function(f) {
h += '<li>image/'+f+': ' + (pPictures.supports('image/'+f)? yes:no) + '</li>';
});
h += '</ul></li>';
h += '<li>Audio Support<ul>';
pAudioUtil.codecs.keys().forEach(function(f) { h += '<li>'+f+' ('+ pAudioUtil.codecs.getValue(f) +'): ' + (pAudioUtil.supports(f)? yes:no) + '</li>'; });
h += '</ul></li>';
h += '<li>Video Support<ul>';
pVideoUtil.codecs.keys().forEach(function(f) { h += '<li>'+f+' (' + pVideoUtil.codecs.getValue(f).join(', ') + '): ' + (pVideoUtil.supports(f)? yes:no) + '</li>'; });
h += '</ul></li>';
h += '</ul>';
pElement.setInnerHTML('js-settings', h);
var L = navigator.plugins.length;
if (L && L.length>0) {
h = '';
h += 'Web-Browser Plugins:<ul>';
L.forEach(function(i_plugin) {
h += '<li>' + i_plugin.name + ((i_plugin.version)? ' version ' + i_plugin.version : '');
if (i_plugin.description != i_plugin.name && i_plugin.description != i_plugin.version)
h += '<br><span class="desc">' + i_plugin.description + '</span>';
//h += '<br>Filename: ' + navigator.plugins[i].filename;
//h += '<br>Version: ' + navigator.plugins[i].version;
//h += '<br>Description: ' + navigator.plugins[i].description;
h += '</li>';
});
h += '</ul>';
pElement.setInnerHTML('browser-plugins', h);
}
else
pDocument.hide('browser-plugins');
if (pConsole.debugging())
pDocument.showComponent('local-storage');
else
pDocument.hideComponent('local-storage');
if (pConsole.debugging())
if (localStorage) {
h = '';
h += 'Local Storage<br><span class="desc">This is the data cached inside your web browser. You can delete it by clicking Reset Settings on this page...</span><ul>';
var i_keys = [];
for(var i=0, len=localStorage.length; i<len; i++)
i_keys[i_keys.length] = localStorage.key(i);
i_keys.sort().forEach(function(i_key) {
h += '<li>' + i_key + ' = ' + localStorage[i_key];
});
h += '</ul>';
pElement.setInnerHTML('local-storage', h);
}
if (pConsole.debugging())
pDocument.showComponent('session-storage');
else
pDocument.hideComponent('session-storage');
if (pConsole.debugging())
if (sessionStorage) {
h = '';
h += 'Session Storage<br><span class="desc">This is the data cached inside your web browser tab or window. You can delete it by clicking Reset Settings on this page...</span><ul>';
var i_keys = [];
for(var i=0, len=sessionStorage.length; i<len; i++)
i_keys[i_keys.length] = sessionStorage.key(i);
i_keys.sort().forEach(function(i_key) {
h += '<li>' + i_key + ' = ' + sessionStorage[i_key];
});
h += '</ul>';
pElement.setInnerHTML('session-storage', h);
}
//var i_mode = "${device.mode}";
//if (i_mode == "") i_mode = "default";
//pElement.x("mode."+i_mode).checked = true;
initRadio('device-transcode-auto', pPlaylistUtil.options.OPTION_DEVICE_TRANSCODE.name);
initRadio('device-transcode-always', pPlaylistUtil.options.OPTION_DEVICE_TRANSCODE.name);
initRadio('device-transcode-never', pPlaylistUtil.options.OPTION_DEVICE_TRANSCODE.name);
pFormManager.initCheckBox('list-show-itunes-items', 'false');
pFormManager.initCheckBox('subtitles-webvtt', 'false');
var i_plugin = getVLCPlugin();
if (i_plugin)
pElement.setInnerHTML('plugin-vlc-label', i_plugin.name + ' (' + i_plugin.version + ')');
i_plugin = getWMPPlugin();
if (i_plugin)
pElement.setInnerHTML('plugin-wmp-label', i_plugin.name + ' (' + i_plugin.version + ')');
pFormManager.initCheckBox('view-user-advanced-noTableHeader', 'false');
pFormManager.initCheckBox('view-user-advanced-showMarkAsPlayedButton', 'false');
pFormManager.initCheckBox('view-user-advanced-showResetPlayButton', 'false');
pFormManager.initCheckBox('view-user-advanced-showLangInPlaylists', 'false');
pFormManager.initCheckBox('view-user-advanced-debug', 'false');
var i_props = pROSE.getProps();
for(var i=0 ; i<i_props.length ; i++)
initCheckBox2(i_props[i], 'true');
for(var i_member in pApplicationUI.options)
initCheckBox2(pApplicationUI.options[i_member], 'true');
for(var m in pPlaylistUtil.options)
initCheckBox2(pPlaylistUtil.options[m], 'true');
[ pPlaylistUtil.options.OPTION_CHAPTERS, pPlaylistUtil.options.OPTION_AUDIO_TRACKS ].forEach(function(o) {
o.vdefault.forEach(function(d) {
initRadio(o.name+'-'+d, o.name);
});
});
}
function initRadio(x, n) {//, p_default) {
if (x = pElement.x(x)) {
var v = pROSE.getProp(n);
x.checked = false;
if (x.value == v)// && p_default===true))
x.checked = true;
}
}
//pStorage.addEventListener(init, null);
pDocument.addOnResize(init);
window.addEventListener('online', init);
window.addEventListener('offline', init);
function reset() {
try {
pConfiguration.doReset(init);
}
catch (exception) {
alert(exception);
}
}
window.addEventListener('storage', init);
var lv = new pListViewInstance();
lv.installKeys();
/******************************************************************************/
/*** END OF FILE ************************************************************/
/******************************************************************************/