/*------------------------------------------*/
/* Name: EMSNow.com News Feed */
/* Version: 1.0 */
/* Updated: Tuesday, December 7, 2004 */
/* Developer: Quadsimia (quadsimia.com) */
/* ------------------------- */
/* Permission granted to use this script in */
/* any application, provided this header is */
/* left intact. */
/*------------------------------------------*/
/* -----------------------------------------------------------
BASIC USAGE:
1. link to this javascript file on the EMSnow site in the header of your page.
2. call the emsNowNews() function from the area on your page where news is to appear.
That's it, for a basic news display.
ADVANCED USAGE:
The emsnowNews() function can be called with arguments to provide more control over the news feed.
The arguments are all optional.
emsNowNews([type [, width [, height [, style]]]]);
type = the type of news you're requesting:
'NA' = news analysis; 'BN' = breaking news; '' = both
width = the width of the news box
height = the height of the news box (if you set a height smaller than the news contents, it will scroll)
style = stylesheet to use. can be a local file or a remote URL:
'' = emsNowNews.css (installed on EMSNow's site); 'none' = no style applied
EXAMPLE:
To produce a box 300 pixels wide by 400 pixels high that contains only the News Analysis:
Put this line in the
of your document:
Put this line in the of your document:
---------------------------------------------------------------- */
// initialize these global variables for later use
var newsType;
var newsBoxWidth;
var newsBoxHeight;
var newsBoxId = 'emsNowNews';
var newsStyle;
var dirBase = 'http://www.emsnow.com/newsadop/';
// the main function - called directly from a web page
function emsNowNews(whichNews,boxWidth,boxHeight,style){
// set these global variables according to the user-specified arguments
newsType = whichNews;
newsBoxWidth = boxWidth;
newsBoxHeight = boxHeight;
newsStyle = style;
// create the news box and hide it until its data is loaded
document.write('');
var newsBox = document.getElementById('emsNowNews');
newsBox.style.display = 'none';
getEMSNow();
}
function applyStylesheet(style){
// determine which stylesheet (if any) to apply
if(!style) {
stylesheet = dirBase + 'emsNowNews.css'; // if no stylesheet was specified, use the default one
} else {
if(style == 'none') return; // don't use any stylesheet
if(style.substr(0,7) == 'http://') {
stylesheet = style;
} else if(style.substr(style.length-4,4) == '.css') {
stylesheet = style;
}
}
// create the style tag
var docHead = document.getElementsByTagName('head')[0];
var styleTag = document.createElement('link');
styleTag.setAttribute('rel','stylesheet');
styleTag.setAttribute('type','text/css');
styleTag.setAttribute('href',stylesheet);
// write the style tag to the page
docHead.appendChild(styleTag);
}
function getEMSNow(){
// which type of news are we requesting?
switch(newsType){
case 'BN':
sBN = showBreakingNews();
break;
case 'NA':
sNA = showNewsAnalysis();
break;
case 'NA+BN':
default:
sNA = showNewsAnalysis();
sBN = showBreakingNews();
break;
}
// add the EMSNow news content to its containing box
var newsBox = document.getElementById('emsNowNews');
newsBox.innerHTML = '
';
if (window.sNA) newsBox.innerHTML += sNA;
if (window.sBN) newsBox.innerHTML += sBN;
if (newsBoxWidth) newsBox.style.width = newsBoxWidth + 'px';
if (newsBoxHeight) newsBox.style.height = newsBoxHeight + 'px';
newsBox.style.display = 'block';
applyStylesheet(newsStyle);
}
// function to parse the "News Analysis" section
function showNewsAnalysis(){
// if the newsAnalysis array exists
if (window.newsAnalysis){
var na = '';
// the newsAnalysis array is defined externally
for(i=1; i' + newsAnalysis[i][1] + '
' + newsAnalysis[i][2] + '
';
}
// add the title and containing box
na = '
News Analysis
' + na + '
';
return na;
}
}
// function to parse the "Breaking News" section
function showBreakingNews(){
// if the breakingNews array exists
if (window.breakingNews){
var bn = '';
// the breakingNews array is defined externally
for(i=1; i' + breakingNews[i][1] + '';
}
// add the title and containing box
bn = '
Breaking News
' + bn + '
';
return bn;
}
}
// news data length, test: 53987
// test var dump:
// na: 16085 - 18659
// bn: 18709 - 21898
var newsAnalysis = new Array(); newsAnalysis[1] = new Array( 'http://www.emsnow.com/npps/story.cfm?pg=story&id=41596', 'Monitor production by top PC, monitor brands to hit 12.9 M. in March', 'Feb 09, 2010 - January LCD monitor production for top PC and monitor brands, which together account for about 85% of the overall market, was 12.5 million units, the highest level in more than a year, according to DisplaySearch.');
newsAnalysis[2] = new Array( 'http://www.emsnow.com/npps/story.cfm?pg=story&id=41595', 'Sapphire 2010 Report - The second half of 2010 faces shortage conditions that should be resolved in 2011', 'Feb 09, 2010 - A comprehensive survey of the main market metrics and companies involvement in sapphire materials for electronic applications.');
newsAnalysis[3] = new Array( 'http://www.emsnow.com/npps/story.cfm?pg=story&id=41587', 'Hon Hai sees best January sales in 10 Years', 'Feb 08, 2010 - Hon Hai Precision Industry Co., Ltd. scored revenue of NT$136.3 billion (US$4.2 billion at US$1:NT$32) in January, its best-ever revenue for the month in 10 years.');
newsAnalysis[4] = new Array( 'http://www.emsnow.com/npps/story.cfm?pg=story&id=41586', 'Subsidies to boost China's 3G handset market in 2010', 'Feb 08, 2010 - Driven by aggressive subsidies from wireless carriers that reduce consumer pricing for cell phones, domestic shipments of 3G handsets in China are expected to rise by nearly a factor of six in 2010, according to iSuppli Corp.');
var breakingNews = new Array();
breakingNews[1] = new Array(
'http://www.emsnow.com/npps/story.cfm?pg=story&id=41597',
'2010 IPC Designers Day has designs on the future');
breakingNews[2] = new Array(
'http://www.emsnow.com/npps/story.cfm?pg=story&id=41599',
'Datest Corp. Receives ITAR Registration');
breakingNews[3] = new Array(
'http://www.emsnow.com/npps/story.cfm?pg=story&id=41600',
'EMS provider, ControlTek, is winning new business');
breakingNews[4] = new Array(
'http://www.emsnow.com/npps/story.cfm?pg=story&id=41601',
'Kimball Electronics partners with Water Optimizer on new water saving devices');
breakingNews[5] = new Array(
'http://www.emsnow.com/npps/story.cfm?pg=story&id=41602',
'Nihon Superior opens new office in Indonesia');
breakingNews[6] = new Array(
'http://www.emsnow.com/npps/story.cfm?pg=story&id=41603',
'P.D. Circuits receives grant for Lean Process Training');
breakingNews[7] = new Array(
'http://www.emsnow.com/npps/story.cfm?pg=story&id=41604',
'Screaming Circuits Adds PCB fab service');
breakingNews[8] = new Array(
'http://www.emsnow.com/npps/story.cfm?pg=story&id=41605',
'SelectConnect Technologies launches LPKF MID Service');
breakingNews[9] = new Array(
'http://www.emsnow.com/npps/story.cfm?pg=story&id=41606',
'Weiner International Associates appoints industry expert as Senior Associate');
breakingNews[10] = new Array(
'http://www.emsnow.com/npps/story.cfm?pg=story&id=41607',
'ZESTRON America hosts first SMTA DC Chapter Meeting in 2010');