/usr/share/mediatomb/web/js/autoscan.js is in mediatomb-common 0.12.1-0ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | /*MT*
MediaTomb - http://www.mediatomb.cc/
autoscan.js - this file is part of MediaTomb.
Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>,
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>
Copyright (C) 2006-2010 Gena Batyan <bgeradz@mediatomb.cc>,
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>,
Leonhard Wimmer <leo@mediatomb.cc>
MediaTomb is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
MediaTomb is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
version 2 along with MediaTomb; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
$Id: autoscan.js 2081 2010-03-23 20:18:00Z lww $
*/
var autoscanId;
var autoscanFromFs;
var autoscanPersistent;
function showAutoscanDirs()
{
setType('db');
var url = link('autoscan', {action: 'list'}, true);
var myAjax = new Ajax.Request(
url,
{
method: 'get',
onComplete: showAutoscanCallback
});
}
function showAutoscanCallback(ajaxRequest)
{
var xml = ajaxRequest.responseXML
if (! errorCheck(xml)) return;
var autoscansXMLel = xmlGetElement(xml, "autoscans");
if (! autoscansXMLel) return;
var autoscans = autoscansXMLel.getElementsByTagName("autoscan");
if (autoscans.length <= 0) return;
var autoscanHTMLel = rightDocument.createElement("div");
autoscanHTMLel.setAttribute("class", "itemsEl");
var itemsTable = rightDocument.createElement("table");
itemsTable.setAttribute("width", "100%");
itemsTable.setAttribute("cellspacing", "0");
var itemsTableBody = rightDocument.createElement("tbody");
itemsTable.appendChild(itemsTableBody);
autoscanHTMLel.appendChild(itemsTable);
for (var i = 0; i < autoscans.length; i++)
{
var itemRow = rightDocument.createElement("tr");
itemRow.setAttribute("class", (i % 2 == 0 ? "itemRowA" : "itemRowB"));
var itemEntryTd = rightDocument.createElement("td");
itemEntryTd.setAttribute("class", "itemEntry");
var itemEntry;
if (isMSIE)
{
itemEntry = rightDocument.createElement("div"); // another div only for IE...
itemEntry.setAttribute("class", "itemLeft");
itemEntryTd.appendChild(itemEntry);
}
else
{
itemEntry = itemEntryTd;
}
var autoscanXMLel = autoscans[i];
var autoscanMode = xmlGetElementText(autoscanXMLel, "scan_mode");
var autoscanFromConfig = xmlGetElementText(autoscanXMLel, "from_config") == "1";
var icon;
var altText;
if (autoscanMode == "timed")
appendImgNode(rightDocument, itemEntry, "Timed-Autoscan:", (autoscanFromConfig ? iconContainerAutoscanTimedConfig : iconContainerAutoscanTimed));
else if (autoscanMode == "inotify")
appendImgNode(rightDocument, itemEntry, "Inotify-Autoscan:", (autoscanFromConfig ? iconContainerAutoscanInotifyConfig : iconContainerAutoscanInotify));
var itemText = rightDocument.createTextNode(" " + xmlGetElementText(autoscanXMLel, "location"));
itemEntry.appendChild(itemText);
var itemButtonsTd = rightDocument.createElement("td");
itemButtonsTd.setAttribute("class", "itemButtons");
itemButtonsTd.setAttribute("align", "right");
var itemButtons;
if (isMSIE)
{
itemButtons = rightDocument.createElement("div"); // another div only for IE...
itemButtons.setAttribute("class", "itemRight");
itemButtonsTd.appendChild(itemButtons);
}
else
{
itemButtons = itemButtonsTd;
}
itemRow.appendChild(itemEntryTd);
itemRow.appendChild(itemButtonsTd);
_addLink(rightDocument, itemButtons, true, "javascript:parent.editLoadAutoscanDirectory('"+autoscanXMLel.getAttribute("objectID")+"', false);", "edit", iconEditAutoscan);
itemsTableBody.appendChild(itemRow);
}
Element.hide(itemRoot);
itemRoot = rightDocument.getElementById('autoscan_list_div');
itemRoot.replaceChild(autoscanHTMLel, itemRoot.firstChild);
Element.show(itemRoot);
}
function editLoadAutoscanDirectory(objectId, fromFs)
{
var url = link("autoscan", {action: 'as_edit_load', object_id: objectId, from_fs: fromFs}, true);
var myAjax = new Ajax.Request(
url,
{
method: 'get',
onComplete: editLoadAutoscanDirectoryCallback
});
}
function editLoadAutoscanDirectoryCallback(ajaxRequest)
{
var xml = ajaxRequest.responseXML;
if (!errorCheck(xml)) return;
var autoscan = xmlGetElement(xml, "autoscan");
updateAutoscanEditFields(autoscan);
scanModeChanged(true);
if (autoscanPersistent)
{
Element.show(frames["rightF"].document.getElementById("autoscan_persistent_message"));
Element.hide(frames["rightF"].document.getElementById("autoscan_set_button"));
}
else
{
Element.hide(frames["rightF"].document.getElementById("autoscan_persistent_message"));
Element.show(frames["rightF"].document.getElementById("autoscan_set_button"));
}
Element.hide(itemRoot);
itemRoot = rightDocument.getElementById('autoscan_div');
Element.show(itemRoot);
}
function updateAutoscanEditFields(autoscan)
{
autoscanId = xmlGetElementText(autoscan, 'object_id');
autoscanFromFs = xmlGetElementText(autoscan, 'from_fs') == '1';
var elements = rightDocument.forms['autoscanForm'].elements;
var scan_mode_checked = 'scan_mode_' + xmlGetElementText(autoscan, 'scan_mode');
var scan_level_checked = 'scan_level_' + xmlGetElementText(autoscan, 'scan_level');
var persistent = xmlGetElementText(autoscan, 'persistent');
if (persistent == '1')
autoscanPersistent = true;
else
autoscanPersistent = false;
elements[scan_mode_checked].checked = true;
elements[scan_level_checked].checked = true;
elements['recursive'].checked = xmlGetElementText(autoscan, 'recursive') == '1';
elements['hidden'].checked = xmlGetElementText(autoscan, 'hidden') == '1';
elements['interval'].value = xmlGetElementText(autoscan, 'interval');
}
function autoscanSubmit()
{
itemChangeType();
var form = rightDocument.forms['autoscanForm'];
var args = new Object();
args['action'] = 'as_edit_save';
args['object_id'] = autoscanId;
args['from_fs'] = (autoscanFromFs ? '1' : '0');
formToArray(form, args);
if (args['scan_mode'] == 'none')
use_inactivity_timeout_short = true;
var url = link('autoscan', args);
var myAjax = new Ajax.Request(
url,
{
method: 'get',
onComplete: autoscanSubmitCallback
});
}
function autoscanSubmitCallback(ajaxRequest)
{
if (errorCheck(ajaxRequest.responseXML))
folderChange(selectedNode);
}
function scanLevelChanged()
{
}
function scanModeChanged(filled)
{
var elements = rightDocument.forms['autoscanForm'].elements;
if (autoscanPersistent)
{
elements['scan_mode_none'].disabled = true;
elements['scan_mode_timed'].disabled = true;
elements['scan_mode_inotify'].disabled = true;
}
else
{
elements['scan_mode_none'].disabled = false;
elements['scan_mode_timed'].disabled = false;
elements['scan_mode_inotify'].disabled = false;
}
var scan_level_text = rightDocument.getElementById("scan_level_text");
if (autoscanPersistent || elements['scan_mode_none'].checked)
{
elements['scan_level_basic'].disabled = true;
elements['scan_level_full'].disabled = true;
elements['recursive'].disabled = true;
elements['hidden'].disabled = true;
elements['interval'].disabled = true;
scan_level_text.replaceChild(rightDocument.createTextNode("Scan Level:"), scan_level_text.firstChild);
}
else
{
elements['scan_level_basic'].disabled = false;
elements['scan_level_full'].disabled = false;
var scan_interval_row = rightDocument.getElementById("scan_interval_row");
if (elements['scan_mode_inotify'].checked)
{
scan_level_text.replaceChild(rightDocument.createTextNode("Initial Scan:"), scan_level_text.firstChild);
if (! filled)
elements['scan_level_basic'].checked = true;
Element.hide(scan_interval_row);
}
else
{
scan_level_text.replaceChild(rightDocument.createTextNode("Scan Level:"), scan_level_text.firstChild);
if (! filled)
elements['scan_level_full'].checked = true;
Element.show(scan_interval_row);
}
elements['recursive'].disabled = false;
elements['hidden'].disabled = false;
if (elements['scan_mode_timed'].checked)
{
elements['interval'].disabled = false;
if (elements['interval'].value == '0')
elements['interval'].value = '1800';
}
else
elements['interval'].disabled = true;
}
}
|