Rapid Chord


Rapid Chord { filterHashtags(); if (Storage.Session.HasKey(‘selected_hashtag’)) { const hashtagName = Storage.Session.GetData(‘selected_hashtag’); Storage.Session.ClearData(‘selected_hashtag’); $(`div[name=${hashtagName}]`).trigger(‘click’); } }); const filterHashtagsTimeout = () => { setTimeout(() => { if (-1 !== filterTimeout) { clearTimeout(filterTimeout); } filterTimeout = setTimeout(() => { filterHashtags(); filterTimeout = -1; }, 500); }); } const filterHashtags = () => { $(‘.block-layout’).html(”); const filterHashtags = hashtags.filter(x => x.hashtag_name.toLowerCase().includes($(‘input[name=”search”]’).val().toLowerCase())) for (let i = 0; i < filterHashtags.length; i++) { const filterHashtag = filterHashtags[i]; const blockItemDiv = $(document.createElement('div')); blockItemDiv.addClass('col-xl-3 col-4 text-center'); blockItemDiv.html(filterHashtag.hashtag_name); blockItemDiv.attr('name', filterHashtag.hashtag_name); blockItemDiv.click(function() { $('.block-layout div').removeClass('active'); $(this).addClass('active'); $('.tab-header').html(filterHashtag.hashtag_name); if (screen.width { if (0 === hashtagId) { hashtagId = lastHashtagId; } else { start = 0; totalSongs = 0; lastHashtagId = hashtagId; $('.hashtag-songs').children().not('.clone-html').remove(); $('.see-more').show(); } App.Ajax.Get('https://rapidchord.com/api/song-lyrics/songs-by-hashtag', { start: start, length: 10, hashtag_id: hashtagId }, (response) => { if (response.result) { if (response.data) { $(‘span[name=total]’).html(response.data.total); if (response.data.items && response.data.items.length) { const songLyrics = response.data.items; if (songLyrics.length > 0) { for (let i = 0; i .clone-html’).clone().removeClass(‘clone-html’); cloneHtml.find(‘[name=”href”]’).attr(‘href’, `https://rapidchord.com/song-lyrics/${songLyric.slug}-${songLyric.id}`) const lyricChordsDiv = cloneHtml.find(‘.lyric-chords’); for (let j = 0; j 4 ? 4 : songLyric.primary.list_chords.length); j++) { lyricChordsDiv.append(`${songLyric.primary.list_chords[j]}`); } cloneHtml.appendTo(‘.hashtag-songs’); App.Feature.BindingData(cloneHtml, songLyric.primary); } start++; } } if ($(‘.hashtag-songs > .song-lyric-item’).length > response.data.total) { $(‘.see-more’).hide(); } } } }); } ]]>

Copyright © 2022 Rapid Chord

{ $(‘.open-sidenav’).click(() => { $(‘.sidenav’).animate({ width: ‘100%’ }, 50); }); $(‘.close-sidenav’).click(() => { $(‘.sidenav’).animate({ width: ‘0%’ }, 50); }); setActiveMenu(); }); const setActiveMenu = () => { liMenuItems.removeClass(‘active’); liMenuItems.find(‘a’).each(function() { if ($(this).attr(‘href’) === ‘https://rapidchord.com/hashtags’) { $(this).parent().addClass(‘active’); } }); } const searchKeywordsTimeout = (event) => { const keyCode = event.keyCode; setTimeout(() => { if ((keyCode > 64 && keyCode 96 && keyCode { searchKeywords(); searchKeywordsTimeoutId = -1; }, 500); } else { if (keyCode === 38 || keyCode === 40) { const searchResultLength = $(‘.search-result a’).length; if (searchResultLength) { let currentActiveIndex = $(‘.search-result a’).index($(‘.search-result a.active’)); $(‘.search-result a’).removeClass(‘active’); if (keyCode === 38) { if (currentActiveIndex – 1 searchResultLength – 2)) { currentActiveIndex = -1; } $(`.search-result a:eq(${currentActiveIndex + 1})`).addClass(‘active’); } } } if (keyCode === 13) { const keywords = $(‘input[name=”search-keywords”]’).val(); if (keywords) { if ($(‘.search-result .active’).length) { $(‘.search-result .active’)[0].click(); } else { location.href = `https://rapidchord.com/search?keywords=${keywords}`; } } else { location.href = ‘https://rapidchord.com’; } } } }); } const searchKeywords = () => { const keywords = $(‘input[name=”search-keywords”]’).val(); const searchChordsEle = $(‘.search-chords’); const searchArtistsEle = $(‘.search-artists’); const searchHashtagsEle = $(‘.search-hashtags’); searchChordsEle.html(”); searchArtistsEle.html(”); searchHashtagsEle.html(”); if (keywords) { App.RestQL.Add(‘https://rapidchord.com/api/song-lyrics/search’, { keywords: keywords }); App.RestQL.Add(‘https://rapidchord.com/api/artists/search’, { keywords: keywords }); App.RestQL.Add(‘https://rapidchord.com/api/hashtags/search’, { keywords: keywords }); App.RestQL.Send((arrResponses) => { if (arrResponses.length) { const songLyricsResponse = arrResponses[0]; if (songLyricsResponse.result && songLyricsResponse.data) { for (let i = 0; i < songLyricsResponse.data.length; i++) { const songLyric = songLyricsResponse.data[i]; searchChordsEle.append( ` ${songLyric.song_lyric_name} - ${songLyric.primary.singer_names} ` ); } } const artistsResponse = arrResponses[1]; if (artistsResponse.result && artistsResponse.data) { for (let i = 0; i < artistsResponse.data.length; i++) { const artist = artistsResponse.data[i]; searchArtistsEle.append(`${artist.primary.artist_name}`); } } const hashtagsResponse = arrResponses[2]; if (hashtagsResponse.result && hashtagsResponse.data) { for (let i = 0; i < hashtagsResponse.data.length; i++) { const hashtag = hashtagsResponse.data[i]; searchHashtagsEle.append(`${hashtag.hashtag_name}`); } } if ($('.search-result a').length) { $('.search-result a:eq(0)').addClass('active'); } } }); } } const summarySongLyricContent = (songLyricContent, limit = 50) => { return (0 === limit ? songLyricContent : songLyricContent.replace(/()/g, ”) .replace(/(
|
| |s+)/g, ‘ ‘).substring(0, limit).trim()) .replace(/[w*$/g, ”).replace(/([(.*?)])/g, ‘$1’) + ‘ …’; } const increaseFontSize = (selector = ‘.song-lyric-content’) => { const lyricRow = $(selector).find(‘.lyric-row’); const currentFontSize = Number(lyricRow.css(‘font-size’).replace(‘px’, ”)); let nextFontSize = currentFontSize + 2; nextFontSize = nextFontSize > 40 ? 40 : nextFontSize; lyricRow.css(‘font-size’, `${nextFontSize}px`); lyricRow.css(‘line-height’, `${nextFontSize}px`); $(‘.preview-song-lyric .finger-position’).css(‘bottom’, (nextFontSize + (contentStyleType === ‘separate-lines’ ? nextFontSize : 0) + 16) + ‘px’); } const decreaseFontSize = (selector = ‘.song-lyric-content’) => { const lyricRow = $(selector).find(‘.lyric-row’); const currentFontSize = Number(lyricRow.css(‘font-size’).replace(‘px’, ”)); let nextFontSize = currentFontSize – 2; nextFontSize = nextFontSize { App.Ajax.Get(‘https://rapidchord.com/api/notifications/latest’, {}, (response) => { if (response.result) { App.Feature.BindingData($(‘.notifications’), response.data); $(‘.notifications div:first’).removeClass(‘unread’); if (response.data.unreadCount) { $(‘.notifications div:first’).addClass(‘unread’); } const notifications = response.data.notifications.reverse(); if (notifications.length) { $(‘.notifications ul .notification-item:not(.clone-html)’).remove(); for (let i = 0; i moment.utc(latestAccountNotificationDateTime).local().valueOf()) { latestAccountNotificationDateTime = notification.created_at; } notification.image_type_url = getNotificationTypeImage(notification.notification_type); notification.created_at = App.Feature.FormatUTCDateTimeFromNow(notification.created_at); const cloneHtml = $(‘.notifications ul .notification-item.clone-html’).clone().removeClass(‘clone-html’); if (!notification.read) { cloneHtml.find(‘.dropdown-item’).addClass(‘unread’); } App.Feature.BindingData(cloneHtml, notification); cloneHtml.insertAfter($(‘.notifications ul .notification-item.clone-html’)); } } subscribeAccountNotifications(); } }, { stealthy: true }); } const markAllAsRead = (event = null) => { if (event) { event.stopPropagation(); } App.Ajax.Post(‘https://rapidchord.com/api/notifications/mark-all-as-read’, {}, (response) => { if (response.result) { getLatestAccountNotifications(); } }); } const hashtagClick = (hashtagName) => { Storage.Session.SetData(‘selected_hashtag’, hashtagName); location.href = ‘https://rapidchord.com/hashtags’; } ]]>
{ $(‘.img-base64’).click(function() { $(this).prev().click(); }); $(‘body’).click(() => { $(‘.chord-space .finger-position’).hide(); }); if (location.href.includes(‘from-notification’)) { history.replaceState(null, document.title, location.pathname); } }); const convertImageToBase64 = (event, target = null) => { const files = event.target.files; if (files && files.length) { const reader = new FileReader(); reader.addEventListener(‘load’, function(e) { (target ? target : $(event.target).next()).attr(‘src’, e.target.result); }); reader.readAsDataURL(files[0]); } } const getComboListChords = (songLyricContent) => { const allComboListChords = {}; const baseChords = songLyricContent.split(‘[‘).filter(x => x.includes(‘]’)).map(x => x.split(‘]’)[0]); for (let i = -5; i { const tmpArr = […x]; let chord = ”; let baseChordIndex = 0; let calcIndex = 0; if (tmpArr.length === 1) { chord = tmpArr[0]; baseChordIndex = hashSignChords.indexOf(chord); calcIndex = baseChordIndex + i; if (calcIndex > hashSignChords.length – 1) { calcIndex -= hashSignChords.length; } else if (calcIndex 1) { if (tmpArr[1] === ‘#’) { chord = tmpArr[0].concat(tmpArr[1]); baseChordIndex = hashSignChords.indexOf(chord); calcIndex = baseChordIndex + i; if (calcIndex > hashSignChords.length – 1) { calcIndex -= hashSignChords.length; } else if (calcIndex bSignChords.length – 1) { calcIndex -= bSignChords.length; } else if (calcIndex hashSignChords.length – 1) { calcIndex -= hashSignChords.length; } else if (calcIndex { App.Ajax.Get(‘https://rapidchord.com/api/chords’, {}, (response) => { if (response.result) { fingerPositionPreviews = App.Feature.GroupBy(response.data, ‘chord_name’); callback(); } }); } let originalSongLyricContent = null; let comboListChords = []; let currentToneLevel = 0; let selectedMusicalInstrument = ‘guitar’; const keepOriginalSongLyric = (songLyricContent) => { originalSongLyricContent = songLyricContent; comboListChords = getComboListChords(songLyricContent); } const previewSongLyric = (selector = ‘.preview-song-lyric’) => { const chords = comboListChords[currentToneLevel]; let previewHtml = originalSongLyricContent.replaceAll(‘ ‘, ‘ ‘).trim(); if (!/^

/g.test(previewHtml) && !/$/g.test(previewHtml)) { previewHtml = `

${previewHtml}`; } // convert
to

previewHtml = previewHtml.replaceAll(/
/g, ‘

‘); // remove tag attr and convert opentag to

previewHtml = previewHtml.replaceAll(/]*)>/g, ‘

‘); // convert closetag to previewHtml = previewHtml.replaceAll(//g, ”); // something here

->

something here

previewHtml = previewHtml.replaceAll(/((w|s)+)/g, ‘

$1

‘); // something here

anything here ->

something here

anything here previewHtml = previewHtml.replaceAll(/^((w|s)+)/g, ‘

$1

‘); //

anything heresomething here ->

anything here

something here previewHtml = previewHtml.replaceAll(/((w|s)+)$/g, ‘

$1′); //

-> ” previewHtml = previewHtml.replaceAll(/s*/g, ‘

 ‘); // something[C] something | something [C]something | something [C] something -> something[C]something previewHtml = previewHtml.replaceAll(/s*([(.*?)])s*/g, ‘$1’); // something something -> something something //

something ->

something // something -> something previewHtml = previewHtml.replaceAll(/s{2,}/g, ‘ ‘).replaceAll(/

s+/g, ‘

‘).replaceAll(/s+/g, ”); // [ F ] [A] [ C] [F ] -> [F] [A] [C] [F] previewHtml = previewHtml.replaceAll(/[s*(.*?)s*]/g, ‘[$1]’); // something[C][G][Am]… -> something [C][G][Am]… previewHtml = previewHtml.replaceAll(/(w+)(([(.*?)])+)/g, ‘$1 $2’); // // …[C][G][Am]something -> …[C][G][Am] something // previewHtml = previewHtml.replaceAll(/(([(.*?)])+)(w+)/g, ‘$1 $4’); // remove beginning

and ending let arrRows = previewHtml.replaceAll(/^

/g, ”).replaceAll(/$/g, ”).split(‘

‘); previewHtml = ”; for (let i = 0; i < arrRows.length; i++) { const isRowOnlyChords = !/w+([(.*?)])|([(.*?)])w+/g.test(arrRows[i]); let arrWords = arrRows[i].split(' '); let previewRow = '

‘; for (let j = 0; j < arrWords.length; j++) { let currentWord = arrWords[j]; if (/(([(.*?)])+)(.*)/g.test(currentWord)) { currentWord = currentWord.replace( /(([(.*?)])+)(.*)/g, `$1 $1$4${isRowOnlyChords ? '' : ' '}` ); currentWord = currentWord.replaceAll( /([(.*?)])/g, ` $1  ` ); console.log(currentWord); const xspan = currentWord.match(/(.|n)*/g)[0] .replaceAll('%x', '').replaceAll(/[(.*?)]/g, '%x').replaceAll(/data-chord="(.*?)"/g, 'data-chord="%x"'); const yspan = currentWord.match(/(.|n)*(.|n)*(.|n)*/g)[0] .replaceAll('%y', '').replaceAll(/[(.*?)]/g, '[%y]').replaceAll(/data-chord="(.*?)"/g, 'data-chord="%y"'); currentWord = `${xspan}${yspan}`.replace(/(xspan|yspan)/g, 'span'); } else { currentWord += ' '; } previewRow += currentWord; } previewRow += ''; previewHtml += previewRow; } for (let i = 0; i { const changeDiv = ` Positions `; for (let i = 0; i x.musical_instrument_name === selectedMusicalInstrument); if (fingerPositions.length) { if (!$(`${selector} .finger-position[data-chord=”${chord.chord_name}”] img`).length) { $(`${selector} .finger-position[data-chord=”${chord.chord_name}”]`).prepend(changeDiv).prepend(``); } } } } $(‘.chord-space’).on(‘click mouseover’, function(event) { event.stopPropagation(); $(‘.chord-space .finger-position’).hide(); const fingerPositionEle = $(this).find(‘.finger-position’); fingerPositionEle.is(‘:hidden’) ? fingerPositionEle.show() : fingerPositionEle.hide(); }); }); } const changeFingerPositions = (target, event, isRight = false) => { event.stopPropagation(); const chordSpace = $(target).closest(‘.chord-space’); const imgPosition = chordSpace.find(‘img’); let chord = fingerPositionPreviews[chordSpace.children(‘.finger-position’).data(‘chord’)]; chord = chord && chord.length ? chord[0] : null; if (chord) { const fingerPositions = chord.finger_positions.filter(x => x.musical_instrument_name === selectedMusicalInstrument); if (fingerPositions.length) { let newPosition = Number(imgPosition.data(‘position’)) + (isRight ? 1 : -1); if (newPosition fingerPositions.length – 1) { newPosition = 0; } imgPosition.data(‘position’, newPosition); imgPosition.attr(‘src’, fingerPositions[newPosition].image); } } } const changeTones = (selector = ‘.preview-song-lyric’, event, isRight = false, callback = null) => { event.stopPropagation(); currentToneLevel += (isRight ? 1 : -1); if (currentToneLevel 6) { currentToneLevel = -5; } if (callback) { callback(); } previewSongLyric(selector); } const getNotificationTypeImage = (notificationType) => { let image = ‘/images/rapidchord-designs/logo.png’; switch (notificationType) { case 8: image = ‘/images/rapidchord-designs/like.png’; break; case 3: image = ‘/images/rapidchord-designs/default-account-image.png’; break; case 6: image = ‘/images/rapidchord-designs/default-account-image.png’; break; case 7: image = ‘/images/rapidchord-designs/default-account-image.png’; break; default: break; } return image; } ]]>

