File: view-image-information.js

package info (click to toggle)
webdeveloper 1.2.5%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,364 kB
  • ctags: 1,608
  • sloc: makefile: 10
file content (164 lines) | stat: -rw-r--r-- 5,301 bytes parent folder | download
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
var WebDeveloper = WebDeveloper || {};

WebDeveloper.Generated = WebDeveloper.Generated || {};

// Displays an image
WebDeveloper.Generated.displayImage = function(image, container, imagesCounter, locale)
{
  var anchor         = "image-" + imagesCounter;
  var childElement   = document.createElement("th");
  var element        = document.createElement("tr");
  var imageSrc       = image.src;
  var linkElement    = document.createElement("a");
  var table          = document.createElement("table");
  var tableContainer = document.createElement("thead");

  childElement.appendChild(document.createTextNode(locale.property));
  element.appendChild(childElement);

  childElement = document.createElement("th");

  childElement.appendChild(document.createTextNode(locale.value));
  element.appendChild(childElement);
  tableContainer.appendChild(element);
  table.setAttribute("class", "table table-bordered table-striped");
  table.appendChild(tableContainer);

  tableContainer = document.createElement("tbody");
  childElement   = document.createElement("td");
  element        = document.createElement("tr");

  childElement.appendChild(document.createTextNode(locale.src));
  element.appendChild(childElement);

  childElement = document.createElement("td");

  linkElement.appendChild(document.createTextNode(imageSrc));
  linkElement.setAttribute("href", imageSrc);
  linkElement.setAttribute("target", "_blank");
  childElement.appendChild(linkElement);
  element.appendChild(childElement);
  tableContainer.appendChild(element);

  childElement = document.createElement("td");
  element      = document.createElement("tr");

  childElement.appendChild(document.createTextNode(locale.width));
  element.appendChild(childElement);

  childElement = document.createElement("td");

  childElement.appendChild(document.createTextNode(image.width));
  element.appendChild(childElement);
  tableContainer.appendChild(element);

  childElement = document.createElement("td");
  element      = document.createElement("tr");

  childElement.appendChild(document.createTextNode(locale.height));
  element.appendChild(childElement);

  childElement = document.createElement("td");

  childElement.appendChild(document.createTextNode(image.height));
  element.appendChild(childElement);
  tableContainer.appendChild(element);

  // If the image has an alt attribute
  if(image.alt)
  {
    childElement = document.createElement("td");
    element      = document.createElement("tr");

    childElement.appendChild(document.createTextNode(locale.alt));
    element.appendChild(childElement);

    childElement = document.createElement("td");

    childElement.appendChild(document.createTextNode(image.alt));
    element.appendChild(childElement);
    tableContainer.appendChild(element);
  }

  table.appendChild(tableContainer);

  childElement = document.createElement("img");
  element      = document.createElement("div");

  childElement.setAttribute("src", imageSrc);
  element.setAttribute("class", "web-developer-image");
  element.setAttribute("id", anchor);
  element.appendChild(childElement);
  container.appendChild(element);
  container.appendChild(table);

  element = document.createElement("div");

  element.setAttribute("class", "web-developer-separator");
  container.appendChild(element);
  document.getElementById("content").appendChild(container);

  childElement = document.createElement("a");
  element      = document.createElement("li");

  childElement.appendChild(document.createTextNode(WebDeveloper.Generated.formatURL(imageSrc)));
  childElement.setAttribute("href", "#" + anchor);
  $(".dropdown-menu", $("#images-dropdown")).get(0).appendChild(element);
};

// Initializes the page with data
WebDeveloper.Generated.initialize = function(data, locale)
{
  var container         = null;
  var contentDocument   = null;
  var documents         = data.documents;
  var imageDescription  = null;
  var images            = null;
  var imagesCounter     = 1;
  var imagesDescription = locale.images;
  var imagesDropdown    = $("#images-dropdown");
  var imagesLength      = null;

  WebDeveloper.Generated.emptyContent();
  WebDeveloper.Generated.localizeHeader(locale);
  WebDeveloper.Generated.setPageTitle(imagesDescription, data, locale);

  $(".dropdown-toggle", imagesDropdown).prepend(imagesDescription);

  // Loop through the documents
  for(var i = 0, l = documents.length; i < l; i++)
  {
    contentDocument  = documents[i];
    imageDescription = imagesDescription.toLowerCase();
    images           = contentDocument.images;
    imagesLength     = images.length;

    // If there is only one image
    if(imagesLength == 1)
    {
      imageDescription = locale.image.toLowerCase();
    }

    WebDeveloper.Generated.addDocument(contentDocument.url, i, imageDescription, imagesLength);

    // If there are images
    if(imagesLength > 0)
    {
      container = WebDeveloper.Generated.generateDocumentContainer();

      // Loop through the images
      for(var j = 0; j < imagesLength; j++)
      {
        WebDeveloper.Generated.displayImage(images[j], container, imagesCounter, locale);

        imagesCounter++;
      }
    }
    else
    {
      WebDeveloper.Generated.addSeparator();
    }
  }

  WebDeveloper.Generated.initializeCommonElements();
};