* Add JS tips section to frontend documentation
* Replace document.getElementsByTagName('body') with document.body
* Replace querySelectorAll with faster selecting methods where appropriate
* Replace querySelector with faster selecting methods where appropriate
* Fix typo
* Fix forEach and getElementsByClassName
* Change querySelector* to faster methods in erb files
* Change querySelector* to faster methods in ruby files
* Fix runkit tag
* Various fixes
* Update app/assets/javascripts/initializers/initializeEllipsisMenu.js
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
* Update app/assets/javascripts/utilities/slideSidebar.js
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
* Commenting out flaky spec
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
33 lines
915 B
JavaScript
33 lines
915 B
JavaScript
import { Controller } from 'stimulus';
|
|
|
|
export default class ArticleController extends Controller {
|
|
static targets = ['featuredNumber'];
|
|
|
|
increaseFeaturedNumber() {
|
|
// Increases the article's chances of being seen
|
|
const seconds = new Date().getTime() / 1000;
|
|
this.featuredNumberTarget.value = Math.round(seconds) + 300;
|
|
}
|
|
|
|
decreaseFeaturedNumber() {
|
|
// Decreases the article's chances of being seen
|
|
const seconds = new Date().getTime() / 1080;
|
|
this.featuredNumberTarget.value = Math.round(seconds);
|
|
}
|
|
|
|
highlightElement() {
|
|
const card = this.element.getElementsByClassName('card-body')[0];
|
|
card.classList.add('bg-highlighted', 'border-highlighted');
|
|
setTimeout(() => {
|
|
card.classList.remove('bg-highlighted');
|
|
}, 350);
|
|
}
|
|
|
|
get articleId() {
|
|
return parseInt(this.data.get('id'), 10);
|
|
}
|
|
|
|
set articleId(value) {
|
|
this.data.set('id', value);
|
|
}
|
|
}
|