Користувач:Danbst/vector.js
Увага: Після публікування слід очистити кеш браузера, щоб побачити зміни.
- Firefox / Safari: тримайте Shift, коли натискаєте Оновити, або натисніть Ctrl-F5 чи Ctrl-Shift-R (⌘-R на Apple Mac)
- Google Chrome: натисніть Ctrl-Shift-R (⌘-Shift-R на Apple Mac)
- Internet Explorer / Edge: тримайте Ctrl, коли натискаєте Оновити, або натисніть Ctrl-F5
- Opera: натисніть Ctrl-F5
var hasClass = (function () {
var reCache = {};
return function (element, className) {
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
};
})();
function removeClass(elem, cls) {
elem.className = elem.className.replace(" " + cls, "");
}
function $(id) {
target = document.getElementById(id);
//target.attr = attr;
target.id = id;
return target;
}
function attr(att, val) {
// 1 параметр - отримати атрибут, 2 - встановити
if (val === undefined)
{
return $(this.id).getAttribute(att);
}
return $(this.id).setAttribute(att, val);
}
function PofVpreprocessPage() {
var indexMn = 0;
var mns = document.getElementsByClassName("fv");
for(var i=0; PofVFrame = mns[i]; i++){
indexMn++;
PofVFrame.setAttribute('id', 'id_fv-' + indexMn);
indexMntms = 0;
var mntms = PofVFrame.getElementsByClassName("pofv-menu-item");
for(var j=0; mntm = mntms[j]; j++){
indexMntms++;
mntm.setAttribute('id', 'id_mntm-' + indexMntms);
mntm.setAttribute('onclick',
"tgglMn('id_mntm-" + indexMntms+"', 'id_fv-" + indexMn+"')");
}
indexDatatms = 0;
var datatms = PofVFrame.getElementsByClassName("pofv-data-item");
for(var j=0; datatm = datatms[j]; j++){
indexDatatms++;
datatm.setAttribute('id', 'id_datatm-' + indexDatatms);
datatm.setAttribute('onclick',
"tgglData('id_datatm-" + indexDatatms+"', 'id_fv-" + indexMn+"')");
}
}
}
function tgglMn(who, where) {
selected = $(who);
allitems = $(where).getElementsByClassName("pofv-menu-item");
tagt = $(where).getElementsByClassName('sd')[0];
// Пройтись по всім елементам, скинути selected
for (var i=0; tm = allitems[i]; i++){
removeClass(tm, 'pofv-selected');
}
// Проставити Selected потрібному
selected.className += ' pofv-selected';
// копіювати перший знайдений контент вибраного у бокову панель
var cntnt = selected.getElementsByClassName("pofv-content")[0];
tagt.innerHTML = cntnt.innerHTML;
}
function tgglData(who, where) {
tagt = $(where).getElementsByClassName('pofv-data')[0];
tagt.innerHTML = $(who).getElementsByClassName("pofv-content")[0].innerHTML;
}
$( PofVpreprocessPage );