{ const firebaseConfig = { apiKey: ‘AIzaSyDhwGbh_ebQHukrY52NNarqjVZ6s7EGBRE’, authDomain: ‘rapid-chord.firebaseapp.com’, projectId: ‘rapid-chord’, storageBucket: ‘rapid-chord.appspot.com’, messagingSenderId: ‘894415416235’, appId: ‘1:894415416235:web:874641eeb5f693dc0880ee’, measurementId: ‘G-97JCZP83MP’ }; // const firebaseConfig = { // apiKey: ‘AIzaSyALAVHo7gTx7nvNp97ehQBhrJ3zZwLHZTQ’, // authDomain: ‘rapidchord-66d63.firebaseapp.com’, // projectId: ‘rapidchord-66d63’, // storageBucket: ‘rapidchord-66d63.appspot.com’, // messagingSenderId: ‘1057081800880’, // appId: ‘1:1057081800880:web:b90a2ac27f82f469f82375’, // measurementId: ‘G-XYKGKK0LKS’ // }; const app = initializeApp(firebaseConfig); const analytics = getAnalytics(app); const db = getFirestore(); const unsubscribeAuthState = getAuth(app).onAuthStateChanged(async (authUser) => { unsubscribeAuthState(); if (authUser) { if (true) { await getAuth(app).signOut(); } else { if (typeof initializeAccountNotifications === ‘function’) { initializeAccountNotifications(); } if (typeof initializeCommentNotifications === ‘function’) { initializeCommentNotifications(); } } } if (typeof initializeAuthentications === ‘function’) { initializeAuthentications(app); } }); }); ]]>

Source

This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.