PageSourceSearch

https://www.mynewsletterbuilder.com/javascript/general.js

js mynewsletterbuilder.com collected 2026-10-02 05:24:39 UTC 19,654 bytes, 810 lines download raw bytes

1var cur_domain = cur_domain || document.domain;
2
3/**
4 * Creates a popup with our framework
5 * @param string path to script
6 * @param string query string
7 * @param mixed popup type "small" || "medium" || "large" || [width, height]
8 * @param string header type "sm" || "norm" || false (to not use header / footer)
9 * @param mixed window location [left, top] || "middle"
10 * @param string security mode "plain" || "tls"
11 * @return FALSE (for use in links)
12 */
13function popContent(src, query, p_type, header, p_loc, mode, contact_type)
14{
15	var p_width, p_height, p_left, p_top, settings;
16
17	if (mode == "tls")
18		var proto = "https";
19	else
20		var proto = "http";
21
22	if (!contact_type)
23		contact_type = '';
24
25	if (isArray(p_type))
26	{
27		p_width = p_type[0];
28		p_height = p_type[1];
29	}
30	else if (p_type == "sm")
31	{
32		p_width = 450;
33		p_height = 355;
34	}
35	else if (p_type == "med")
36	{
37		p_width = 570;
38		p_height = 515;
39	}
40	else
41	{
42		p_width = 800;
43		p_height = 600;
44		header = "med";
45	}
46
47	if (header == '')
48		header = p_type;
49
50	if (isArray(p_loc))
51	{
52		p_left = p_loc[0];
53		p_top = p_loc[1];
54	}
55	else
56	{
57		var mid = calcMiddle(p_width, p_height);
58		p_left = mid[0];
59		p_top = mid[1];
60	}
61
62	query = BuildQueryString(query, '&');
63	settings = "toolbar=no, location=no, resizable=yes, menubar=no, scrollbars=yes, width=" + p_width + ",height=" + p_height + ", left=" + p_left + ", top=" + p_top;
64	win = window.open(proto + "://" + cur_domain + "/popup.php?page=" + src + "&header=" + header + "&contact_type=" + contact_type + query, "MNB_popf_content", settings);
65
66	if (win)
67		win.window.focus();
68
69	return false;
70}
71
72/**
73 * Generate a totally custom popup
74 * @param string page to open
75 * @param mixed request data "key=val&..." || ['key': 'val',...]
76 * @param string popup window settings
77 * @param string window name
78 * @param [optional] array geo position / dimensions (if this is included
79 * +do not include height / width, etc... in settings string.)
80 */
81function newPopup(src, request, settings, geo, name)
82{
83	var pos;
84	var request_vals = '';
85
86	if (!name || name == '')
87		name = "MNB_pop_content";
88
89	if (!settings || settings == '')
90	{
91		var settings = "toolbar=no, location=no, resizable=yes, menubar=no, scrollbars=yes";
92	}
93
94	if (geo['align'] == "middle")
95	{
96		var mid = calcMiddle(geo['width'], geo['height']);
97		geo['left'] = mid[0];
98		geo['top'] = mid[1];
99	}
100
101	if (geo['height'])
102		settings += ", height=" + geo['height'] + ", width=" + geo['width'];
103
104	if (geo['top'])
105		settings += ", top=" + geo['top'] + ", left=" + geo['left'];
106
107	src += BuildQueryString(request, '?');
108	win = window.open(src, name, settings);
109
110	if (win)
111		win.window.focus();
112
113	return false;
114}
115
116/**
117 * Creates a preview popup
118 * @param string location of preview document
119 * @return false
120 */
121function popExample(pre_src)
122{
123	var mid = calcMiddle(800, 600);
124
125	var settings = "toolbar=no, location=no, resizeable=yes, menubar=no, scrollbars=yes, ";
126	settings += "height=600, width=800, top=" + mid[1] + ", left=" + mid[0];
127	win = window.open(pre_src, "MNB_preview", settings);
128
129	if (win)
130		win.window.focus();
131
132	return false;
133}
134
135/**
136 * Open newsletter popup
137 * @param int newsletter id
138 * @return false (for use in links)
139 */
140function PopPreview(nl_id, as_id, uniq_id)
141{
142	if (nl_id)
143		nl_id = "?nl_id=" + nl_id;
144	else
145		nl_id = '';
146
147	if (as_id)
148		as_id = "?as_id=" + as_id;
149	else
150		as_id = '';
151
152	if (uniq_id)
153		uniq_id = '?uniq_id=' + uniq_id;
154	else
155		uniq_id = '';
156
157	newPopup('//' + cur_domain + "/my/newsletters/preview.php" + nl_id + as_id + uniq_id, '', '', {"align": "middle", "height": 700, "width": 900}, "MNB_preview");
158
159	return false;
160}
161
162/**
163 * Creates a popup contact window.
164 */
165function popContact(type)
166{
167	if (!type || type == "contact")
168		var page = "contact.php"
169	else
170		var page = "feedback.php"
171
172	newPopup('//' + cur_domain + '/my/help/' + page, '', '', {'align':'middle', 'height':275, 'width':400}, '');
173}
174
175/**
176 * Creates a help system popup (or re-uses the current window)
177 * @param string help topic
178 * @param boolean new window or resize current
179 * @return false (for use in links)
180 */
181function popHelpSys(topic, new_win)
182{
183	if (new_win == true)
184		newPopup("http://www.mynewsletterbuilder.com/help" + topic, '', '', {"align": "middle", "height": 600, "width": 970}, "MNB_help");
185	else
186	{
187		window.resizeTo(900, 600);
188		document.location.href = "http://www.mynewsletterbuilder.com/help";
189	}
190
191	return false;
192}
193
194/**
195 * Old pop-up help function.
196 */
197function PopHelp(topic, query)
198{
199	newPopup('//' + cur_domain + "/pop_help.php?doc=" + topic, query, '', {"align": "middle", "height": 600, "width": 970}, "MNB_help");
200
201	return false;
202}
203
204/**
205 * New pop-up help function.
206 */
207function popHelp(href)
208{
209	newPopup(href, '', '', {align: 'middle', height: 600, width: 970}, 'MNB_help');
210	return false;
211}
212
213/**
214 * Creates a preview popup
215 * @param string location of preview document
216 * @return false
217 */
218function PopVideo(src, width, height, auto, toc)
219{
220	if (!height)
221		var height = 600;
222
223	if (!width)
224		var width = 800;
225
226	if (!toc)
227		var toc = 0;
228
229	var mid = calcMiddle(width, height);
230	var page_height = height + 100;
231	var page_width = width + 40;
232	var settings = "toolbar=no, location=no, resizeable=no, menubar=no, scrollbars=no, ";
233	settings += "height=" + page_height + ", width=" + page_width + ", top=" + mid[1] + ", left=" + mid[0];
234	win = window.open('//' + cur_domain + "/video_player.php?src=" + src + "&auto=" + auto + "&h=" + height + "&w=" + width + "&t=" + toc, "MNB_video", settings);
235
236	if (win)
237		win.window.focus();
238
239	return false;
240}
241
242/**
243 * Creates a preview popup with a youtube video
244 * @param id the youtube id
245 * @param size small, regular, large, largest... should stick to regular.
246 *   Sizes based on on youtube recommendations
247 * @param cust_w if you want to override the width, must include cust_h also
248 * @param cust_h if you want to override the height, must include cust_w also
249 * @param hide_related set to 1 if you don't want to show related videos at the end
250 */
251function PopYoutube(id, size, cust_w, cust_h, hide_related)
252{
253	if (size == 'small')
254	{
255		width = 560;
256		height = 340;
257	}
258	else if (size == 'regular')
259	{
260		width = 640;
261		height = 385;
262	}
263	else if (size == 'large')
264	{
265		width = 853;
266		height = 505;
267	}
268	else if (size == 'largest')
269	{
270		width = 1280;
271		height = 745;
272	}
273	else
274	{
275		width = cust_w;
276		height = cust_h;
277	}
278
279	var rel = "";
280	if (hide_related == 1)
281		rel = "&hide_rel=1";
282
283	var mid = calcMiddle(width, height);
284	var page_height = height + 100;
285	var page_width = width + 40;
286	var settings = "toolbar=no, location=no, resizeable=no, menubar=no, scrollbars=no, ";
287	settings += "height=" + page_height + ", width=" + page_width + ", top=" + mid[1] + ", left=" + mid[0];
288	win = window.open('//' + cur_domain + "/video_player.php?youtube=" + id + "&w=" + width + "&h=" + height + rel, "MNB_video", settings);
289
290	if (win)
291		win.window.focus();
292
293	return false;
294}
295
296/**
297 * Builds a query string
298 * @param mixed query string data "the string" || ['key': val,...]
299 * @param prefix string '?' || '&'
300 * @return string the query string
301 */
302function BuildQueryString(request, prefix)
303{
304	var query_str = prefix;
305
306	if (isArray(request))
307		for (var key in request)
308		{
309			if (query_str != "")
310				query_str += "&";
311
312			query_str += key + "=" + request[key];
313		}
314	else if (request != '')
315		query_str += request;
316	else
317		query_str = '';
318
319	return query_str;
320}
321
322//Clears the default username field value
323function clearUsername(username)
324{
325	if (username.value == "username")
326		username.value = '';
327}
328
329//Clears the default password field value
330function clearPassword(password)
331{
332	if (password.value == '********')
333	{
334		password.value = '';
335	}
336}
337
338//Clears the default email address field value
339function clearEmail(email)
340{
341	if (email.value == "email address")
342		email.value = '';
343}
344
345// Gets window centered on the screen
346function calcMiddle(width, height)
347{
348	var mid = [];
349	mid[0] = (screen.width - width) / 2;
350	mid[1] = (screen.height - height) / 2;
351
352	return mid;
353}
354
355// Toggle the visibility of a DOM element
356function toggleVisibility(dom_elem)
357{
358	if (document.getElementById(dom_elem).style.visibility == "hidden")
359		document.getElementById(dom_elem).style.visibility = "visible";
360	else
361		document.getElementById(dom_elem).style.visibility = "hidden";
362
363}
364
365/**
366 *  Toggles the display attribute of the specified object
367 *  @param string ID of object to toggle
368 *  @return TRUE if displayed, FALSE if hidden
369 */
370function toggleDisplay(obj) {
371	if(document.getElementById(obj).style.display == 'none' )
372	{
373		document.getElementById(obj).style.display = 'block';
374		return true;
375	}
376	else
377	{
378		document.getElementById(obj).style.display = 'none';
379		return false;
380	}
381}
382
383// Make this DOM element visible
384function visibleDisplay(dom_elem)
385{
386		document.getElementById(dom_elem).style.visibility = 'visible';
387}
388
389// Make this DOM element hidden
390function hiddenDisplay(dom_elem)
391{
392		document.getElementById(dom_elem).style.visibility = 'hidden';
393}
394
395// Make this DOM element visible
396function displayBlock(dom_elem)
397{
398		document.getElementById(dom_elem).style.display = "block";
399}
400
401// Make this DOM element visible, inline
402function displayInline(dom_elem)
403{
404		document.getElementById(dom_elem).style.display = "inline";
405}
406
407// Make this DOM element hidden
408function displayNone(dom_elem)
409{
410		document.getElementById(dom_elem).style.display = "none";
411}
412
413//Code to ensure that users enter fully qualified URI's
414function checkHTTP(what)
415{
416	a = what.value.trim()
417	if(a != "")
418	{
419		if (a.search(/^\#/) != -1)	//anchor
420			return;
421		else if (a.search(/\@/) > 0 && (a.search(/mailto:/) < 0 && (a.search(/\//) < 0))) // mail
422			what.value = "mailto:" + a
423		else if(a.search(/:\/\//) <= 0 && a.search(/mailto:/) < 0)	// link
424			what.value = "http://" + a;
425		else
426			return;
427	}
428}
429
430function testURL(what)
431{
432	checkHTTP(what);
433
434	if(what.value != "")
435		window.open(what.value);
436}
437
438// Override string trim only if necessary, also updating to the latest
439// jQuery string trim
440if(!String.prototype.trim){
441
442	var trimLeft = /^\s+/,
443		trimRight = /\s+$/;
444
445	if ( !/\s/.test( "\xA0" ) ) {
446		trimLeft = /^[\s\xA0]+/;
447		trimRight = /[\s\xA0]+$/;
448	}
449
450	String.prototype.trim = function() {
451		return this == null ?
452			"" :
453			this.toString().replace( trimLeft, "" ).replace( trimRight, "" );
454	};
455
456}
457
458function isArray(obj)
459{
460   if (obj.constructor.toString().indexOf("Array") == -1)
461      return false;
462   else
463      return true;
464}
465
466function jumpTo(id, isElem)
467{
468	if (isElem == true)
469	{
470		var elem = document.getElementById(id);
471		var val = elem.options[elem.selectedIndex].value;
472	}
473	else
474		var val = id;
475
476	window.location.hash = val;
477}
478
479function submitSearch()
480{
481	document.getElementById('search_button').disabled = true;
482	return true;
483}
484
485//toggles 1 element enabled and another disabled, depending on which is currently enabled
486//one or the other should be disabled in the first place
487function toggleEnabled(ele1, ele2)
488{
489	if (document.getElementById(ele1).disabled == true)
490	{
491		document.getElementById(ele1).disabled = false;
492		document.getElementById(ele2).disabled = true;
493	}
494	else
495	{
496		document.getElementById(ele1).disabled = true;
497		document.getElementById(ele2).disabled = false;
498	}
499}
500
501/**
502 * Replaces the options of a select box
503 * @param string element id
504 * @param mixed options ['display', 'value', defaultSelected, selected]
505 */
506function ReplaceSelectOptions(id, options)
507{
508	var sel_obj = document.getElementById(id);
509
510	if (!sel_obj)
511		return;
512
513	sel_obj.options.length = 0;
514
515	var count = options.length;
516
517	if (count == 0)
518		sel_obj.options[0] = new Option("Select", '', true, true);
519	else
520		for (var i = 0; i < count; i++)
521			sel_obj.options[i]=new Option(options[i][0], options[i][1], options[i][2], options[i][3])
522
523	return;
524}
525
526/**
527 *  Toggles display of an object AND updates the expander image
528 *  @param string ID of the object to toggle.
529 *  @param string ID of the image to update.
530 */
531function toggleExpander(obj, btn)
532{
533	if(toggleDisplay(obj))
534
535		document[btn].src = "/images/info/toc_expanded.gif";
536	else
537		document[btn].src = "/images/info/toc_collapsed.gif";
538}
539
540/**
541 * Allow only numeric input (should be called on keyup)
542 * @param dom input object
543 */
544function ForceNumeric(elem)
545{
546	var val = elem.value;
547	elem.value = val.replace(/\D/g, '');
548}
549
550/**
551 * Get an associative array of query parameters
552 * @param [string query var to check]
553 * @return mixed ["key": "val", ...]
554 * + string if val_var found
555 * + FALSE if no query match
556 */
557function GetQueryVals(name)
558{
559	var query = window.location.search.substring(1);
560
561	if (query == '')
562		return false;
563
564	var elems = new Array();
565	var tmp = query.split('&');
566
567	for (var i = 0; i < tmp.length; i++)
568	{
569		var pair = tmp[i].split('=');
570		elems[pair[0]] = pair[1];
571	}
572
573	if (typeof name == 'string' && name != '')
574		return (elems[name]) ? elems[name] : false;
575	else
576		return elems;
577}
578
579/**
580 * On page Google Analytics tracking
581 * @param [string target URI :: pathname]
582 * @param [string target DOM element]
583 */
584function OnPageGat(uri, dom)
585{
586	if (cur_domain == "www.mynewsletterbuilder.com")
587	{
588		if (typeof uri == 'undefined' || uri == '')
589			uri = document.location.pathname;
590
591		if (typeof dom == 'string')
592			uri += dom;
593
594		var pageTracker = _gat._getTracker("UA-3177177-1");
595		pageTracker._initData();
596		pageTracker._trackPageview(uri);
597	}
598}
599
600//confirm that user wanted to click the button
601function confirmClick(msg) {
602	if (msg == null)
603		msg = "Are you sure?";
604	var agree = confirm(msg);
605	if (agree)
606		return true;
607	else
608		return false;
609}
610
611//uses confirmClick and disables on true
612function disableAfterConfirm(id, msg)
613{
614	if(confirmClick(msg))
615	{
616		$('#'+id).prop('disabled', true);
617		return true;
618	}
619	else
620		return false;
621}
622
623//disables button after submit
624function disableAfterSubmit(id, form)
625{
626	if (form)
627		document.forms[form].submit();
628	else
629		document.forms[0].submit();
630	$('#'+id).prop('disabled', true);
631	return true;
632}
633
634//set defaults on personalization pages
635function setPersonalizeDefaults()
636{
637	if(confirmClick('Are you sure you want to Restore Defaults?  This will overwrite any custom content you already have.'))
638	{
639		$.ajax({
640			type: "POST",
641			url: '//' + cur_domain + "/my/tools/personalize/defaults",
642			timeout: 10000,
643			success: function(responseText){
644				var res = eval("(" + responseText + ")");
645
646				for (var i in res)
647				{
648					id = i.toLowerCase();
649					if ($("#"+id).length > 0)
650						$("#"+id).val(res[i]);
651					var elem = tinyMCE.getInstanceById(id);
652					if (typeof(elem) != "undefined")
653						tinyMCE.getInstanceById(id).setContent(res[i]);
654				}
655			}
656		});
657	}
658}
659
660function AddStyleClass(elem, cls)
661{
662	$("#" + elem).addClass(cls);
663}
664
665function RemoveStyleClass(elem, cls)
666{
667	$("#" + elem).removeClass(cls);
668}
669
670function addCommas(nStr)
671{
672	nStr += '';
673	x = nStr.split('.');
674	x1 = x[0];
675	x2 = x.length > 1 ? '.' + x[1] : '';
676	var rgx = /(\d+)(\d{3})/;
677	while (rgx.test(x1)) {
678		x1 = x1.replace(rgx, '$1' + ',' + '$2');
679	}
680	return x1 + x2;
681}
682
683function ChangeAutoNl(id)
684{
685	$.ajax({
686		type: "POST",
687		url: '//' + cur_domain + "/my/query.php",
688		timeout: 20000,
689		data: "m=auto_nl&nl_id=" + id,
690		success: ConfAutoNlChange
691	});
692}
693
694function ConfAutoNlChange(success)
695{
696	if (success != 0)
697		alert("Your welcome newsletter has been changed to " + success + ", and your settings have been saved.");
698	else
699		alert("Sorry, we could not complete your request.");
700}
701
702function ToggleAcMenu(id)
703{
704	var opts = id.split("-");
705	if ($("#"+opts[0]+"_item_"+opts[1]).css('display') == 'none')
706	{
707		$(".ac_menu_"+opts[0]).each(function(){
708			if ($(this).css('display') != 'none')
709				$(this).slideUp();
710		});
711		$("#"+opts[0]+"_item_"+opts[1]).slideDown();
712	}
713}
714
715var ExtractSortable = function(node)
716{
717	if ($(node).children('.sortable'))
718	{
719		data = $(node).children('.sortable');
720		str = $(data).html();
721
722		return (str) ? str : '';
723	}
724	else
725		return $(node).html();
726}
727
728function AddFavorite(page)
729{
730	var default_name = "";
731	if (page == "Subscriber_Categories") default_name = "Subscribers/Categories";
732	else if (page == "Subscribers_Add") default_name = "Subscribers/Add";
733	else if (page == "Subscribers_Update") default_name = "Subscribers/Update";
734	else if (page == "Subscribers_Remove") default_name = "Subscribers/Remove";
735	else if (page == "Subscribers_Prefs") default_name = "Subscribers/Preferences";
736	else if (page == "Reports") default_name = "Reports/Newsletters";
737	else if (page == "Reports_Autoseries") default_name = "Reports/Autoseries";
738	else if (page == "Reports_Surveys") default_name = "Reports/Surveys";
739	else if (page == "Reports_Activity") default_name = "Reports/Activity";
740	else if (page == "Autoseries") default_name = "Newsletters/Autoseries";
741	else if (page == "Autoseries_Edit") default_name = "Autoseries/Edit "+ $("input[name=series_name]").val();
742	else if (page == "Survey_List") default_name = "Features/Surveys";
743	else if (page == "Survey_Report") default_name = "Reports/Survey: "+ $("#bookmark_name").val();
744	else if (page == "Survey_Editor") default_name = "Surveys/Edit "+ $("input[name=survey_name]").val();
745	else if (page == "Newsstand") default_name = "Features/Publish-to-Web";
746	else if (page == "Account_Summary") default_name = "Account/Summary";
747	else if (page == "Account_Plans") default_name = "Account/Pricing Plans";
748	else if (page == "Account_Billing") default_name = "Account/Billing";
749	else if (page == "Settings") default_name = "Account Settings";
750	else if (page == "Autoresponders") default_name = "Features/Autoresponders";
751	else if (page == "Autoresponder_Edit") default_name = "Autoresponder/Edit "+ $("input[name=title]").val();
752	else if (page == "Media") default_name = "Features/Media";
753	else if (page == "Features_Contact") default_name = "Features/Contact Data";
754	else if (page == "Mission_Control") default_name = "Master Control Panel";
755	else if (page == "Personalization") default_name = "Personalization Options";
756	else if (page == "Signup_Builder") default_name = "Features/Signup Builder";
757	else if (page == "Custom_Branding") default_name = "Features/Custom Branding";
758	else if (page == "Subscription_System") default_name = "Features/Subscription System";
759	else if (page == "Confirmation_System") default_name = "Features/Confirmation System";
760	else if (page == "Forward_Manage") default_name = "Features/Forward to a Friend";
761	else if (page == "Instant_Import") default_name = "Newsletters/Instant Import";
762
763	var link = prompt("Adding this page to favorites.  Use the default name if one was provided, enter a custom name, or cancel this action.", default_name);
764	if (jQuery.trim(link))
765	{
766		var proto = document.location.protocol + '//';
767		var url = document.location.href;
768		$.ajax({
769				type: "POST",
770				url: proto + cur_domain + "/my/account/",
771				timeout: 20000,
772				data: {"m": "add_page", "link": link, "url": url},
773				success: function(responseText) {
774					if (responseText == "1")
775						alert("This page has been added to your favorites.");
776					else
777						alert("Unable to add this page to favorites.  You may do so manually by copy/pasting the url into the Favorites -> Add field on your login dashboard.");
778				}
779		});
780	}
781}
782
783/**
784 * Workaround for bug in Firefox versions < 22, which prevent label clicks from
785 * firing click events on corresponding file inputs.
786 */
787function getFiles() {
788	if ( window.mozIndexedDB !== undefined ) {
789		document.getElementById("browsefiles").click();
790		return false;
791	}
792}
793
794function getFileName(obj) {
795    var file = obj.value;
796    var fileName = file.split("\\");
797    document.getElementById("fname_target").value = fileName[fileName.length-1];
798}
799
800function itemExpander(obj) {
801	var $slider = $("#"+obj);
802	if ($slider.is(':visible'))
803	{
804		$slider.slideUp(300);
805	}
806	else
807	{
808		$slider.slideDown(300);
809	}
810}

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.