PageSourceSearch

https://www.rosecelebrationsrentals.com/cp/resources/js/box_autosort.js?2

js rosecelebrationsrentals.com collected 2026-10-04 08:49:35 UTC 4,330 bytes, 156 lines download raw bytes

1use_box_classname = "bc";
2function box_classname() {
3  return use_box_classname;
4}
5
6function find_highest_position_available(boxes_across) {
7  var dstr = "";
8  var prefbox = new Array();
9  prefbox["id"] = 0;
10  prefbox["top"] = 0;
11  prefbox["left"] = 0;
12  for (var c = 1; c <= boxes_across; c++) {
13    setelem = false;
14    var elempos = getElementPosition("cn" + c);
15    var elem_top = elempos["top"] * 1 + elempos["height"] * 1;
16    var elem_left = elempos["left"] * 1;
17    dstr += c + ") " + elem_top + "\n";
18    if (prefbox["id"] == 0) setelem = true;
19    else {
20      if (elem_top < prefbox["top"] * 1) setelem = true;
21      else if (
22        elem_top == prefbox["top"] * 1 &&
23        elem_left < prefbox["left"] * 1
24      )
25        setelem = true;
26    }
27    if (setelem) {
28      prefbox["id"] = c;
29      prefbox["top"] = elem_top;
30      prefbox["left"] = elem_left;
31    }
32  }
33  return prefbox["id"];
34}
35
36function reset_box_positions() {
37  var box_counts = get_box_counts();
38  boxes_across = box_counts["across"];
39  total_boxes = box_counts["total"];
40
41  for (var b = 1; b <= total_boxes; b++) {
42    tobj = document.getElementById("bx" + b);
43    var append_to = document.getElementById("cn" + b);
44    if (tobj && append_to) {
45      append_to.appendChild(tobj);
46    }
47  }
48}
49
50function arrange_boxes(set_box_classname) {
51  if (set_box_classname) use_box_classname = set_box_classname;
52  reset_box_positions();
53
54  var box_counts = get_box_counts();
55  boxes_across = box_counts["across"];
56  total_boxes = box_counts["total"];
57
58  for (var b = boxes_across + 1; b <= total_boxes; b++) {
59    arrange_box(b, boxes_across);
60  }
61}
62
63function arrange_box(boxn, boxes_across) {
64  var highest_box = find_highest_position_available(boxes_across);
65  tobj = document.getElementById("bx" + boxn);
66  var append_to = document.getElementById("cn" + highest_box);
67  if (tobj && append_to) {
68    append_to.appendChild(tobj);
69  }
70}
71
72function start_arrange_boxes() {
73  setTimeout("arrange_boxes()", 100);
74}
75
76//window.onload = start_arrange_boxes();
77function test_two_col() {
78  if (document.getElementById("box_container").style.width == "500px")
79    setwidth = "800px";
80  else setwidth = "500px";
81  document.getElementById("box_container").style.width = setwidth;
82  reset_box_positions();
83  //arrange_boxes();
84}
85
86function get_box_counts() {
87  var box_counts = new Array();
88  var bcelems;
89  if (element_exists("main_section_editor_container")) {
90    bcelems = document
91      .getElementById("main_section_editor_container")
92      .getElementsByClassName(box_classname());
93  } else {
94    bcelems = document.getElementsByClassName(box_classname());
95  }
96  box_counts["total"] = bcelems.length;
97  highest_top = 0;
98  highest_count = 0;
99  dstr = "";
100  for (var b = 1; b <= bcelems.length; b++) {
101    var celem = bcelems[b - 1];
102    if (!celem.hasAttribute("id")) {
103      celem.id = "cn" + b;
104      innerelem = celem.firstElementChild;
105      innerelem.id = "bx" + b;
106      dstr += celem.id + "-" + innerelem.id + ") " + elem_top + "\n";
107    }
108
109    var elempos = getObjPosition(celem);
110    var elem_top = elempos["top"] * 1;
111    var use_elem = false;
112
113    if (elempos["height"] * 1 > 10) {
114      if (highest_count == 0) {
115        highest_top = elem_top;
116        highest_count = 1;
117      } else if (highest_top * 1 == elem_top * 1) {
118        highest_count++;
119      } else if (elem_top * 1 < highest_top * 1) {
120        highest_top = elem_top;
121        highest_count = 1;
122      }
123    }
124  }
125  //if(dstr!='') alert(dstr);
126  box_counts["across"] = highest_count;
127  return box_counts;
128}
129
130function exec_enable_auto_box_sort(set_box_classname) {
131  use_box_classname = set_box_classname;
132  start_arrange_boxes();
133  //window.addEventListener("resize", start_arrange_boxes);
134}
135
136function string_contained_in_path(str_in_path) {
137  var pathstr = "" + window.location + "";
138  if (pathstr.indexOf(str_in_path) == -1) return false;
139  else return true;
140}
141
142function enable_auto_box_sort(set_box_classname) {
143  // Global variable to disable auto box sort
144  if (window.disable_auto_box_sort) {
145    return;
146  }
147
148  exec_enable_auto_box_sort(set_box_classname);
149
150  if (string_contained_in_path("/checkout/")) {
151    if (set_box_classname == "col-md-6") {
152      exec_enable_auto_box_sort("col-md-4");
153    }
154    setTimeout('exec_enable_auto_box_sort("' + set_box_classname + '")', 180);
155  }
156}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.