このコードは機能しますが、変数リストが大きくなるとすぐに非効率になります(すでにそうですか?)。
新しいAPIを使用してTwitterストリームをページに追加しています。つまり、手動で情報を提供する必要があり、ID文字列が返されます。それはOKです。回避策はありません。
この例では、3つのストリームに必要な情報を使用していますが、リストはすぐに数十以上に増えます。
function isValidTweets(ts_titletweets) {
var widgetid = $('#TweetStuff').attr('data-widget-id');
var jackID = '243441836335697920'; //IDs associated with streams
var jillID = '243398621595312128';
var harryID = '243398621595312130';
var ts_titletweets = title.toLowerCase(); //title is parsed from URL elsewhere
validtweets = "jack|jill|harry"; // if the title doesn't match then no streams should be used
if (validtweets.indexOf(ts_titletweets.toLowerCase() + "|") > -1) {
console.log('TweetsEnabled');
if (ts_titletweets == "jack")
{widgetid = jackID;
console.log(widgetid + title)}
else if (ts_titletweets == "jill")
{widgetid = jillID;
console.log(widgetid + title)}
else if (ts_titletweets == "harry")
{widgetid = harryID;
console.log(widgetid + title)};
$('#TweetStuff').html("<a class=\"twitter-timeline\" width=\"500\" height=\"600\" data-widget-id=" + widgetid + "></a>");
$("#newTweetsButton").delay(3000).show(0);
$("#filters").css({'margin' : '-30px 0px 0px 0px'});
return true;
} console.log('no Tweets');
return false;
}
私は手動で再入力していると確信しており、リストが大きくなるにつれてそれを避けたいと思っています。
ありとあらゆる提案は、ありがたい初心者に大いに感謝されます。
ありがとう!
更新されたタイプミス