This commit is contained in:
rwldrn 2011-01-19 21:14:28 -05:00
Родитель 3b40cb8c1d 742ed140bb
Коммит c1c75b0a21
9 изменённых файлов: 5805 добавлений и 11 удалений

1
.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1 @@
dist

105
Makefile
Просмотреть файл

@ -1,11 +1,110 @@
PREFIX = .
BUILD_DIR = ${PREFIX}/build
DIST_DIR = ${PREFIX}/dist
RHINO ?= java -jar ${BUILD_DIR}/js.jar
CLOSURE_COMPILER = ${BUILD_DIR}/google-compiler-20100917.jar
# minify
MINJAR ?= java -jar ${CLOSURE_COMPILER}
# source
POPCORN_SRC = ${PREFIX}/popcorn.js
# distribution files
POPCORN_DIST = ${DIST_DIR}/popcorn.js
POPCORN_MIN = ${DIST_DIR}/popcorn.min.js
all: popcorn min lint
@@echo "Popcorn build complete."
${DIST_DIR}:
@@mkdir -p ${DIST_DIR}
popcorn: ${POPCORN_DIST}
p: ${POPCORN_DIST}
${POPCORN_DIST}: ${POPCORN_SRC} | ${DIST_DIR}
@@echo "Building" ${POPCORN_DIST}
@@cat ${POPCORN_SRC} > ${POPCORN_DIST};
min: ${POPCORN_MIN}
${POPCORN_MIN}: ${POPCORN_DIST}
@@echo "Building" ${POPCORN_MIN}
@@head -11 ${POPCORN_DIST} > ${POPCORN_MIN}
@@${MINJAR} --js ${POPCORN_DIST} --warning_level QUIET --js_output_file ${POPCORN_MIN}.tmp
@@cat ${POPCORN_MIN}.tmp >> ${POPCORN_MIN}
@@rm -f ${POPCORN_MIN}.tmp
lint: ${POPCORN_DIST}
@@echo "Checking Popcorn against JSLint..."
@@${RHINO} build/jslint-check.js
clean:
@@echo "Removing Distribution directory:" ${DIST_DIR}
@@rm -rf ${DIST_DIR}
# Make sure $JSSHELL points to your js shell binary in .profile or .bashrc
TOOLSDIR=./tools
TOOLSDIR= ${PREFIX}/tools
# Most targets use commands that need a js shell path specified
JSSHELL ?= $(error Specify a valid path to a js shell binary in ~/.profile: export JSSHELL=C:\path\js.exe or /path/js)
check: check-lint
check-lint:
${TOOLSDIR}/jslint.py ${JSSHELL} popcorn.js
# Most targets use commands that need a js shell path specified
JSSHELL ?= $(error Specify a valid path to a js shell binary in ~/.profile: export JSSHELL=C:\path\js.exe or /path/js)
PLUGINS_DIR = ${PREFIX}/plugins
PLUGINS_DIST = ${DIST_DIR}/popcorn.plugins.js
PLUGINS_MIN = ${DIST_DIR}/popcorn.plugins.min.js
PLUGINS_SRC = ${PLUGINS_DIR}/attribution/popcorn.attribution.js\
${PLUGINS_DIR}/flickr/popcorn.flickr.js\
${PLUGINS_DIR}/footnote/popcorn.footnote.js\
${PLUGINS_DIR}/googlemap/popcorn.googlemap.js\
${PLUGINS_DIR}/googlenews/popcorn.googlenews.js\
${PLUGINS_DIR}/image/popcorn.image.js\
${PLUGINS_DIR}/lowerthird/popcorn.lowerthird.js\
${PLUGINS_DIR}/subtitle/popcorn.subtitle.js\
${PLUGINS_DIR}/tagthisperson/popcorn.tagthisperson.js\
${PLUGINS_DIR}/twitter/popcorn.twitter.js\
${PLUGINS_DIR}/webpage/popcorn.webpage.js\
${PLUGINS_DIR}/wikipedia/popcorn.wikipedia.js
plugins: ${PLUGINS_DIST}
${PLUGINS_DIST}: ${PLUGINS_SRC} | ${DIST_DIR}
@@echo "Building" ${PLUGINS_DIST}
@@cat ${PLUGINS_SRC} > ${PLUGINS_DIST};
pluginsmin: ${PLUGINS_MIN}
${PLUGINS_MIN}: ${PLUGINS_DIST}
@@echo "Building" ${PLUGINS_MIN}
@@head -0 ${PLUGINS_DIST} > ${PLUGINS_MIN}
@@${MINJAR} --js ${PLUGINS_DIST} --warning_level QUIET --js_output_file ${PLUGINS_MIN}.tmp
@@cat ${PLUGINS_MIN}.tmp >> ${PLUGINS_MIN}
@@rm -f ${PLUGINS_MIN}.tmp

