Skip to content

Instantly share code, notes, and snippets.

@twobob
Last active January 18, 2016 03:59
Show Gist options
  • Save twobob/ac3d10362a972891a53f to your computer and use it in GitHub Desktop.
Save twobob/ac3d10362a972891a53f to your computer and use it in GitHub Desktop.
Eighteens Magic Numbers
<!-- Warning, the CHART DISPLAY part is pretty horrible - outdated - POC code
that needs a damn good looking at before it made it to production
Don't even ask about DOCTYPE declarations until this has had a tidy up //-->
<!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
<html>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<TITLE>iMatch</TITLE>
<!-- Google Fonts embed code -->
<script type="text/javascript">
(function() {
var link_element = document.createElement("link"),
s = document.getElementsByTagName("script")[0];
if (window.location.protocol !== "http:" && window.location.protocol !== "https:") {
link_element.href = "http:";
}
link_element.href += "//fonts.googleapis.com/css?family=Cabin+Condensed:400,500,600,700";
link_element.rel = "stylesheet";
link_element.type = "text/css";
s.parentNode.insertBefore(link_element, s);
})();
</script>
<script language="javascript" >
// Helper Functions
var originalentries = null;
function InitSearching() {
// Look for input box and insert key handler
var prevTxt = null;
var txt = document.getElementsByName('filterTxt');
if ( txt != null ) {
txt[0].onkeyup=function(event) {
var e = event || window.event;
var curTxt = txt[0].value;
handleKeyPress(prevTxt,curTxt);
prevTxt = curTxt;
return true;
}
}
}
function handleKeyPress(oldVal, newVal) {
var components = document.getElementsByName('person');
var select = components[0];
// Store the original list of entries to restore when backspacing
if ( originalentries === null ) {
originalentries = new Array();
for ( c = 0; c < select.children.length; c++ ) {
originalentries.push(select.children[c]);
}
}
// If the number of characters in the text box is less than last time
// it must be because the user pressed delete
if ( oldVal !== null && (newVal.length < oldVal.length) ) {
// Restore the lists original set of entriesÊ
// and start from the beginning
for ( c = 0; c < originalentries.length ; c++ ) {
select.add(originalentries[c]);
}
}
// Break out all of the parts of the search textÊ
// by splitting on white space
var parts = newVal.split(' ');
// Filter out the entries that don't contain the entered text
var toremove= new Array();
for ( i = 0; i < select.children.length; i++ ) {
var entry = select.children[i];
var match = true;
var entryTxt = entry.text;
for ( p = 0; p < parts.length; p++ ) {
// The entry needs to contain all portions of the
// search string *but* in any order
var part = parts[p].toUpperCase();
if ( entryTxt.toUpperCase().lastIndexOf(part) < 0 ) {
match = false;
break;
}
}
if ( match == false ) {
toremove.push(entry);
}
}
if ( toremove != null ) {
for ( t = 0; t < toremove.length; t++ ) {
var entryTxt = toremove[t].text;
select.removeChild(toremove[t]);
}
}
}
function storageAvailable(type) {
try {
var storage = window[type],
x = '__storage_test__';
storage.setItem(x, x);
storage.removeItem(x);
return true;
}
catch(e) {
return false;
}
}
// Helper function to remove whitespace from form elements and convert them to numbers. even double zeros et cetera.
function TidyUpAndFloat(id)
{
return parseFloat(id);
}
//return parseFloat(document.getElementById(id).value.trim());}
// Shim for crap browsers for sanity output.
if (!Date.now) {
Date.now = function() { return new Date().getTime(); }
}
var PlanetNeatTitles=["Sun","Moon","Mercury","Venus","Mars","Jupiter","Saturn","Uranus","Neptune","Pluto","Ascendant","Midheaven"];
var PlanetNeatSymbols=["1","2","3","4","5","6","7","8","9","10","11","12"];
/* ******************************************************************************* */
// In lieu of copyright
// This method of analysis by summing related occurrences of signifiers I found
// in a work by an American woman astrologer whose name, and book title, I do
// not unfortunately recall, about 4 or 5 decades ago.
// Since it is a sensible and logical approach I have followed it here, with some
// modifications.
// Will 18, Jan. 2016.
// [email protected]
/* ******************************************************************************* */
/* iMatch algorithm version: 5.1 */
var rp = -1; // ruling planet ( number )
// AspectValues a: Conjunction, Opposition, Trine, Square, Sextile, Semi-square, Semi-sextile
var a = [0,180,120,90,60,45,30]; // FIXED
// Aspect Factor af: Conjunction, Opposition, Trine, Square, Sextile, Semi-square, Semi-sextile
// values calculated as _reciprocals_ of:
// 1*sqrt(1), 2*sqrt(1), 3*sqrt(1), 2*sqrt(2), 3*sqrt(2), 2*sqrt(4), 3*sqrt(4)
var af = [1,0.5,0.3333,0.3536,0.2357,0.25,0.1667]; // FIXED
// Aspect Orb ao: Conjunction, Opposition, Trine, Square, Sextile, Semi-square, Semi-sextile
/* aoIndex = 0 for default. 1 for other (unimplemented)*/
var ao = [[9,9,7,7,5,3,3],[0,0,0,0,0,0]]; // USER-DEFINABLE but need to be defaulted for 'Reset'
var aoIndex = 0
/* Traditional factors (ancient/modern): [signNum[ruler],[exaltation],[detriment],[fall]] */
/* tfIndex = 0 for ancient, 4 for modern (offset into array) */
var tf = [[4,3,2,1,0,2,3,4,5,6,6,5],[0,1,-1,5,-1,2,6,-1,-1,4,-1,3],[3,4,5,6,6,5,4,3,2,1,0,2],[6,-1,-1,4,-1,3,0,1,-1,5,-1,2],
[4,3,2,1,0,2,3,4,5,6,7,8],[0,1,-1,5,1,8,2,6,,7,-1,4,-1,3],[3,9,5,7,8,4,-1,2,1,0,-1],[6,7,-1,4,-1,3,0,1,-1,5,8,2]]; // USER-DEFINABLE but need to be defaulted for 'Reset/OtherRules'
var tfIndex = 4;
/* Traditional factors: [signNum[polarity],[triplicity],[quadruplicity]] */
var ptq = [[1,0,1,0,1,0,1,0,1,0,1,0],[0,1,2,3,0,1,2,3,0,1,2,3],[0,1,2,0,1,2,0,1,2,0,1,2]]; // FIXED
/* Theme values ( t[n] in algorithm ) */
var theme = [0,0,0,0,0,0,0,0,0,0,0,0]; // INTERNAL
/* numAspects [conjunction, opposition, trine, square, sextile, semi-square, semi-sextile] */
var numAspects = [0,0,0,0,0,0,0]; // number of aspect types. INTERNAL
/* numTradFactors [+ve, -ve, fire, earth, air, water, cardinal, fixed, mutable] */
var numTradFactors = [0,0,0,0,0,0,0,0,0]; // totals for traditional factors. INTERNAL
/* tfDominant: [polarity, triplicity, quadruplicity] - dominant pol., trip., quad. or -1 */
var tfDominant = [0,0,0]; // INTERNAL
/* planet strength [planetNum,...] - arbitrary value for contribution to event occurrence */
var ps = [1,1,1,1,1,1,1,1,1,1,1,1]; // INTERNAL
// Utility functions
function isAspect(pos1,pos2,aspect,aspectOrb)
{
var diff = Math.abs(pos1-pos2);
diff = ( diff > 180 ? 360-diff : diff );
var value = Math.abs(diff-aspect);
value = ( value > 180 ? 360 - value : value );
var min = aspect-aspectOrb;
var max = aspect+aspectOrb;
max = ( max>360 ? max-360 : max );
value = ( (min < diff ) && ( diff < max ) ? 1 : 0 );
return value;
}
function aspectStrength(pos1,pos2,aspect,orb,factor)
{ // -ve return is not-an-aspect
var strength = 0;
var pDiff = Math.abs ( pos1- pos2 );
pDiff = ( pDiff > 180 ? 360 - pDiff : pDiff );
strength = 1 - ( Math.abs ( pDiff - aspect ) / orb );
// if not in [0, 1], reject, invalid
strength = ( ( ( strength < 0 ) || ( strength > 1 ) ) ? -1 : strength*factor );
return strength;
}
function signNum ( pos )
{
value = pos/30-0.5
value = ( value<0 ? 0 : value)
value = Math.round( value )
value = (value>=12 ? -1 : value)
return value
}
function house ( pos, ascendant )
{
var value = (pos - ascendant ) / 30-0.5;
value = Math.round(value);
value = ( value < 0 ? value + 12 : value );
value = ( value > 12 ? value - 12 : value );
return value+1;
}
function debugP(StringToPrint)
{
var CRLF = "&#013;&#010;";
document.getElementById('debugArea').innerHTML += (StringToPrint.toString() + CRLF);
}
// main algorithm
function getThemeValues(Sun,Moon,Mercury,Venus,Mars,Jupiter,Saturn,Uranus,Neptune,Pluto,Ascendant,Midheaven) {
// functions internal to getThemeValues()
function numPlanetsInHouse ( houseNum )
{
numPlanets = 0;
for ( n = 0; n < 10; n++ )
if ( house ( planet[n], planet[10] ) == houseNum )
numPlanets++;
// EXAMPLE DEBUG
debugP("There are "+numPlanets+" planets in house #"+houseNum);
return numPlanets;
}
function numStrongPlanetsInHouse ( houseNum )
{
numStrong = 0;
for ( n = 0; n < 10; n++ )
if ( house ( planet[n], planet[10] ) == houseNum ) // planet n in house 1
{
if ( tf[tfIndex][signNum(planet[n])] == n ) // ruler?
numStrong++;
if ( tf[tfIndex+1][signNum(planet[n])] != -1 )
if ( tf[tfIndex+1][signNum(planet[n])] == n ) // exalted?
numStrong++;
}
debugP("There are "+numPlanets+" strong planets in house #"+sign);
return numStrong;
}
function numPlanetsInSign ( sign )
{
numPlanets = 0;
for ( n = 0; n < 10; n++ )
if ( signNum ( planet[n] ) == sign )
numPlanets++;
debugP("There are "+numPlanets+" planets in sign #"+sign);
return numPlanets;
}
function numStrongPlanetsInSign ( sign )
{
numStrong = 0;
for ( n = 0; n < 10; n++ ) // for all planets
{
if ( signNum ( planet[n] ) == sign )
{
if ( tf[tfIndex][sign] == n ) // ruler
numStrong++;
if ( tf[tfIndex+1][signNum(planet[n])] != -1 )
if ( tf[tfIndex+1][sign] == n ) // exalted
numStrong++;
}
}
debugP("There are "+numPlanets+" strong planets in sign #"+sign);
return numStrong;
}
function isMutualReception ( Px )
{
var Py, Sx, Sy, rpSy, n;
Sx = signNum ( planet[Px] );
Py = tf[tfIndex][Sx]; // Sx ruled by Py
Sy = signNum ( planet[Py] );
rpSy = tf[tfIndex][Sy];
if ( rpSy == Px ) // in mutual reception
return Sy; // return mutual sign
return -1;
}
function calculateThemeValue ( themeNum, signRuler, rulerWeighting ) // 1 - 12
{
var weighting = ( rulerWeighting == 0.5 ? 0.5 : 1 ) // alternate rulers
// avoid adding contribution from non-ruler associations twice
var themeValue, inMR;
themeValue = 0;
// i) Are any of the following in House themeNum?
// ruler of sign themeNum-1, Sun, Moon, Ascendant ruler, a strong
// planet, two or more planets (allocate one point ( * weighting ) for each).
if ( signRuler != -1 ) // check for sign ruler in House themeNum
{ // is ruler in House?
themeValue += ( house ( planet[signRuler], planet[10] ) == themeNum ? ps[signRuler]*rulerWeighting : 0 );
// is the ruler in mutual reception?
inMR = isMutualReception ( signRuler );
if ( inMR != -1 )
{ // effective conjunction affects theme of both planets involved
themeValue += ps[signRuler]; // add a point - note: we do not consider aspect just sign
theme[inMR] += ps[signRuler]; // inMR is mutual sign number
}
}
if ( themeNum != 5 ) // Sun in House themeNum (not Leo)?
themeValue += ( house ( planet[0], planet[10] ) == themeNum ? ps[0]*weighting : 0 );
if ( themeNum != 4 ) // // Moon in House themeNum (not Cancer)?
themeValue += ( house ( planet[1], planet[10] ) == themeNum ? ps[1]*weighting : 0 );
// Asc. ruler in House themeNum?
if ( rp != - 1)
themeValue += ( house ( planet[rp], planet[10] ) == themeNum ? ps[rp]*weighting : 0 );
// any strong planets? Add extra point
// it is possible for more than 1 planet to be in exaltation, depending on
// rules in tf[planetNum, 1]
themeValue += ( numStrongPlanetsInHouse ( themeNum ) > 1 ? weighting : 0 ); // 1 point for each?
// 2 or more planets in house 1?
themeValue += ( numPlanetsInHouse ( themeNum ) > 1 ? weighting : 0 );
// ii) Are any of the following in sign themeNum? Sign ruler, Sun, Moon, Ascendant
// a strong planet, two or more planets?
if ( signRuler != -1 ) // check for signRuler in sign
themeValue += ( signNum ( planet[signRuler] ) == themeNum-1 ? ps[signRuler]*rulerWeighting : 0 );
if ( themeNum != 5 )
themeValue += ( signNum ( planet[0] ) == themeNum-1 ? ps[0]*weighting : 0 );
if ( themeNum != 4 )
themeValue += ( signNum ( planet[1] ) == themeNum-1 ? ps[1]*weighting : 0 );
themeValue += ( signNum ( planet[10] ) == themeNum-1 ? weighting : 0 );
// strong planets in sign include both rp and exalted
themeValue += ( numStrongPlanetsInSign ( themeNum-1 ) > 0 ? weighting : 0 );
// 2 or more planets in sign themeNum-1?
themeValue += ( numPlanetsInSign ( themeNum-1 ) > 1 ? weighting : 0 );
// iii) Check for: sign ruler aspecting the Sun, Moon, Ascendant (add
// strength of the aspect).
for ( n = 0; n < 7; n++ ) // aspect list
{
if ( themeNum != 5 )
if ( isAspect ( planet[0], planet[signRuler], a[n], ao[aoIndex][n] ) ) // signRuler/Sun aspect
themeValue += ps[0]*ps[signRuler]*weighting * rulerWeighting * aspectStrength ( planet[0], planet[signRuler], a[n], ao[aoIndex][n], af[n] );
if ( themeNum != 4 )
if ( isAspect ( planet[1], planet[signRuler], a[n], ao[aoIndex][n] ) ) // signRuler/Moon aspect
themeValue += ps[1]*ps[signRuler]*weighting * rulerWeighting * aspectStrength ( planet[1], planet[signRuler], a[n], ao[aoIndex][n], af[n] );
if ( isAspect ( planet[10], planet[signRuler], a[n], ao[aoIndex][n] ) ) // signRuler/Ascendant aspect
themeValue +=ps[signRuler]* weighting * aspectStrength ( planet[10], planet[signRuler], a[n], ao[aoIndex][n], af[n] );
if ( themeNum != 1 ) // don't consider MC in Aries?
if ( isAspect ( planet[11], planet[signRuler], a[n], ao[aoIndex][n] ) ) // signRuler/Midheaven aspect
themeValue += ps[signRuler]*weighting * aspectStrength ( planet[11], planet[signRuler], a[n], ao[aoIndex][n], af[n] );
}
theme[themeNum-1] += themeValue; // allow for multiple calls
}
// Create f prefixed usable values
var fSun = TidyUpAndFloat(Sun);
var fMoon = TidyUpAndFloat(Moon);
var fMercury = TidyUpAndFloat(Mercury);
var fVenus = TidyUpAndFloat(Venus);
var fMars = TidyUpAndFloat(Mars);
var fJupiter = TidyUpAndFloat(Jupiter);
var fSaturn = TidyUpAndFloat(Saturn);
var fUranus = TidyUpAndFloat(Uranus);
var fNeptune = TidyUpAndFloat(Neptune);
var fPluto = TidyUpAndFloat(Pluto);
var fAscendant = TidyUpAndFloat(Ascendant);
var fMidheaven = TidyUpAndFloat(Midheaven);
var numPlanets = 0;
var numStrong = 0;
/* Planetary positions */
var planet = [fSun,fMoon,fMercury,fVenus,fMars,fJupiter,fSaturn,fUranus,fNeptune,fPluto,fAscendant,fMidheaven];
var interimResult = 0;
/*
var WeightedFloatValue =0;
var arrayLength = theme.length;
for (var i = 0; i < arrayLength; i++) {
// Document something inside the loop! cool.
// what's this do?
document.getElementById("LookupsUsed").innerHTML += theme[i] +" &nbsp;";
}
*/
// algorithm main starts here
var m,n,o; // loop vars.
var k,tmp;
// find number of polarities, triplicities, quadruplicities
//-ve, +ve, fire, earth, air, water, card, fix, mut totals
for ( n = 0; n <12; n++) // for all planets, Asc., M.C.
{
k = signNum ( planet[n] )
if ( ptq[0][k] == 1 ) // can only be [0,1]
numTradFactors[0]++; // +ve sign
else
numTradFactors[1]++; // -ve sign
if ( ptq[1][k] == 0 )
numTradFactors[2]++; // fire
if ( ptq[1][k] ==1 )
numTradFactors[3]++; // earth
if ( ptq[1][k] == 2 )
numTradFactors[4]++; // air
if ( ptq[1][k] == 3 )
numTradFactors[5]++; // water
if ( ptq[2][k] == 0 )
numTradFactors[6]++; // cardinal
if ( ptq[2][k] == 1 )
numTradFactors[7]++; // fixed
if ( ptq[2][k] == 2 )
numTradFactors[8]++; // mutable
}
if ( numTradFactors[0] > numTradFactors[1] ) // polarity
tfDominant[0] = 1; // +ve dominant
else
tfDominant[0] = 0; // -ve dominant
tfDominant[0] = (numTradFactors[0] == numTradFactors[1] ? -1 : tfDominant[0] );
tfDominant[1] = 0; // default fire
for ( n = 3; n < 6; n++ )
if ( numTradFactors[n] > tfDominant[1] )
tfDominant[1] = numTradFactors[n];
for ( n = 3; n < 6; n++ )
if ( n != tfDominant[1] )
if ( numTradFactors[n] == tfDominant[1] ) // no dominant trip.
tfDominant[1] = -1;
tfDominant[2] = 0; // default cardinal
for ( n = 7; n < 10; n++ )
if ( numTradFactors[n] > tfDominant[2] )
tfDominant[2] = numTradFactors[n];
for ( n = 7; n < 10; n++ )
if ( n != tfDominant[2] )
if ( numTradFactors[n] == tfDominant[2] ) // no dominant trip.
tfDominant[2] = -1;
// find number of each aspect
// for each planet, then for each aspect, if aspect, add 1
for ( n = 0; n < 12; n++ )
for ( m = n+1; m < 12; m++ )
if ( n != m )
{
for ( o = 0; o < 7; o++ )
if ( isAspect ( planet[n], planet[m], a[o], ao[aoIndex][o] ) )
numAspects[o]++;
}
// find dominant aspect (if any)
tmp = 0;
for ( n = 0; n < 7; n++ )
if ( numAspects[n] > tmp )
tmp = n;
for ( m = 0; m < 7; m++ )
if ( m != tmp )
{
if ( numAspects[m] == tmp ) // no dominant aspect type
tmp = -1;
}
dominantAspect = tmp;
// check for debility/fall in planets and reduce contribution
// find planet
// find its sign
// check whether tf[3 or 4][planetNum] is same as planet
// if yes, debility or fall
for ( n = 0 ; n < 10; n++ ) // not Ascendant or Midheaven
{
var sign = signNum ( planet[n] );
if ( ( tf[3][sign] == n ) || ( tf[4][sign] == n ) )
ps[n] = 0.5; // reduce contribution
}
// Ascendant ruler
rp = tf[tfIndex][signNum ( planet[10] )];
// ##### end initialisation #####
// Chart analysis - calculate theme values
// n.b. signs are numbered [0,11], houses are [1,12]
// initialise theme array
for ( n = 0; n < 12; n++ )
theme[n] = 0;
// ##### Theme 1 #####
calculateThemeValue ( 1, tf[tfIndex][0],1 );
// Is the chart emphasis on any of the following: fire, cardinal, conjunctions?
if ( tfDominant[1] == 0 ) // fire dominant?
theme[0] += 1;
if ( tfDominant[2] == 0 ) // cardinal dominant?
theme[0] += 1;
if ( dominantAspect == 0 ) // conjunctions dominant
theme[0] += 1;
// ##### end Theme 1 #####
// ##### Theme 2 #####
calculateThemeValue ( 2, tf[tfIndex][1], 1 );
// Is the chart emphasis on any of the following: earth, fixed
if ( tfDominant[1] == 1 ) // earth dominant?
theme[1] += 1;
if ( tfDominant[2] == 1 ) // fixed dominant?
theme[1] += 1;
theme[1] = ( theme[1] > 3 ? theme[1]+1 : theme[1] ); // this requires max aspect strength!
// ##### end Theme 2 #####
// ##### Theme 3 #####
calculateThemeValue ( 3, tf[tfIndex][2], 1 );
// Is the chart emphasis on any of the following: air, mutable, sextile
if ( tfDominant[1] == 2 ) // air dominant?
theme[2] += 1;
if ( tfDominant[2] == 2 ) // mutable dominant?
theme[2] += 1;
if ( dominantAspect == 4 ) // sextiles dominant
theme[2] += 1;
// ##### end Theme 3 #####
// ##### Theme 4 #####
// if the moon is in debility or fall, reduce points to 1?
// but what about other planets/placings ?
// or simply allocate planet 'strengths' as 1 and modify for deb/fall?
// exaltation and ruler are then treated differently - so they affect 'occurrences'
// but deb/fall affect 'amount of occurrence' !!!
calculateThemeValue ( 4, tf[tfIndex][3], 2 );
// Is the chart emphasis on water, cardinal, square aspects?
if ( tfDominant[1] == 3 ) // water dominant?
theme[3] += 1;
if ( tfDominant[2] == 0 ) // cardinal dominant?
theme[3] += 1;
if ( dominantAspect == 3 ) // squares dominant
theme[3] += 1;
// ##### end Theme 4 #####
// ##### Theme 5 #####
calculateThemeValue ( 5, tf[tfIndex][4],2 );
// Is the chart emphasis on fire, fixed, trine aspects?
if ( tfDominant[1] == 0 ) // fire dominant?
theme[4] += 1;
if ( tfDominant[2] == 1 ) // fixed dominant?
theme[4] += 1;
if ( dominantAspect == 2 ) // trines dominant
theme[4] += 1;
// ##### end Theme 5 #####
// ##### Theme 6 #####
calculateThemeValue ( 6, tf[tfIndex][5], 1 );
// Is the chart emphasis on earth, mutable?
if ( tfDominant[1] == 1 ) // earth dominant?
theme[5] += 1;
if ( tfDominant[2] == 2 ) // mutable dominant?
theme[5] += 1;
theme[5] = ( theme[5] > 3 ? theme[5]+1 : theme[5] );
// ##### end Theme 6 #####
// ##### Theme 7 #####
calculateThemeValue ( 7, tf[tfIndex][6], 1 );
// Is the chart emphasis on any of the following: air, cardinal,
// oppositions?
if ( tfDominant[1] == 2 ) // air dominant?
theme[6] += 1;
if ( tfDominant[2] == 0 ) // cardinal dominant?
theme[6] += 1;
if ( dominantAspect == 1 ) // oppositions dominant
theme[6] += 1;
// ##### end Theme 7 #####
// ##### Theme 8 #####
var ruler = tf[tfIndex][7];
if ( ruler == 9 ) // Pluto, modern ruler of Scorpio
{
calculateThemeValue ( 8, ruler, 0.5 );
calculateThemeValue ( 8, 4, 0.5 ); // add contribution from ancient ruler Mars
// also check Mars/Pluto aspects
for ( n = 0; n < 7; n++ )
{
if ( isAspect ( planet[4], planet[ruler], a[n], ao[aoIndex][n] )) // signRuler/Mars aspect
theme[7] += ps[4]*ps[ruler]*aspectStrength ( planet[4], planet[ruler], a[n], ao[aoIndex][n], af[n] );
}
}
else
calculateThemeValue ( 8, ruler, 1 ); // just use ancient ruler Mars
if ( tfDominant[1] == 3 ) // water dominant?
theme[7] += 1;
if ( tfDominant[2] == 1 ) // fixed dominant?
theme[7] += 1;
theme[7] = ( theme[7] > 3 ? theme[7]+1 : theme[7] );
// ##### end Theme 8 #####
// ##### Theme 9 #####
calculateThemeValue ( 9, tf[tfIndex][8], 1 );
// Is the chart emphasis on any of the following: fire, mutable, trine aspects
if ( tfDominant[1] == 0 ) // fire dominant?
theme[8] += 1;
if ( tfDominant[2] == 2 ) // mutable dominant?
theme[8] += 1;
if ( dominantAspect == 2 ) // trines dominant
theme[8] += 1;
// ##### end Theme 9 #####
// ##### Theme 10 #####
calculateThemeValue ( 10, tf[tfIndex][9], 1 );
// Is the chart emphasis on any of the following: fire, mutable, trine aspects
if ( tfDominant[1] == 1 ) // earth dominant?
theme[9] += 1;
if ( tfDominant[2] == 0 ) // cardinal dominant?
theme[9] += 1;
if ( dominantAspect == 3 ) // squares dominant
theme[9] += 1;
// ##### end Theme 10 #####
// ##### Theme 11 #####
var ruler = tf[tfIndex][10];
if ( ruler == 7 ) // Uranus, modern ruler of Aquarius
{
calculateThemeValue ( 11, ruler, 0.5 );
calculateThemeValue ( 11, 6, 0.5 ); // add contribution from ancient ruler Saturn
// also check Saturn/Uranus aspects
for ( n = 0; n < 7; n++ )
{
if ( isAspect ( planet[6], planet[ruler], a[n], ao[aoIndex][n] )) // signRuler/Saturn aspect
theme[10] += ps[6]*ps[ruler]*aspectStrength ( planet[6], planet[ruler], a[n], ao[aoIndex][n], af[n] );
}
}
else
calculateThemeValue ( 11, ruler, 1 ); // just use ancient ruler Saturn
// Is the chart emphasis on air, fixed, sextile aspects?
if ( tfDominant[1] == 2 ) // air dominant?
theme[10] += 1;
if ( tfDominant[2] == 1 ) // fixed dominant?
theme[10] += 1;
if ( dominantAspect == 4 ) // sextiles dominant
theme[10] += 1;
// ##### end Theme 11 #####
// ##### Theme 12 #####
var ruler = tf[tfIndex][11];
if ( ruler == 8 ) // Neptune, modern ruler of Pisces
{
calculateThemeValue ( 12, ruler, 0.5 );
calculateThemeValue ( 12, 5, 0.5 ); // add contribution from ancient ruler Jupiter
// also check Jupiter/Neptune aspects
for ( n = 0; n < 7; n++ )
{
if ( isAspect ( planet[5], planet[ruler], a[n], ao[aoIndex][n] )) // signRuler/Jupiter aspect
theme[11] += ps[5]*ps[ruler]*aspectStrength ( planet[5], planet[ruler], a[n], ao[aoIndex][n], af[n] );
}
}
else
calculateThemeValue ( 12, ruler, 1 ); // just use ancient ruler Saturn
// Is the chart emphasis on water, mutable?
if ( tfDominant[1] == 3 ) // water dominant?
theme[11] += 1;
if ( tfDominant[2] == 2 ) // mutable dominant?
theme[11] += 1;
theme[11] = ( theme[11] > 3 ? theme[11]+1 : theme[11] );
// ##### end Theme 12 #####
// add balance of polarities to each theme, 1 extra point
if ( tfDominant[0] == 1 )
{
n = 0;
while ( n < 12 )
{
theme[n] += 1;
n += 2;
}
}
else
{
n = 1;
while ( n < 12 )
{
theme[n] += 1;
n += 2;
}
}
var totalStrength = 0;
for ( n = 0; n < 12; n++ )
if ( theme[n] > totalStrength )
totalStrength = theme[n];
for ( n = 0; n < 12; n++ )
theme[n] /= totalStrength;
// at this point we have the 12 theme values in theme[0],..., theme[11], normalised
var arrayLength = theme.length;
// what's this do?
// It first walks the Document Object Model and then when it finds a matching tag it replaces/appends the innerHTML (the visible bit) of the tag with our text.
for (var i = 0; i < arrayLength; i++) {
document.getElementById("LookupsUsed").innerHTML += parseFloat(theme[i]).toFixed(4) +" &nbsp;";
}
document.getElementById("LookupsUsed").innerHTML +="<br />";
}
// Encoding Begins
function encode(c){var x='charCodeAt',b,e={},f=c.split(""),d=[],a=f[0],g=256;for(b=1;b<f.length;b++)c=f[b],null!=e[a+c]?a+=c:(d.push(1<a.length?e[a]:a[x](0)),e[a+c]=g,g++,a=c);d.push(1<a.length?e[a]:a[x](0));for(b=0;b<d.length;b++)d[b]=String.fromCharCode(d[b]);return d.join("")};
function decode(b){var a,e={},d=b.split(""),c=f=d[0],g=[c],h=o=256;for(b=1;b<d.length;b++)a=d[b].charCodeAt(0),a=h>a?d[b]:e[a]?e[a]:f+c,g.push(a),c=a.charAt(0),e[o]=f+c,o++,f=a;return g.join("")};
//positions to 5 d.p
//themes to 4
// string , array, array
// ExampleSubject, SubjectsValues, VerY
// ExampleSubject, TargetsValues, VerY2
var delimeter = "¬"; // IS GLOBAL
// Provide a way to save data
function StorageSaveOperation(nameOfThing, positions , themes ) {
var storedValues = "";
// set the values in the store
// positions.length + themes.length = 24
for (i = 0; i < 12 ; i++){
storedValues += parseFloat(positions[i]).toFixed(5)
storedValues += delimeter;
storedValues += parseFloat(themes[i]).toFixed(4);
if (i < 11)
storedValues += delimeter;
}
//alert("ToSTORE:"+storedValues);
storedValues = encode(storedValues);
//alert("ENCODED:"+storedValues);
localStorage.setItem(nameOfThing, storedValues);
}
// Provide a way to retrieve data
// This will populate the passed arrays with the values
function StorageRetrieveOperation(nameOfThing, positions , themes ) {
var storedValues = decode(localStorage.getItem(nameOfThing)).split(delimeter);
//alert("STORED"+storedValues );
// set the values from the store
// positions.length + themes.length = 24
var simpleIndex =0;
for (i = 0; i < 24 ; i+=2){
positions[simpleIndex] = parseFloat(storedValues[i]).toFixed(5);
themes[simpleIndex] = parseFloat(storedValues[i+1]).toFixed(4);
simpleIndex ++;
}
// alert("LOADED:"+positions +" THEMES:" +themes );
}
function autofill(){
// Create some random data... We will reuse the global PlanetNeatTitles, why not :)
var precision = 5;
// min precision should be 5 probably to not have to deal with the "." seperator
arrPositions = PlanetNeatTitles;
for (i = 0; i < 12; i++){
document.f1.label[i].value = arrPositions[i];
// Reworked to ACTUALLY give 5 DP on precision.
document.f1.numvalue1[i].value = parseFloat(Math.random() * 360).toFixed(precision);
document.f1.numvalue2[i].value = parseFloat(Math.random() * 360).toFixed(precision);
// We could add an OnClick function that removes the previous value when the field is highlighted for convenience.
}
}
var Content;
var vmax;
var chartwidth=800;
var tdwd;
var chartHeight = 500;
//var chartYAxisInterval = 100;
//var displayYAxisScale = true;
var colNum = 12;
function isCanvasSupported(){
var elem = document.createElement('canvas');
return !!(elem.getContext && elem.getContext('2d'));
}
// Based on concept by Neeraj Saluja massacred by twobob to work with Firefox 24.0
function GenerateChart(){
// We want to swtich to HTML5 when we can.
//Use HTML4 when we cant
if (isCanvasSupported()){
// ADD HTML5 Support
}
else
{
// Clear down our debug output area.
document.getElementById("LookupsUsed").innerHTML = "";
function PopulateContent(ArrayToWalk){
//for Columns
var totalCol = 12;
// Allow for side label as we always use one
totalCol = totalCol + 1;
tdwd = parseInt((chartwidth-(totalCol*4))/totalCol);
// Stub for when we spawn an entire window...
//Content = "<html><head><title>iMatch Chart</title></head><body text=black>";
Content = "";
// Mangle together a table
Content += "<span width=" + chartwidth + " style='border-width: 0px; border-style: none; margin: 0px; padding: 0px;'><table id=tblgraph align=center width=" + chartwidth + " cellpadding=2 cellspacing=0 border=0>";
Content += "<tr bgcolor=#e3e3e3>";
// Write the graph - This is dicey but works on Firefox 24.0 and later if you dont be too choosy about the DOCTYPE
for (i = 0; i < HorX.length; i++){
h = parseInt(ArrayToWalk[i] / (vmax / 200)); // Fudge factor - will scale all this lot later when the Main function puts out real numbers
Content+="<td align=center valign=bottom width=" + tdwd + ">"
Content+= "<div style='writing-mode:tb-rl; background-color:#00a4ff; width:" + (tdwd-5) + "; height:" + h + ";' />"
Content+="</td>";
}
Content += "</tr><tr bgcolor=#505050>";
// Write the X Axis Contents
// Add the blank Cell for Y Axis Scale (if we had one)
// Content += "<td align=center bordor=1 bgcolor=#FFFFFF>&nbsp;</td>";
for (i=0; i < HorX.length; i++){
Content += "<td align=center><font face=arial size='-3' color=white>" + HorX[i] + "</font></td>";
}
Content += "</tr>";
// Content += "<tr bgcolor=WHITE><td align=center colspan=" + colNum +2 + "><br/></td></tr>";
Content += "</table></span>";
// Stub for when we spawn an entire window...
//</body></html>";
document.getElementById("sanityTime").innerHTML = "Completed at "+ Date.now();
}
//testing for browsers
ms = 0;
nc = 0;
// Twobobs notes...
//The returned value varies from different browsers:
//IE11, Firefox, Chrome and Safari returns "Netscape"
//IE 10 and earlier versions return "Microsoft Internet Explorer"
//Opera returns "Opera", meh opera, Todo
if (navigator.appName == "Netscape") nc = 1
if (navigator.appName.indexOf("Microsoft") != -1) ms = 1
HorX = new Array();
VerY = new Array();
VerY2 = new Array();
var j = 0;
colNum = 12;
chartwidth = (colNum * 40);
SubjectsValues = new Array();
TargetsValues = new Array();
//parse pairs into something we can process through WJ18 function
for(i = 0; i < colNum; i++){
if (document.f1.numvalue1[i].value != '' && parseInt(document.f1.numvalue1[i].value) >= 0){
HorX[j] = PlanetNeatSymbols[i];// document.f1.label[i].value;
SubjectsValues[j] = document.f1.numvalue1[i].value;
TargetsValues[j] = document.f1.numvalue2[i].value;
j++;
}
}
// Run Routine
getThemeValues(SubjectsValues[0],SubjectsValues[1],SubjectsValues[2],SubjectsValues[3],SubjectsValues[4],SubjectsValues[5],SubjectsValues[6],SubjectsValues[7],SubjectsValues[8],SubjectsValues[9],SubjectsValues[10],SubjectsValues[11]);
if(localStorage.getItem('ExampleSubject')) {localStorage.removeItem('ExampleTarget')};
if (storageAvailable('localStorage')) {if(localStorage.getItem('ExampleSubject')) {
StorageSaveOperation('ExampleSubject',SubjectsValues,theme ); } }
if(localStorage.getItem('ExampleSubject')) {
StorageRetrieveOperation('ExampleSubject',SubjectsValues,theme ); }
// Copy the values as intened Y values then scale them for display
VerY=theme;
var verticalFudge = 150;
vmax = 200; // Fudge factor - fix it later.
for(i = 0; i < theme.length; i++){
VerY[i] = VerY[i] * verticalFudge; // Fudge factor - fix it later.
}
PopulateContent(VerY);
document.getElementById("dvChart").innerHTML = Content;
// add a space
document.getElementById("dvChart").innerHTML +="<br/>";
// Run Routine on other data
getThemeValues(TargetsValues[0],TargetsValues[1],TargetsValues[2],TargetsValues[3],TargetsValues[4],TargetsValues[5],TargetsValues[6],TargetsValues[7],TargetsValues[8],TargetsValues[9],TargetsValues[10],TargetsValues[11]);
// Test deletion
if(localStorage.getItem('ExampleTarget')) {localStorage.removeItem('ExampleTarget')};
// Check storage is available
if (storageAvailable('localStorage')) {
// Test Saving an item (with compression)
if(localStorage.getItem('ExampleTarget')) {
//if(localStorage.getItem('ExampleTarget')) {
StorageSaveOperation('ExampleTarget',TargetsValues,theme ); } }
// Test retrieval of a set of data
if(localStorage.getItem('ExampleTarget')) {
StorageRetrieveOperation('ExampleTarget',TargetsValues,theme ); }
VerY2=theme;
for(i = 0; i < theme.length; i++){
VerY2[i] = VerY2[i] * verticalFudge; // Fudge factor - fix it later.
}
PopulateContent(VerY2);
document.getElementById("dvChartTwo").innerHTML = Content;
// Stub for when we spawn an entire window...
// Left this in so I can implement it later...
// if (document.getElementById("optShowInSameWindow").checked == true)
// document.getElementById("dvChart").innerHTML = Content;
// else
// {
// //create a window to display Column graph in top left corner
// newWin1 = open('','chart1',"width=" + (chartwidth + 75) + ",height=320,top=0,left=0,scrollbars=yes, scroll=yes,toolbar=no");
// newWin1.document.write(Content);
// newWin1.document.close();
// newWin1.focus();
// }
// }
//}
}
}
</script>
<style>
/* I added this section just so you can see how the cascading selectors make it simple to change everything in one place.
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video
{
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1.618em;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
/* Label */
label {
height: 18px; width: 200px; vertical-align:top; font-size: 16px; font-weight: 200; display: inline-block;
}
/* Set this second to override the height :) */
textarea {
height: 30px; width: 200px;
}
/* Set this second to override the height :) */
input {
height: 30px; width: 150px;
}
button {
height: 100px; width: 500px; vertical-align:top;
}
/* we could have set the heights of things here but to many elements it would be meaningless and just ignored, up to you really
, defining the height in TEXTAREA more clearly expresses the purpose, I digree onward.*/
/* The EVERYTHING CSS Selector */
*{
font-family: "Cabin Condensed",Arial,Helvetica Neue,Helvetica,sans-serif;
font-size: 18px;
font-style: normal;
font-variant: normal;
font-weight: 500;
line-height: 26.4px;
}
nav select{height:310px; width:85%; margin-top:18px;}
nav select{overflow:hidden; overflow-y:scroll;}
nav textarea{height:500px; width:97%; margin-top:8px;}
nav textarea{overflow:hidden; overflow-y:scroll;}
</style>
</HEAD>
<body onload="InitSearching();">
<form name="f1">
<table valign="top" bgColor="#fdfdfd" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; POSITION: absolute; ; TOP: expression(document.all('dvChart').clientTop + document.all('dvChart').clientHeight + document.all('dvChartTwo').clientTop + document.all('dvChartTwo').clientHeight +10)">
<tr>
<TD align="left"><img title="iMatch, Star-crossed liaisons" src="image/imatch.png" />
&nbsp;<A href="javascript:autofill();"><img title="AUTOFILL WITH RANDOM DATA" src="image/auto.png" width=48 height=48 /></A>
&nbsp; &nbsp; &nbsp; <A href="javascript:GenerateChart();"><img title="RUN WITH CURRENT DATA" src="image/run.png" /></A>
</TD>
</tr>
<!-- <tr>
<td colspan="5">
// Stub for when we spawn an entire window...
<input type="radio" id="optShowInSameWindow" name="opt">
<label for="optShowInSameWindow">Show Chart in Same Window</label>
<input type="radio" id="optShowInNewWindow" name="opt" checked>
<label for="optShowInNewWindow">Show Chart in New Window</label>
</td>
</tr>
//-->
<tr>
<td>
<table>
<tr align="center">
<td></td>
<td>
Subject</td>
<td>
Target</td>
<td rowspan="13" width="230" align="middle">
<!-- Add some meaningful list for the client listing //-->
<header> RECORDS AREA</header>
<label style="font-weight:200"><b>></b>
<input type="text" name="filterTxt" id="filterTxt" style="vertical-align:left; display: inline-block; width:187px;"></input></label>
<nav>
<select id="person" name="person" size=10 tabindex="2" style="width: 200px">
<option>Example Subject</option>
<option>Example Target</option>
<option>Link Bob</option>
<option>Link fred</option>
<option>Link jane</option>
<option>Link test</option>
<option>Fredrick</option>
<option>Link 8</option>
<option>Link 9</option>
<option>Link 10</option>
<option>Link 11</option>
<option>Link 13</option>
<option>Link 13</option>
<option>Link 1</option>
<option>Link 2</option>
<option>Link 3</option>
<option>Link 4</option>
<option>Link 5</option>
<option>Link 6</option>
<option>Link 7</option>
<option>Link 8</option>
<option>Link 9</option>
<option>Link 10</option>
<option>Link 11</option>
<option>Link 13</option>
<option>Link 13</option>
<select>
</nav>
<footer>SAVE [SUBJECT] [TARGET] </footer>
<footer>DELETE RECORD </footer>
<footer>LOAD [SUBJECT] [TARGET]</footer>
</td>
</tr>
<tr>
<td><input type="text" size="4" name="label" value="Sun" style='width:100px;' disabled>
</td>
<td><input type="text" size="4" name="numvalue1" value="175.65806" > </td>
<td><input type="text" size="4" name="numvalue2" value="175.65806"> </td>
<td rowspan="15" align="left" valign="top" >
</td>
</tr>
<tr>
<td><input type="text" size="4" name="label" value="Moon" style='width:100px;' disabled>
</td>
<td><input type="text" size="4" name="numvalue1" value="296.50028" /></td>
<td><input type="text" size="4" name="numvalue2" value="296.50028" /></td>
</tr>
<tr>
<td><input type="text" size="4" name="label" value="Mercury" style='width:100px;' disabled>
</td>
<td><input type="text" size="4" name="numvalue1" value="185.15833" /></td>
<td><input type="text" size="4" name="numvalue2" value="185.15833" /></td>
</tr>
<tr>
<td><input type="text" size="4" name="label" value="Venus" style='width:100px;' disabled></td>
<td><input type="text" size="4" name="numvalue1" value="143.63889" /></td>
<td><input type="text" size="4" name="numvalue2" value="143.63889" /></td>
</tr>
<tr>
<td><input type="text" size="4" name="label" value="Mars" style='width:100px;' disabled>
</td>
<td><input type="text" size="4" name="numvalue1" value="152.62028" /></td>
<td><input type="text" size="4" name="numvalue2" value="152.62028" /></td>
</tr>
<tr>
<td><input type="text" size="4" name="label" value="Jupiter" style='width:100px;' disabled></td>
<td><input type="text" size="4" name="numvalue1" value="85.36250" /></td>
<td><input type="text" size="4" name="numvalue2" value="85.36250" /></td>
</tr>
<tr>
<td><input type="text" size="4" name="label" value="Saturn" style='width:100px;' disabled></td>
<td><input type="text" size="4" name="numvalue1" value="206.04083" /></td>
<td><input type="text" size="4" name="numvalue2" value="206.04083" /></td>
</tr>
<tr>
<td><input type="text" size="4" name="label" value="Uranus" style='width:100px;' disabled></td>
<td><input type="text" size="4" name="numvalue1" value="112.37861" /></td>
<td><input type="text" size="4" name="numvalue2" value="112.37861" /></td>
</tr>
<tr>
<td><input type="text" size="4" name="label" value="Neptune" style='width:100px;' disabled></td>
<td><input type="text" size="4" name="numvalue1" value="202.59472" /></td>
<td><input type="text" size="4" name="numvalue2" value="202.59472" /></td>
</tr>
<tr>
<td><input type="text" size="4" name="label" value="Pluto" style='width:100px;' disabled></td>
<td><input type="text" size="4" name="numvalue1" value="143.95056" /></td>
<td><input type="text" size="4" name="numvalue2" value="143.95056" /></td>
</tr>
<tr>
<td><input type="text" size="4" name="label" value="Ascendant" style='width:100px;' disabled></td>
<td><input type="text" size="4" name="numvalue1" value="83.26694" /></td>
<td><input type="text" size="4" name="numvalue2" value="83.26694" /></td>
</tr>
<tr>
<td><input type="text" size="4" name="label" value="Midheaven" style='width:100px;' disabled></td>
<td><input type="text" size="4" name="numvalue1" value="317.4019" /></td>
<td><input type="text" size="4" name="numvalue2" value="317.4019" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<div id="status"></div>
<div id = "LookupsUsed"><!-- Left here for debug output. //--></div>
</td>
</tr>
<tr>
<td><div align="middle"><span style="color:white;">Subject Chart</span>
<div id="dvChart" style="margin-top: -25px;"></div></div>
</td>
</tr>
<tr>
<td><div align="middle"><span style="color:white;">Target Chart</span>
<div id="dvChartTwo" style="margin-top: -25px;"></div></div>
</td>
</tr>
<tr><td>
<header height="300"> DEBUG AREA</header>
<nav ><textarea name="debugArea" id="debugArea">></textarea></nav>
</td></tr>
<tr>
<td>
<div id = "sanityTime" style="color:LightGrey;font-size:15px;padding-right:5px;font-style:italic;" align="middle"></div>
</td>
<tr>
</table>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment