-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
168 lines (137 loc) · 6.5 KB
/
script.js
File metadata and controls
168 lines (137 loc) · 6.5 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
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
165
166
167
168
document.addEventListener('DOMContentLoaded', () => {
console.log('DOM loaded, looking for elements...');
const analyzeBtn = document.getElementById('analyze-btn');
const accountsInput = document.getElementById('accounts-input');
const resultsContainer = document.getElementById('results-container');
console.log('Elements found:', {
analyzeBtn: analyzeBtn,
accountsInput: accountsInput,
resultsContainer: resultsContainer
});
if (!analyzeBtn) {
console.error('Analyze button not found!');
return;
}
if (!accountsInput) {
console.error('Accounts input not found!');
return;
}
if (!resultsContainer) {
console.error('Results container not found!');
return;
}
console.log('All elements found successfully!');
const writerUseCases = {
marketing: "Scaling content creation for marketing campaigns.",
hr: "Developing consistent HR and internal communications.",
product: "Generating clear and concise product documentation.",
support: "Creating accurate and helpful support articles.",
brand: "Maintaining brand consistency across all written materials."
};
const jobKeywords = {
marketing: ['content marketing', 'content strategist', 'head of content', 'seo manager'],
hr: ['hr communications', 'internal communications', 'employee experience'],
product: ['product marketing', 'ux writer', 'technical writer'],
brand: ['brand manager', 'brand voice', 'copywriter']
};
analyzeBtn.addEventListener('click', async () => {
console.log('Button clicked!');
const accounts = accountsInput.value.split('\n').filter(line => line.trim() !== '');
console.log('Accounts to analyze:', accounts);
if (accounts.length === 0) {
resultsContainer.innerHTML = '<p>Please enter some domains to analyze.</p>';
return;
}
resultsContainer.innerHTML = '<h2>Analyzing...</h2>';
const results = await Promise.all(accounts.map(account => analyzeAccount(account.trim())));
displayResults(results);
});
async function analyzeAccount(domain) {
// In a real application, you would make API calls here.
// For this simulation, we'll generate mock data.
const mockData = generateMockData(domain);
const tier = determineTier(mockData);
const pov = generatePov(mockData, tier);
return { ...mockData, tier, pov };
}
function generateMockData(domain) {
const industries = ['SaaS', 'Fintech', 'Healthcare', 'E-commerce', 'Manufacturing'];
const newsItems = [
`Announced a new round of funding to expand operations.`,
`Launched a new flagship product to disrupt the market.`,
`Reported record growth in the last quarter.`,
`Is expanding into the European market.`
];
const jobPostings = [
{ title: 'Head of Content Strategy', department: 'marketing' },
{ title: 'Senior Product Marketing Manager', department: 'product' },
{ title: 'Internal Communications Specialist', department: 'hr' },
{ title: 'Brand Manager', department: 'brand' },
{ title: 'Software Engineer', department: 'engineering' },
{ title: 'Sales Development Representative', department: 'sales' }
];
return {
domain,
companyName: domain.split('.')[0].charAt(0).toUpperCase() + domain.split('.')[0].slice(1),
industry: industries[Math.floor(Math.random() * industries.length)],
recentNews: newsItems[Math.floor(Math.random() * newsItems.length)],
// Simulate finding relevant job postings
jobs: jobPostings.filter(() => Math.random() > 0.5).slice(0, 2)
};
}
function determineTier(data) {
const hasHighIntentJobs = data.jobs.some(job =>
Object.values(jobKeywords).flat().some(keyword => job.title.toLowerCase().includes(keyword))
);
if (hasHighIntentJobs) {
return 1; // High priority
}
if (data.recentNews.includes('funding') || data.recentNews.includes('growth')) {
return 2; // Medium priority
}
return 3; // Low priority
}
function generatePov(data, tier) {
const povs = [];
// POV based on job postings
const relevantJobs = data.jobs.filter(job =>
Object.values(jobKeywords).flat().some(keyword => job.title.toLowerCase().includes(keyword))
);
if (relevantJobs.length > 0) {
const job = relevantJobs[0];
const useCase = writerUseCases[job.department] || writerUseCases.brand;
povs.push(`<strong>Hiring Signal:</strong> Noticed you're hiring for a <em>${job.title}</em>. As you scale the team, Writer can help ensure all new content aligns with your brand voice from day one. ${useCase}`);
}
// POV based on news
if (tier <= 2) {
povs.push(`<strong>Company News:</strong> Congrats on the recent news: "<em>${data.recentNews}</em>". As you continue to grow, maintaining a consistent message across all channels is key. Writer can help with that.`);
}
// General POV
if (povs.length === 0) {
povs.push(`<strong>Industry Trend:</strong> Many leading companies in the <em>${data.industry}</em> sector are leveraging generative AI to accelerate their content pipeline. Writer provides an enterprise-grade platform to do this securely and on-brand.`);
}
return povs;
}
function displayResults(results) {
resultsContainer.innerHTML = '';
if (results.length === 0) {
resultsContainer.innerHTML = '<p>No accounts to display. Please enter some domains above.</p>';
return;
}
results.sort((a, b) => a.tier - b.tier);
results.forEach(result => {
const card = document.createElement('div');
card.className = 'account-card';
let povHtml = result.pov.map(p => `<li>${p}</li>`).join('');
card.innerHTML = `
<h2>${result.companyName}</h2>
<div class="tier tier-${result.tier}">Tier ${result.tier}</div>
<h3>Personalization POVs</h3>
<ul>
${povHtml}
</ul>
`;
resultsContainer.appendChild(card);
});
}
});