Двоичные данные
build/google-compiler-20100917.jar Normal file

Двоичный файл не отображается.

Двоичные данные
build/js.jar Normal file

Двоичный файл не отображается.

36
build/jslint-check.js Normal file
Просмотреть файл

@ -0,0 +1,36 @@
load("build/jslint.js");
var src = readFile("popcorn.js");
JSLINT(src, { evil: true, forin: true, maxerr: 100 });
// All of the following are known issues that we think are 'ok'
// (in contradiction with JSLint) more information here:
// http://docs.jquery.com/JQuery_Core_Style_Guidelines
var ok = {
"Expected an identifier and instead saw 'undefined' (a reserved word).": true,
"Use '===' to compare with 'null'.": true,
"Use '!==' to compare with 'null'.": true,
"Expected an assignment or function call and instead saw an expression.": true,
"Expected a 'break' statement before 'case'.": true,
"'e' is already defined.": true
};
var e = JSLINT.errors, found = 0, w;
for ( var i = 0; i < e.length; i++ ) {
w = e[i];
if ( !ok[ w.reason ] ) {
found++;
print( "\n" + w.evidence + "\n" );
print( " Problem at line " + w.line + " character " + w.character + ": " + w.reason );
}
}
if ( found > 0 ) {
print( "\n" + found + " Error(s) found." );
} else {
print( "JSLint check passed." );
}

5500
build/jslint.js Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -813,7 +813,11 @@
Popcorn.xhr = function ( options ) {
<<<<<<< HEAD
if ( ( options.dataType || "" ).toLowerCase() === "jsonp" ) {
=======
if ( options.dataType && options.dataType.toLowerCase() === "jsonp" ) {
>>>>>>> 742ed140bbafc94a08a0024346c62eeff8407d07
Popcorn.xhr.getJSONP(
options.url,
@ -823,9 +827,14 @@
}
var settings = Popcorn.extend( {}, setup, options );
// Create new XMLHttpRequest object
settings.ajax = settings.xhr();
// Normalize dataType
settings.dataType = settings.dataType.toLowerCase();
if ( settings.ajax ) {
if ( settings.type === "GET" && settings.data ) {
@ -865,6 +874,12 @@
text: settings.ajax.responseText,
json: json
};
// If a dataType was specified, return that type of data
if ( settings.dataType ) {
data = data[ settings.dataType ];
}
settings.success.call( settings.ajax, data );
@ -881,6 +896,7 @@
script = document.createElement("script"),
paramStr = url.split("?")[1],
fired = false,
<<<<<<< HEAD
params, callback;
script.src = url;
@ -888,6 +904,25 @@
params = paramStr.split("&");
callback = params.length ? params[ params.length - 1 ].split("=")[1] : Popcorn.guid("jsonp");
=======
params = [],
callback;
if ( paramStr ) {
params = paramStr.split("&");
}
callback = params.length ? params[ params.length - 1 ].split("=")[1] : "jsonp";
if ( !paramStr ) {
url += "?callback=" + callback;
}
script.src = url;
>>>>>>> 742ed140bbafc94a08a0024346c62eeff8407d07
if ( callback ) {
// define the jsonp success callback globally
@ -909,7 +944,11 @@
head.insertBefore( script, head.firstChild );
<<<<<<< HEAD
}
=======
};
>>>>>>> 742ed140bbafc94a08a0024346c62eeff8407d07
// Exposes Popcorn to global context

Просмотреть файл

@ -4,6 +4,8 @@
<title>Popcorn API</title>
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
<script src="jquery.js"></script>
<script src="jquery.message.js"></script>
<script src="qunit/qunit.js"></script>
<!--
do not move - this must be called immediately prior to

Просмотреть файл

@ -1021,7 +1021,7 @@ test("Text Response", function () {
expect(expects);
stop( 10000 );
stop()
Popcorn.xhr({
url: 'data/test.txt',
@ -1037,6 +1037,37 @@ test("Text Response", function () {
});
});
test("dataType: Text Response", function () {
var expects = 2,
count = 0;
function plus() {
if ( ++count === expects ) {
start();
}
}
expect(expects);
stop()
Popcorn.xhr({
url: 'data/test.txt',
dataType: "text",
success: function( data ) {
ok(data, "xhr returns data");
plus();
equals( data, "This is a text test", "dataType: 'text', test.txt returns the string 'This is a text test'");
plus();
}
});
});
test("JSON Response", function () {
var expects = 2,
@ -1050,7 +1081,7 @@ test("JSON Response", function () {
expect(expects);
stop( 10000 );
stop()
var testObj = { "data": {"lang": "en", "length": 25} };
@ -1071,9 +1102,9 @@ test("JSON Response", function () {
});
test("JSONP Response", function () {
test("dataType: JSON Response", function () {
var expects = 4,
var expects = 2,
count = 0;
function plus() {
@ -1084,7 +1115,42 @@ test("JSONP Response", function () {
expect(expects);
stop( 10000 );
stop()
var testObj = { "data": {"lang": "en", "length": 25} };
Popcorn.xhr({
url: 'data/test.js',
dataType: "json",
success: function( data ) {
ok(data, "xhr returns data");
plus();
ok( QUnit.equiv(data, testObj) , "dataType: 'json', data returns an object of data");
plus();
}
});
});
test("JSONP Response", function () {
var expects = 6,
count = 0;
function plus() {
if ( ++count === expects ) {
start();
}
}
expect(expects);
stop();
var testObj = { "data": {"lang": "en", "length": 25} };
@ -1099,7 +1165,6 @@ test("JSONP Response", function () {
plus();
console.log(data);
ok( QUnit.equiv(data, testObj) , "Popcorn.xhr({}) data.json returns an object of data");
plus();
@ -1123,6 +1188,21 @@ test("JSONP Response", function () {
);
Popcorn.xhr.getJSONP(
'data/jsonp.json',
function( data ) {
ok(data, "xhr returns data");
plus();
ok( QUnit.equiv(data, testObj) , "Popcorn.xhr.getJSONP data.json returns an object of data");
plus();
}
);
});
test("XML Response", function () {
@ -1138,7 +1218,7 @@ test("XML Response", function () {
expect(expects);
stop( 10000 );
stop()
Popcorn.xhr({
@ -1160,6 +1240,43 @@ test("XML Response", function () {
});
test("dataType: XML Response", function () {
var expects = 2,
count = 0;
function plus() {
if ( ++count === expects ) {
start();
}
}
expect(expects);
stop()
Popcorn.xhr({
url: 'data/test.xml',
dataType: "xml",
success: function( data ) {
ok(data, "xhr returns data");
plus();
var parser = new DOMParser(),
xml = parser.parseFromString('<?xml version="1.0" encoding="UTF-8"?><dashboard><locations class="foo"><location for="bar"><infowindowtab> <tab title="Location"><![CDATA[blabla]]></tab> <tab title="Users"><![CDATA[blublu]]></tab> </infowindowtab> </location> </locations> </dashboard>',"text/xml");
equals( data.toString(), xml.toString(), "dataType: 'xml', data.xml returns a document of xml");
plus();
}
});
});
module("Popcorn Parser");
test("Parsing Functions", function () {