companion-projects.js
8.28 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
/*
* This is the rotation sript for the Companion Projects section
*
* we hase some limited number of static items whcih are displayed always and
* the rest is rendered randomly
*/
function renderCompanionProjectIcons() {
/* number of items we want to render */
var itemsToRender = 5;
/* domain where images live - we can easily switch for local testing to localhost to see images */
var domain = "http://localhost"; //
/* links output */
var randomizedLinks = "";
var staticLinks = "";
/* items definition using JSON object notation */
var staticItemsContainer = {
"items" : [
{
"image": "/images_www/v6/mysql_logo.gif",
"link": "http://www.mysql.com/",
"alt": "MySQL - Open Source Database Server",
"width": "53",
"height": "45"
},
{
"image": "/images_www/v6/glassfish.gif",
"link": "http://glassfish.java.net/",
"alt": "GlassFish Community: an Open Source Application Server",
"width": "53",
"height": "45"
}
]
}
var randItemsContainer = {
"items" : [
{
"image": "/images_www/v6/javafx.png",
"link": "http://www.oracle.com/technetwork/java/javafx/",
"alt": "JavaFX",
"width": "74",
"height": "26"
},
{
"image": "/images_www/v6/openjdk.gif",
"link": "http://openjdk.org/",
"alt": "Open JDK: an Open SourceJDK",
"width": "81",
"height": "45"
},
{
"image": "/images_www/v6/vbox.gif",
"link": "http://www.virtualbox.org/wiki/VirtualBox",
"alt": "Virtual Box - full virtualizer",
"width": "108",
"height": "35"
},
{
"image": "/images_www/v6/javanet.gif",
"link": "http://www.java.net/",
"alt": "Java.net - The Source for Java Technology Collaboration",
"width": "82",
"height": "45"
},
{
"image": "/images_www/v6/open-office.gif",
"link": "http://www.openoffice.org/",
"alt": "OpenOffice - The free and open productivity suite",
"width": "87",
"height": "45"
},
{
"image": "/images_www/v6/hudson.png",
"link": "http://hudson-ci.org/",
"alt": "Hudson - Continuous Integration",
"width": "75",
"height": "25"
}
]
};
/* opening and closing html chunks */
var openingHtml="<center><table><tr><td class=\"companions-left b-green-left valign-center\">Companion <br>Projects: </td><td class=\"valign-center\">";
var closingHtml="<td class=\"companions-right b-green-right valign-center align-center\"> Sponsored by <br><a href=\"http://www.oracle.com/\"><img src=\""+domain+"/images_www/v6/logo_oracle_footer.gif\" width=\"100\" height=\"29\" alt=\"Sponsored by Oracle\" title=\"Sponsored by Oracle\"></a></td></tr></table></center>";
/* let's stup the sttaic links */
for (i=0; i<staticItemsContainer.items.length; i++) {
staticLinks += '<td class="valign-center"><a href="'+staticItemsContainer.items[i].link+'"><img src="'+domain+staticItemsContainer.items[i].image+'" alt="'+staticItemsContainer.items[i].alt+'" title="'+staticItemsContainer.items[i].alt+'" width="'+staticItemsContainer.items[i].width+'" height="'+staticItemsContainer.items[i].height+'"></a> </td>';
}
/* now randomize the rand items array */
randItemsContainer.items.sort(function() {
return (Math.round(Math.random())-0.5)
});
/* make sure we do not want to display more items then we actually have */
itemsToRender = (itemsToRender > randItemsContainer.items.length)? randItemsContainer.items.length : itemsToRender ;
/* now setup randomized items */
for (i = 0; i < itemsToRender; i++) {
// setup the style - there is line after the last item
var style = (i==(itemsToRender-1))? 'class="valign-center b-green-right" style="padding-right:10px;"' : 'class="valign-center"' ;
var space = (i==(itemsToRender-1))? '' : ' ';
randomizedLinks += '<td '+style+'><a href="'+randItemsContainer.items[i].link+'"><img src="'+domain+randItemsContainer.items[i].image+'" alt="'+randItemsContainer.items[i].alt+'" title="'+randItemsContainer.items[i].alt+'" width="'+randItemsContainer.items[i].width+'" height="'+randItemsContainer.items[i].height+'"></a>'+space+'</td>';
}
/* return the html */
//return openingHtml+staticLinks+randomizedLinks+closingHtml;
return '';
}
/**
* function which renders randomly 2 links to the Sun Support Program pane in kb/rcol
*/
function renderRandomSupportLinks() {
// JSON objects holding links and urls for the rendering
var links={
"items":[
{
"link":"Oracle Development Tools Support Offering for NetBeans IDE",
"url":"http://www.oracle.com/us/support/development-tools-080025.html"
}
]
};
// setup rand counter
var rand1 = Math.floor(Math.random() * links.items.length);
/*var rand2 = rand1;
do {
rand2 = Math.floor(Math.random() * links.items.length);
}
while(rand1 == rand2)
*/
// now render the links according to rand counters
document.write("<div class=\"rrrarticle\"><div class=\"rarticletitle\"><a href=\""+links.items[rand1].url+"\">"+links.items[rand1].link+"</a></div></div>");
//document.write("<div class=\"rrrarticle\"><div class=\"rarticletitle\"><a href=\""+links.items[rand2].url+"\">"+links.items[rand2].link+"</a></div></div>");
}
/*
* We need to display custom nav column on project pages,
* so do taht by ajax from their /nav-col.html
*
* This will be run only for particular domains
*/
var navColLocation='/nav-col.nav';
var topNavLocation='/top-nav.nav';
var jQueryLocation='http://netbeans.org/images_www/js/jquery-1.3.2.min.js';
var navColSelector='#col-right-context';
function showCustomNavCol() {
// hide the nav element so it does not appear at all at the beginning
document.write('<style>'+navColSelector+', #floating-col-right div:nth-child(2) {display:none;}</style>')
// check for jQuery
if (typeof jQuery == 'undefined') {
document.write('<script type="text/javascript" src="'+jQueryLocation+'"></script>');
}
if(jQuery) {
// do the magic using ajax - load content of /nav-col.html into <div id="col-right-context">
$(function(){
// drop junction content
$(navColSelector).html('');
// drop also Navidation pane
$('#floating-col-right div:nth-child(2)').hide();
// load nav-col
$.get(navColLocation, function(data){
$(navColSelector).html(data).slideDown();
});
});
}
}
function showCustomTopCol() {
if (typeof jQuery == 'undefined') {
document.write('<script type="text/javascript" src="'+jQueryLocation+'"></script>');
}
if(jQuery) {
$(function(){
$.get(topNavLocation, function(data){
$('table.colapse.full-width.f-page-table-2col tr:first').before(data);
});
});
}
}
// DO IT
if(window.location.toString().match(/^http:\/\/platform\.netbeans\.org\//)) {
document.write('<link rel="stylesheet" type="text/css" href="//netbeans.org/platform.css"/>');
showCustomNavCol();
showCustomTopCol();
} else if(window.location.toString().match(/^http:\/\/localhost\//)) {
//document.write('<link rel="stylesheet" type="text/css" href="//netbeans.org/platform.css"/>');
//showCustomNavCol();
//showCustomTopCol();
} else if(window.location.toString().match(/^http:\/\/edu\.netbeans\.org\//)) {
showCustomNavCol();
}
if(jQuery) {
$(function() {
// IE6-9 css3 support
if (window.PIE) {
$('#navtabs,#search-input,#navig-breadcrumbs').each(function() {
PIE.attach(this);
});
}
// top tabs sbetter links
$('#navtabs li').each(function() {
$(this).click(function() {
window.location=$(this).find('a').attr('href');
});
});
$('#search-input').click(function() {
if($(this).val()=='Search') {
$(this).val('');
}
});
});
}