Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #6

Open
wants to merge 19 commits into
base: es6-webpack
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# v0.2.1
* Fix messages if browser has no sessionStorage

# v0.2.0
* Add history polyfill
* Fix files for matching jscs rules
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Easy interaction with R7 box for external webapps
Include the `dist/r7extlib.js` file in your webapp to use it. No build process is
required.

## Versions

STABLE : 0.2.8

DEV(ES6 compatible) : es6-webpack branch

## Build

In order to build this application on your own:
Expand Down
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-cayman
Binary file added am.pak
Binary file not shown.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "r7extlib",
"version": "0.1.8",
"version": "0.2.8",
"homepage": "https://github.com/canalplus/r7extlib",
"description": "Easy interaction with Canal+ R7 box for external webapps",
"main": "dist/r7extlib.js",
Expand Down
4 changes: 2 additions & 2 deletions dist/r7extlib.js

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "r7extlib",
"private": true,
"version": "0.2.0",
"version": "0.2.8",
"description": "Easy interaction with Canal+ R7 box for external webapps",
"main": "r7extlib.js",
"main": "dist/r7extlib.js",
"repository": {
"type": "git",
"url": "git://github.com/canalplus/r7extlib.git"
Expand All @@ -12,7 +12,12 @@
"url": "https://github.com/canalplus/r7extlib/issues"
},
"homepage": "https://github.com/canalplus/r7extlib",
"scripts": {
"build": "bower install && gulp",
"test": "bower install && gulp test"
},
"devDependencies": {
"bower": "^1.8.4",
"chai": "^3.4.0",
"gulp": "^3.9.0",
"gulp-browserify": "^0.5.1",
Expand All @@ -22,7 +27,7 @@
"gulp-rename": "^1.2.2",
"gulp-rimraf": "^0.1.1",
"gulp-uglify": "^1.4.2",
"lodash": "^2.4.1",
"lodash": "^4.17.11",
"mocha": "^2.3.3",
"q": "^1.1.2",
"sinon": "^1.17.2",
Expand Down
31 changes: 25 additions & 6 deletions src/history.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
(function(exports) {
'use strict';

// Only for boxes (History and its prototype must be rewritten). In chrome, we can only extend prototype
try {
window.history = function() {};
} catch (e) {
console.warn('window.history is readonly. History will not be fully available.');
console.warn(e);
return;
}

var _ = require('lodash');

// Check if SessionStorage is available
Expand All @@ -20,7 +29,7 @@
};

if (!hasSessionStorage()) {
console.warn('History can not be rewritten: window.sessionStorage not available!');
console.error('window.sessionStorage not available! History will not be fully available.');
return;
}

Expand Down Expand Up @@ -121,9 +130,6 @@
return __sessionStorage.setItem('R7History', JSON.stringify(this));
};

// Only for boxes (History and its prototype must be rewritten). In chrome, we can only extend prototype
window.history = function() {};

var __isBox = window.history instanceof Function;

if (__isBox) {
Expand Down Expand Up @@ -191,10 +197,23 @@

//Only for boxes (History and its prototype must be rewritten).
if (__isBox) {
window.history = new window.History();
try {
window.history = new window.History();
} catch (e) {
console.warn(e);
}
}

window.addEventListener('hashchange', function() { history.save(); }, false);
window.addEventListener(
'hashchange', function() {
try {
history.save();
} catch (e) {
console.log(e);
}
},
false
);

if (window.Backbone && window.Backbone.history) {
window.Backbone.history.history = window.history;
Expand Down
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,11 @@
window.addEventListener('load', function() {
rpc('ready', function(notUsed, response) {
if (response) {
window.history.init(response.clearHistory);
try {
window.history.init(response.clearHistory);
} catch (e) {
console.warn(e);
}
}

_bind(callback, context)();
Expand Down