PageSourceSearch

https://vratzadnes.com/Templates/vratzadnes/assets/custom.js

js vratzadnes.com collected 2026-10-02 06:10:44 UTC 5,782 bytes, 153 lines download raw bytes

1// var url = "api/page.php?n=195395&prev=0&next=10";
2// $.get(url, function(data){
3//      var article = $(".sPage").first();
4//      var content =  article.parent();
5//      $.each(data, function(i, page){
6//          var p = article;
7//          p.find("a").attr('href', page.name.link);
8//          p.find('a').text(page.name.str);
9//          p.appendTo(p.parent());
10//       });
11// });
12// 
13// var url = 'api/?command=newest_pages&SiteID=922&n=13321&limit=5'
14// $.get(url, function(data){
15//     $.each(data, function(k, v){
16//         var html = '<div class="news_preview">' +
17//                ' <div class="image"><a href="#">zaglavie</a></div>' +
18//                ' <h2 class="title"><a href="#">zaglavie</a></h2>' +
19//                ' <span class="label">label</span>&nbsp;<span class="counter-visits">123</span>'+
20//                ' <br clear="all">'+
21//                ' <p class="text">content</p></div>';
22//         $("#recent_news").append(html);
23//     }); 
24// 
25// });
26
27/* ---------------------------------------------------------------
28 * img_render.php thumbnails
29 * URL: /img/{img_dir}/{format}/{profile}/{size}/{file}
30 * Thumbs are generated once and cached on disk under /img/.
31 * Replaces the old on-the-fly /img_preview.php?image_file=...
32 * ------------------------------------------------------------- */
33var MS_IMG_DIR     = 1003;       // image_dirs.ID for SiteID 922 => web/images/upload/922
34var MS_IMG_FORMAT  = "jpg";
35var MS_IMG_PROFILE = "default";
36
37// image_src comes from the API as "web/images/upload/922/21.jpg";
38// img_render.php resolves the directory itself, so only the file name is passed.
39function msImgUrl(image_src, size, image_dir) {
40  var dir  = parseInt(image_dir, 10) > 0 ? parseInt(image_dir, 10) : MS_IMG_DIR;
41  var file = String(image_src || "").split("?")[0].split("/").pop();
42
43  if (!file) {
44    // "ph" profile renders a generated placeholder instead of 404
45    return "/img/" + dir + "/" + MS_IMG_FORMAT + "/ph/" + size + "/placeholder.jpg";
46  }
47
48  return "/img/" + dir + "/" + MS_IMG_FORMAT + "/" + MS_IMG_PROFILE + "/" + size + "/" + encodeURIComponent(file);
49}
50
51function trimByWord(sentence) {
52  var result = sentence;
53  var resultArray = result.split(" ");
54  if (resultArray.length > 30) {
55    resultArray = resultArray.slice(0, 30);
56    result = resultArray.join(" ") + "...";
57  }
58  return result.trim();
59}
60
61function appendNews(url, selector)
62{
63    var s = selector;
64    $.get(url, function(data){
65        $.each(data, function(k, v){
66            hot = '   |    <i class="fa fa-calendar" aria-hidden="true"></i>   ' + v.date_added;
67            var html = '<div class="post-container">'+
68                       '<h3 class="post-title"><a href="page.php?n='+v.n+'&SiteID='+v.SiteID+'">'+v.Name+'</a></h3>'+
69                       '<div class="post-thumb"><img src="'+msImgUrl(v.image_src, 280, v.image_dir)+'" alt="'+v.imageName+'"/></div>'+
70                       '<div class="post-content">'+
71                       '<p><span><i class="fa fa-eye" aria-hidden="true"></i> ' + v.preview +' ' + hot +'</span></p>' +
72                       '<p>'+ trimByWord(v.textStr) +'</p></div></div>';
73            $(s).append(html);
74        }); 
75    });
76}
77
78function get(url) {
79  // Return a new promise.
80  return new Promise(function(resolve, reject) {
81    // Do the usual XHR stuff
82    var req = new XMLHttpRequest();
83    req.open('GET', url);
84
85    req.onload = function() {
86      // This is called even on 404 etc
87      // so check the status
88      if (req.status == 200) {
89        // Resolve the promise with the response text
90        resolve(req.response);
91      }
92      else {
93        // Otherwise reject with the status text
94        // which will hopefully be a meaningful error
95        reject(Error(req.statusText));
96      }
97    };
98
99    // Handle network errors
100    req.onerror = function() {
101      reject(Error("Network Error"));
102    };
103
104    // Make the request
105    req.send();
106  });
107}
108
109// {{msImg this 218}} -> /img/1003/jpg/default/218/21.jpg
110Handlebars.registerHelper("msImg", function(page, size) {
111  if (!page || typeof page !== "object") { page = {}; }
112  return msImgUrl(page.image_src, parseInt(size, 10) || 218, page.image_dir);
113});
114
115Handlebars.registerHelper("showHr", function(index_count,block) {
116  if(parseInt(index_count)%2=== 0){
117    return block.fn(this);}
118});
119
120Handlebars.registerHelper("indexEqual", function(index_count,block) {
121  if(parseInt(index_count) === 6){
122    return block.fn(this);}
123});
124Handlebars.registerHelper("indexBiggerThan", function(index_count,block) {
125  if(parseInt(index_count) >= 6){
126    return block.fn(this);}
127});
128
129function constructLiveNewsContainer(article) {
130    liveNewsStorage[article.n] = article;
131    var articles = liveNewsStorage;
132    html = "";
133    for (i in articles){
134        var article = articles[i];
135        html += articleJSONtoHTML(article);
136    }
137    $("#currentReaders").html(html);
138}
139
140function articleJSONtoHTML(data)
141{
142    hot = '   |    <i class="fa fa-calendar" aria-hidden="true"></i>   ' + data.date_added;
143    var html = '<div class="post-container">'+
144               '<h3 class="post-title"><a href="page.php?n='+data.n+'&SiteID='+data.SiteID+'">'+data.name+'</a></h3>';
145    if(data.img && data.img != "web/images/upload/922/images.jpg"){
146        html+= '<div class="post-thumb">';
147        html+= '<img src="/'+data.img+'" alt="'+data.imageName+'"/></div>';
148    }
149    html += '<div class="post-content">'+
150               '<p><span><i class="fa fa-eye" aria-hidden="true"></i> ' + data.preview +' ' + hot +'</span></p>' +
151               '<p>'+ trimByWord(data.content) +'</p></div></div>';
152    return html;
153}

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.