PageSourceSearch

https://webcup.com.br/static/tpl/webcupv3/jscript/attachment.js

js webcup.com.br collected 2026-10-02 14:09:17 UTC 4,596 bytes, 94 lines download raw bytes

1var Attachment = function (options) {
2    var attachmentObj;
3    var AttachmentClass = {
4        properties: {},
5        __defaults: {
6            id: 'new-' + getUUID(),
7            name: null,
8            attachedTo: null,
9            fileType: null,
10            path: null,
11            validDocs: ['txt', 'pdf', 'doc', 'docx', 'odt', 'xls', 'xlsx', 'ods'],
12            validImages: ['jpeg', 'jpg', 'png', 'gif']
13        },
14        __construct: function (srcOpt) {
15            this.properties = $.extend({}, this.__defaults, srcOpt);
16            attachmentObj = this;
17
18            // setting filyType
19            if (!isValidVal(attachmentObj.properties.fileType)) {
20                var path = attachmentObj.properties.path.split('.');
21                if (isValidVal(path[path.length - 1])) {
22                    if (0 <= $.inArray(path[path.length - 1], attachmentObj.properties.validDocs)) {
23                        attachmentObj.properties.fileType = 'doc';
24                    } else if (0 <= $.inArray(path[path.length - 1], attachmentObj.properties.validImages)) {
25                        attachmentObj.properties.fileType = 'image';
26                    }
27                }
28            }
29
30            return this;
31        },
32        getSerializeAttachment: function () {
33            return {
34                id: attachmentObj.properties.id,
35                name: attachmentObj.properties.name,
36                attachedTo: attachmentObj.properties.attachedTo,
37                fileType: attachmentObj.properties.fileType,
38                path: attachmentObj.properties.path
39            };
40        },
41        parse: {
42            container: function (editable) {
43                var html =
44                        '<div class="game-attachments-item" id="' + attachmentObj.properties.id + '-attachment-item">' +
45                        '<a href="' + attachmentObj.properties.path + '" title="' + attachmentObj.properties.name + '" target="_blank">' +
46                        attachmentObj.parse.image() +
47                        attachmentObj.properties.name +
48                        '</a>' +
49                        (editable ? '<span class="rmv_attachment cursor-pointer" title="' + __("Remove attachment") + '"><i class="fa fa-trash"></i></span>' : '') +
50                        '</div>';
51                return html;
52            },
53            image: function () {
54                var html = '';
55                var imgPath;
56                var ext = attachmentObj.properties.path.split('.');
57                if (isValidVal(ext[ext.length - 1])) {
58                    ext = ext[ext.length - 1];
59                    var images = ['jpeg', 'jpg', 'png', 'gif'];
60                    var text = ['txt', 'doc', 'docx', 'odt'];
61                    var spreadsheet = ['xls', 'xlsx', 'ods'];
62                    var pdf = ['pdf'];
63                    if (0 <= $.inArray(ext, images)) {
64                        imgPath = TPL_ROOT + 'images/file_icons/image_file_icon.jpg';
65                    } else if (0 <= $.inArray(ext, text)) {
66                        imgPath = TPL_ROOT + 'images/file_icons/text_file_icon.jpg';
67                    } else if (0 <= $.inArray(ext, spreadsheet)) {
68                        imgPath = TPL_ROOT + 'images/file_icons/excel_file_icon.jpg';
69                    } else if (0 <= $.inArray(ext, pdf)) {
70                        imgPath = TPL_ROOT + 'images/file_icons/pdf_file_icon.jpg';
71                    } else {
72                        imgPath = TPL_ROOT + 'images/file_icons/generic_file_icon.jpg';
73                    }
74                    html += '<img class="game-attachment-file-image" title="' + attachmentObj.properties.name + '" src="' + imgPath + '" alt="' + attachmentObj.properties.name + '" />';
75                }
76                return html;
77            }
78        },
79        isValid: function () {
80            if (!isValidVal(attachmentObj.properties.name, 'string') || !isValidVal(attachmentObj.properties.attachedTo, 'string') || !isValidVal(attachmentObj.properties.fileType, 'string') || !isValidVal(attachmentObj.properties.path)) {
81                return false;
82            }
83            var path = attachmentObj.properties.path.split('.');
84            if (!isValidVal(path[path.length - 1], 'string') || ((0 > $.inArray(path[path.length - 1], attachmentObj.properties.validDocs)) && (0 > $.inArray(path[path.length - 1], attachmentObj.properties.validImages)))) {
85                return false;
86            }
87            return true;
88        },
89        getImage: function () {
90
91        }
92    };
93    return AttachmentClass.__construct(options);
94};

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.