PageSourceSearch

https://afishi.ru/sites/all/modules/vote_up_down/ajax_vote_up_down.js

js afishi.ru collected 2026-10-04 23:19:29 UTC 2,000 bytes, 62 lines download raw bytes

1// $Id: ajax_vote_up_down.js,v 1.5 2006/11/24 13:18:35 frjo Exp $
2
3Drupal.voteUpDownAutoAttach = function() {
4  var vdb = [];
5  $('span.vote-up-inact, span.vote-down-inact, span.vote-up-act, span.vote-down-act').each(function () {
6    // Read in the path to the PHP handler
7    uri = $(this).attr('title');
8    // Remove the title, so no tooltip will display
9    $(this).removeAttr('title');
10    // remove href link
11    $(this).html('');
12    // Create an object with this uri. Because
13    // we feed in the span as an argument, we'll be able
14    // to attach events to this element.
15    if (!vdb[uri]) {
16      vdb[uri] = new Drupal.VDB(this, uri);
17    }
18  });
19}
20
21/**
22 * A Vote DataBase object
23 */
24Drupal.VDB = function(elt, uri, id) {
25  var db = this;
26  // By making the span element a property of this object,
27  // we get the ability to attach behaviours to that element.
28  this.elt = elt;
29  this.uri = uri;
30  this.id = $(elt).attr('id');
31  this.dir1 = this.id.indexOf('vote_up') > -1 ? 'up' : 'down';
32  this.dir2 = this.dir1 == 'up' ? 'down' : 'up';
33  $(elt).click(function() {
34    // Ajax GET request for vote data
35    $.ajax({
36      type: "GET",
37      url: db.uri,
38      success: function (data) {
39        // extract the cid so we can change other elements for the same cid
40        var cid = db.id.match(/[0-9]+$/);
41        var pid = 'vote_points_' + cid;
42        //update the voting arrows
43        $('#' + db.id + '.vote-' + db.dir1 + '-inact')
44          .removeClass('vote-' + db.dir1 + '-inact')
45          .addClass('vote-' + db.dir1 + '-act');
46        $('#' + 'vote_' + db.dir2 + '_' + cid)
47          .removeClass('vote-' + db.dir2 + '-act')
48          .addClass('vote-' + db.dir2 + '-inact');
49        // update the points
50        $('#' + pid).html(data);
51      },
52      error: function (xmlhttp) {
53        alert('An HTTP error '+ xmlhttp.status +' occured.\n'+ db.uri);
54      }
55    });
56  });
57}
58
59// Global killswitch
60if (Drupal.jsEnabled) {
61  $(document).ready(Drupal.voteUpDownAutoAttach);
62}

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.