Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 27
  1. #11
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    I need a code like this for my Habbo Home script.

    I need it so you can drag the DIV layer around and then either click a button to save the co-ords or it just saves them when the layer is moved. I guess it could be done using cookies aslong as it is done effitiently.

  2. #12
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Create a link, run a function.
    use the function to getbyid the dragable layer, and save its x y co ords somewhere, on load, set them by when its generated as the top and left css paramiters.
    Easy as pie. although the script works from position relative, not absoulte positioning, so you should choose one and stick with it.

  3. #13
    Topps Guest

    Default

    Quote Originally Posted by nets View Post
    Does it have to be saved permanently, or could it be saved in a cookie (positions would be lost once the user clears their cookies)? It would be easier and more efficient to use cookies, if that's a viable option.
    Cookie would be great just warn the user it will go back to it's normal state once cleared their cookies.

  4. #14
    Join Date
    Aug 2004
    Location
    bristol
    Posts
    3,799
    Tokens
    0

    Latest Awards:

    Default

    I've written a script allowing clients to drag elements. However, once dragged the element's position is saved within a cookie. Upon page load, the element (identified by its ID) is moved into the position given by the cookie. I could easily implement a httpRequest object allowing for the positions to be saved on your server (if desired).

    Code:
    <script>
    
      window.onload = function () {
        var cookies = document.cookie.split('; ');
        for(var i=0; i<cookies.length; i++) {
          var cookie = cookies[i];
          if(cookie.match(/^position/)) {
            exp = cookie.substr(8).split('=');
            positions = exp[1].split('|');
            document.getElementById(exp[0]).style.top = positions[0];
            document.getElementById(exp[0]).style.left = positions[1];
          }
        }
      }
    
      document.onmouseup = function(e) {
        e = e?e:window.event;
        t = e.target?e.target:e.srcElement;
        document.onmousemove = '';
    
        if(t.className == 'drag') {
          var date = new Date();
          date.setTime(date.getTime()+1209600000);
          document.cookie = "position"+t.id+"="+t.style.top+"|"+t.style.left+"; expires="+date.toGMTString()+"; path=/";
        }
      }
    
      document.onmousedown = function(e) {
        e = e?e:window.event;
        t = e.target?e.target:e.srcElement;
    
        if(t.className == 'drag') {
          xy= e.clientY - parseInt(t.style.top);
          xx= e.clientX - parseInt(t.style.left);
    
          document.onmousemove = function uc(e) {
            e = e ? e : window.event;
            t.style.top = e.clientY - xy;
            t.style.left = e.clientX - xx;
            return false;
          }
    
          return false;
        }
      }
    
    </script>
    Typical usage:
    HTML Code:
    <img style="left: 150px; top: 150px; position: absolute;" src='example.jpg' id='example' class='drag'>
    <img style="left: 150px; top: 150px; position: absolute;" src='example2.jpg' id='example2' class='drag'>
    kinda quit.

  5. #15
    Topps Guest

    Default

    Quote Originally Posted by nets View Post
    I've written a script allowing clients to drag elements. However, once dragged the element's position is saved within a cookie. Upon page load, the element (identified by its ID) is moved into the position given by the cookie. I could easily implement a httpRequest object allowing for the positions to be saved on your server (if desired).

    Code:
    <script>
    
      window.onload = function () {
        var cookies = document.cookie.split('; ');
        for(var i=0; i<cookies.length; i++) {
          var cookie = cookies[i];
          if(cookie.match(/^position/)) {
            exp = cookie.substr(8).split('=');
            positions = exp[1].split('|');
            document.getElementById(exp[0]).style.top = positions[0];
            document.getElementById(exp[0]).style.left = positions[1];
          }
        }
      }
    
      document.onmouseup = function(e) {
        e = e?e:window.event;
        t = e.target?e.target:e.srcElement;
        document.onmousemove = '';
    
        if(t.className == 'drag') {
          var date = new Date();
          date.setTime(date.getTime()+1209600000);
          document.cookie = "position"+t.id+"="+t.style.top+"|"+t.style.left+"; expires="+date.toGMTString()+"; path=/";
        }
      }
    
      document.onmousedown = function(e) {
        e = e?e:window.event;
        t = e.target?e.target:e.srcElement;
    
        if(t.className == 'drag') {
          xy= e.clientY - parseInt(t.style.top);
          xx= e.clientX - parseInt(t.style.left);
    
          document.onmousemove = function uc(e) {
            e = e ? e : window.event;
            t.style.top = e.clientY - xy;
            t.style.left = e.clientX - xx;
            return false;
          }
    
          return false;
        }
      }
    
    </script>
    Typical usage:
    HTML Code:
    <img style="left: 150px; top: 150px; position: absolute;" src='example.jpg' id='example' class='drag'>
    <img style="left: 150px; top: 150px; position: absolute;" src='example2.jpg' id='example2' class='drag'>
    Would there be a way to make it so it is viewable to everyone else and not just the user?

  6. #16
    Join Date
    Aug 2004
    Location
    bristol
    Posts
    3,799
    Tokens
    0

    Latest Awards:

    Default

    Do you mean, so other people can view it but not edit it?
    kinda quit.

  7. #17
    Topps Guest

    Default

    Quote Originally Posted by nets View Post
    Do you mean, so other people can view it but not edit it?
    Yes. Would it be hard? :S

  8. #18
    Join Date
    Aug 2004
    Location
    bristol
    Posts
    3,799
    Tokens
    0

    Latest Awards:

    Default

    No, but I'm assuming you would need to have some form of a user system.
    kinda quit.

  9. #19
    Join Date
    Mar 2007
    Location
    Kent
    Posts
    11,415
    Tokens
    787

    Latest Awards:

    Default

    so a new habbo home tbh?

  10. #20
    Topps Guest

    Default

    Quote Originally Posted by nets View Post
    No, but I'm assuming you would need to have some form of a user system.
    I have a very simple one.

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •