-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinfusionsoft.user.js
88 lines (73 loc) · 2.55 KB
/
infusionsoft.user.js
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
// ==UserScript==
// @name My Fancy New Userscript
// @namespace infusionsoftUserScriptProject
// @version 0.1
// @description enter something useful
// @author You
// @match https://*.infusionsoft.com/Contact/manageContact.jsp*
// @grant none
// ==/UserScript==
InfusionsoftUserscriptFramework = function(){
var ns = {};
var tabs = {
'ManageContact': [],
'Order': []
};
ns.addTab = addTab;
ns.init = init;
ns.addWidget = addWidget;
ns.tabs = tabs;
function init(){
log.on();
if(typeof jQuery === "function"){
var where = whereAreWe();
switch(where){
case 'Dashboard':
//Insert new widgets...
break;
case 'ManageContact':
debugger;
log.info("Adding Tabs For ManageContact");
alert(tabs.ManageContact.length);
for(var key in tabs.ManageContact){
if(tabs.ManageContact.hasOwnProperty(key)){
addTabToPage(tabs.ManageContact[key], key);
}
}
break;
}
} else {
log.warn("jQuery not detected, so I'm going to assume this page isn't important...");
}
log.off();
}
/**
*
*/
function addTab(where, linkText, source){
tabs[where][linkText] = source;
}
function addWidget(source){
}
function whereAreWe(){
console.log(location.pathname);
switch(location.pathname){
case '/Admin/home.jsp':
return "Dashboard";
case '/Contact/manageContact.jsp':
return "ManageContact";
}
}
function addTabToPage(value, name){
alert("Here");
var $tabUl = jQuery(jQuery('ul.tabs').eq(0));
$tabUl.append('<li class="tab-sel active" id="tab_addressa" nowrap="nowrap"><a class="tab-sel" id="tab_link_addressa" href="#" onclick="showTabtabs(\'address\');return false;">' + String(value) + '</a></li>');
}
return ns;
}();
function testContactTab(){
return 'Bob';
}
InfusionsoftUserscriptFramework.addTab('ManageContact', 'Bob', testContactTab);
InfusionsoftUserscriptFramework.addWidget(testContactTab);
InfusionsoftUserscriptFramework.init();