summaryrefslogtreecommitdiff
path: root/static/tests/space.packing/search.html
blob: 34065d4c79f82efc808079a67df17a136bbacd95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html>
<html>
  <head>
    <title>dump.fm image packing test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="description" content="dump.fm - Talk with pictures!" />
    <link rel="stylesheet" type="text/css" href="http://dump.fm/static/css/dump.css">
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://dump.fm/static/js/pichat.js"></script>
    <script type="text/javascript" src="spacefill.js"></script>
    <script type="text/javascript" src="search.js"></script>

  <style>
  html,body,img,div{margin:0; border:0; padding:0}
  body { overflow: visible;}
  img { max-width: 400px; max-height: 400px;}
  h1 { display:inline-block; margin: 20px; font-size: 30px;}
  #content { position: relative; width: 100%; overflow: visible; }
  fieldset { display: inline }
  p { margin-left: 20px; display: inline-block; }
  #content a.animating canvas { display: none }
  </style>

<script>

$(document).ready(Search.init)

function initSpaceFill(){

  $("#content").html("")

  getWindowSize()

  SpaceFill.init({
    "container": "#content",
    "width": Width,
    "height": Height,
    "type": "columns",
    "spacing": "justify",
    "minMargin": 16,
    "columnWidth": 200
  })


  setTimeout(fill, 50)
}


function fill(){

  //if (ColumnFill.isSpaceFilled()) return;

  if(Search.imageCache.loadedImages.length) {
    var img = Search.imageCache.loadedImages.shift()

    var j = Search.imageCache.displayedImages.length
    Search.imageCache.displayedImages.push(img)    
    var width = img.width
    var height = img.height
    
    if (width > SpaceFill.config.columnWidth) {
      scaleFactor = SpaceFill.config.columnWidth / width
      width = SpaceFill.config.columnWidth
      height = Math.floor(height * scaleFactor)
    }
    img.adjWidth = width
    img.adjHeight = height
    
    var c = document.createElement("canvas")
    c.width = width
    c.height = height

    var ctx = c.getContext('2d');
    ctx.drawImage(img, 0, 0, c.width, c.height)

    var a = document.createElement("a")
    a.index = j
    a.href = img.src
    a.style.width = width + "px"
    a.style.height = height + "px"
    a.id = "imagelink-" + j;

    a.appendChild(c)
    
    SpaceFill.add(a)
  }

  setTimeout(fill, 200)

}

function getWindowSize(){
  Width = $(document).width()
  Height = $(document).height()
}



</script>
</head>
<body>

  <center>search dumps: <input type="text" name="search-query" id="search-query" /></center><br><br>
  <center><div id="message"></div><br><br></center>
  <div id="content"></div>


</body>
</html>