Skip to content
Browse files

cleanup and a good stopping point.

  • Loading branch information...
1 parent e9c6ed5 commit c00f24ae2a5903ec08451721a0c0efe19fdb731f @smith committed Aug 24, 2011
View
BIN CollegeFootball.wdgt/Back.png
Deleted file not rendered
View
202 CollegeFootball.wdgt/CollegeFootball.css
@@ -1,202 +0,0 @@
-body {
- margin: 0px;
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
-}
-
-table {
- color: white;
- font-size: 12px;
- margin-left: auto;
- margin-right: auto;
-}
-
-td {
- white-space: nowrap;
- text-align: right;
- padding-bottom: 5px;
- border-bottom: dotted 1px;
-}
-
-.link {
- font-size: 16px;
- font-weight: bold;
- position: absolute;
- color: white;
- top: 25px;
-}
-
-.link:hover {
- border-bottom: 1px dotted;
-}
-
-h1#teamName {
- color: white;
- position: absolute;
- margin: 0px;
- padding: 0px;
- top: 35px;
- left: 80px;
- display: inline;
- font-size: 16px;
- font-weight: bold;
-}
-
-
-#teamLogo {
- position: absolute;
- left: 20px;
- top: 15px;
- z-index: 0;
- width: 50px;
- height: 50px;
- background-color: #000000;
-}
-
-.statsText {
- position: absolute;
- right: 25px;
- top: 38px;
- font-size: 10px;
-}
-
-.newsText {
- right: 25px;
- top: 50px;
- font-size: 10px;
-}
-
-.backgroundImage {
- position: absolute;
- top: 0px;
- left: 0px;
-}
-
-#schedule {
- position:absolute;
- top:70px;
- bottom:25px;
- left: 15px;
- right: 15px;
-}
-
-#loading {
- position: absolute;
- top: 280px;
- left: 70px;
- font-size: 16px;
- color: white;
- display: none;
-}
-
-/************
- Back side
-*************/
-#about {
- color: white;
- position: absolute;
- left: 20px;
- top: 40px;
- right: 20px;
- bottom: 200px;
- border-top: 2px solid;
- border-bottom: 2px solid;
-}
-
-#widgetName {
- top: 20px;
- position: absolute;
- white-space: nowrap;
- font-size: 24px;
- font-family: "Rockwell Extra Bold", "Helvetica Neue", Helvetica, Arial, sans-serif;
- font-weight: bold;
-}
-
-#by {
- position: absolute;
- bottom: 20px;
- right: 5px;
- font-family: "Rockwell", "Helvetica Neue", Helvetica, Arial, sans-serif;
- font-size: 14px;
-}
-
-#by:hover {
- border-bottom: 1px solid;
-}
-
-.label {
- position: absolute;
- font-size: 12px;
- color:white;
- left: 70px;
-}
-
-#division-label {
- top:150px;
-}
-
-#conference-label {
- top:190px;
-}
-
-#team-label {
- top:230px;
-}
-
-.popup {
- position:absolute;
- left: 70px;
- width:132px;
-}
-
-#division-popup {
- top:162px;
-}
-
-#conference-popup {
- top:202px;
-}
-
-#team-popup {
- top:242px;
-}
-
-#done {
- position: absolute;
- bottom: 30px;
- right: 30px;
-}
-
-#back {
- display: none;
-}
-
-
-
-/*
- ********************************
- * Flipper styles *
- ********************************
- */
-
-.flip {
- position:absolute;
- bottom: 20px;
- right: 12px;
- width:13px;
- height:13px;
-}
-
-#flip {
- opacity:0;
- background: url(file:///System/Library/WidgetResources/ibutton/white_i.png) no-repeat top left;
- z-index:8000;
-}
-
-#fliprollie {
- display:none;
- opacity:0.25;
- background: url(file:///System/Library/WidgetResources/ibutton/white_rollie.png) no-repeat top left;
- z-index:7999;
-
-}
-
View
85 CollegeFootball.wdgt/CollegeFootball.html
@@ -1,85 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<style type="text/css">
- @import "CollegeFootball.css";
-</style>
-
-<!-- The JavaScript file contains the logic needed for this widget -->
-<script type='text/javascript' src='CollegeFootball.js' charset='utf-8'/>
-
-<!-- The JavaScript file contains the logic we can use to create Dashboard-like Buttons -->
-<script type='text/javascript' src='file:///System/Library/WidgetResources/button/genericButton.js' />
-
-</head>
-
-<body onload='setup();'>
-
-<div id="front" onmousemove='mousemove(event);' onmouseout='mouseexit(event);'>
-<img span="backgroundImage" src="Default.png" alt="" />
-
-<div id="top">
-<div id="teamLogo">&nbsp;</div>
-<h1 id="teamName"></h1>
-<span class="newsText link" onclick="news();">News</span>
-<span class="statsText link" onclick="stats();">Stats</span>
-</div>
-<div id="schedule"></div>
-
-<!-- The following elements comprise the info button, present in the bottom right of thw widget upon mouse over -->
-<div class='flip' id='fliprollie'></div>
-<div class='flip' id='flip' onclick='showPrefs(event);' onmouseover='enterflip(event);' onmouseout='exitflip(event);'></div>
-</div>
-
-<!-- The back div is the preferences UI of the widget. It is hidden by the
- style sheet and shown by the showPrefs() function
- -->
- <div id="back">
- <img span="backgroundImage" src="Back.png" alt="" />
- <span id="loading">Loading...</span>
- <div id="about">
- <span id="widgetName">College Football</span>
- <span id="by" onclick="by();">www.nlsmith.com</span>
- </div>
- <div id='conference-label' class='label'>Conference:</div>
- <select id='conference-popup' class='popup' onchange='conferenceChanged(this);'>
- </select>
- <div id='team-label' class='label'>Team:</div>
- <select id='team-popup' class='popup' onchange='teamChanged(this);'>
- </select>
- <script type="text/javascript">
- updateDefaults();
- if (window.widget)
- {
- var pref = widget.preferenceForKey(createkey("team"));
- if (pref != null)
- {
- defaultTeamIndex = parseInt(pref);
- }
- else
- {
- defaultTeamIndex = 2;
- }
- pref = widget.preferenceForKey(createkey("conference"));
- if (pref != null)
- {
- defaultConferenceIndex = parseInt(pref);
- }
- else
- {
- defaultConferenceIndex = 3;
- }
- }
- populateConferenceSelect();
- document.getElementById ('conference-popup').options[defaultConferenceIndex].selected = true;
- popuplateTeamSelect(conferences[defaultConferenceIndex].array);
- document.getElementById ('team-popup').options[defaultTeamIndex].selected = true;
- </script>
-
- <div id="done"></div>
- </div>
-
-</body>
-
-</html>
View
697 CollegeFootball.wdgt/CollegeFootball.js
@@ -1,697 +0,0 @@
-var ACC = [
- {team:'Boston College', id:103, color:'111111'},
- {team:'Clemson', id:228, color:'f35b0f'},
- {team:'Duke', id:150, color:'004a7b'},
- {team:'Florida State', id:52, color:'b72931'},
- {team:'Georgia Tech', id:59, color:'000000'},
- {team:'Maryland', id:120, color:'d60039'},
- {team:'Miami', id:2390, color:'004325'},
- {team:'N.C. State', id:152, color:'d60039'},
- {team:'North Carolina', id:153, color:'002942'},
- {team:'Virginia', id:258, color:'000066'},
- {team:'Virginia Tech', id:259, color:'7b2129'},
- {team:'Wake Forest', id:154, color:'000000'}
-];
-
-var Big12 = [
- {team:'Baylor', id:239, color:'00844a'},
- {team:'Colorado', id:38, color:'bd9c00'},
- {team:'Iowa State', id:66, color:'d62949'},
- {team:'Kansas', id:2305, color:'0337b4'},
- {team:'Kansas State', id:2306, color:'633194'},
- {team:'Missouri', id:142, color:'000000'},
- {team:'Nebraska', id:158, color:'fe0d04'},
- {team:'Oklahoma', id:201, color:'7b0000'},
- {team:'Oklahoma State', id:197, color:'ff7300'},
- {team:'Texas', id:251, color:'ef7321'},
- {team:'Texas A&M', id:245, color:'6A3333'},
- {team:'Texas Tech', id:2641, color:'d60039'}
-];
-
-var BigEast = [
- {team:'Cincinnati', id:2132, color:'000000'},
- {team:'Connecticut', id:41, color:'0A1E5B'},
- {team:'Louisville', id:97, color:'de0018'},
- {team:'Pittsburgh', id:221, color:'313169'},
- {team:'Rutgers', id:164, color:'000000'},
- {team:'South Florida', id:58, color:'004231'},
- {team:'Syracuse', id:183, color:'1A3E86'},
- {team:'West Virginia', id:277, color:'395ab5'}
-];
-
-var BigTen = [
- {team:'Illinois', id:356, color:'f77329'},
- {team:'Indiana', id:84, color:'580000'},
- {team:'Iowa', id:2294, color:'000000'},
- {team:'Michigan', id:130, color:'292942'},
- {team:'Michigan State', id:127, color:'226b31'},
- {team:'Minnesota', id:135, color:'752132'},
- {team:'Northwestern', id:77, color:'372286'},
- {team:'Ohio State', id:194, color:'de3129'},
- {team:'Penn State', id:213, color:'29294a'},
- {team:'Purdue', id:2509, color:'211818'},
- {team:'Wisconsin', id:275, color:'c32122'}
-];
-
-var ConferenceUSA = [
- {team:'Central Florida', id:2116, color:'000000'},
- {team:'East Carolina', id:151, color:'4b1869'},
- {team:'Houston', id:248, color:'e73139'},
- {team:'Marshall', id:276, color:'186329'},
- {team:'Memphis', id:235, color:'29299c'},
- {team:'Rice', id:242, color:'00315a'},
- {team:'SMU', id:2567, color:'e73139'},
- {team:'Southern Miss', id:2572, color:'FFAA3C'},
- {team:'Tulane', id:2655, color:'084a38'},
- {team:'Tulsa', id:202, color:'004273'},
- {team:'UAB', id:5, color:'000000'},
- {team:'UTEP', id:2638, color:'ff7339'}
-];
-
-var IAIndependents = [
- {team:'Army', id:349, color:'ce9c00'},
- {team:'Navy', id:2426, color:'0f1021'},
- {team:'Notre Dame', id:87, color:'313a98'},
- {team:'Temple', id:218, color:'bc0138'}
-];
-
-var MidAmerican = [
- {team:'Akron', id:2006, color:'0A1E5B'},
- {team:'Ball State', id:2050, color:'de0000'},
- {team:'Bowling Green', id:189, color:'663300'},
- {team:'Buffalo', id:2084, color:'004a84'},
- {team:'Central Michigan', id:2117, color:'7b0000'},
- {team:'Eastern Michigan', id:2199, color:'217038'},
- {team:'Kent State', id:2309, color:'212142'},
- {team:'Miami (OHIO)', id:193, color:'ce2229'},
- {team:'Northern Illinois', id:2459, color:'e73139'},
- {team:'Ohio', id:195, color:'006342'},
- {team:'Toledo', id:2649, color:'00275D'},
- {team:'Western Michigan', id:2711, color:'825229'}
-];
-
-var MountainWest = [
- {team:'Air Force', id:2005, color:'004a7b'},
- {team:'BYU', id:252, color:'002942'},
- {team:'Colorado State', id:36, color:'008c73'},
- {team:'New Mexico', id:167, color:'000000'},
- {team:'San Diego State', id:21, color:'d60039'},
- {team:'TCU', id:2628, color:'201852'},
- {team:'UNLV', id:2439, color:'000000'},
- {team:'Utah', id:254, color:'ce4242'},
- {team:'Wyoming', id:2751, color:'523921'}
-];
-
-var Pacific10 = [
- {team:'Arizona', id:12, color:'102142'},
- {team:'Arizona State', id:9, color:'942139'},
- {team:'California', id:25, color:'002942'},
- {team:'Oregon', id:2483, color:'044520'},
- {team:'Oregon State', id:204, color:'000000'},
- {team:'Stanford', id:24, color:'b72931'},
- {team:'UCLA', id:26, color:'005a94'},
- {team:'USC', id:30, color:'a50010'},
- {team:'Washington', id:264, color:'3E3468'},
- {team:'Washington State', id:265, color:'94022a'}
-];
-
-var SEC = [
- {team:'Alabama', id:333, color:'a42d47'},
- {team:'Arkansas', id:8, color:'9c1831'},
- {team:'Auburn', id:2, color:'182942'},
- {team:'Florida', id:57, color:'2a42ce'},
- {team:'Georgia', id:61, color:'d60022'},
- {team:'Kentucky', id:96, color:'003399'},
- {team:'LSU', id:99, color:'2B0D57'},
- {team:'Mississippi', id:145, color:'101894'},
- {team:'Mississippi St.', id:344, color:'531122'},
- {team:'South Carolina', id:2579, color:'000000'},
- {team:'Tennessee', id:2633, color:'EE9627'},
- {team:'Vanderbilt', id:238, color:'000000'}
-];
-
-var SunBelt = [
- {team:'Arkansas State', id:2032, color:'e81018'},
- {team:'Fla Atlantic', id:2226, color:'000099'},
- {team:'Florida Intl', id:2229, color:'091731'},
- {team:'La Lafayette', id:309, color:'ce2842'},
- {team:'Louisiana Monroe', id:2433, color:'000000'},
- {team:'Middle Tenn. St.', id:2393, color:'1842d6'},
- {team:'North Texas', id:249, color:'006342'},
- {team:'Troy', id:2653, color:'843131'},
-];
-
-var WAC = [
- {team:'Boise State', id:68, color:'29299c'},
- {team:'Fresno State', id:278, color:'e73139'},
- {team:'Hawaii', id:62, color:'004231'},
- {team:'Idaho', id:70, color:'000000'},
- {team:'Louisiana Tech', id:2348, color:'3129e7'},
- {team:'Nevada', id:2440, color:'084a73'},
- {team:'New Mexico State', id:166, color:'730000'},
- {team:'San Jose State', id:23, color:'005a94'},
- {team:'Utah State', id:328, color:'020767'}
-];
-
-var Atlantic10 = [
- {team:'Delaware', id:48, color:'285998'},
- {team:'Hofstra', id:2275, color:'27297c'},
- {team:'James Madison', id:256, color:'0f1358'},
- {team:'Maine', id:311, color:'000000'},
- {team:'Massachusetts', id:113, color:'ac0d1e'},
- {team:'New Hampshire', id:160, color:'004371'},
- {team:'Northeastern', id:111, color:'CC0001'},
- {team:'Rhode Island', id:227, color:'003366'},
- {team:'Richmond', id:257, color:'004371'},
- {team:'Towson', id:119, color:'F3AE22'},
- {team:'Villanova', id:222, color:'006699'},
- {team:'William & Mary', id:2729, color:'00423e'}
-];
-
-var BigSky = [
- {team:'Eastern Wash.', id:331, color:'d72d35'},
- {team:'Idaho State', id:304, color:'ef8c00'},
- {team:'Montana', id:149, color:'63104a'},
- {team:'Montana State', id:147, color:'010670'},
- {team:'Northern Arizona', id:2464, color:'001894'},
- {team:'Portland State', id:2502, color:'005e60'},
- {team:'Sacramento State', id:16, color:'145f52'},
- {team:'Weber State', id:2692, color:'18005a'}
-];
-
-var BigSouth = [
- {team:'Char. Southern', id:2127, color:'2e3192'},
- {team:'Coastal Carolina', id:324, color:'59a0a0'},
- {team:'Gardner Webb', id:2241, color:'CF0000'},
- {team:'Liberty', id:2335, color:'000073'},
- {team:'VMI', id:2678, color:'000000'}
-];
-
-var Gateway = [
- {team:'Illinois State', id:2287, color:'d72d35'},
- {team:'Indiana State', id:282, color:'00669a'},
- {team:'Missouri State', id:2623, color:'4a0010'},
- {team:'Northern Iowa', id:2460, color:'130671'},
- {team:'Southern Illinois', id:79, color:'85283D'},
- {team:'Western Illinois', id:2710, color:'4e1e8a'},
- {team:'Western Kentucky', id:98, color:'000000'},
- {team:'Youngstown State', id:2754, color:'961f22'}
-];
-
-var GreatWest = [
- {team:'Cal Poly', id:13, color:'083808'},
- {team:'North Dakota St', id:2449, color:'006421'},
- {team:'Northern Colorado', id:2458, color:'003399'},
- {team:'South Dakota St', id:2571, color:'00256f'},
- {team:'Southern Utah', id:253, color:'d10000'},
- {team:'UC Davis', id:302, color:'103670'}
-];
-
-var IAAIndependents = [
- {team:'Savannah State', id:2542, color:'330099'}
-];
-
-var Ivy = [
- {team:'Brown', id:225, color:'54413a'},
- {team:'Columbia', id:171, color:'00295a'},
- {team:'Cornell', id:172, color:'d60027'},
- {team:'Dartmouth', id:159, color:'005730'},
- {team:'Harvard', id:108, color:'990000'},
- {team:'Pennsylvania', id:219, color:'B10021'},
- {team:'Princeton', id:163, color:'ff9408'},
- {team:'Yale', id:43, color:'004a81'}
-];
-
-var MAAC = [
- {team:'Duquesne', id:2184, color:'283a61'},
- {team:'Iona', id:314, color:'8c001a'},
- {team:'La Salle', id:2325, color:'000063'},
- {team:'Marist', id:2368, color:'e53730'},
- {team:"St. Peter's", id:2612, color:'001555'}
-];
-
-var MEAC = [
- {team:'Bethune Cookman', id:2065, color:'7b1831'},
- {team:'Delaware State', id:2169, color:'FF3630'},
- {team:'Florida A&M', id:50, color:'ff7329'},
- {team:'Hampton', id:2261, color:'0067AC'},
- {team:'Howard', id:47, color:'9e0b0e'},
- {team:'Morgan State', id:2415, color:'0505aa'},
- {team:'N. Carolina A&T', id:2448, color:'0505aa'},
- {team:'Norfolk State', id:2450, color:'08614f'},
- {team:'South Carolina St', id:2569, color:'7d1315'}
-];
-
-var Northeast = [
- {team:'Albany', id:399, color:'56438E'},
- {team:'Central Conn.', id:2115, color:'1e489c'},
- {team:'Monmouth (N.J.)', id:2405, color:'0d217b'},
- {team:'Robert Morris', id:2523, color:'3d4262'},
- {team:'Sacred Heart', id:2529, color:'bb003a'},
- {team:'St. Francis (PA)', id:2598, color:'a20012'},
- {team:'Stony Brook', id:2619, color:'003559'},
- {team:'Wagner', id:2681, color:'003e22'}
-];
-
-var OhioValley = [
- {team:'Eastern Illinois', id:2197, color:'000000'},
- {team:'Eastern Kentucky', id:2198, color:'800000'},
- {team:'Jacksonville St.', id:55, color:'c61018'},
- {team:'Murray State', id:93, color:'182356'},
- {team:'Samford', id:2535, color:'005485'},
- {team:'SE Missouri State', id:2546, color:'cc0000'},
- {team:'Tenn. Martin', id:2630, color:'000099'},
- {team:'Tennessee State', id:2634, color:'21398c'},
- {team:'Tennessee Tech', id:2635, color:'440e62'}
-];
-
-var PatriotLeague = [
- {team:'Bucknell', id:2083, color:'000060'},
- {team:'Colgate', id:2142, color:'910028'},
- {team:'Fordham', id:2230, color:'a50019'},
- {team:'Georgetown', id:46, color:'38427a'},
- {team:'Holy Cross', id:107, color:'0a0a0a'},
- {team:'Lafayette', id:322, color:'790000'},
- {team:'Lehigh', id:2329, color:'6c2b2a'}
-];
-
-var Pioneer = [
- {team:'Austin Peay', id:2046, color:'8e0b0b'},
- {team:'Butler', id:2086, color:'0d1361'},
- {team:'Davidson', id:2166, color:'000000'},
- {team:'Dayton', id:2168, color:'e50b0d'},
- {team:'Drake', id:2181, color:'0d1361'},
- {team:'Jacksonville', id:294, color:'008568'},
- {team:'Morehead State', id:2413, color:'29109c'},
- {team:'San Diego', id:301, color:'0d1361'},
- {team:'Valparaiso', id:2674, color:'000000'}
-];
-
-var Southern = [
- {team:'Appalachian St.', id:2026, color:'000000'},
- {team:'Elon University', id:2210, color:'020303'},
- {team:'Furman', id:231, color:'4A2184'},
- {team:'Georgia Southern', id:290, color:'0a3861'},
- {team:'The Citadel', id:2643, color:'000000'},
- {team:'UT-Chattanooga', id:236, color:'253b81'},
- {team:'Western Carolina', id:2717, color:'6e268b'},
- {team:'Wofford', id:2747, color:'000000'}
-];
-
-var Southland = [
- {team:'McNeese State', id:2377, color:'003366'},
- {team:'Nicholls State', id:2447, color:'2a5074'},
- {team:'Northwestern St.', id:2466, color:'68565f'},
- {team:'Sam Houston St.', id:2534, color:'FF7800'},
- {team:'SE Louisiana', id:2545, color:'205228'},
- {team:'Stephen F. Austin', id:2617, color:'230d3c'},
- {team:'Texas State', id:326, color:'94314a'}
-];
-
-var SWAC = [
- {team:'Alabama A&M', id:2010, color:'790000'},
- {team:'Alabama State', id:2011, color:'603913'},
- {team:'Alcorn State', id:2016, color:'C1B881'},
- {team:'Ark Pine Bluff', id:2029, color:'000000'},
- {team:'Grambling', id:2755, color:'ee8601'},
- {team:'Jackson State', id:2296, color:'123297'},
- {team:'Miss. Valley St.', id:2400, color:'054105'},
- {team:'Prairie View', id:2504, color:'4d0960'},
- {team:'Southern', id:2582, color:'291b4c'},
- {team:'Texas Southern', id:2640, color:'680100'}
-];
-
-var conferences = [
- {name:"ACC", array:ACC},
- {name:"Big 12", array:Big12},
- {name:"Big East", array:BigEast},
- {name:"Big Ten", array:BigTen},
- {name:"Conference USA", array:ConferenceUSA},
- {name:"IA Independents", array:IAIndependents},
- {name:"Mid-American", array:MidAmerican},
- {name:"Mountain West", array:MountainWest},
- {name:"Pacific-10", array:Pacific10},
- {name:"SEC", array:SEC},
- {name:"Sun Belt", array:SunBelt},
- {name:"WAC", array:WAC},
- {name:"Atlantic 10", array:Atlantic10},
- {name:"Big Sky", array:BigSky},
- {name:"Big South", array:BigSouth},
- {name:"Gateway", array:Gateway},
- {name:"Great West", array:GreatWest},
- {name:"IAA Independents", array:IAAIndependents},
- {name:"Ivy", array:Ivy},
- {name:"MAAC", array:MAAC},
- {name:"MEAC", array:MEAC},
- {name:"Northeast", array:Northeast},
- {name:"Ohio Valley", array:OhioValley},
- {name:"Patriot League", array:PatriotLeague},
- {name:"Pioneer", array:Pioneer},
- {name:"Southern", array:Southern},
- {name:"Southland", array:Southland},
- {name:"SWAC", array:SWAC}
-];
-
-var defaultTeamIndex = 0;
-var defaultConferenceIndex = 0;
-var teamID;
-var color;
-
-function setup()
-{
- var doneButton = document.getElementById("done");
- createGenericButton(doneButton, "Done", hidePrefs);
-
- teamID = conferences[defaultConferenceIndex].array[defaultTeamIndex].id;
- teamName = conferences[defaultConferenceIndex].array[defaultTeamIndex].team;
- color = conferences[defaultConferenceIndex].array[defaultTeamIndex].color;
-
- get_schedule();
- get_logo();
- get_name();
- set_color();
-}
-
-function get_schedule()
-{
- var commandLine = '/usr/bin/ruby get_schedule.rb ' + teamID;
- var output = widget.system(commandLine, null);
- document.getElementById("schedule").innerHTML = output.outputString;
-}
-
-function get_logo()
-{
- //var logo = '<img src="http://www.nlsmith.com/collegefootball/logos/'
- //+ teamID + '.png" alt="" />';
- var logo = "http://www.nlsmith.com/collegefootball/logos/" + teamID + ".png";
- //document.getElementById("teamLogo").innerHTML = logo;
- document.getElementById("teamLogo").style.backgroundImage = "url(" + logo + ")";
-}
-
-function get_name()
-{
- document.getElementById("teamName").innerHTML = teamName;
-}
-
-function set_color()
-{
- document.getElementById("schedule").style.backgroundColor= "#" + color;
-}
-
-function news()
-{
- widget.openURL('http://sports.espn.go.com/ncf/content?teamId=' + teamID);
-}
-
-function stats()
-{
- widget.openURL('http://sports.espn.go.com/ncf/teams/stats?teamId=' + teamID);
-}
-
-function by()
-{
- widget.openURL('http://www.nlsmith.com/collegefootball.php');
-}
-
-/*********************
- Backside selection
- ******************/
-function updateDefaults()
-{
- // reset defaults to Iowa
- defaultConferenceIndex = 3;
- defaultTeamIndex = 2;
-
- var conferenceName = conferences[defaultConferenceIndex].name;
- var count = conferences.length;
-
- for(i = 0; i < count; i++)
- {
- if (conferenceName == conferences[i].name)
- {
- defaultConferenceIndex = i;
- break;
- }
- }
-
- // get team
- teamName = "Iowa"
- // find city in
-
- var teamArray = conferences[defaultConferenceIndex].array;
- count = teamArray.length;
- var found = false;
- for(i = 0; i < count; i++)
- {
- if (teamName == teamArray[i].team)
- {
- defaultTeamIndex = i;
- found = true;
- break;
- }
- }
-}
-
-function populateConferenceSelect()
-{
- var select = document.getElementById ('conference-popup');
- var c = conferences.length;
-
- for (var i = 0; i < c; ++i)
- {
-
- var element = document.createElement("option");
- element.innerText = conferences[i].name;
- select.appendChild (element);
- }
-}
-
-function popuplateTeamSelect(teams)
-{
- var select = document.getElementById ('team-popup');
-
- // remove all children
- while (select.hasChildNodes())
- select.removeChild(select.firstChild);
-
- var c = teams.length;
-
- for (var i = 0; i < c; ++i)
- {
- var element = document.createElement("option");
- element.innerText = teams[i].team;
- select.appendChild (element);
- }
-}
-
-function createkey(key)
-{
- return widget.identifier + "-" + key;
-}
-
-function conferenceChanged (select)
-{
- if (defaultConferenceIndex != select.selectedIndex)
- {
- defaultConferenceIndex = select.selectedIndex;
- popuplateTeamSelect(conferences[defaultConferenceIndex].array);
- defaultTeamIndex = 0;
- document.getElementById ('team-popup').options[defaultTeamIndex].selected = true;
- teamID = conferences[defaultConferenceIndex].array[defaultTeamIndex].id
- teamName = conferences[defaultConferenceIndex].array[defaultTeamIndex].team
- color = conferences[defaultConferenceIndex].array[defaultTeamIndex].color;
-
- if (window.widget)
- {
- widget.setPreferenceForKey (defaultConferenceIndex.toString(), createkey("conference"));
- widget.setPreferenceForKey (defaultTeamIndex.toString(), createkey("team"));
-
- }
- }
-}
-
-function teamChanged (select)
-{
- if (defaultTeamIndex != select.selectedIndex)
- {
- defaultTeamIndex = select.selectedIndex;
- teamID = conferences[defaultConferenceIndex].array[defaultTeamIndex].id
- teamName = conferences[defaultConferenceIndex].array[defaultTeamIndex].team
- color = conferences[defaultConferenceIndex].array[defaultTeamIndex].color;
-
- if (window.widget)
- {
- widget.setPreferenceForKey (defaultConferenceIndex.toString(), createkey("conference"));
- widget.setPreferenceForKey (defaultTeamIndex.toString(), createkey("team"));
- }
- }
-}
-/*********************************/
-// HIDING AND SHOWING PREFERENCES
-/*********************************/
-
-// showPrefs() is called when the preferences flipper is clicked upon. It freezes the front of the widget,
-// hides the front div, unhides the back div, and then flips the widget over.
-
-function showPrefs()
-{
- var front = document.getElementById("front");
- var back = document.getElementById("back");
-
- if (window.widget)
- {
- widget.prepareForTransition("ToBack"); // freezes the widget so that you can change it without the user noticing
- }
- front.style.display="none"; // hide the front
- back.style.display="block"; // show the back
-
- if (window.widget)
- { setTimeout ('widget.performTransition();', 0); // and flip the widget over
- }
- document.getElementById('fliprollie').style.display = 'none'; // clean up the front side - hide the circle behind the info button
-
-}
-
-
-// hidePrefs() is called by the done button on the back side of the widget. It performs the opposite transition
-// as showPrefs() does.
-
-function hidePrefs()
-{
- document.getElementById("loading").style.display = "block";
- get_schedule();
- get_logo();
- get_name();
- set_color();
- document.getElementById("loading").style.display = "none";
-
- var front = document.getElementById("front");
- var back = document.getElementById("back");
-
- if (window.widget) {
- widget.prepareForTransition("ToFront"); // freezes the widget and prepares it for the flip back to the front
- }
- back.style.display="none"; // hide the back
- front.style.display="block"; // show the front
-
- if (window.widget)
- { setTimeout ('widget.performTransition();', 0); // and flip the widget back to the front
- }
-
-}
-
-
-// PREFERENCE BUTTON ANIMATION (- the pref flipper fade in/out)
-
-var flipShown = false; // a flag used to signify if the flipper is currently shown or not.
-
-
-// A structure that holds information that is needed for the animation to run.
-var animation = {duration:0, starttime:0, to:1.0, now:0.0, from:0.0, firstElement:null, timer:null};
-
-
-// mousemove() is the event handle assigned to the onmousemove property on the front div of the widget.
-// It is triggered whenever a mouse is moved within the bounds of your widget. It prepares the
-// preference flipper fade and then calls animate() to performs the animation.
-
-function mousemove (event)
-{
- if (!flipShown) // if the preferences flipper is not already showing...
- {
- if (animation.timer != null) // reset the animation timer value, in case a value was left behind
- {
- clearInterval (animation.timer);
- animation.timer = null;
- }
-
- var starttime = (new Date).getTime() - 13; // set it back one frame
-
- animation.duration = 500; // animation time, in ms
- animation.starttime = starttime; // specify the start time
- animation.firstElement = document.getElementById ('flip'); // specify the element to fade
- animation.timer = setInterval ("animate();", 13); // set the animation function
- animation.from = animation.now; // beginning opacity (not ness. 0)
- animation.to = 1.0; // final opacity
- animate(); // begin animation
- flipShown = true; // mark the flipper as animated
- }
-}
-
-// mouseexit() is the opposite of mousemove() in that it preps the preferences flipper
-// to disappear. It adds the appropriate values to the animation data structure and sets the animation in motion.
-
-function mouseexit (event)
-{
- if (flipShown)
- {
- // fade in the flip widget
- if (animation.timer != null)
- {
- clearInterval (animation.timer);
- animation.timer = null;
- }
-
- var starttime = (new Date).getTime() - 13;
-
- animation.duration = 500;
- animation.starttime = starttime;
- animation.firstElement = document.getElementById ('flip');
- animation.timer = setInterval ("animate();", 13);
- animation.from = animation.now;
- animation.to = 0.0;
- animate();
- flipShown = false;
- }
-}
-
-
-// animate() performs the fade animation for the preferences flipper. It uses the opacity CSS property to simulate a fade.
-
-function animate()
-{
- var T;
- var ease;
- var time = (new Date).getTime();
-
-
- T = limit_3(time-animation.starttime, 0, animation.duration);
-
- if (T >= animation.duration)
- {
- clearInterval (animation.timer);
- animation.timer = null;
- animation.now = animation.to;
- }
- else
- {
- ease = 0.5 - (0.5 * Math.cos(Math.PI * T / animation.duration));
- animation.now = computeNextFloat (animation.from, animation.to, ease);
- }
-
- animation.firstElement.style.opacity = animation.now;
-}
-
-
-// these functions are utilities used by animate()
-
-function limit_3 (a, b, c)
-{
- return a < b ? b : (a > c ? c : a);
-}
-
-function computeNextFloat (from, to, ease)
-{
- return from + (to - from) * ease;
-}
-
-// these functions are called when the info button itself receives onmouseover and onmouseout events
-
-function enterflip(event)
-{
- document.getElementById('fliprollie').style.display = 'block';
-}
-
-function exitflip(event)
-{
- document.getElementById('fliprollie').style.display = 'none';
-}
View
0 CollegeFootball.wdgt/Default.png 100755 → 100644
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0 CollegeFootball.wdgt/Icon.png 100755 → 100644
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
10 CollegeFootball.wdgt/Info.plist 100755 → 100644
@@ -15,20 +15,20 @@
<key>AllowNetworkAccess</key>
<true/>
<key>AllowSystem</key>
- <true/>
+ <false/>
<key>CFBundleDisplayName</key>
<string>College Football</string>
<key>CFBundleIdentifier</key>
<string>com.nlsmith.widget.CollegeFootball</string>
<key>CFBundleName</key>
<string>College Football</string>
<key>CFBundleVersion</key>
- <string>1.3.5</string>
+ <string>2.0.0</string>
<key>CloseBoxInsetX</key>
- <integer>12</integer>
+ <integer>3</integer>
<key>CloseBoxInsetY</key>
- <integer>12</integer>
+ <integer>3</integer>
<key>MainHTML</key>
- <string>CollegeFootball.html</string>
+ <string>index.html</string>
</dict>
</plist>
View
120 CollegeFootball.wdgt/get_schedule.rb
@@ -1,120 +0,0 @@
-require "open-uri"
-require "htmltokenizer/lib/html/htmltokenizer.rb"
-
-# read table from web
-url = "http://sports.espn.go.com/ncf/teamsched?teamId=" + ARGV[0]
-inTable = false
-table = "<table>"
-open(url).each do |line|
- if(line =~ /<tr.*class="oddrow"/)
- table << line
- end
-end
-
-# modify table contents
-
-# strip <a> and <img> tags
-tokenizer = HTMLTokenizer.new(table)
-table = ""
-while(token = tokenizer.getTag)
- if(token.to_s =~ /<a/)
- table << tokenizer.getText
- elsif(token.to_s =~ /<\/a/ or token.to_s =~ /<img/);
- else
- table << token.to_s << tokenizer.getText
- end
-end
-
-#remove colums 4-5
-tokenizer = HTMLTokenizer.new(table)
-table = ""
-table << tokenizer.getTag('table').to_s
-while(token = tokenizer.getTag('tr'))
- table << token.to_s
- 3.times do
- token = tokenizer.getTag('td')
-
- # Handle glossary table
- break if token.nil?
- text = tokenizer.getText
- break if text =~ /^\*/ || text == "Glossary"
-
- table << token.to_s << text
- token = tokenizer.getTag('/td')
- table << token.to_s
- end
- token = tokenizer.getTag('/tr')
- table << token.to_s
-end
-table << "</table>"
-
-#strip tag attributes
-tokenizer = HTMLTokenizer.new(table)
-table = ""
-while(token = tokenizer.getTag)
- if token.attr_hash.length > 0
- table << "<#{token.tag_name}>"
- else
- table << token.to_s
- end
-
- unless(token.to_s =~ /<\/.*/)
- table << tokenizer.getText
- end
-end
-
-#change months to numbers
-months = {
- "January" => "1",
- "February" => "2",
- "March" => "3",
- "April" => "4",
- "May" => "5",
- "June" => "6",
- "July" => "7",
- "August" => "8",
- "September" => "9",
- "October" => "10",
- "November" => "11",
- "December" => "12"
-}
-months.each_pair { |name, number| table.gsub!("#{name} ","#{number}/") }
-
-
-#replace "No. " w/ "#"
-table.gsub!(/No.\s/, "#")
-
-
-#convert time zone
-tz = Time.now.zone
-if(tz =~ /[C|M|P][D|S]T/) # central, mountain, or pacific
- if(tz =~ /C[D|S]T/) # central
- tzOffset = 1
- elsif(tz =~ /M[D|S]T/) # mountain
- tzOffset = 2
- elsif(tz =~ /P[D|S]T/) # mountain
- tzOffset = 3
- end
-
- re = /(\d+):(\d+) ([A|P]M)&nbsp;ET(.*?)</ # match a time hh:mm A|PM ET
-
- table.gsub!(re) do |m|
- md = re.match(m)
-
- # convert to 24 hour form and make tz adjustment
- hour = md[1].to_i
- hour += 12 if hour < 12 && md[3].upcase == 'PM'
- hour -= 12 if hour == 12 && md[3].upcase == 'AM'
- hour -= tzOffset # the tz adjustment from ET to local
- hour += 24 if hour < 0
-
- # convert back to 12 hour form
- ampm = (hour < 12 ? 'AM' : 'PM')
- hour -= 12 if hour > 12
-
- hour.to_s + ':' + md[2] + ' ' + ampm + '<'
- end
-end
-
-print table
-
View
63 CollegeFootball.wdgt/htmltokenizer/README
@@ -1,63 +0,0 @@
-htmltokenizer README
-============
-
- htmltokenizer is a port of the idea behind Perl's HTML::TokeParser::Simple.
- The basic concept is that it treats a web page as a series of tokens, which
- are either text, html tags, or html comments. This class provides a way
- of getting these tokens in sequence, either one at a time regardless of
- type, or by choosing a list of interesting tags.
-
-Requirements
-------------
-
- * ruby
-
-Install
--------
-
- De-Compress archive and enter its top directory.
- Then type:
-
- $ ruby install.rb config
- $ ruby install.rb setup
- $ su -c "ruby install.rb install"
-
- or
-
- $ ruby install.rb config
- $ ruby install.rb setup
- $ sudo ruby install.rb install
-
- You can also install files into your favorite directory
- by supplying install.rb some options. Try "ruby install.rb --help".
-
-Usage
------
-
-require 'html/htmltokenizer'
-
-page = getSomePageFromTheInternetAsAString()
-
-tokenizer = HTMLTokenizer.new(page)
-
-while token = tokenizer.getTag('a', 'font', '/tr', 'div')
- if 'div' == token.tag_name
- if 'headlinesheader' == token.attr_hash['class']
- puts "Header is: " + tokenizer.getTrimmedText('/div')
- else
- tokenizer.getTag('/div')
- token = tokenizer.getTag('a')
- if token.attr_hash['href']
- puts "Found a link after a div going to #{token.attr_hash['href']}"
- end
- end
- end
-end
-
-License
--------
-
- Ruby's license, see http://www.ruby-lang.org/en/LICENSE.txt
-
-
-Ben Giddings <bg-rubyraa@infofiend.com>
View
17 CollegeFootball.wdgt/htmltokenizer/index.html
@@ -1,17 +0,0 @@
-<html>
- <head>
- <title>HTML Tokenizer</title>
- </head>
- <body>
- <h1>HTML Tokenizer</h1>
- <p>
- This is a port of the idea behind Perl's HTML::TokeParser::Simple.
- </p>
- <p>
- For more information, see the
- <a href="README">README</a> file or just download
- <a href="lib/html/htmltokenizer.rb">the source</a> or
- <a href="htmltokenizer-0.91.tar.gz">the installable tarball</a>.
- </p>
- </body>
-</html>
View
1,098 CollegeFootball.wdgt/htmltokenizer/install.rb
@@ -1,1098 +0,0 @@
-#
-# This file is automatically generated. DO NOT MODIFY!
-#
-# install.rb
-#
-# Copyright (c) 2000-2003 Minero Aoki <aamine@loveruby.net>
-#
-# This program is free software.
-# You can distribute/modify this program under the terms of
-# the GNU Lesser General Public License version 2.
-#
-
-### begin compat.rb
-
-module Enumerable
- methods = instance_methods()
-
- unless methods.include?('map')
- alias map collect
- end
-
- unless methods.include?('select')
- alias select find_all
- end
-
- unless methods.include?('reject')
- def reject
- result = []
- each do |i|
- result.push i unless yield(i)
- end
- result
- end
- end
-
- unless methods.include?('inject')
- def inject( result )
- each do |i|
- result = yield(result, i)
- end
- result
- end
- end
-
- unless methods.include?('any?')
- def any?
- each do |i|
- return true if yield(i)
- end
- false
- end
- end
-end
-
-def File.read_all( fname )
- File.open(fname, 'rb') {|f| return f.read }
-end
-
-def File.write( fname, str )
- File.open(fname, 'wb') {|f| f.write str }
-end
-
-### end compat.rb
-### begin config.rb
-
-if i = ARGV.index(/\A--rbconfig=/)
- file = $'
- ARGV.delete_at(i)
- require file
-else
- require 'rbconfig'
-end
-
-
-class ConfigTable
-
- c = ::Config::CONFIG
-
- rubypath = c['bindir'] + '/' + c['ruby_install_name']
-
- major = c['MAJOR'].to_i
- minor = c['MINOR'].to_i
- teeny = c['TEENY'].to_i
- version = "#{major}.#{minor}"
-
- # ruby ver. >= 1.4.4?
- newpath_p = ((major >= 2) or
- ((major == 1) and
- ((minor >= 5) or
- ((minor == 4) and (teeny >= 4)))))
-
- re = Regexp.new('\A' + Regexp.quote(c['prefix']))
- subprefix = lambda {|path|
- re === path and path.sub(re, '$prefix')
- }
-
- if c['rubylibdir']
- # V < 1.6.3
- stdruby = subprefix.call(c['rubylibdir'])
- siteruby = subprefix.call(c['sitedir'])
- versite = subprefix.call(c['sitelibdir'])
- sodir = subprefix.call(c['sitearchdir'])
- elsif newpath_p
- # 1.4.4 <= V <= 1.6.3
- stdruby = "$prefix/lib/ruby/#{version}"
- siteruby = subprefix.call(c['sitedir'])
- versite = siteruby + '/' + version
- sodir = "$site-ruby/#{c['arch']}"
- else
- # V < 1.4.4
- stdruby = "$prefix/lib/ruby/#{version}"
- siteruby = "$prefix/lib/ruby/#{version}/site_ruby"
- versite = siteruby
- sodir = "$site-ruby/#{c['arch']}"
- end
-
- DESCRIPTER = [
- [ 'prefix', [ c['prefix'],
- 'path',
- 'path prefix of target environment' ] ],
- [ 'std-ruby', [ stdruby,
- 'path',
- 'the directory for standard ruby libraries' ] ],
- [ 'site-ruby-common', [ siteruby,
- 'path',
- 'the directory for version-independent non-standard ruby libraries' ] ],
- [ 'site-ruby', [ versite,
- 'path',
- 'the directory for non-standard ruby libraries' ] ],
- [ 'bin-dir', [ '$prefix/bin',
- 'path',
- 'the directory for commands' ] ],
- [ 'rb-dir', [ '$site-ruby',
- 'path',
- 'the directory for ruby scripts' ] ],
- [ 'so-dir', [ sodir,
- 'path',
- 'the directory for ruby extentions' ] ],
- [ 'data-dir', [ '$prefix/share',
- 'path',
- 'the directory for shared data' ] ],
- [ 'ruby-path', [ rubypath,
- 'path',
- 'path to set to #! line' ] ],
- [ 'ruby-prog', [ rubypath,
- 'name',
- 'the ruby program using for installation' ] ],
- [ 'make-prog', [ 'make',
- 'name',
- 'the make program to compile ruby extentions' ] ],
- [ 'without-ext', [ 'no',
- 'yes/no',
- 'does not compile/install ruby extentions' ] ]
- ]
-
- SAVE_FILE = 'config.save'
-
- def ConfigTable.each_name( &block )
- keys().each(&block)
- end
-
- def ConfigTable.keys
- DESCRIPTER.map {|k,*dummy| k }
- end
-
- def ConfigTable.each_definition( &block )
- DESCRIPTER.each(&block)
- end
-
- def ConfigTable.get_entry( name )
- name, ent = DESCRIPTER.assoc(name)
- ent
- end
-
- def ConfigTable.get_entry!( name )
- get_entry(name) or raise ArgumentError, "no such config: #{name}"
- end
-
- def ConfigTable.add_entry( name, vals )
- ConfigTable::DESCRIPTER.push [name,vals]
- end
-
- def ConfigTable.remove_entry( name )
- get_entry name or raise ArgumentError, "no such config: #{name}"
- DESCRIPTER.delete_if {|n,arr| n == name }
- end
-
- def ConfigTable.config_key?( name )
- get_entry(name) ? true : false
- end
-
- def ConfigTable.bool_config?( name )
- ent = get_entry(name) or return false
- ent[1] == 'yes/no'
- end
-
- def ConfigTable.value_config?( name )
- ent = get_entry(name) or return false
- ent[1] != 'yes/no'
- end
-
- def ConfigTable.path_config?( name )
- ent = get_entry(name) or return false
- ent[1] == 'path'
- end
-
-
- class << self
- alias newobj new
-
- def new
- c = newobj()
- c.__send__ :init
- c
- end
-
- def load
- c = newobj()
- raise InstallError, "#{File.basename $0} config first"\
- unless FileTest.file?(SAVE_FILE)
- File.foreach(SAVE_FILE) do |line|
- k, v = line.split(/=/, 2)
- c.instance_eval {
- @table[k] = v.strip
- }
- end
- c
- end
- end
-
- def initialize
- @table = {}
- end
-
- def init
- DESCRIPTER.each do |k, (default, vname, desc, default2)|
- @table[k] = default
- end
- end
- private :init
-
- def save
- File.open(SAVE_FILE, 'w') {|f|
- @table.each do |k, v|
- f.printf "%s=%s\n", k, v if v
- end
- }
- end
-
- def []=( k, v )
- ConfigTable.config_key? k or raise InstallError, "unknown config option #{k}"
- if ConfigTable.path_config? k
- @table[k] = (v[0,1] != '$') ? File.expand_path(v) : v
- else
- @table[k] = v
- end
- end
-
- def []( key )
- @table[key] or return nil
- @table[key].gsub(%r<\$([^/]+)>) { self[$1] }
- end
-
- def set_raw( key, val )
- @table[key] = val
- end
-
- def get_raw( key )
- @table[key]
- end
-
-end
-
-
-module MetaConfigAPI
-
- def eval_file_ifexist( fname )
- instance_eval File.read_all(fname), fname, 1 if FileTest.file?(fname)
- end
-
- def config_names
- ConfigTable.keys
- end
-
- def config?( name )
- ConfigTable.config_key? name
- end
-
- def bool_config?( name )
- ConfigTable.bool_config? name
- end
-
- def value_config?( name )
- ConfigTable.value_config? name
- end
-
- def path_config?( name )
- ConfigTable.path_config? name
- end
-
- def add_config( name, argname, default, desc )
- ConfigTable.add_entry name,[default,argname,desc]
- end
-
- def add_path_config( name, default, desc )
- add_config name, 'path', default, desc
- end
-
- def add_bool_config( name, default, desc )
- add_config name, 'yes/no', default ? 'yes' : 'no', desc
- end
-
- def set_config_default( name, default )
- if bool_config? name
- ConfigTable.get_entry!(name)[0] = default ? 'yes' : 'no'
- else
- ConfigTable.get_entry!(name)[0] = default
- end
- end
-
- def remove_config( name )
- ent = ConfigTable.get_entry(name)
- ConfigTable.remove_entry name
- ent
- end
-
-end
-
-### end config.rb
-### begin fileop.rb
-
-module FileOperations
-
- def mkdir_p( dname, prefix = nil )
- dname = prefix + dname if prefix
- $stderr.puts "mkdir -p #{dname}" if verbose?
- return if no_harm?
-
- # does not check '/'... it's too abnormal case
- dirs = dname.split(%r<(?=/)>)
- if /\A[a-z]:\z/i === dirs[0]
- disk = dirs.shift
- dirs[0] = disk + dirs[0]
- end
- dirs.each_index do |idx|
- path = dirs[0..idx].join('')
- Dir.mkdir path unless dir? path
- end
- end
-
- def rm_f( fname )
- $stderr.puts "rm -f #{fname}" if verbose?
- return if no_harm?
-
- if File.exist? fname or File.symlink? fname
- File.chmod 0777, fname
- File.unlink fname
- end
- end
-
- def rm_rf( dn )
- $stderr.puts "rm -rf #{dn}" if verbose?
- return if no_harm?
-
- Dir.chdir dn
- Dir.foreach('.') do |fn|
- next if fn == '.'
- next if fn == '..'
- if dir? fn
- verbose_off {
- rm_rf fn
- }
- else
- verbose_off {
- rm_f fn
- }
- end
- end
- Dir.chdir '..'
- Dir.rmdir dn
- end
-
- def mv( src, dest )
- rm_f dest
- begin
- File.link src, dest
- rescue
- File.write dest, File.read_all(src)
- File.chmod File.stat(src).mode, dest
- end
- rm_f src
- end
-
- def install( from, dest, mode, prefix = nil )
- $stderr.puts "install #{from} #{dest}" if verbose?
- return if no_harm?
-
- realdest = prefix + dest if prefix
- if dir? realdest
- realdest += '/' + File.basename(from)
- end
- str = File.read_all(from)
- if diff? str, realdest
- verbose_off {
- rm_f realdest if File.exist? realdest
- }
- File.write realdest, str
- File.chmod mode, realdest
-
- File.open(objdir + '/InstalledFiles', 'a') {|f| f.puts realdest }
- end
- end
-
- def diff?( orig, targ )
- return true unless File.exist? targ
- orig != File.read_all(targ)
- end
-
- def command( str )
- $stderr.puts str if verbose?
- system str or raise RuntimeError, "'system #{str}' failed"
- end
-
- def ruby( str )
- command config('ruby-prog') + ' ' + str
- end
-
- def dir?( dname )
- # for corrupted windows stat()
- File.directory?((dname[-1,1] == '/') ? dname : dname + '/')
- end
-
- def all_files_in( dname )
- Dir.open(dname) {|d|
- return d.select {|n| FileTest.file? "#{dname}/#{n}" }
- }
- end
-
- REJECT_DIRS = %w(
- CVS SCCS RCS CVS.adm
- )
-
- def all_dirs_in( dname )
- Dir.open(dname) {|d|
- return d.select {|n| dir? "#{dname}/#{n}" } - %w(. ..) - REJECT_DIRS
- }
- end
-
-end
-
-### end fileop.rb
-### begin base.rb
-
-class InstallError < StandardError; end
-
-
-class Installer
-
- Version = '3.1.4'
- Copyright = 'Copyright (c) 2000-2003 Minero Aoki'
-
-
- @toplevel = nil
-
- def self.declare_toplevel_installer( inst )
- raise ArgumentError, 'two toplevel installers declared' if @toplevel
- @toplevel = inst
- end
-
- def self.toplevel_installer
- @toplevel
- end
-
-
- FILETYPES = %w( bin lib ext data )
-
- include FileOperations
-
- def initialize( config, opt, srcroot, objroot )
- @config = config
- @options = opt
- @srcdir = File.expand_path(srcroot)
- @objdir = File.expand_path(objroot)
- @currdir = '.'
- end
-
- def inspect
- "#<#{self.class} #{__id__}>"
- end
-
- #
- # configs/options
- #
-
- def get_config( key )
- @config[key]
- end
-
- alias config get_config
-
- def set_config( key, val )
- @config[key] = val
- end
-
- def no_harm?
- @options['no-harm']
- end
-
- def verbose?
- @options['verbose']
- end
-
- def verbose_off
- save, @options['verbose'] = @options['verbose'], false
- yield
- @options['verbose'] = save
- end
-
- #
- # srcdir/objdir
- #
-
- attr_reader :srcdir
- alias srcdir_root srcdir
- alias package_root srcdir
-
- def curr_srcdir
- "#{@srcdir}/#{@currdir}"
- end
-
- attr_reader :objdir
- alias objdir_root objdir
-
- def curr_objdir
- "#{@objdir}/#{@currdir}"
- end
-
- def srcfile( path )
- curr_srcdir + '/' + path
- end
-
- def srcexist?( path )
- File.exist? srcfile(path)
- end
-
- def srcdirectory?( path )
- dir? srcfile(path)
- end
-
- def srcfile?( path )
- FileTest.file? srcfile(path)
- end
-
- def srcentries( path = '.' )
- Dir.open(curr_srcdir + '/' + path) {|d|
- return d.to_a - %w(. ..) - hookfilenames
- }
- end
-
- def srcfiles( path = '.' )
- srcentries(path).select {|fname|
- FileTest.file? File.join(curr_srcdir, path, fname)
- }
- end
-
- def srcdirectories( path = '.' )
- srcentries(path).select {|fname|
- dir? File.join(curr_srcdir, path, fname)
- }
- end
-
- def dive_into( rel )
- return unless dir?("#{@srcdir}/#{rel}")
-
- dir = File.basename(rel)
- Dir.mkdir dir unless dir?(dir)
- prevdir = Dir.pwd
- Dir.chdir dir
- $stderr.puts '---> ' + rel if verbose?
- @currdir = rel
- yield
- Dir.chdir prevdir
- $stderr.puts '<--- ' + rel if verbose?
- @currdir = File.dirname(rel)
- end
-
- #
- # TASK config
- #
-
- def exec_config
- exec_task_traverse 'config'
- end
-
- def config_dir_bin( rel )
- end
-
- def config_dir_lib( rel )
- end
-
- def config_dir_ext( rel )
- extconf if extdir? curr_srcdir
- end
-
- def extconf
- opt = @options['config-opt'].join(' ')
- command "#{config('ruby-prog')} #{curr_srcdir}/extconf.rb #{opt}"
- end
-
- def config_dir_data( rel )
- end
-
- #
- # TASK setup
- #
-
- def exec_setup
- exec_task_traverse 'setup'
- end
-
- def setup_dir_bin( relpath )
- all_files_in(curr_srcdir()).each do |fname|
- add_rubypath "#{curr_srcdir}/#{fname}"
- end
- end
-
- SHEBANG_RE = /\A\#!\s*\S*ruby\S*/
-
- def add_rubypath( path )
- $stderr.puts %Q<set #! line to "\#!#{config('ruby-path')}" for #{path} ...> if verbose?
- return if no_harm?
-
- tmpfile = File.basename(path) + '.tmp'
- begin
- File.open(path) {|r|
- File.open(tmpfile, 'w') {|w|
- first = r.gets
- return unless SHEBANG_RE === first # reject '/usr/bin/env ruby'
-
- w.print first.sub(SHEBANG_RE, '#!' + config('ruby-path'))
- w.write r.read
- } }
- mv tmpfile, File.basename(path)
- ensure
- rm_f tmpfile if File.exist? tmpfile
- end
- end
-
- def setup_dir_lib( relpath )
- end
-
- def setup_dir_ext( relpath )
- make if extdir?(curr_srcdir)
- end
-
- def setup_dir_data( relpath )
- end
-
- #
- # TASK install
- #
-
- def exec_install
- exec_task_traverse 'install'
- end
-
- def install_dir_bin( rel )
- install_files target_filenames(), config('bin-dir') + '/' + rel, 0755
- end
-
- def install_dir_lib( rel )
- install_files target_filenames(), config('rb-dir') + '/' + rel, 0644
- end
-
- def install_dir_ext( rel )
- install_dir_ext_main File.dirname(rel) if extdir?(curr_srcdir)
- end
-
- def install_dir_ext_main( rel )
- install_files allext('.'), config('so-dir') + '/' + rel, 0555
- end
-
- def install_dir_data( rel )
- install_files target_filenames(), config('data-dir') + '/' + rel, 0644
- end
-
- def install_files( list, dest, mode )
- mkdir_p dest, @options['install-prefix']
- list.each do |fname|
- install fname, dest, mode, @options['install-prefix']
- end
- end
-
- def target_filenames
- if FileTest.file? "#{curr_srcdir()}/MANIFEST"
- mapdir(target_filenames_MANIFEST())
- else
- mapdir(target_filenames_AUTO())
- end
- end
-
- def mapdir( filelist )
- filelist.map {|fname|
- if File.exist? fname # current objdir == '.'
- fname
- else
- File.join(curr_srcdir(), fname)
- end
- }
- end
-
- def target_filenames_MANIFEST
- File.read_all("#{curr_srcdir()}/MANIFEST").split
- end
-
- # picked up many entries from cvs-1.11.1/src/ignore.c
- REJECT_PATTERNS = %w(
- core RCSLOG tags TAGS .make.state
- .nse_depinfo #* .#* cvslog.* ,* .del-* *.a *.olb *.o *.obj
- *.so *.Z *~ *.old *.elc *.ln *.bak *.BAK *.orig *.rej *.exe _$* *$
-
- *.org *.in .*
- ).map {|pattern|
- Regexp.compile('\A' + pattern.gsub(/[\.\$]/) {|s| '\\' + s }.gsub(/\*/, '.*') + '\z')
- }
-
- def target_filenames_AUTO
- (existfiles() - hookfiles()).reject {|fname|
- REJECT_PATTERNS.any? {|re| re === fname }
- }
- end
-
- def existfiles
- all_files_in(curr_srcdir()) | all_files_in(curr_objdir())
- end
-
- def hookfiles
- %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt|
- %w( config setup install clean ).map {|t| sprintf(fmt, t) }
- }.flatten
- end
-
- def allext( dir )
- _allext(dir) or raise InstallError,
- "no extention exists: Have you done 'ruby #{$0} setup' ?"
- end
-
- DLEXT = /\.#{ ::Config::CONFIG['DLEXT'] }\z/
-
- def _allext( dir )
- Dir.open(dir) {|d|
- return d.select {|fname| DLEXT === fname }
- }
- end
-
- #
- # TASK clean
- #
-
- def exec_clean
- exec_task_traverse 'clean'
- rm_f 'config.save'
- rm_f 'InstalledFiles'
- end
-
- def clean_dir_bin( rel )
- end
-
- def clean_dir_lib( rel )
- end
-
- def clean_dir_ext( rel )
- make 'clean' if FileTest.file?('Makefile')
- end
-
- def clean_dir_data( rel )
- end
-
- #
- # TASK distclean
- #
-
- def exec_distclean
- exec_task_traverse 'distclean'
- rm_f 'config.save'
- rm_f 'InstalledFiles'
- end
-
- def distclean_dir_bin( rel )
- end
-
- def distclean_dir_lib( rel )
- end
-
- def distclean_dir_ext( rel )
- make 'distclean' if FileTest.file?('Makefile')
- end
-
- #
- # lib
- #
-
- def make( task = '' )
- command config('make-prog') + ' ' + task
- end
-
- def exec_task_traverse( task )
- run_hook 'pre-' + task
- FILETYPES.each do |type|
- if config('without-ext') == 'yes' and type == 'ext'
- $stderr.puts 'skipping ext/* by user option' if verbose?
- next
- end
- traverse task, type, task + '_dir_' + type
- end
- run_hook 'post-' + task
- end
-
- def traverse( task, rel, mid )
- dive_into(rel) {
- run_hook 'pre-' + task
- __send__ mid, rel.sub(%r[\A.*?(?:/|\z)], '')
- all_dirs_in(curr_srcdir()).each do |d|
- traverse task, rel + '/' + d, mid
- end
- run_hook 'post-' + task
- }
- end
-
- def run_hook( name )
- try_run_hook curr_srcdir + '/' + name or
- try_run_hook curr_srcdir + '/' + name + '.rb'
- end
-
- def try_run_hook( fname )
- return false unless FileTest.file?(fname)
-
- env = self.dup
- begin
- env.instance_eval File.read_all(fname), fname, 1
- rescue
- raise InstallError, "hook #{fname} failed:\n" + $!.message
- end
- true
- end
-
- def extdir?( dir )
- File.exist? dir + '/MANIFEST'
- end
-
-end
-
-### end base.rb
-### begin toplevel.rb
-
-class ToplevelInstaller < Installer
-
- def self.invoke
- new(File.dirname($0)).invoke
- end
-
-
- TASKS = [
- [ 'config', 'saves your configurations' ],
- [ 'show', 'shows current configuration' ],
- [ 'setup', 'compiles extention or else' ],
- [ 'install', 'installs files' ],
- [ 'clean', "does `make clean' for each extention" ],
- [ 'distclean',"does `make distclean' for each extention" ]
- ]
-
-
- def initialize( root )
- super nil, {'verbose' => true}, root, '.'
- Installer.declare_toplevel_installer self
- end
-
-
- def invoke
- run_metaconfigs
-
- case task = parsearg_global()
- when 'config'
- @config = ConfigTable.new
- else
- @config = ConfigTable.load
- end
- parsearg_TASK task
-
- exectask task
- end
-
- include MetaConfigAPI
-
- def run_metaconfigs
- eval_file_ifexist "#{srcdir_root()}/metaconfig"
- end
-
-
- def exectask( task )
- if task == 'show'
- exec_show
- else
- try task
- end
- end
-
- def try( task )
- $stderr.printf "#{File.basename $0}: entering %s phase...\n", task if verbose?
- begin
- __send__ 'exec_' + task
- rescue
- $stderr.printf "%s failed\n", task
- raise
- end
- $stderr.printf "#{File.basename $0}: %s done.\n", task if verbose?
- end
-
- #
- # processing arguments
- #
-
- def parsearg_global
- task_re = /\A(?:#{TASKS.map {|i| i[0] }.join '|'})\z/
-
- while arg = ARGV.shift
- case arg
- when /\A\w+\z/
- task_re === arg or raise InstallError, "wrong task: #{arg}"
- return arg
-
- when '-q', '--quiet'
- @options['verbose'] = false
-
- when '--verbose'
- @options['verbose'] = true
-
- when '-h', '--help'
- print_usage $stdout
- exit 0
-
- when '-v', '--version'
- puts "#{File.basename $0} version #{Version}"
- exit 0
-
- when '--copyright'
- puts Copyright
- exit 0
-
- else
- raise InstallError, "unknown global option '#{arg}'"
- end
- end
-
- raise InstallError, "No task or global option given.
-Typical installation procedure is:
- $ ruby #{File.basename $0} config
- $ ruby #{File.basename $0} setup
- # ruby #{File.basename $0} install (may require root privilege)
-"
- end
-
-
- def parsearg_TASK( task )
- mid = "parsearg_#{task}"
- if respond_to? mid, true
- __send__ mid
- else
- ARGV.empty? or
- raise InstallError, "#{task}: unknown options: #{ARGV.join ' '}"
- end
- end
-
- def parsearg_config
- re = /\A--(#{ConfigTable.keys.join '|'})(?:=(.*))?\z/
- @options['config-opt'] = []
-
- while i = ARGV.shift
- if /\A--?\z/ === i
- @options['config-opt'] = ARGV.dup
- break
- end
- m = re.match(i) or raise InstallError, "config: unknown option #{i}"
- name, value = m.to_a[1,2]
- if value
- if ConfigTable.bool_config?(name)
- /\A(y(es)?|n(o)?|t(rue)?|f(alse))\z/i === value or raise InstallError, "config: --#{name} allows only yes/no for argument"
- value = (/\Ay(es)?|\At(rue)/i === value) ? 'yes' : 'no'
- end
- else
- ConfigTable.bool_config?(name) or raise InstallError, "config: --#{name} requires argument"
- value = 'yes'
- end
- @config[name] = value
- end
- end
-
- def parsearg_install
- @options['no-harm'] = false
- @options['install-prefix'] = ''
- while a = ARGV.shift
- case a
- when /\A--no-harm\z/
- @options['no-harm'] = true
- when /\A--prefix=(.*)\z/
- path = $1
- path = File.expand_path(path) unless path[0,1] == '/'
- @options['install-prefix'] = path
- else
- raise InstallError, "install: unknown option #{a}"
- end
- end
- end
-
-
- def print_usage( out )
- out.puts 'Typical Installation Procedure:'
- out.puts " $ ruby #{File.basename $0} config"
- out.puts " $ ruby #{File.basename $0} setup"
- out.puts " # ruby #{File.basename $0} install (may require root privilege)"
- out.puts
- out.puts 'Detailed Usage:'
- out.puts " ruby #{File.basename $0} <global option>"