Skip to content

Instantly share code, notes, and snippets.

@A-gambit
Created May 18, 2014 16:59
Show Gist options
  • Save A-gambit/f716c3a3327d94a96327 to your computer and use it in GitHub Desktop.
Save A-gambit/f716c3a3327d94a96327 to your computer and use it in GitHub Desktop.
ДО
function position(el){
//елемент, що шукається серед елментів after
for(var i=0;i<aTag.length;i++){
if(aTag[i].tagName===el.tagName){
if(aTag[i].src!==undefined){
if(aTag[i].style.cssText!=="border: 4px solid green;" && el.src===aTag[i].src && mark[i]){
mark[i]=false;
//перевірка чи поточний знайдений елемент має правильне розташування
if(i>cur){
cur=i;
return true;
}
else
return false;
}
}
else{
if(aTag[i].style.color!="green" && el.innerHTML===aTag[i].innerHTML && mark[i]){
mark[i]=false;
//перевірка чи поточний знайдений елмент має правильне розташування
if(i>cur){
cur=i;
return true;
}
else
return false;
}
}
}
}
}
После
function position(el){
// console.log(cur);
//елемент, що шукається серед елментів after
var some=false;
for(var i=0;i<aTag.length;i++){
if(makeSome(aTag[i], i)) some=true;
}
return some;
function makeSome(element, index){
var someTag=aTag[i].tagName===el.tagName;
if(someTag) return checkSrc(element, index);
else return false;
}
function checkSrc(element, index){
if(element.src!==undefined) return tagTrue(element, index);
else return tagFalse(element, index);
}
function tagTrue(element, index){
console.log(el.innerHTML===element.innerHTML);
var condition=(element.style.cssText!=="border: 4px solid green;" && el.src===element.src && mark[index]);
if(condition)
return last(element, index);
else
return false;
}
function tagFalse(element, index){
console.log(el.innerHTML===element.innerHTML+" "+element.innerHTML+" "+el.innerHTML);
var condition=(element.style.color!=="green" && el.innerHTML===element.innerHTML && mark[index]);
if(condition)
return last(element, index);
else
return false;
}
function last(element, index){
mark[index]=false;
var pos = (index>cur)
cur= pos ? index : cur;
//flag=pos;
//console.log(cur);
return pos;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment