parent
2bf19ae652
commit
056921b1e8
@ -0,0 +1,363 @@
|
||||
<?php
|
||||
/**
|
||||
* Name: Calculator App
|
||||
* Description: Simple Calculator Application
|
||||
* Version: 1.0
|
||||
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||
*/
|
||||
|
||||
|
||||
function calc_install() {
|
||||
register_hook('app_menu', 'addon/calc/calc.php', 'calc_app_menu');
|
||||
}
|
||||
|
||||
function calc_uninstall() {
|
||||
unregister_hook('app_menu', 'addon/calc/calc.php', 'calc_app_menu');
|
||||
|
||||
}
|
||||
|
||||
function calc_app_menu($a,&$b) {
|
||||
$b['app_menu'] .= '<div class="app-title"><a href="calc">Calculator</a></div>';
|
||||
}
|
||||
|
||||
|
||||
function calc_module() {}
|
||||
|
||||
|
||||
|
||||
|
||||
function calc_init($a) {
|
||||
|
||||
$x = <<< EOT
|
||||
|
||||
<script language="JavaScript">
|
||||
/**************************************
|
||||
* www.FemaleNerd.com *
|
||||
**************************************/
|
||||
|
||||
// Declare global variables
|
||||
var displayText = ""
|
||||
var num1
|
||||
var num2
|
||||
var operatorType
|
||||
|
||||
// Write to display
|
||||
function addDisplay(n){
|
||||
id = document.getElementById("display");
|
||||
id.value = ""
|
||||
displayText += n
|
||||
id.value = displayText
|
||||
}
|
||||
|
||||
// Addition
|
||||
function addNumbers() {
|
||||
if (displayText == "") {
|
||||
displayText = result
|
||||
}
|
||||
num1 = parseFloat(displayText)
|
||||
operatorType = "add"
|
||||
displayText = ""
|
||||
}
|
||||
|
||||
// Subtraction
|
||||
function subtractNumbers() {
|
||||
if (displayText == "") {
|
||||
displayText = result
|
||||
}
|
||||
num1 = parseFloat(displayText)
|
||||
operatorType = "subtract"
|
||||
displayText = ""
|
||||
}
|
||||
|
||||
// Multiplication
|
||||
function multiplyNumbers() {
|
||||
if (displayText == "") {
|
||||
displayText = result
|
||||
}
|
||||
num1 = parseFloat(displayText)
|
||||
operatorType = "multiply"
|
||||
displayText = ""
|
||||
}
|
||||
|
||||
// Division
|
||||
function divideNumbers() {
|
||||
if (displayText == "") {
|
||||
displayText = result
|
||||
}
|
||||
num1 = parseFloat(displayText)
|
||||
operatorType = "divide"
|
||||
displayText = ""
|
||||
}
|
||||
|
||||
// Sine
|
||||
function sin() {
|
||||
id = document.getElementById("display");
|
||||
if (displayText == "") {
|
||||
num1 = result
|
||||
}
|
||||
else {
|
||||
num1 = parseFloat(displayText)
|
||||
}
|
||||
if (num1 != "") {
|
||||
result = Math.sin(num1)
|
||||
id.value = result
|
||||
displayText = ""
|
||||
}
|
||||
else {
|
||||
alert("Please write the number first")
|
||||
}
|
||||
}
|
||||
|
||||
// Cosine
|
||||
function cos() {
|
||||
id = document.getElementById("display");
|
||||
if (displayText == "") {
|
||||
num1 = result
|
||||
}
|
||||
else {
|
||||
num1 = parseFloat(displayText)
|
||||
}
|
||||
if (num1 != "") {
|
||||
result = Math.cos(num1)
|
||||
id.value = result
|
||||
displayText = ""
|
||||
}
|
||||
else {
|
||||
alert("Please write the number first")
|
||||
}
|
||||
}
|
||||
|
||||
// ArcSine
|
||||
function arcSin() {
|
||||
id = document.getElementById("display");
|
||||
if (displayText == "") {
|
||||
num1 = result
|
||||
}
|
||||
else {
|
||||
num1 = parseFloat(displayText)
|
||||
}
|
||||
if (num1 != "") {
|
||||
result = Math.asin(num1)
|
||||
id.value = result
|
||||
displayText = ""
|
||||
}
|
||||
else {
|
||||
alert("Please write the number first")
|
||||
}
|
||||
}
|
||||
|
||||
// ArcCosine
|
||||
function arcCos() {
|
||||
id = document.getElementById("display");
|
||||
if (displayText == "") {
|
||||
num1 = result
|
||||
}
|
||||
else {
|
||||
num1 = parseFloat(displayText)
|
||||
}
|
||||
if (num1 != "") {
|
||||
result = Math.acos(num1)
|
||||
id.value = result
|
||||
displayText = ""
|
||||
}
|
||||
else {
|
||||
alert("Please write the number first")
|
||||
}
|
||||
}
|
||||
|
||||
// Square root
|
||||
function sqrt() {
|
||||
id = document.getElementById("display");
|
||||
if (displayText == "") {
|
||||
num1 = result
|
||||
}
|
||||
else {
|
||||
num1 = parseFloat(displayText)
|
||||
}
|
||||
if (num1 != "") {
|
||||
result = Math.sqrt(num1)
|
||||
id.value = result
|
||||
displayText = ""
|
||||
}
|
||||
else {
|
||||
alert("Please write the number first")
|
||||
}
|
||||
}
|
||||
|
||||
// Square number (number to the power of two)
|
||||
function square() {
|
||||
id = document.getElementById("display");
|
||||
if (displayText == "") {
|
||||
num1 = result
|
||||
}
|
||||
else {
|
||||
num1 = parseFloat(displayText)
|
||||
}
|
||||
if (num1 != "") {
|
||||
result = num1 * num1
|
||||
id.value = result
|
||||
displayText = ""
|
||||
}
|
||||
else {
|
||||
alert("Please write the number first")
|
||||
}
|
||||
}
|
||||
|
||||
// Convert degrees to radians
|
||||
function degToRad() {
|
||||
id = document.getElementById("display");
|
||||
if (displayText == "") {
|
||||
num1 = result
|
||||
}
|
||||
else {
|
||||
num1 = parseFloat(displayText)
|
||||
}
|
||||
if (num1 != "") {
|
||||
result = num1 * Math.PI / 180
|
||||
id.value = result
|
||||
displayText = ""
|
||||
}
|
||||
else {
|
||||
alert("Please write the number first")
|
||||
}
|
||||
}
|
||||
|
||||
// Convert radians to degrees
|
||||
function radToDeg() {
|
||||
id = document.getElementById("display");
|
||||
if (displayText == "") {
|
||||
num1 = result
|
||||
}
|
||||
else {
|
||||
num1 = parseFloat(displayText)
|
||||
}
|
||||
if (num1 != "") {
|
||||
result = num1 * 180 / Math.PI
|
||||
id.value = result
|
||||
displayText = ""
|
||||
}
|
||||
else {
|
||||
alert("Please write the number first")
|
||||
}
|
||||
}
|
||||
|
||||
// Calculations
|
||||
function calculate() {
|
||||
id = document.getElementById("display");
|
||||
|
||||
if (displayText != "") {
|
||||
num2 = parseFloat(displayText)
|
||||
// Calc: Addition
|
||||
if (operatorType == "add") {
|
||||
result = num1 + num2
|
||||
id.value = result
|
||||
}
|
||||
// Calc: Subtraction
|
||||
if (operatorType == "subtract") {
|
||||
result = num1 - num2
|
||||
id.value = result
|
||||
}
|
||||
// Calc: Multiplication
|
||||
if (operatorType == "multiply") {
|
||||
result = num1 * num2
|
||||
id.value = result
|
||||
}
|
||||
// Calc: Division
|
||||
if (operatorType == "divide") {
|
||||
result = num1 / num2
|
||||
id.value = result
|
||||
}
|
||||
displayText = ""
|
||||
}
|
||||
else {
|
||||
id.value = "Oops! Error!"
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the display
|
||||
function clearDisplay() {
|
||||
id = document.getElementById("display");
|
||||
|
||||
displayText = ""
|
||||
id.value = ""
|
||||
}
|
||||
</script>
|
||||
|
||||
EOT;
|
||||
$a->page['htmlhead'] .= $x;
|
||||
}
|
||||
|
||||
function calc_content($app) {
|
||||
|
||||
$o = '';
|
||||
|
||||
$o .= <<< EOT
|
||||
|
||||
<h3>Calculator</h3>
|
||||
<br /><br />
|
||||
<table>
|
||||
<tbody><tr><td>
|
||||
<table bgcolor="#af9999" border="1">
|
||||
<tbody><tr><td>
|
||||
<table border="1" cellpadding="2" cellspacing="2">
|
||||
<form name="calc">
|
||||
<!--
|
||||
<TR><TD VALIGN=top colspan=6 ALIGN="center"> <H2>Calculator</H2> </TD>
|
||||
-->
|
||||
<tbody><tr>
|
||||
<td colspan="5"><input size="22" id="display" name="display" type="text"></td>
|
||||
</tr><tr align="left" valign="middle">
|
||||
<td><input name="one" value=" 1 " onclick="addDisplay(1)" type="button"></td>
|
||||
<td><input name="two" value=" 2 " onclick="addDisplay(2)" type="button"></td>
|
||||
<td><input name="three" value=" 3 " onclick="addDisplay(3)" type="button"></td>
|
||||
<td><input name="plus" value=" + " onclick="addNumbers()" type="button"></td>
|
||||
</tr><tr align="left" valign="middle">
|
||||
<td><input name="four" value=" 4 " onclick="addDisplay(4)" type="button"></td>
|
||||
<td><input name="five" value=" 5 " onclick="addDisplay(5)" type="button"></td>
|
||||
<td><input name="six" value=" 6 " onclick="addDisplay(6)" type="button"></td>
|
||||
<td><input name="minus" value=" - " onclick="subtractNumbers()" type="button"></td>
|
||||
</tr><tr align="left" valign="middle">
|
||||
<td><input name="seven" value=" 7 " onclick="addDisplay(7)" type="button"></td>
|
||||
<td><input name="eight" value=" 8 " onclick="addDisplay(8)" type="button"></td>
|
||||
<td><input name="nine" value=" 9 " onclick="addDisplay(9)" type="button"></td>
|
||||
<td><input name="multiplication" value=" * " onclick="multiplyNumbers()" type="button"></td>
|
||||
</tr><tr align="left" valign="middle">
|
||||
<td><input name="zero" value=" 0 " onclick="addDisplay(0)" type="button"></td>
|
||||
<td><input name="pi" value=" Pi " onclick="addDisplay(Math.PI)" type="button"> </td>
|
||||
<td><input name="dot" value=" . " onclick='addDisplay(".")' type="button"></td>
|
||||
<td><input name="division" value=" / " onclick="divideNumbers()" type="button"></td>
|
||||
</tr><tr align="left" valign="middle">
|
||||
<td><input name="sqareroot" value="sqrt" onclick="sqrt()" type="button"></td>
|
||||
<td><input name="squarex" value=" x^2" onclick="square()" type="button"></td>
|
||||
<td><input name="deg-rad" value="d2r " onclick="degToRad()" type="button"></td>
|
||||
<td><input name="rad-deg" value="r2d " onclick="radToDeg()" type="button"></td>
|
||||
</tr><tr align="left" valign="middle">
|
||||
<td><input name="sine" value=" sin " onclick="sin()" type="button"></td>
|
||||
<td><input name="arcsine" value="asin" onclick="arcSin()" type="button"></td>
|
||||
<td><input name="cosine" value="cos" onclick="cos()" type="button"></td>
|
||||
<td><input name="arccosine" value="acs" onclick="arcCos()" type="button"></td>
|
||||
|
||||
</tr><tr align="left" valign="middle">
|
||||
<td colspan="2"><input name="clear" value=" Clear " onclick="clearDisplay()" type="button"></td>
|
||||
<td colspan="3"><input name="enter" value=" = " onclick="calculate()" type="button"></td>
|
||||
|
||||
</tr></tbody></table>
|
||||
</form>
|
||||
|
||||
<!--
|
||||
<TD VALIGN=top>
|
||||
<B>NOTE:</B> All sine and cosine calculations are
|
||||
<br>done in radians. Remember to convert first
|
||||
<br>if using degrees.
|
||||
</TD>
|
||||
-->
|
||||
|
||||
</td></tr></tbody></table>
|
||||
|
||||
|
||||
</td></tr></tbody></table>
|
||||
|
||||
EOT;
|
||||
return $o;
|
||||
|
||||
}
|
Binary file not shown.
@ -0,0 +1,283 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP version 4.0 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 2.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/2_02.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Authors: Stanislav Okhvat <stanis@ngs.ru> |
|
||||
// | Co-authored by : CVH, Chris Hansel <chris@cpi-service.com> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id: UnitConvertor.php,v 1.00 2002/02/20 11:40:00 stasokhvat Exp $
|
||||
|
||||
/**
|
||||
* UnitConvertor is able to convert between different units and currencies.
|
||||
*
|
||||
* @author Stanislav Okhvat <stanis@sibfair.nsk.su, stanis@ngs.ru>
|
||||
* @version $Id: UnitConvertor.php,v 1.00 2002/03/01 17:00:00 stasokhvat Exp $
|
||||
* @package UnitConvertor
|
||||
* @access public
|
||||
* @history 01.03.2002 Implemented the code for regular and offset-based
|
||||
* conversions
|
||||
*
|
||||
* 13.12.2004
|
||||
* By Chris Hansel (CVH): changed getConvSpecs in order to have it look up
|
||||
* intermediary conversions (also see comments in check_key).
|
||||
*
|
||||
* Intermediary conversions are useful when no conversion ratio is specified
|
||||
* between two units when we calculate between the two. For example, we want
|
||||
* to convert between Fahrenheit and Kelvin, and we have only
|
||||
* specified how to convert Centigrade<->Fahrenheit and
|
||||
* Centigrade<->Kelvin. While a direct (Fahrenheit->Kelvin) or
|
||||
* reverse (Kelvin->Fahrenheit) lookups fail, looking for an intermediary
|
||||
* unit linking the two (Centigrade) helps us do the conversion.
|
||||
*
|
||||
* 13.12.2004
|
||||
* Chris Hansel (CVH): $to_array argument of addConversion method can now
|
||||
* contain units as 'unit1/unit2/unit3', when all units stand for the same
|
||||
* thing. See examples in unitconv.php
|
||||
*/
|
||||
class UnitConvertor
|
||||
{
|
||||
/**
|
||||
* Stores conversion ratios.
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $conversion_table = array();
|
||||
|
||||
/**
|
||||
* Decimal point character (default is "." - American - set in constructor).
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $decimal_point;
|
||||
|
||||
/**
|
||||
* Thousands separator (default is "," - American - set in constructor).
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $thousand_separator;
|
||||
|
||||
/**
|
||||
* For future use
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $bases = array();
|
||||
|
||||
/**
|
||||
* Constructor. Initializes the UnitConvertor object with the most important
|
||||
* properties.
|
||||
*
|
||||
* @param string decimal point character
|
||||
* @param string thousand separator character
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function UnitConvertor($dec_point = '.', $thousand_sep = ',')
|
||||
{
|
||||
$this->decimal_point = $dec_point;
|
||||
$this->thousand_separator = $thousand_sep;
|
||||
|
||||
} // end func UnitConvertor
|
||||
|
||||
/**
|
||||
* Adds a conversion ratio to the conversion table.
|
||||
*
|
||||
* @param string the name of unit from which to convert
|
||||
* @param array array(
|
||||
* "pound"=>array("ratio"=>'', "offset"=>'')
|
||||
* )
|
||||
* "pound" - name of unit to set conversion ration to
|
||||
* "ratio" - 'double' conversion ratio which, when
|
||||
* multiplied by the number of $from_unit units produces
|
||||
* the result
|
||||
* "offset" - an offset from 0 which will be added to
|
||||
* the result when converting (needed for temperature
|
||||
* conversions and defaults to 0).
|
||||
* @return boolean true if successful, false otherwise
|
||||
* @access public
|
||||
*/
|
||||
function addConversion($from_unit, $to_array)
|
||||
{
|
||||
if (!isset($this->conversion_table[$from_unit])) {
|
||||
while(list($key, $val) = each($to_array))
|
||||
{
|
||||
if (strstr($key, '/'))
|
||||
{
|
||||
$to_units = explode('/', $key);
|
||||
foreach ($to_units as $to_unit)
|
||||
{
|
||||
$this->bases[$from_unit][] = $to_unit;
|
||||
|
||||
if (!is_array($val))
|
||||
{
|
||||
$this->conversion_table[$from_unit."_".$to_unit] = array("ratio"=>$val, "offset"=>0);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->conversion_table[$from_unit."_".$to_unit] =
|
||||
array(
|
||||
"ratio"=>$val['ratio'],
|
||||
"offset"=>(isset($val['offset']) ? $val['offset'] : 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->bases[$from_unit][] = $key;
|
||||
|
||||
if (!is_array($val))
|
||||
{
|
||||
$this->conversion_table[$from_unit."_".$key] = array("ratio"=>$val, "offset"=>0);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->conversion_table[$from_unit."_".$key] =
|
||||
array(
|
||||
"ratio"=>$val['ratio'],
|
||||
"offset"=>(isset($val['offset']) ? $val['offset'] : 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
} // end func addConversion
|
||||
|
||||
/**
|
||||
* Converts from one unit to another using specified precision.
|
||||
*
|
||||
* @param double value to convert
|
||||
* @param string name of the source unit from which to convert
|
||||
* @param string name of the target unit to which we are converting
|
||||
* @param integer double precision of the end result
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function convert($value, $from_unit, $to_unit, $precision)
|
||||
{
|
||||
if ($this->getConvSpecs($from_unit, $to_unit, $value, $converted ))
|
||||
{
|
||||
return number_format($converted , (int)$precision, $this->decimal_point, $this->thousand_separator);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} // end func
|
||||
|
||||
/**
|
||||
* CVH : changed this Function getConvSpecs in order to have it look up
|
||||
* intermediary Conversions from the
|
||||
* "base" unit being that one that has the highest hierarchical order in one
|
||||
* "logical" Conversion_Array
|
||||
* when taking $conv->addConversion('km',
|
||||
* array('meter'=>1000, 'dmeter'=>10000, 'centimeter'=>100000,
|
||||
* 'millimeter'=>1000000, 'mile'=>0.62137, 'naut.mile'=>0.53996,
|
||||
* 'inch(es)/zoll'=>39370, 'ft/foot/feet'=>3280.8, 'yd/yard'=>1093.6));
|
||||
* "km" would be the logical base unit for all units of dinstance, thus,
|
||||
* if the function fails to find a direct or reverse conversion in the table
|
||||
* it is only logical to suspect that if there is a chance
|
||||
* converting the value it only is via the "base" unit, and so
|
||||
* there is not even a need for a recursive search keeping the perfomance
|
||||
* acceptable and the ressource small...
|
||||
*
|
||||
* CVH check_key checks for a key in the Conversiontable and returns a value
|
||||
*/
|
||||
function check_key( $key) {
|
||||
if ( array_key_exists ($key,$this->conversion_table)) {
|
||||
if (! empty($this->conversion_table[$key])) {
|
||||
return $this->conversion_table[$key];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Key function. Finds the conversion ratio and offset from one unit to another.
|
||||
*
|
||||
* @param string name of the source unit from which to convert
|
||||
* @param string name of the target unit to which we are converting
|
||||
* @param double conversion ratio found. Returned by reference.
|
||||
* @param double offset which needs to be added (or subtracted, if negative)
|
||||
* to the result to convert correctly.
|
||||
* For temperature or some scientific conversions,
|
||||
* i.e. Fahrenheit -> Celcius
|
||||
* @return boolean true if ratio and offset are found for the supplied
|
||||
* units, false otherwise
|
||||
* @access private
|
||||
*/
|
||||
function getConvSpecs($from_unit, $to_unit, $value, &$converted)
|
||||
{
|
||||
$key = $from_unit."_".$to_unit;
|
||||
$revkey = $to_unit."_".$from_unit;
|
||||
$found = false;
|
||||
if ($ct_arr = $this->check_key($key)) {
|
||||
// Conversion Specs found directly
|
||||
$ratio = (double)$ct_arr['ratio'];
|
||||
$offset = $ct_arr['offset'];
|
||||
$converted = (double)(($value * $ratio)+ $offset);
|
||||
|
||||
return true;
|
||||
} // not found in direct order, try reverse order
|
||||
elseif ($ct_arr = $this->check_key($revkey)) {
|
||||
$ratio = (double)(1/$ct_arr['ratio']);
|
||||
$offset = -$ct_arr['offset'];
|
||||
$converted = (double)(($value + $offset) * $ratio);
|
||||
|
||||
return true;
|
||||
} // not found test for intermediary conversion
|
||||
else {
|
||||
// return ratio = 1 if keyparts match
|
||||
if ($key == $revkey) {
|
||||
$ratio = 1;
|
||||
$offset = 0;
|
||||
$converted = $value;
|
||||
return true;
|
||||
}
|
||||
// otherwise search intermediary
|
||||
reset($this->conversion_table);
|
||||
while (list($convk, $i1_value) = each($this->conversion_table)) {
|
||||
// split the key into parts
|
||||
$keyparts = preg_split("/_/",$convk);
|
||||
// return ratio = 1 if keyparts match
|
||||
|
||||
// Now test if either part matches the from or to unit
|
||||
if ($keyparts[1] == $to_unit && ($i2_value = $this->check_key($keyparts[0]."_".$from_unit))) {
|
||||
// an intermediary $keyparts[0] was found
|
||||
// now let us put things together intermediary 1 and 2
|
||||
$converted = (double)(((($value - $i2_value['offset']) / $i2_value['ratio']) * $i1_value['ratio'])+ $i1_value['offset']);
|
||||
|
||||
$found = true;
|
||||
|
||||
} elseif ($keyparts[1] == $from_unit && ($i2_value = $this->check_key($keyparts[0]."_".$to_unit))) {
|
||||
// an intermediary $keyparts[0] was found
|
||||
// now let us put things together intermediary 2 and 1
|
||||
$converted = (double)(((($value - $i1_value['offset']) / $i1_value['ratio']) + $i2_value['offset']) * $i2_value['ratio']);
|
||||
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
return $found;
|
||||
}
|
||||
|
||||
} // end func getConvSpecs
|
||||
|
||||
} // end class UnitConvertor
|
||||
?>
|
@ -0,0 +1,228 @@
|
||||
<?php
|
||||
/**
|
||||
* Name: Converter App
|
||||
* Description: Unit converter application
|
||||
* Version: 1.0
|
||||
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||
*/
|
||||
|
||||
function convert_install() {
|
||||
register_hook('app_menu', 'addon/convert/convert.php', 'convert_app_menu');
|
||||
}
|
||||
|
||||
function convert_uninstall() {
|
||||
unregister_hook('app_menu', 'addon/convert/convert.php', 'convert_app_menu');
|
||||
}
|
||||
|
||||
function convert_app_menu($a,&$b) {
|
||||
$b['app_menu'] .= '<div class="app-title"><a href="convert">Units Conversion</a></div>';
|
||||
}
|
||||
|
||||
|
||||
function convert_module() {}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function convert_content($app) {
|
||||
|
||||
include("UnitConvertor.php");
|
||||
|
||||
class TP_Converter extends UnitConvertor {
|
||||
function TP_Converter($lang = "en")
|
||||
{
|
||||
if ($lang != 'en' ) {
|
||||
$dec_point = '.'; $thousand_sep = "'";
|
||||
} else {
|
||||
$dec_point = '.'; $thousand_sep = ",";
|
||||
}
|
||||
|
||||
$this->UnitConvertor($dec_point , $thousand_sep );
|
||||
|
||||
} // end func UnitConvertor
|
||||
|
||||
function find_base_unit($from,$to) {
|
||||
while (list($skey,$sval) = each($this->bases)) {
|
||||
if ($skey == $from || $to == $skey || in_array($to,$sval) || in_array($from,$sval)) {
|
||||
return $skey;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getTable($value, $from_unit, $to_unit, $precision) {
|
||||
|
||||
if ($base_unit = $this->find_base_unit($from_unit,$to_unit)) {
|
||||
|
||||
// A baseunit was found now lets convert from -> $base_unit
|
||||
|
||||
$cell ['value'] = $this->convert($value, $from_unit, $base_unit, $precision)." ".$base_unit;
|
||||
$cell ['class'] = ($base_unit == $from_unit || $base_unit == $to_unit) ? "framedred": "";
|
||||
$cells[] = $cell;
|
||||
// We now have the base unit and value now lets produce the table;
|
||||
while (list($key,$val) = each($this->bases[$base_unit])) {
|
||||
$cell ['value'] = $this->convert($value, $from_unit, $val, $precision)." ".$val;
|
||||
$cell ['class'] = ($val == $from_unit || $val == $to_unit) ? "framedred": "";
|
||||
$cells[] = $cell;
|
||||
}
|
||||
|
||||
$cc = count($cells);
|
||||
$string = "<table class=\"framed grayish\" border=\"1\" cellpadding=\"5\" width=\"80%\" align=\"center\"><tr>";
|
||||
$string .= "<td rowspan=\"$cc\" align=\"center\">$value $from_unit</td>";
|
||||
$i=0;
|
||||
foreach ($cells as $cell) {
|
||||
if ($i==0) {
|
||||
$string .= "<td class=\"".$cell['class']."\">".$cell['value']."</td>";
|
||||
$i++;
|
||||
} else {
|
||||
$string .= "</tr><tr><td class=\"".$cell['class']."\">".$cell['value']."</td>";
|
||||
}
|
||||
}
|
||||
$string .= "</tr></table>";
|
||||
return $string;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$conv = new TP_Converter('en');
|
||||
|
||||
|
||||
$conversions = array(
|
||||
'Temperature'=>array('base' =>'Celsius',
|
||||
'conv'=>array(
|
||||
'Fahrenheit'=>array('ratio'=>1.8, 'offset'=>32),
|
||||
'Kelvin'=>array('ratio'=>1, 'offset'=>273),
|
||||
'Reaumur'=>0.8
|
||||
)
|
||||
),
|
||||
'Weight' => array('base' =>'kg',
|
||||
'conv'=>array(
|
||||
'g'=>1000,
|
||||
'mg'=>1000000,
|
||||
't'=>0.001,
|
||||
'grain'=>15432,
|
||||
'oz'=>35.274,
|
||||
'lb'=>2.2046,
|
||||
'cwt(UK)' => 0.019684,
|
||||
'cwt(US)' => 0.022046,
|
||||
'ton (US)' => 0.0011023,
|
||||
'ton (UK)' => 0.0009842
|
||||
)
|
||||
),
|
||||
'Distance' => array('base' =>'km',
|
||||
'conv'=>array(
|
||||
'm'=>1000,
|
||||
'dm'=>10000,
|
||||
'cm'=>100000,
|
||||
'mm'=>1000000,
|
||||
'mile'=>0.62137,
|
||||
'naut.mile'=>0.53996,
|
||||
'inch(es)'=>39370,
|
||||
'ft'=>3280.8,
|
||||
'yd'=>1093.6,
|
||||
'furlong'=>4.970969537898672,
|
||||
'fathom'=>546.8066491688539
|
||||
)
|
||||
),
|
||||
'Area' => array('base' =>'km 2',
|
||||
'conv'=>array(
|
||||
'ha'=>100,
|
||||
'acre'=>247.105,
|
||||
'm 2'=>pow(1000,2),
|
||||
'dm 2'=>pow(10000,2),
|
||||
'cm 2'=>pow(100000,2),
|
||||
'mm 2'=>pow(1000000,2),
|
||||
'mile 2'=>pow(0.62137,2),
|
||||
'naut.miles 2'=>pow(0.53996,2),
|
||||
'in 2'=>pow(39370,2),
|
||||
'ft 2'=>pow(3280.8,2),
|
||||
'yd 2'=>pow(1093.6,2),
|
||||
)
|
||||
),
|
||||
'Volume' => array('base' =>'m 3',
|
||||
'conv'=>array(
|
||||
'in 3'=>61023.6,
|
||||
'ft 3'=>35.315,
|
||||
'cm 3'=>pow(10,6),
|
||||
'dm 3'=>1000,
|
||||
'litre'=>1000,
|
||||
'hl'=>10,
|
||||
'yd 3'=>1.30795,
|
||||
'gal(US)'=>264.172,
|
||||
'gal(UK)'=>219.969,
|
||||
'pint' => 2113.376,
|
||||
'quart' => 1056.688,
|
||||
'cup' => 4266.753,
|
||||
'fl oz' => 33814.02,
|
||||
'tablespoon' => 67628.04,
|
||||
'teaspoon' => 202884.1,
|
||||
'pt (UK)'=>1000/0.56826,
|
||||
'barrel petroleum'=>1000/158.99,
|
||||
'Register Tons'=>2.832,
|
||||
'Ocean Tons'=>1.1327
|
||||
)
|
||||
),
|
||||
'Speed' =>array('base' =>'kmph',
|
||||
'conv'=>array(
|
||||
'mps'=>0.0001726031,
|
||||
'milesph'=>0.62137,
|
||||
'knots'=>0.53996,
|
||||
'mach STP'=>0.0008380431,
|
||||
'c (warp)'=>9.265669e-10
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
while (list($key,$val) = each($conversions)) {
|
||||
$conv->addConversion($val['base'], $val['conv']);
|
||||
$list[$key][] = $val['base'];
|
||||
while (list($ukey,$uval) = each($val['conv'])) {
|
||||
$list[$key][] = $ukey;
|
||||
}
|
||||
}
|
||||
|
||||
$o .= '<h3>Unit Conversions</h3>';
|
||||
|
||||
|
||||
if (isset($_POST['from_unit']) && isset($_POST['value'])) {
|
||||
$_POST['value'] = $_POST['value'] + 0;
|
||||
|
||||
|
||||
$o .= ($conv->getTable($_POST['value'], $_POST['from_unit'], $_POST['to_unit'], 5))."</p>";
|
||||
} else {
|
||||
$o .= "<p>Select:</p>";
|
||||
}
|
||||
|
||||
if(isset($_POST['value']))
|
||||
$value = $_POST['value'];
|
||||
else
|
||||
$value = '';
|
||||
|
||||
$o .= '<form action="convert" method="post" name="conversion">';
|
||||
$o .= '<input name="value" type="text" id="value" value="' . $value . '" size="10" maxlength="10" />';
|
||||
$o .= '<select name="from_unit" size="12">';
|
||||
|
||||
|
||||
|
||||
reset($list);
|
||||
while(list($key,$val) = each($list)) {
|
||||
$o .= "\n\t<optgroup label=\"$key\">";
|
||||
while(list($ukey,$uval) = each($val)) {
|
||||
$selected = (($uval == $_POST['from_unit']) ? ' selected="selected" ' : '');
|
||||
$o .= "\n\t\t<option value=\"$uval\" $selected >$uval</option>";
|
||||
}
|
||||
$o .= "\n\t</optgroup>";
|
||||
}
|
||||
|
||||
$o .= '</select>';
|
||||
|
||||
$o .= '<input type="submit" name="Submit" value="Submit" /></form>';
|
||||
|
||||
return $o;
|
||||
}
|
Binary file not shown.
@ -0,0 +1,39 @@
|
||||
Installing the Friendika/Facebook connector
|
||||
|
||||
1. register an API key for your site from developer.facebook.com
|
||||
a. We'd be very happy if you include "Friendika" in the application name
|
||||
to increase name recognition. The Friendika icons are also present
|
||||
in the images directory and may be uploaded as a Facebook app icon.
|
||||
Use images/friendika-16.jpg for the Icon and images/friendika-128.jpg for the Logo.
|
||||
b. The url should be your site URL with a trailing slash.
|
||||
You may use http://portal.friendika.com/privacy as the privacy policy
|
||||
URL unless your site has different requirements, and
|
||||
http://portal.friendika.com as the Terms of Service URL unless
|
||||
you have different requirements. (Friendika is a software application
|
||||
and does not require Terms of Service, though your installation of it might).
|
||||
c. Set the following values in your .htconfig.php file
|
||||
$a->config['facebook']['appid'] = 'xxxxxxxxxxx';
|
||||
$a->config['facebook']['appsecret'] = 'xxxxxxxxxxxxxxx';
|
||||
Replace with the settings Facebook gives you.
|
||||
d. Navigate to Set Web->Site URL & Domain -> Website Settings. Set Site URL
|
||||
to yoursubdomain.yourdomain.com. Set Site Domain to your yourdomain.com.
|
||||
2. Enable the facebook plugin by including it in .htconfig.php - e.g.
|
||||
$a->config['system']['addon'] = 'plugin1,plugin2,facebook';
|
||||
3. Visit the Facebook Settings section of the "Settings->Plugin Settings" page.
|
||||
and click 'Install Facebook Connector'.
|
||||
4. This will ask you to login to Facebook and grant permission to the
|
||||
plugin to do its stuff. Allow it to do so.
|
||||
5. You're done. To turn it off visit the Plugin Settings page again and
|
||||
'Remove Facebook posting'.
|
||||
|
||||
Vidoes and embeds will not be posted if there is no other content. Links
|
||||
and images will be converted to a format suitable for the Facebook API and
|
||||
long posts truncated - with a link to view the full post.
|
||||
|
||||
Facebook contacts will not be able to view private photos, as they are not able to
|
||||
authenticate to your site to establish identity. We will address this
|
||||
in a future release.
|
||||
|
||||
Info: please make sure that you understand all aspects due to Friendika's
|
||||
default licence which is: Creative Commons Attribution 3.0 (further info:
|
||||
http://creativecommons.org/licenses/by/3.0/ )
|
@ -0,0 +1,13 @@
|
||||
|
||||
#facebook-enable-wrapper {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
#facebook-disable-wrapper {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
#facebook-post-default-form input {
|
||||
margin-top: 20px;
|
||||
margin-right: 20px;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -0,0 +1,7 @@
|
||||
.fortunate {
|
||||
margin-top: 25px;
|
||||
margin-left: 100px;
|
||||
margin-bottom: 25px;
|
||||
color: #000088;
|
||||
font-size: 14px;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Name: Fortunate
|
||||
* Description: Add a random fortune cookie at the bottom of every pages.
|
||||
* Version: 1.0
|
||||
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||
*/
|
||||
|
||||
|
||||
function fortunate_install() {
|
||||
register_hook('page_end', 'addon/fortunate/fortunate.php', 'fortunate_fetch');
|
||||
}
|
||||
|
||||
function fortunate_uninstall() {
|
||||
unregister_hook('page_end', 'addon/fortunate/fortunate.php', 'fortunate_fetch');
|
||||
}
|
||||
|
||||
|
||||
function fortunate_fetch($a,&$b) {
|
||||
|
||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'
|
||||
. $a->get_baseurl() . '/addon/fortunate/fortunate.css' . '" media="all" />' . "\r\n";
|
||||
|
||||
$s = fetch_url('http://fortunemod.com/cookie.php?numlines=2&equal=1&rand=' . mt_rand());
|
||||
$b .= '<div class="fortunate">' . $s . '</div>';
|
||||
}
|
||||
|
Binary file not shown.
@ -0,0 +1,27 @@
|
||||
Impressum Plugin for Friendika
|
||||
|
||||
Author: Tobias Diekershoff
|
||||
tobias.diekershoff@gmx.net
|
||||
|
||||
License: 3-clause BSD license (same as Friendika)
|
||||
|
||||
About
|
||||
This plugin adds an Impressum block to the /friendika page with informations
|
||||
about the page operator/owner and how to contact you in case of any questions.
|
||||
|
||||
In the notes and postal fields you can use HTML tags for formatting.
|
||||
|
||||
Configuration:
|
||||
For configuration you can set the following variables in the .htconfig file
|
||||
* $a->config['impressum']['owner'] this is the Name of the Operator
|
||||
* $a->config['impressum']['ownerprofile'] this is an optional Friendika account
|
||||
where the above owner name will link to
|
||||
* $a->config['impressum']['email'] a contact email address (optional)
|
||||
will be displayed slightly obfuscated
|
||||
as name(at)example(dot)com
|
||||
* $a->config['impressum']['postal'] should contain a postal address where
|
||||
you can be reached at (optional)
|
||||
* $a->config['impressum']['notes'] additional informations that should
|
||||
be displayed in the Impressum block
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
{{ inc field_input.tpl with $field=$owner }}{{ endinc }}
|
||||
{{ inc field_input.tpl with $field=$ownerprofile }}{{ endinc }}
|
||||
{{ inc field_input.tpl with $field=$postal }}{{ endinc }}
|
||||
{{ inc field_input.tpl with $field=$notes }}{{ endinc }}
|
||||
{{ inc field_input.tpl with $field=$email }}{{ endinc }}
|
||||
<div class="submit"><input type="submit" name="page_site" value="$submit" /></div>
|
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* Name: Impressum
|
||||
* Description: Plugin to add contact information to the about page (/friendika)
|
||||
* Version: 1.0
|
||||
* Author: Tobias Diekershoff <https://diekershoff.homeunix.net/friendika/profile/tobias>
|
||||
* License: 3-clause BSD license
|
||||
*/
|
||||
|
||||
function impressum_install() {
|
||||
register_hook('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
|
||||
logger("installed impressum plugin");
|
||||
}
|
||||
|
||||
function impressum_uninstall() {
|
||||
unregister_hook('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
|
||||
logger("uninstalled impressum plugin");
|
||||
}
|
||||
function obfuscate_email ($s) {
|
||||
$s = str_replace('@','(at)',$s);
|
||||
$s = str_replace('.','(dot)',$s);
|
||||
return $s;
|
||||
}
|
||||
function impressum_show($a,&$b) {
|
||||
$b .= '<h3>'.t('Impressum').'</h3>';
|
||||
$owner = get_config('impressum', 'owner');
|
||||
$owner_profile = get_config('impressum','ownerprofile');
|
||||
$postal = get_config('impressum', 'postal');
|
||||
$notes = get_config('impressum', 'notes');
|
||||
$email = obfuscate_email( get_config('impressum','email') );
|
||||
if (strlen($owner)) {
|
||||
if (strlen($owner_profile)) {
|
||||
$tmp = '<a href="'.$owner_profile.'">'.$owner.'</a>';
|
||||
} else {
|
||||
$tmp = $owner;
|
||||
}
|
||||
if (strlen($email)) {
|
||||
$b .= '<p><strong>'.t('Site Owner').'</strong>: '. $tmp .'<br /><strong>'.t('Email Address').'</strong>: '.$email.'</p>';
|
||||
} else {
|
||||
$b .= '<p><strong>'.t('Site Owner').'</strong>: '. $tmp .'</p>';
|
||||
}
|
||||
if (strlen($postal)) {
|
||||
$b .= '<p><strong>'.t('Postal Address').'</strong><br />'. $postal .'</p>';
|
||||
}
|
||||
if (strlen($notes)) {
|
||||
$b .= '<p>'.$notes.'</p>';
|
||||
}
|
||||
} else {
|
||||
$b .= '<p>'.t('The impressum addon needs to be configured!<br />Please add at least the <tt>owner</tt> variable to your config file. For other variables please refer to the README file of the addon.').'</p>';
|
||||
}
|
||||
}
|
||||
|
||||
function impressum_plugin_admin_post (&$a) {
|
||||
$owner = ((x($_POST, 'owner')) ? notags(trim($_POST['owner'])) : '');
|
||||
$ownerprofile = ((x($_POST, 'ownerprofile')) ? notags(trim($_POST['ownerprofile'])) : '');
|
||||
$postal = ((x($_POST, 'postal')) ? (trim($_POST['postal'])) : '');
|
||||
$notes = ((x($_POST, 'notes')) ? (trim($_POST['notes'])) : '');
|
||||
$email = ((x($_POST, 'email')) ? notags(trim($_POST['email'])) : '');
|
||||
set_config('impressum','owner',$owner);
|
||||
set_config('impressum','ownerprofile',$ownerprofile);
|
||||
set_config('impressum','postal',$postal);
|
||||
set_config('impressum','email',$email);
|
||||
set_config('impressum','notes',$notes);
|
||||
info( t('Settings updated.'). EOL );
|
||||
}
|
||||
function impressum_plugin_admin (&$a, &$o) {
|
||||
$t = file_get_contents( dirname(__file__). "/admin.tpl" );
|
||||
$o = replace_macros($t, array(
|
||||
'$submit' => t('Submit'),
|
||||
'$owner' => array('owner', t('Site Owner'), get_config('impressum','owner'), ''),
|
||||
'$ownerprofile' => array('ownerprofile', t('Site Owners Profile'), get_config('impressum','ownerprofile'), ''),
|
||||
'$postal' => array('postal', t('Postal Address'), get_config('impressum','postal'), ''),
|
||||
'$notes' => array('notes', t('Notes'), get_config('impressum','notes'), ''),
|
||||
'$email' => array('email', t('Email Address'), get_config('impressum','email'), ''),
|
||||
));
|
||||
}
|
Binary file not shown.
@ -0,0 +1,38 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<link href="fileuploader.css" rel="stylesheet" type="text/css">
|
||||
<style>
|
||||
body {font-size:13px; font-family:arial, sans-serif; width:700px; margin:100px auto;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p><a href="http://github.com/valums/file-uploader">Back to project page</a></p>
|
||||
|
||||
<p>To upload a file, click on the button below. Drag-and-drop is supported in FF, Chrome.</p>
|
||||
<p>Progress-bar is supported in FF3.6+, Chrome6+, Safari4+</p>
|
||||
|
||||
<div id="file-uploader-demo1">
|
||||
<noscript>
|
||||
<p>Please enable JavaScript to use file uploader.</p>
|
||||
<!-- or put a simple form for upload here -->
|
||||
</noscript>
|
||||
</div>
|
||||
|
||||
<script src="fileuploader.js" type="text/javascript"></script>
|
||||
<script>
|
||||
function createUploader(){
|
||||
var uploader = new qq.FileUploader({
|
||||
element: document.getElementById('file-uploader-demo1'),
|
||||
action: 'do-nothing.htm',
|
||||
debug: true
|
||||
});
|
||||
}
|
||||
|
||||
// in your app create uploader as soon as the DOM is ready
|
||||
// don't wait for the window to load
|
||||
window.onload = createUploader;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1 @@
|
||||
{success:true}
|
@ -0,0 +1,31 @@
|
||||
.qq-uploader { position:relative; width: 100%;}
|
||||
|
||||
.qq-upload-button {
|
||||
display:block; /* or inline-block */
|
||||
width: 105px; padding: 7px 0; text-align:center;
|
||||
background:#880000; border-bottom:1px solid #ddd;color:#fff;
|
||||
}
|
||||
.qq-upload-button-hover {background:#cc0000;}
|
||||
.qq-upload-button-focus {outline:1px dotted black;}
|
||||
|
||||
.qq-upload-drop-area {
|
||||
position:absolute; top:0; left:0; width:100%; height:100%; min-height: 70px; z-index:2;
|
||||
background:#FF9797; text-align:center;
|
||||
}
|
||||
.qq-upload-drop-area span {
|
||||
display:block; position:absolute; top: 50%; width:100%; margin-top:-8px; font-size:16px;
|
||||
}
|
||||
.qq-upload-drop-area-active {background:#FF7171;}
|
||||
|
||||
.qq-upload-list {margin:15px 35px; padding:0; list-style:disc;}
|
||||
.qq-upload-list li { margin:0; padding:0; line-height:15px; font-size:12px;}
|
||||
.qq-upload-file, .qq-upload-spinner, .qq-upload-size, .qq-upload-cancel, .qq-upload-failed-text {
|
||||
margin-right: 7px;
|
||||
}
|
||||
|
||||
.qq-upload-file {}
|
||||
.qq-upload-spinner {display:inline-block; background: url("loading.gif"); width:15px; height:15px; vertical-align:text-bottom;}
|
||||
.qq-upload-size,.qq-upload-cancel {font-size:11px;}
|
||||
|
||||
.qq-upload-failed-text {display:none;}
|
||||
.qq-upload-fail .qq-upload-failed-text {display:inline;}
|
File diff suppressed because it is too large
Load Diff
After Width: | Height: | Size: 1.6 KiB |
@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
@ -0,0 +1,24 @@
|
||||
File uploader component is licensed under GNU GPL 2 or later, see gpl-2.0.txt.
|
||||
© 2010 Andrew Valums
|
||||
|
||||
This distribution also includes:
|
||||
|
||||
server/OctetStreamReader.java
|
||||
Dual Licensed under the MIT and GPL v.2
|
||||
|
||||
jQuery JavaScript Library
|
||||
http://jquery.com/
|
||||
Copyright 2010, John Resig
|
||||
Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
http://jquery.org/license
|
||||
|
||||
Sizzle.js - CSS selector engine used by jQuery
|
||||
http://sizzlejs.com/
|
||||
Copyright 2010, The Dojo Foundation
|
||||
Released under the MIT, BSD, and GPL Licenses.
|
||||
|
||||
QUnit - A JavaScript Unit Testing Framework
|
||||
http://docs.jquery.com/QUnit
|
||||
Copyright (c) 2009 John Resig, Jörn Zaefferer
|
||||
Dual licensed under the MIT (MIT-LICENSE.txt)
|
||||
and GPL (GPL-LICENSE.txt) licenses.
|
@ -0,0 +1,152 @@
|
||||
[donation_link]: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=3PMY37SL9L888&lc=US&item_name=JavaScript%20file%20uploader¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted
|
||||
|
||||
This plugin uses XHR for uploading multiple files with progress-bar in FF3.6+, Safari4+,
|
||||
Chrome and falls back to hidden iframe based upload in other browsers,
|
||||
providing good user experience everywhere.
|
||||
|
||||
### <a href="http://valums.com/files/2010/file-uploader/demo.htm">Demo</a> [Donate][donation_link] ###
|
||||
|
||||
### Features ###
|
||||
* multiple file select, progress-bar in FF, Chrome, Safari
|
||||
* drag-and-drop file select in FF, Chrome
|
||||
* uploads are cancellable
|
||||
* no external dependencies
|
||||
* doesn't use Flash
|
||||
* fully working with https
|
||||
* keyboard support in FF, Chrome, Safari
|
||||
* tested in IE7,8; Firefox 3,3.6,4; Safari4,5; Chrome; Opera10.60;
|
||||
|
||||
### License ###
|
||||
This plugin is open sourced under <a href="http://www.gnu.org/licenses/gpl-2.0.html">GNU GPL 2</a> or later.
|
||||
If this license doesn't suit you mail me at andrew (at) valums.com.
|
||||
|
||||
Please [donate][donation_link] if you are willing to support the further development of file upload plugin.
|
||||
|
||||
### Known Issues ###
|
||||
Plugin breaks back button functionality in Opera.
|
||||
|
||||
### Getting started ###
|
||||
The fileuploader.js contains two classes that are meant to be used directly.
|
||||
If you need a complete upload widget (from demo) to quickly drop
|
||||
into your current design, use qq.FileUploader.
|
||||
|
||||
If you want to customize uploader, by using a different looking file list
|
||||
or change the behaviour or functionality use qq.FileUploaderBasic.
|
||||
|
||||
The difference between them is that qq.FileUploader provides a list of files,
|
||||
drag-and-drop, but qq.FileUploaderBasic only creates button and handles validation.
|
||||
Basic uploader is easier extendable, and doesn't limit possible customization.
|
||||
|
||||
qq.FileUploader extends qq.FileUploaderBasic, so that all the options present
|
||||
in the basic uploader also exist in the full widget.
|
||||
|
||||
### qq.FileUploader - Setting up full upload widget ###
|
||||
|
||||
Include fileuploader.js and fileuploader.css into your page.
|
||||
Create container element.
|
||||
|
||||
<div id="file-uploader">
|
||||
<noscript>
|
||||
<p>Please enable JavaScript to use file uploader.</p>
|
||||
<!-- or put a simple form for upload here -->
|
||||
</noscript>
|
||||
</div>
|
||||
|
||||
Initialize uploader when the DOM is ready. Change the action option.
|
||||
For example ../server/php.php for the default folder structure.
|
||||
In the server folder you will find examples for different platforms.
|
||||
If you can't find the one you need, check the readme.txt in the same folder.
|
||||
|
||||
var uploader = new qq.FileUploader({
|
||||
// pass the dom node (ex. $(selector)[0] for jQuery users)
|
||||
element: document.getElementById('file-uploader'),
|
||||
// path to server-side upload script
|
||||
action: '/server/upload'
|
||||
});
|
||||
|
||||
### Options of both classes ###
|
||||
|
||||
// url of the server-side upload script, should be on the same domain
|
||||
action: '/server/upload',
|
||||
// additional data to send, name-value pairs
|
||||
params: {},
|
||||
|
||||
// validation
|
||||
// ex. ['jpg', 'jpeg', 'png', 'gif'] or []
|
||||
allowedExtensions: [],
|
||||
// each file size limit in bytes
|
||||
// this option isn't supported in all browsers
|
||||
sizeLimit: 0, // max size
|
||||
minSizeLimit: 0, // min size
|
||||
|
||||
// set to true to output server response to console
|
||||
debug: false,
|
||||
|
||||
// events
|
||||
// you can return false to abort submit
|
||||
onSubmit: function(id, fileName){},
|
||||
onProgress: function(id, fileName, loaded, total){},
|
||||
onComplete: function(id, fileName, responseJSON){},
|
||||
onCancel: function(id, fileName){},
|
||||
|
||||
messages: {
|
||||
// error messages, see qq.FileUploaderBasic for content
|
||||
},
|
||||
showMessage: function(message){ alert(message); }
|
||||
|
||||
Instance methods
|
||||
|
||||
* setParams(newParams)
|
||||
|
||||
#### Changing alert/messages to something more user friendly ####
|
||||
|
||||