Created
March 16, 2020 16:45
-
-
Save gartes/da1ed0a521bff2cc30b9cfd2b6843214 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var $ = jQuery ; | |
var Domen = 'https://fotosmart.artos.pp.ua' | |
// Интервал между проверками новых сообщений | |
var tInterval = 10000 ; | |
var mp3 = { | |
// сигнал для раздела - Предлагаю работу | |
alarm : Domen + '/libraries/GNZ11/assets/sound/alarm/Alarm-Fast-A1.mp3', | |
ring : Domen + '/libraries/GNZ11/assets/sound/alarm/Alarm-Fast-High-Pitch-A3-Ring-Tone.mp3', | |
} | |
document.addEventListener("DOMContentLoaded", function () { | |
var I = setInterval(function(){ | |
if (typeof Storage_class === 'function') { | |
clearInterval(I); | |
AjaxStart() ; | |
} | |
},1000) | |
}); | |
function AjaxStart(){ | |
var I = setInterval(function(){ | |
getHtml() | |
},tInterval ) | |
getHtml() | |
} | |
function getHtml(){ | |
$.get({ | |
url : 'https://joomlaforum.ru/index.php' , | |
success: function(date) { | |
var $recentpostsFirst = $(date).find('#ic_recentposts dt').first(); | |
getText($recentpostsFirst) | |
} | |
}) | |
} | |
function getText($el){ | |
var newMessage = $el.closest('#ic_recentposts'); | |
var t = $el.text() ; | |
// Тема сообщения | |
var topic = $($el.find('a')[0]).text(); | |
// Автор | |
var autor = $($el.find('a')[1]).text(); | |
// | |
var board = $el.find('a')[2] | |
// Раздел | |
var boardText = $(board).text(); | |
console.log( boardText ); | |
var $ic_recentposts = $el.closest('#ic_recentposts'); | |
var AllTheme = Storage_class.get('joomlaforum'); | |
var $lastMess = $(document).find('#ic_recentposts'); | |
var $parent = $lastMess.parent(); | |
if (!AllTheme) { | |
// сохранить все темы | |
saveAllMessage( $ic_recentposts ); | |
sound(boardText); | |
}else{ | |
if (autor === 'gartes') { | |
console.log( $el ); | |
} | |
// Если есть новое сообщение | |
if ( t !== AllTheme[0] && autor !== 'gartes' ) { | |
// сохранить все темы | |
saveAllMessage( $ic_recentposts ); | |
sound(boardText); | |
$lastMess.remove(); | |
$parent.append(newMessage) | |
}else{ | |
beep (); | |
// console.log( $lastMess ); | |
// console.log( newMessage ); | |
} | |
console.clear(); | |
console.log( 'topic' , topic ); | |
console.log( 'razdel' , boardText ); | |
console.log( 'autor' , autor ); | |
// console.log( t ); | |
// console.log( board ); | |
// console.log( boardText ); | |
// console.log( AllTheme[0] ); | |
} | |
} | |
/*** | |
* сохранить все темы | |
*/ | |
function saveAllMessage($ic_recentposts){ | |
var arr = []; | |
var text ; | |
$ic_recentposts.children('dt').each(function(i,a){ | |
text = $(a).text(); | |
arr[ i ] = text ; | |
}); | |
Storage_class.set('joomlaforum' , arr ) | |
console.log( arr ); | |
// Storage_class.set() | |
} | |
function beep (){ | |
var audio ; | |
audio = new Audio('https://www.w3schools.com/graphics/bounce.mp3'); | |
audio.play(); | |
} | |
/** | |
* Звуковое сообщение | |
*/ | |
function sound(level){ | |
var audio | |
switch (level) { | |
case 'Предлагаю работу': | |
audio = new Audio(mp3.alarm); | |
break; | |
default: | |
audio = new Audio(mp3.ring); | |
} | |
audio.play(); | |
} | |
})(); | |
setTimeout(function(){ | |
/*var wgnz = new GNZ11(); | |
// var Storage = Storage_class.prototype ; | |
console.log(wgnz); | |
console.log(Storage_class);*/ | |
},5000) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment