/ / प्रति उपयोगकर्ता पॉपअप को दोहराने के लिए एक jquery कुकी कैसे सेट करें - jquery, ruby-on-rails, ruby-on-rails-3, कुकीज़, रूबी-ऑन-रेल -4

प्रति उपयोगकर्ता पॉपअप को दोहराने के लिए एक jquery कुकी कैसे सेट करें - jquery, ruby-on-rails, ruby-on-rails-3, कुकीज़, रूबी-ऑन-रेल -4

तो, अगर तुम मेरे पास जाओ स्टेजिंग सर्वर आप एक मिनी ट्यूटोरियल देखेंगे जिसे मैंने उपयोग किया है यह उपकरण

हालांकि, अगर आप उस मामले के लिए साइन-अप या किसी अन्य पृष्ठ पर क्लिक करते हैं, तो ट्यूटोरियल पॉप-अप जारी रहेगा। तो, मैं कुकी कैसे बना सकता हूं ताकि यह केवल प्रति उपयोगकर्ता एक बार प्रदर्शित हो सके?

मैंने कोशिश की jquery कुकीहालांकि, यह पता नहीं लगा सकता कि यह कैसे काम कर रहा है।

यह जो मैंने किया है:

1. Copied jquery.cookie.js into assets/javascript/jquery.cookie.js
2. Created a new file called cookie.js
3. Added this arbitrary code: $.cookie(guider, true);

अब दिमाग में, मुझे वास्तव में पता नहीं है कि मुझे cookie.js में कौन सा कोड डालना है ताकि इसे guiders.js टूल के लिए कुकी जोड़ सकें। इसलिए, कि मार्गदर्शक केवल एक बार प्रदर्शित होंगे।

हम इसे काम करने के लिए कैसे प्राप्त कर सकते हैं? केवल प्रति उपयोगकर्ता एक बार प्रदर्शित करें।

Guiders.js कोड:

guiders.createGuider({
buttons: [{ name: "Next" }]
, description: "Follow this short 7 tip tutorial and learn how to get the most out of Leap. It will only take a few minutes :)"
, id: "first"
, next: "second"
, overlay: true
, title: "Welcome to LeapFM! Mini Tutorial:"
}).show();

guiders.createGuider({
attachTo: ".title"
, buttons: [{name: "Close"}, {name: "Next"}]
, description: "The number of leaps a song gets determines how high it will rank on the charts. A song with more leaps will rank higher than a song with less leaps."
, id: "second"
, next: "third"
, position: 7
, title: "Tip 1. Ranking system:"
});

guiders.createGuider({
attachTo: ".arrow"
, buttons: [{name: "Close"}, {name: "Next"}]
, description: "To add a leap to a song simply hit the up arrow. You must be logged in to add 1 leap. Users can only add 1 leap per song."
, id: "third"
, next: "fourth"
, position: 2
, title: "Tip 2. Adding leaps:"
});

guiders.createGuider({
attachTo: ".title"
, buttons: [{name: "Close"}, {name: "Next"}]
, description: "You can view the songs genres within the parentheses"
, id: "fourth"
, next: "fifth"
, position: 6
, title: "Tip 3. Genres:"
});


guiders.createGuider({
attachTo: ".song"
, buttons: [{name: "Close"}, {name: "Next"}]
, description: "By clicking the song title you can listen to the song, comment on it and share it with the social media buttons. But dont"t do it yet, lets finish the tutorial first!"
, id: "fifth"
, next: "sixth"
, position: 7
, title: "Tip 4. Listening to songs:"
});

guiders.createGuider({
attachTo: "#query"
, buttons: [{name: "Close"}, {name: "Next"}]
, description: "You can search songs by genre, title or artist."
, id: "sixth"
, next: "seventh"
, position: 5
, title: "Tip 5. Search:"
});

guiders.createGuider({
attachTo: ".left"
, buttons: [{name: "Close"}, {name: "Next"}]
, description: "You must be logged in to submit a song. LeapFM only accepts YouTube urls so your song must first be on YouTube."
, id: "seventh"
, next: "eigth"
, position: 7
, title: "Tip 6. Submit a song:"
});

guiders.createGuider({
attachTo: ".newsongs"
, buttons: [{name: "Close"}, {name: "Next"}]
, description: "By clicking "New songs" you will be able to view the songs from upload date (newest to oldest). Where as the default page displays songs by leap/rank."
, id: "eigth"
, next: "ninth"
, position: 7
, title: "Tip 7. Newest to oldest:"
});

guiders.createGuider({
attachTo: ".signup"
, buttons: [{name: "Close"}]
, description: "Sign up and start participating :)"
, id: "ninth"
, next: "tenth"
, position: 5
, title: "Call to action!"
});

उत्तर:

जवाब के लिए 0 № 1

स्थानीय भंडारण आपका मित्र है, और गैर-सहायक ब्राउज़र के लिए आप पॉलीफ़िल का उपयोग कर सकते हैं MDN :

if ( ! localStorage.getItem("visited") ) {
localStorage.setItem("visited", true);
runMyTutorial();
}