wpseo-premium-contact-support-370.js
2.03 KB
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
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
"use strict";
/* global HS */
(function ($) {
$(window).on("YoastSEO:ContactSupport", function (e, data) {
if (data.usedQueries !== undefined) {
var identity = HS.beacon.get_helpscout_beacon_identity();
identity["User searched for"] = usedQueriesWithHTML(data.usedQueries);
HS.beacon.identify(identity);
}
HS.beacon.open();
});
/**
* Format the search queries done by the user in HTML
*
* @param {array} usedQueries List of queries entered by the user.
* @returns {string} The generated output.
*/
function usedQueriesWithHTML(usedQueries) {
var output = "";
if ($.isEmptyObject(usedQueries)) {
output += "<em>Search history is empty.</em>";
} else {
output += "<table><tr><th>Searched for</th><th>Opened article</th></tr>";
$.each(usedQueries, function (searchString, posts) {
output += "<tr><td>" + searchString + "</td>";
output += getPostsHTML(posts);
output += "</tr>";
});
output = output + "</table>";
}
return output;
}
/**
* Format the posts looked at by the user in HTML
*
* @param {array} posts List of posts opened by the user.
* @returns {string} The generated output.
*/
function getPostsHTML(posts) {
var output = "";
var first = true;
if ($.isEmptyObject(posts)) {
output += "<td><em>No articles were opened.</em></td>";
} else {
$.each(posts, function (postId, post) {
if (first === false) {
output += "<td></td>";
}
output += "<td><a href='" + post.link + "'>" + post.title + "</a></td>";
first = false;
});
}
return output;
}
})(jQuery);
},{}]},{},[1]);