The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Do not save your changes

View previous topic View next topic Go down

Do not save your changes

Post by hamesashek on July 4th 2017, 4:52 pm

Hello

I have a problem with this code
Do not save your changes
This code places a specific color into a specific item, but a problem occurs when the page is not updated and it returns to its default state
If you can help


Show icon:

Code:

$(document).ready(function(){
 $(function(){
  $('#colorwheel .colors').each(function(i){
  $(this).attr('id','color_' + ++i);
  });
 });
 
 var speed = 500;
 
 function hex(rgb){
  rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
  return '#' +
  ('0' + parseInt(rgb[1],10).toString(16)).slice(-2) +
  ('0' + parseInt(rgb[2],10).toString(16)).slice(-2) +
  ('0' + parseInt(rgb[3],10).toString(16)).slice(-2);
 }
 
 $(function(){
  $('.prev').bind('click',function(){ slide('prev'); });
  $('.next').bind('click',function(){ slide('next'); });
  $('.colors').last().addClass('active');
  function slide($control) {
  var $active = $('.active'),
  $next = $active.next().length ? $active.next() : $('.colors').first(),
  $prev = $active.prev().length ? $active.prev() : $('.colors').last();
  console.log('next',$next);
  console.log('prev',$prev);
  if ($control === 'next'){
  console.log($control);
  $active.removeClass('active');
  $next.addClass('active');
  var $activeBg = $('.active .color').first().css('backgroundColor');
  $('#info .info-bg').animate({ backgroundColor: $activeBg },speed);
  $('#info .arrow').animate({ 'border-bottom-color': $activeBg },speed);
  var big = $('.active .color').first().css('backgroundColor'),
  medium = $('.active .color').first().next().css('backgroundColor'),
  small = $('.active .color').last().css('backgroundColor');
  $('#info .values .big span').text(hex(big));
     $('#info .values .medium span').text(hex(medium));
     $('#info .values .small span').text(hex(small));
  }
  if ($control === 'prev'){
  console.log($control);
  $active.removeClass('active');
  $prev.addClass('active');
  var $activeBg = $('.active .color').first().css('backgroundColor');
  $('#info .info-bg').animate({ backgroundColor: $activeBg },speed);
  $('#info .arrow').animate({ 'border-bottom-color': $activeBg },speed);
  var big = $('.active .color').first().css('backgroundColor'),
  medium = $('.active .color').first().next().css('backgroundColor'),
  small = $('.active .color').last().css('backgroundColor');
  $('#info .values .big span').text(hex(big));
     $('#info .values .medium span').text(hex(medium));
     $('#info .values .small span').text(hex(small));
  }
  }
 });
 
 $(function(){
  var $activeBg = $('.active .color').first().css('backgroundColor');
  $('#info .info-bg').css({ backgroundColor: $activeBg });
  $('#info .arrow').css({ 'border-bottom-color': $activeBg });
  var big = $('.active .color').first().css('backgroundColor'),
  medium = $('.active .color').first().next().css('backgroundColor'),
  small = $('.active .color').last().css('backgroundColor');
  $('#info .values .big span').text(hex(big));
  $('#info .values .medium span').text(hex(medium));
  $('#info .values .small span').text(hex(small));
 });
 
 $(function(){
  var $frame = $('.frame'), angle = 0;
  $('.next').rotate({
  bind: {
  click: function(){
  angle -= 30;
  $frame.rotate({ duration: speed*2, animateTo: angle, easing: $.easing.easeOutElastic });
  }
  }
  });
  $('.prev').rotate({
  bind: {
  click: function(){
  angle += 30;
  $frame.rotate({ duration: speed*2, animateTo: angle, easing: $.easing.easeOutElastic });
  }
  }
  });
 });
});

avatar
hamesashek
Forumember

Male Posts : 103
Reputation : 1
Language : hamesashek

http://bestk.forumegypt.net

Back to top Go down

Re: Do not save your changes

Post by hamesashek on July 6th 2017, 1:21 am

Does anyone know its programming?
Is there no help?
avatar
hamesashek
Forumember

Male Posts : 103
Reputation : 1
Language : hamesashek

http://bestk.forumegypt.net

Back to top Go down

Re: Do not save your changes

Post by SLGray on July 6th 2017, 1:29 am

I really do not understand the issue. Could you please screenshots of the issue?


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

avatar
SLGray
Administrator
Administrator

Male Posts : 39122
Reputation : 2625
Language : English
Location : United States

https://fmthemes.forumotion.com/

Back to top Go down

Re: Do not save your changes

Post by hamesashek on July 7th 2017, 12:49 am

Hi
How can I put cookies?
To save the changes you made to the JavaScript example?

Code:



var themeCookie=my_getcookie("bubcloud");""!==themeCookie&&null!==themeCookie&&(themeCookie=themeCookie.split("|"),themeChoose(themeCookie[0],themeCookie[1],themeCookie[2]),
avatar
hamesashek
Forumember

Male Posts : 103
Reputation : 1
Language : hamesashek

http://bestk.forumegypt.net

Back to top Go down

Re: Do not save your changes

Post by SLGray on July 8th 2017, 3:49 am

What do mean by when the page is not updated?


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

avatar
SLGray
Administrator
Administrator

Male Posts : 39122
Reputation : 2625
Language : English
Location : United States

https://fmthemes.forumotion.com/

Back to top Go down

Re: Do not save your changes

Post by Wolfuryo on July 8th 2017, 6:31 am

Hi,

I don't understand what that code is supposed to do. If you want to save something, I would recommend using the localStorage API instead of the cookies. It's much easier to use in my opinion:
Code:
if(localStorage && localStorage.getItem("item")){
/*The data is saved and can be used:localStorage.getItem("item") or localStorage.item returns the data*/
} else {
/*The data is not saved, we have to get it and then save it with localStorage.setItem("item", "data")*/
}

About the localStorage API's methods:
-getItem()
it receives the name of the item as a parameter and returns it's value if it exists or null if it doesn't exists
-setItem()
it receives the name of the item as the first parameter and the value as the second parameter
-deleteItem()
it receives the name of the item as the parameter and deletes that item from localStorage
avatar
Wolfuryo
Forumember

Posts : 346
Reputation : 92
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Re: Do not save your changes

Post by Luiz~ on July 11th 2017, 1:11 am

If you want to work with cookies, you should use:
Code:
my_setcookie('key', 'value'); // To set a cookie.

And:
Code:
my_getcookie('key'); // To get a cookie.

---

Example:
Code:
my_setcookie('esf', 'English Support Forum');

/**
 * Now, we want to get this cookie:
 */
my_getcookie('esf'); // "English Support Forum"

This is a little plugin that is available on all FM forums.

o/
avatar
Luiz~
New Member

Male Posts : 16
Reputation : 7
Language : PT
Location : Brazil

http://ajuda.forumeiros.com/

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum