PromptBase
Upgrade
Close icon
General
Home
Marketplace
Create
Hire
Login
Chat
Sell
Explore

Prompt Details

Model
Chat - GPT-4 (gpt-4)
Token size
321 ($0.00960 / call)
Example input
$(function() { // Make add music on page load makeAddMusicMenus(); }); $('#submit-music').submit( async function(event) { // Take submit form and make it yo bish. event.preventDefault(); // POP DAT BUBBLE!!! //--- We gon need some facts in this erria ---\\ let yt = $("#yt").val(); let sc = $("#sc").val(); let spot = $("#spot").val(); let atomict = $("#atomict").val(); atomicc = "";// = $("#atomict").attr("collection"); let mood = $("#mood option:selected").val(); let genre = $("#genre option:selected").val(); let format = $("#format option:selected").val(); let songLat = $("#submit-music-btn").attr("valueLat"); let songLng = $("#submit-music-btn").attr("valueLng"); let songIso3 = $("#submit-music-btn").attr("songIso3"); let boost_sp_val = $("#boost-sp option:selected").val(); if (songIso3 == "USA" || songIso3 == "PRI") { songCounty = $("#submit-music-btn").attr("songCounty"); songStateID = $("#submit-music-btn").attr("songStateID"); songCityAscii = $("#submit-music-btn").attr("songCityAscii"); } console.log(genre); console.log(mood); errors = []; spotSlug = ""; scSlug = ""; ytSlug = ""; ytChannel = ""; valid = true; if (yt) { validateYouTubeUrl(yt); } if (sc) { validateSoundcloudUrl(sc); } if (spot) { validateSpotifyUrl(spot); } //--- Check if content is blank ---\\ if ((!spot && !sc && !yt)) { errors.push("The Sound of Silence. Good choice."); valid = false; } //--- Require YT Videos also have another Player ---\\ if ((!spot && !sc) && yt) { errors.push("πŸŽ₯ For YouTube, we require at least 1 other player of the same song/album. If you aren't yet <a style='color:green' href=https://distrokid.com/vip/seven/694648 alt='referral to Distrokid (Douglas uses Distrokid)'>distributing your music to all platforms<a/> you may use Soundcloud; playlists work."); valid = false; } //--- Limit posting to 1 per minute ---\\ if(Cookies.get('lastPost') !== undefined) { /// CHECK THIS valid = false; errors.push("To combat spam, please wait 30 seconds between posts. ⏱️"); } //--- Make sure they marked Genre/Mood/Format ---\\ if(genre == "" || mood == "" || format == "") { valid = false; errors.push("Don't forget about the genre, mood, and format"); } if(typeof songIso3 == 'undefined') { valid = false; errors.push("Please post on land and try again."); } // --- Make sure user is logged in --- \\ if($("#boost-title").text() == 'Log in to post') { valid = false; errors.push("You must be logged in to post."); } // --- Make NFT use NFT type --- \\ if((atomict == '') && format == "nft") { valid = false; errors.push("To use NFT format, you must include Template ID"); } // --- Force NFT type to only be for NFTs--- \\ if((atomict != '') && format != "nft") { valid = false; errors.push("To use Template ID, you must choose NFT format "); } // --- Get Collection + Verify Audio or Video field --- \\ console.log("atomict",atomict); if (atomict != ''){ await getAtomicCollection(atomict) } justSendIt = { "yt":ytSlug, "yt_channel":window.ytChannelf ? window.ytChannelf: "", "sc":scSlug, "spot":spotSlug, "mood":mood, "genre":genre, "lat":songLat, "lng":songLng, "format":format, "iso3":songIso3, "atomict":atomict, "atomicc":atomicc, "city_ascii":(typeof songCityAscii !== 'undefined') ? songCityAscii: "", "county_name":(typeof songCounty !== 'undefined') ? songCounty: "", "state_id":(typeof songStateID !== 'undefined') ? songStateID: "", "boost_sp":boost_sp_val }; console.log("//justSendIt", justSendIt); if (Cookies.get('username') !== undefined){ justSendIt.username = Cookies.get('username'); } if( valid ){ // Send that shit $.ajax({ method:"post", url:'php/add_music.php', data:justSendIt, dataType:"json" }) // END .ajax() .done(function(data){ console.log(data); if (data.success == true) { // Hide any previous errors $("#add-music-error").hide(); // Show Success Message $("#add-music-success").html('Your <a class="alert-link" href="'+window.location.protocol + "//" + window.location.host + ( !areWeLive ? "/cxc/" : "/")+'?id='+data.songid+'">music</a> has been posted to the map. πŸ‘ <br> Upvote <img style="vertical-align:middle;" src="images/icons/up12.png"> this track and it will grow bigger 🌱🌳').fadeIn(222); // --- Send event to Google Analytics --- \\ ADD THIS WHEN WE GO LIVE Cookies.set('lastPost', 'true', { expires: (1/8640) }); // expires in 0.5 minutes (1/8640 of a day) console.log("no duplicate error"); $("#yt, #sc, #spot").val(''); //--- Remove +Music Marker ---\\ if (typeof addMusicMarker !== 'undefined') { addMusicMarker.remove(); } // -- Post Song to Map -- \\ //Cookies.set('getItSteemy', data.songid); // Adds cookie that will make user post to Steemit var marker = L.circleMarker( [songLat,songLng], { radius: 20, "title": data.songid, color: genreColors[genre], fillColor: moodColors[mood] } ) .on("click", function (e) { //--- Force refresh with ID GET param that makes content display ---\\ urlGet.id = data.songid; //window.location = location.protocol+'//'+location.host+location.pathname + "?" + $.param(urlGet); window.location = window.location.protocol + "//" + window.location.host + ( !areWeLive ? "/cxc/" : "/")+ "?id=" + urlGet.id; } ).addTo(mymap); } else //END/CTN if (typeof addMusicMarker !== 'undefined') { $("#music-geopol-info, #add-music-error, #add-music-success").hide(); //--- either There was a duplicate ---\\ if (data.success == false) { console.log("Error Message Should Appear"); if(typeof data.duplicate != undefined){ $("#add-music-error").html('It looks like we already <a class="alert-link" href="'+location.protocol+'//'+location.host+location.pathname+'?id='+data.duplicate+'">have that song</a> on the map. Try another!').show(); } else { $("#add-music-error").html('A wild Error appeared. We aren\'t sure why πŸ€” Try again later.').show(); } } else { // --- or Show Exact Error --- \\ htmlErrors = []; if (data.scInvalid){ htmlErrors.push("The Soundcloud link is in the right format, but showing nothing 🧐 Make sure it's public and try again."); } if (data.ytInvalid){ htmlErrors.push("The YouTube link seems legit, but we can't embedd it. Make sure it's public and try again 🧐"); } if (data.spotInvalid){ htmlErrors.push("The Spotify link seems cool, but isn't working. Make sure it's a song not an album 🧐 Click the three dots and then \"copy song link\"."); } if (data.duplicate){ htmlErrors.push("It looks like that song is already on the map. Try another +🎡"); } console.log(errors); htmlErrorsExpanded = htmlErrors.join("<br /><br />"); $("#add-music-error").html(htmlErrorsExpanded).show(); } } //END if (typeof addMusicMarker !== 'undefined') console.log(data); }) .fail(function( textStatus ) { // Debug console.log({ "yt":ytSlug, "sc":scSlug, "spot":spotSlug, "mood":mood, "genre":genre, "lat":songLat, "lng":songLng, "format":format }); $("#alert-holder") .prepend('<div id="unknown-add-error-alert" class="alert alert-info bottom-alert" role="alert">Something went wrong on our end, try again in a few.</div>'); $("#unknown-add-error-alert").fadeIn(222).delay(6000).fadeOut(222); console.log( "Request failed: " + JSON.stringify(textStatus) ); }); // END .fail() } else { // END Validation if() console.log(errors); errorsExpanded = errors.join("<br /><br />"); $("#add-music-error").html(errorsExpanded).show(); } });// END $('#submit-music') TODO // --- Put information abouf Country, city, state when user puts in their info --- \\ function getGeopol(songLng, songLat){ // Send request to the database to get back the location information //songLat = $("#submit-music-btn").attr("valueLat"); //songLng = $("#submit-music-btn").attr("valueLng"); console.log(songLat); console.log(songLng); if(!isNaN(songLat)){ $.ajax({ method:"get", async:true, url:'php/get_geopol.php', data:{ lat:songLat, lng:songLng }, error: function(jqXHR, textStatus, errorThrown) { }, dataType:"json" }) .done(function(geodata){ if (geodata.iso3 == undefined) { geopolMessage = "Our charts only work on land 🏝️ Please double click/tap to choose the location this music was recorded πŸŽ™οΈ"; $("#submit-music-btn").attr("missingGeoloc", "true"); // What is this. -This is to catchon back to catch that bug we found - yes i am talking to myself } else { if (geodata.iso3 == "USA" || geodata.iso3 == "PRI") { geopolMessage = "Posting to <strong>"+geodata.city+"</strong>, <strong>"+geodata.state_id+"</strong>."; $("#submit-music-btn").attr({ "songIso3": geodata.iso3, "songCounty": geodata.county_name, "songStateID": geodata.state_id, "songCityAscii": geodata.city_ascii }); } else // User is not in the USA { geopolMessage = "Posting to <strong>"+geodata.nation+"</strong>."; $("#submit-music-btn").attr("songIso3", geodata.iso3); } } // ENDif (!geodata.iso3) Else //console.log(geopolMessage); $("#music-geopol-info").html(geopolMessage).show(); }); // END $.ajax({'../php/get_geopol.php',}) } else { //alert("Non-numeric"); } }; // END getGeopol // --- Gets location information --- \\ // --- Set Label of Hive Opt-in/out --- \\ if(Cookies.get('steemOptOut')=='1'){ $("#add-music-steem-opt").html('Post To Hive: Off'); } else { $("#add-music-steem-opt").html('Post To Hive: On'); } $("#add-music-steem-opt").on('click', function() { //--- Set Cookie ---\\ if(Cookies.get('steemOptOut')=='1'){ $("#add-music-steem-opt").html('Post To Hive: On'); Cookies.set('steemOptOut', "0"); } else { $("#add-music-steem-opt").html('Post To Hive: Off'); Cookies.set('steemOptOut', "1"); } }); // === FUNCTIONS === \\ // --- Youtube Validation --- \\ function validateYouTubeUrl(passed) { var url = passed; var ytChannelf; if (url != undefined || url != '') { var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=|\?v=)([^#\&\?]*).*/; var match = url.match(regExp); if (match && match[2].length == 11) { // Valid ytSlug = match[2]; console.log('yt validation passed'); console.log(match[2]); // --- Get Channel ID of Youtube --- \\ $.ajax({ method:"get", async:false, url:'https://www.googleapis.com/youtube/v3/videos', data:{ part:"snippet", id: ytSlug, key: "" }, error: function(jqXHR, textStatus, errorThrown) { }, dataType:"json" }) .done(function(resultGoogle){ window.ytChannelf = resultGoogle.items[0].snippet.channelId; }); /* if (typeof window.ytChannelf == "string"){ return window.ytChannelf; console.log('return "window.ytChannelf";'+window.ytChannelf); } else { console.log('return "NULL";'); } */ } else { valid = false; console.log('youtube validation failed'); errors.push("Youtube link is invalid 🧐 You can use youtu.be or youtube.com links."); } } } // --- Spotify Validation --- \\ function validateSpotifyUrl(passed) { var url = passed; var regExp = /^.*(spotify:|spotify\.com\/track\/)([^#\&\?]*).*/; var match = url.match(regExp); if (match && match[2].length == 22 ) {// Valid spotSlug = match[2]; console.log('spotify validation passed'); return true; } else { // Invalid valid = false; console.log('spotify validation failed'); errors.push("The Spotify link isn't working 😲 Right now, we can only embedd a single track from Spotfy, not an album (even a \"single\" album) πŸš«πŸ’Ώ To add one track, go to the album and click the three dots beside the track name and then click \"copy song link\" 😌 If you're posting an album, you can use the first track, or your favorite single 🎼"); } };// END validateSpotifyUrl, Outputs 'true' // --- SoundCloud Validation --- \\ function validateSoundcloudUrl(passed) { var url = passed; var regExp = /^.*(soundcloud\.com\/)([\w\-\.]+(\/)+[^#\&\?]*).*/; var match = url.match(regExp); if (match && match[2] ) { // Valid scSlug = match[2]; console.log('SoundCloud validation passed'); return true; } else { // Invalid valid = false; console.log('Soundcloud validation failed'); errors.push("Something is off with the Soundcloud link"); } } function makeAddMusicMenus() { // --- Add Genre Options --- \\ if ($("#genre option").length == 0) { $("#genre").append('<option role="presentation" class="label-add-music" value=""><a role="menuitem" tabindex="-1" href="#">Choose a Genre</a></option>'); $.each(genreOptions, function(name, description) { if(name != "null"){ $("#genre").append('<option role="presentation" value="' + name + '"><a role="menuitem" tabindex="-1" style="color:'+genreColors[String(name)]+'" href="#">'+ description + '</a></option>'); } else { $("#genre").append('<option role="presentation" value=""><a role="menuitem" tabindex="-1" href="#">Not exact? Clarify with mood</a></option>') } }); } // END if ($("#genre option").length == 0) // --- Add Mood Options --- \\ if ($("#mood option").length == 0) { $("#mood").append('<option role="presentation" class="label-add-music" value=""><a role="menuitem" tabindex="-1" href="#">Choose a Mood</a></option>'); $.each(moodOptions, function(name, description) { if(name != "null"){ $("#mood").append('<option role="presentation" value="' + name + '"><a role="menuitem" tabindex="-1" style="color:'+moodColors[String(name)]+'" href="#">'+ description + '</a></option>'); } else { $("#mood").append('<option role="presentation" value=""><a role="menuitem" tabindex="-1" href="#">Not perfect? Put the closest</a></option>') } }); } // END if ($("#genre option").length == 0) // --- Add Format Options --- \\ if ($("#format option").length == 0) { $("#format").append('<option role="presentation" class="label-add-music" value=""><a role="menuitem" tabindex="-1" href="#">Choose a Format</a></option>'); $.each(formatOptions, function(name, description) { if(name != "null"){ $("#format").append('<option role="presentation" value="' + name + '"><a role="menuitem" tabindex="-1" href="#">'+ description + '</a></option>'); } else { $("#format").append('<option role="presentation" value=""><a role="menuitem" tabindex="-1" href="#">Not here? Choose the closest</a></option>') } }); } // END if ($("#genre option").length == 0) } // END function makeAddMusicMenus() function getAtomicCollection(atomict){ if (atomict != ''){ $.ajax({ method:"get", url:'https://wax.api.atomicassets.io/atomicassets/v1/templates?', data:{ ids: atomict, page:"1", limit:"100" }, dataType:"json" //async: false }) .done( function (result){ console.log("check collection", result); console.log(result.data); if (result.success && result.data.length > 0) { // --- Prepare the Atomic Assets Data --- \\ let col_data = result.data[0]; valid = false; // --- Ensure this is a Music NFT --- \\ col_data.schema.format.forEach(function(field){ if(field.name == "video" || field.name == "audio" ){ valid = true; resolve(col_data.collection.collection_name); } })//END foreach(field) if (!valid){ errors.push("Music NFTs require an audio or video field"); resolve(false); } }else{//API gave back blank resule valid = false; errors.push("Error getting NFT data. Check template id, and try again"); resolve(false); } }).fail(function (){ valid = false; errors.push("We couldn't find your Atomic template"); resolve(false); }) } }//END getAtomicCollection /*/ atomict = $("#atomict").val(); // --- Match th --- \\ if ($("#format option").length == 0) { $("#format").append('<option role="presentation" class="label-add-music" value=""><a role="menuitem" tabindex="-1" href="#">Choose a Format</a></option>'); $.each(formatOptions, function(name, description) { if(name != "null"){ $("#format").append('<option role="presentation" value="' + name + '"><a role="menuitem" tabindex="-1" href="#">'+ description + '</a></option>'); } else { $("#format").append('<option role="presentation" value=""><a role="menuitem" tabindex="-1" href="#">Not here? Choose the closest</a></option>') } }); } // END if ($("#genre option").length == 0) /*/
Example output
To improve the code, here are the suggested changes: 1. Move the code inside the `$(function() {})` block to a separate function for better organization. 2. Remove unnecessary comments and console.log statements. 3. Use consistent indentation for better readability. 4. Use descriptive variable names instead of abbreviations to improve code understanding. 5. Use camelCase for variable names to follow standard naming conventions. 6. Remove unused variables to reduce clutter. 7. Combine similar if conditions using logical operators. 8. Use strict equality (`===`) instead of loose equality (`==`) for better type checking. Here's the updated code with the suggested improvements: ```javascript $(function() { makeAddMusicOnPageLoad(); }); function makeAddMusicOnPageLoad() { makeAddMusicMenus(); } $('#submit-music').submit(async function(event) { event.preventDefault(); let yt = $("#yt").val(); let sc = $("#sc").val(); let spot = $("#spot").val(); let atomict = $("#atomict").val(); let atomicc = ""; let mood = $("#mood option:selected").val(); let genre = $("#genre option:selected").val(); let format = $("#format option:selected").val(); let songLat = $("#submit-music-btn").attr("valueLat"); let songLng = $("#submit-music-btn").attr("valueLng"); let songIso3 = $("#submit-music-btn").attr("songIso3"); let boostSpVal = $("#boost-sp option:selected").val(); if (songIso3 === "USA" || songIso3 === "PRI") { let songCounty = $("#submit-music-btn").attr("songCounty"); let songStateID = $("#submit-music-btn").attr("songStateID"); let songCityAscii = $("#submit-music-btn").attr("songCityAscii"); } let errors = []; let spotSlug = ""; let scSlug = ""; let ytSlug = ""; let ytChannel = ""; let valid = true; if (yt) { validateYouTubeUrl(yt); } if (sc) { validateSoundcloudUrl(sc); } if (spot) { validateSpotifyUrl(spot); } if ((!spot && !sc && !yt)) { errors.push("The Sound of Silence. Good choice."); valid = false; } if ((!spot && !sc) && yt) { errors.push("πŸŽ₯ For YouTube, we require at least 1 other player of the same song/album. If you aren't yet <a style='color:green' href=https://distrokid.com/vip/seven/694648 alt='referral to Distrokid (Douglas uses Distrokid)'>distributing your music to all platforms<a/> you may use Soundcloud; playlists work."); valid = false; } if (Cookies.get('lastPost') !== undefined) { valid = false; errors.push("To combat spam, please wait 30 seconds between posts. ⏱️"); } if (genre === "" || mood === "" || format === "") { valid = false; errors.push("Don't forget about the genre, mood, and format"); } if (typeof songIso3 === 'undefined') { valid = false; errors.push("Please post on land and try again."); } if ($("#boost-title").text() === 'Log in to post') { valid = false; errors.push("You must be logged in to post."); } if ((atomict === '') && format === "n ft") { valid = false; errors.push("To use NFT format, you must include Template ID"); } if ((atomict !== '') && format !== "nft") { valid = false; errors.push("To use Template ID, you must choose NFT format "); } console.log("atomict", atomict); if (atomict !== '') { await getAtomicCollection(atomict); } let justSendIt = { "yt": ytSlug, "yt_channel": window.ytChannel ? window.ytChannel : "", "sc": scSlug, "spot": spotSlug, "mood": mood, "genre": genre, "lat": songLat, "lng": songLng, "format": format, "iso3": songIso3, "atomict": atomict, "atomicc": atomicc, "city_ascii": (typeof songCityAscii !== 'undefined') ? songCityAscii : "", "county_name": (typeof songCounty !== 'undefined') ? songCounty : "", "state_id": (typeof songStateID !== 'undefined') ? songStateID : "", "boost_sp": boostSpVal }; console.log("//justSendIt", justSendIt); if (Cookies.get('username') !== undefined) { justSendIt.username = Cookies.get('username'); } if (valid) { $.ajax({ method: "post", url: 'php/add_music.php', data: justSendIt, dataType: "json" }) .done(function(data) { console.log(data); if (data.success) { $("#add-music-error").hide(); $("#add-music-success").html('Your <a class="alert-link" href="'+window.location.protocol + "//" + window.location.host + ( !areWeLive ? "/cxc/" : "/")+'?id='+data.songid+'">music</a> has been posted to the map. πŸ‘ <br> Upvote <img style="vertical-align:middle;" src="images/icons/up12.png"> this track and it will grow bigger 🌱🌳').fadeIn(222); Cookies.set('lastPost', 'true', { expires: (1/8640) }); console.log("no duplicate error"); $("#yt, #sc, #spot").val(''); if (typeof addMusicMarker !== 'undefined') { addMusicMarker.remove(); } var marker = L.circleMarker( [songLat, songLng], { radius: 20, "title": data.songid, color: genreColors[genre], fillColor: moodColors[mood] } ) .on("click", function(e) { urlGet.id = data.songid; window.location = window.location.protocol + "//" + window.location.host + (!areWeLive ? "/cxc/" : "/") + "?id=" + urlGet.id; }) .addTo(mymap); } else { $("#music-geopol-info, #add-music-error, #add-music-success").hide(); if (data.success === false) { console.log("Error Message Should Appear"); if (typeof data.duplicate !== undefined) { $("#add-music-error").html('It looks like we already <a class="alert-link" href="'+location.protocol+'//'+location.host+location.pathname+'?id='+data.duplicate+'">have that song</a> on the map. Try another!').show(); } else { $("#add-music-error").html('A wild Error appeared. We aren\'t sure why πŸ€” Try again later.').show(); } } else { let htmlErrors = []; if (data.scInvalid) { htmlErrors.push("The Soundcloud link is in the right format, but showing nothing 🧐 Make sure it's public and try again."); } if (data.ytInvalid) { htmlErrors.push("The YouTube link seems legit, but we can't embed it. Make sure it's public and try again 🧐"); } if (data.spotInvalid) { htmlErrors.push("The Spotify link seems cool, but isn't working. Make sure it's a song not an album 🧐 Click the three dots and then \"copy song link\"."); } if (data.duplicate) { htmlErrors.push("It looks like that song is already on the map. Try another +🎡"); } console.log(errors); let htmlErrorsExpanded = htmlErrors.join("<br /><br />"); $("#add-music-error").html(htmlErrorsExpanded).show(); } } console.log(data); }) .fail(function(textStatus) { console.log({ "yt": ytSlug, "sc": scSlug, "spot": spotSlug, "mood": mood, "genre": genre, "lat": songLat, "lng": songLng, "format": format }); $("#alert-holder") .prepend('<div id="unknown-add-error-alert" class="alert alert-info bottom-alert" role="alert">Something went wrong on our end, try again in a few.</div>'); $("#unknown-add-error-alert").fadeIn(222).delay(6000).fadeOut(222); console.log("Request failed: " + JSON.stringify(textStatus)); }); } else { console.log(errors); let errorsExpanded = errors.join("<br /><br />"); $("#add-music-error").html(errorsExpanded).show(); } }); function getGeopol(songLng, songLat) { console.log(songLat); console.log(songLng); if (!isNaN(songLat)) { $.ajax({ method: "get", async: true, url: 'php/get_geopol.php', data: { lat: songLat, lng: songLng }, error: function(jqXHR, textStatus, errorThrown) {}, dataType: "json" }) .done(function(geodata) { let geopolMessage = ""; if (geodata.iso3 === undefined) { geopolMessage = "Our charts only work on land 🏝️ Please double click/tap to choose the location this music was recorded πŸŽ™οΈ"; $("#submit-music-btn").attr("missingGeoloc", "true"); } else { if (geodata.iso3 === "USA" || geodata.iso3 === "PRI") { geopolMessage = "Posting to <strong>" + geodata.city + "</strong>, <strong>" + geodata.state_id + "</strong>."; $("#submit-music-btn").attr({ "songIso3": geodata.iso3, "songCounty": geodata.county_name, "songStateID": geodata.state_id, "songCityAscii": geodata.city_ascii }); } else { geopolMessage = "Posting to <strong>" + geodata.nation + "</strong>."; $("#submit-music-btn").attr("songIso3", geodata.iso3); } } $("#music- geopol-info").html(geopolMessage).show(); }); } } function validateYouTubeUrl(passed) { let url = passed; let regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=|\?v=)([^#\&\?]*).*/; let match = url.match(regExp); if (match && match[2].length === 11) { ytSlug = match[2]; console.log('yt validation passed'); console.log(match[2]); $.ajax({ method: "get", async: false, url: 'https://www.googleapis.com/youtube/v3/videos', data: { part: "snippet", id: ytSlug, key: "YOUR_YOUTUBE_API_KEY" }, error: function(jqXHR, textStatus, errorThrown) {}, dataType: "json" }) .done(function(resultGoogle) { window.ytChannel = resultGoogle.items[0].snippet.channelId; }); } else { valid = false; console.log('youtube validation failed'); errors.push("Youtube link is invalid 🧐 You can use youtu.be or youtube.com links."); } } function validateSpotifyUrl(passed) { let url = passed; let regExp = /^.*(spotify:|spotify\.com\/track\/)([^#\&\?]*).*/; let match = url.match(regExp); if (match && match[2].length === 22) { spotSlug = match[2]; console.log('spotify validation passed'); return true; } else { valid = false; console.log('spotify validation failed'); errors.push("The Spotify link isn't working 😲 Right now, we can only embed a single track from Spotify, not an album (even a \"single\" album) πŸš«πŸ’Ώ To add one track, go to the album and click the three dots beside the track name and then click \"copy song link\" 😌 If you're posting an album, you can use the first track, or your favorite single 🎼"); } } function validateSoundcloudUrl(passed) { let url = passed; let regExp = /^.*(soundcloud\.com\/)([\w\-\.]+(\/)+[^#\&\?]*).*/; let match = url.match(regExp); if (match && match[2]) { scSlug = match[2]; console.log('SoundCloud validation passed'); return true; } else { valid = false; console.log('Soundcloud validation failed'); errors.push("Something is off with the Soundcloud link"); } } function makeAddMusicMenus() { if ($("#genre option").length === 0) { $("#genre").append('<option role="presentation" class="label-add-music" value=""><a role="menuitem" tabindex="-1" href="#">Choose a Genre</a></option>'); $.each(genreOptions, function(name, description) { if (name !== "null") { $("#genre").append('<option role="presentation" value="' + name + '"><a role="menuitem" tabindex="-1" style="color:' + genreColors[String(name)] + '" href="#">' + description + '</a></option>'); } else { $("#genre").append('<option role="presentation" value=""><a role="menuitem" tabindex="-1" href="#">Not exact? Clarify with mood</a></option>'); } }); } if ($("#mood option").length === 0) { $("#mood").append('<option role="presentation" class="label-add-music" value=""><a role="menuitem" tabindex="-1" href="#">Choose a Mood</a></option>'); $.each(moodOptions, function(name, description) { if (name !== "null") { $("#mood").append('<option role="presentation" value="' + name + '"><a role="menuitem" tabindex="-1" style="color:' + moodColors[String(name)] + '" href="#">' + description + '</a></option>'); } else { $("#mood").append('<option role="presentation" value=""><a role="menuitem" tabindex="-1" href="#">Not perfect? Put the closest</a></option>'); } }); } if ($("#format option").length === 0) { $("#format").append('<option role="presentation" class="label-add-music" value=""><a role="menuitem" tabindex="-1" href="#">Choose a Format</a></option>'); $.each(formatOptions, function(name, description) { if (name !== "null") { $("#format").append('<option role="presentation" value="' + name + '"><a role="menuitem" tabindex="-1" href="#">' + description + '</a></option>'); } else { $("#format").append('<option role="presentation" value=""><a role="menuitem" tabindex="-1" href="#">Not here? Choose the closest</a></option>'); } }); } } function getAtomicCollection(atomict) { if (atomict !== '') { $.ajax({ method: "get", url: 'https://wax.api.atomicassets.io/atomicassets/v1/templates?', data: { ids: atomict, page: "1", limit: "100" }, dataType: "json" }) .done(function(result) { console.log("check collection", result); console.log(result.data); if (result.success && result.data.length > 0) { let colData = result.data[0]; valid = false; colData.schema.format.forEach(function(field) { if (field.name === "video" || field.name === "audio") { valid = true; resolve(colData.collection.collection_name); } }); if (!valid) { errors.push("Music NFTs require an audio or video field"); resolve(false); } } else { valid = false; errors.push("Error getting NFT data. Check template id, and try again"); resolve(false); } }).fail(function() { valid = false; errors.push("We couldn't find your Atomic template"); resolve(false); }); } } getGeopol(songLng, songLat); function getGeopol(songLng, songLat) { console.log(songLat); console.log(songLng); if (!isNaN(songLat)) { $.ajax({ method: "get", async: true, url: 'php/get_geopol.php', data: { lat: songLat, lng: songLng }, error: function(jqXHR, textStatus, errorThrown) {}, dataType: "json" }) .done(function(geodata) { let geopolMessage = ""; if (geodata.iso3 === undefined) { geopolMessage = "Our charts only work on land 🏝️ Please double click/tap to choose the location this music was recorded πŸŽ™οΈ"; $("#submit-music-btn").attr(" missingGeoloc", "true"); } else { if (geodata.iso3 === "USA" || geodata.iso3 === "PRI") { geopolMessage = "Posting to <strong>" + geodata.city + "</strong>, <strong>" + geodata.state_id + "</strong>."; $("#submit-music-btn").attr({ "songIso3": geodata.iso3, "songCounty": geodata.county_name, "songStateID": geodata.state_id, "songCityAscii": geodata.city_ascii }); } else { geopolMessage = "Posting to <strong>" + geodata.nation + "</strong>."; $("#submit-music-btn").attr("songIso3", geodata.iso3); } } $("#music-geopol-info").html(geopolMessage).show(); }); } }
Add to Cart
Instant accessInstant access
Usage rightsCommercial use
Money-back guaranteeMoney‑back
By purchasing this prompt, you agree to our terms of service
GPT-4
Tested icon
Guide icon
Free credits icon
Just send this prompt to ChatGPT in 3.5 or 4, and follow up with a files-worth of code
...more
Added over 1 month ago
Report
Browse Marketplace