forked from nfriedly/MacAdSense
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
875 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC | ||
"-//Apple Computer//DTD PLIST 1.0//EN" | ||
"http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>AllowFullAccess</key> | ||
<true/> | ||
<key>AllowMultipleInstances</key> | ||
<false/> | ||
<key>CFBundleIdentifier</key> | ||
<string>de.oswaldism.mac.macadsense</string> | ||
<key>CFBundleName</key> | ||
<string>MacAdSense</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>MacAdSense</string> | ||
<key>DefaultImage</key> | ||
<string>Default.png</string> | ||
<key>Height</key> | ||
<string>150</string> | ||
<key>MainHTML</key> | ||
<string>MacAdSense.html</string> | ||
<key>Width</key> | ||
<integer>200</integer> | ||
</dict> | ||
</plist> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#front { | ||
background-image: url(Default.png); | ||
width: 187px; | ||
height: 138px; | ||
font-family: Lucida Grande; | ||
color: #fff; | ||
} | ||
#front_content { | ||
display: none; | ||
} | ||
#back { | ||
background-image: url(Backside.png); | ||
width: 187px; | ||
height: 138px; | ||
font-family: Lucida Grande; | ||
color: #fff; | ||
font-size: 10px; | ||
display: none; | ||
} | ||
#back_content { | ||
position: absolute; | ||
top: 20px; | ||
left: 30px; | ||
width: 140px; | ||
} | ||
#dialog { | ||
width: 187px; | ||
height: 138px; | ||
} | ||
#dialog_content { | ||
position: absolute; | ||
top: 40px; | ||
left: 30px; | ||
width: 140px; | ||
font-size: 16px; | ||
font-weight: bold; | ||
text-align: center; | ||
} | ||
.small { | ||
font-size: 11px; | ||
} | ||
#top { | ||
position: absolute; | ||
top: 20px; | ||
left: 20px; | ||
width: 150px; | ||
// border: 1px solid red; | ||
font-size: 30px; | ||
font-weight: bold; | ||
text-align: right; | ||
} | ||
#bottom { | ||
position: absolute; | ||
top: 60px; | ||
left: 30px; | ||
width: 140px; | ||
// border: 1px solid red; | ||
font-size: 10px; | ||
} | ||
#i { | ||
position: absolute; | ||
top: 103px; | ||
left: 158px; | ||
} | ||
#rollie { | ||
position: absolute; | ||
top: 103px; | ||
left: 158px; | ||
opacity: 0; | ||
} | ||
#done { | ||
position: absolute; | ||
top: 93px; | ||
left: 115px; | ||
} | ||
#version { | ||
position: absolute; | ||
top: 100px; | ||
left: 30px; | ||
font-size: 9px; | ||
} | ||
input { | ||
width: 135px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<html> | ||
<head> | ||
<title>MacAdSense Widget</title> | ||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" > | ||
<link href="MacAdSense.css" rel="stylesheet" type="text/css"> | ||
|
||
<script type='text/javascript' src='file:///System/Library/WidgetResources/AppleClasses/AppleInfoButton.js' charset='utf-8'/> | ||
<script type='text/javascript' src='file:///System/Library/WidgetResources/AppleClasses/AppleAnimator.js' charset='utf-8'/> | ||
<script type='text/javascript' src='file:///System/Library/WidgetResources/AppleClasses/AppleButton.js' charset='utf-8'/> | ||
<script type='text/javascript' src='MacAdSense.js' charset='utf-8'/> | ||
|
||
</head> | ||
|
||
<body onload="setup();"> | ||
<div id="front"> | ||
<div id="front_content"> | ||
<div id="top"> | ||
<span id="earnings"></span> | ||
</div> | ||
<div id="bottom"> | ||
<b>Updated</b>: <span id="updated"></span><br> | ||
<b>Clicks</b>: <span id="clicks"></span><br> | ||
<b>eCPM</b>: <span id="ecpm"></span><br> | ||
<b>Extrapolated</b>: <span id="extrapolated"></span> | ||
</div> | ||
</div> | ||
<div id="dialog"><div id="dialog_content"></div></div> | ||
<div id="i"></div> | ||
</div> | ||
<div id="back"> | ||
<div id="back_content"> | ||
<form id="ff" onSubmit="hideBack(); return false;"> | ||
<b>Username</b>:<br><input type="text" name="username"><br> | ||
<b>Password</b>:<br><input type="password" name="password"> | ||
</div> | ||
<div id="version"></div> | ||
<div id="done"></div> | ||
</div> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
/* | ||
* | ||
* Copyright (C) 2007-2009 Kai 'Oswald' Seidler, http://oswaldism.de | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the Free | ||
* Software Foundation; either version 2 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program; if not, write to the Free Software Foundation, Inc., 675 Mass | ||
* Ave, Cambridge, MA 02139, USA. | ||
* | ||
*/ | ||
|
||
var version = "0.9"; | ||
var timeout = 60*20; // set update frequency to 20 minutes | ||
var now=0; | ||
var timeoutevent=0; | ||
|
||
// many parts of this Widged were based on Apple's Widget tutorial at | ||
// http://developer.apple.com/documentation/AppleApplications/Conceptual/Dashboard_ProgTopics/ | ||
|
||
function showBack() | ||
{ | ||
var front = document.getElementById("front"); | ||
var back = document.getElementById("back"); | ||
|
||
if (window.widget) | ||
widget.prepareForTransition("ToBack"); | ||
|
||
front.style.display="none"; | ||
back.style.display="block"; | ||
|
||
if (window.widget) | ||
setTimeout ('widget.performTransition();', 0); | ||
|
||
} | ||
|
||
function hideBack() | ||
{ | ||
var front = document.getElementById("front"); | ||
var back = document.getElementById("back"); | ||
|
||
if (window.widget) | ||
{ | ||
var form=document.getElementById("ff"); | ||
|
||
if(form.username.value!="" && form.password.value!="") | ||
{ | ||
widget.setPreferenceForKey(form.username.value, "username"); | ||
|
||
now=0; | ||
showDialog("Saving to keychain..."); | ||
var command=widget.system("./MacAdSense.php setcredentials", onshow); | ||
command.write(form.username.value+"\n"); | ||
command.write(form.password.value+"\n"); | ||
command.close(); | ||
|
||
form.password.value=""; | ||
} | ||
} | ||
|
||
|
||
if (window.widget) | ||
widget.prepareForTransition("ToFront"); | ||
|
||
back.style.display="none"; | ||
front.style.display="block"; | ||
|
||
if (window.widget) | ||
{ | ||
setTimeout ('widget.performTransition();', 0); | ||
} | ||
} | ||
|
||
function showDialog(message) | ||
{ | ||
dialog_content.innerHTML=message; | ||
dialog.style.display="block"; | ||
front_content.style.display="none"; | ||
} | ||
|
||
function hideDialog() | ||
{ | ||
front_content.style.display="block"; | ||
dialog.style.display="none"; | ||
} | ||
|
||
function endHandler() | ||
{ | ||
} | ||
|
||
function fetchData() | ||
{ | ||
var command=widget.system("./MacAdSense.php getdata", displayData); | ||
command.write(widget.preferenceForKey("username")+"\n"); | ||
command.close(); | ||
} | ||
|
||
function displayData(data) | ||
{ | ||
output=data.outputString.split("#"); | ||
|
||
// do we get real data | ||
if(output[1]!=0) | ||
{ | ||
document.getElementById("updated").innerHTML=output[0]; | ||
document.getElementById("extrapolated").innerHTML="$"+output[1]; | ||
document.getElementById("clicks").innerHTML=output[3]; | ||
document.getElementById("earnings").innerHTML="$"+output[2]; | ||
document.getElementById("ecpm").innerHTML=output[5]; | ||
|
||
now = Math.round(new Date().getTime()/1000); | ||
|
||
hideDialog(); | ||
} | ||
else | ||
{ | ||
showDialog("Can't fetch AdSense data.<br><span class=\"small\">Maybe wrong credentials or network problems?</span>"); | ||
} | ||
|
||
if(timeoutevent!=0) | ||
{ | ||
clearTimeout(timeoutevent); | ||
} | ||
timeoutevent=setTimeout('fetchData();',timeout*1000); | ||
} | ||
|
||
function onshow() | ||
{ | ||
if(widget.preferenceForKey("username")!=undefined && widget.preferenceForKey("username")!="") | ||
{ | ||
if(now && Math.round(new Date().getTime()/1000)-now<timeout) | ||
{ | ||
// still not the time to fetch new adsense data | ||
} | ||
else | ||
{ | ||
showDialog("Loading..."); | ||
|
||
setTimeout('fetchData()',100); | ||
} | ||
} | ||
else | ||
{ | ||
showDialog("Please set username and<br>password on the back side."); | ||
} | ||
} | ||
|
||
function onhide() | ||
{ | ||
} | ||
|
||
function setup() | ||
{ | ||
if (window.widget) | ||
{ | ||
widget.onshow = onshow; | ||
widget.onhide = onhide; | ||
|
||
var form=document.getElementById("ff"); | ||
form.username.value=widget.preferenceForKey("username"); | ||
} | ||
var done_button = new AppleGlassButton(document.getElementById("done"), "Done", hideBack); | ||
i_button = new AppleInfoButton(document.getElementById("i"), document.getElementById("front"), "white", "white", showBack); | ||
document.getElementById("version").innerHTML=version; | ||
|
||
var dialog = document.getElementById("dialog"); | ||
var dialog_content = document.getElementById("dialog_content"); | ||
var front_content = document.getElementById("front_content"); | ||
|
||
} |
Oops, something went wrong.