├── LICENSE
├── README.md
├── docs
├── api_usage.md
├── index.md
├── options.md
├── setup.md
└── source.md
├── torrentstime.js
└── torrentstime.min.js
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Embedding [Torrents Time](https://torrents-time.com)
2 | Torrents Time is a one of a kind fully customizable bittorrent client, advanced video player and downloads manager which is installed directly on the browser.
3 | Embeding Torrents Time in your website enables you to offer a unique, amazing and one of a kind experience to your websites' visitors.
4 |
5 | Torrents Time was designed to fully support and enhance the needs of users on video streaming, downloads and torrents websites, while taking into consideration the needs and wants of those site owners to maximize the value they can gain from embedding Torrents Time on their site.
6 |
7 | ##Quick start
8 | Embedding Torrents Time is as simple as adding an `iframe` to your website
9 | ```html
10 |
11 | ```
12 | Or just even by linking to it directly using an `WATCH
15 | ```
16 | ####Javascript API
17 | For those who don't want to include any 3rd party elements on their site or just seek for some more advanced embedding options, we have created this super simple `Javascript` API which takes about 5 seconds to implement in your site:
18 | ```html
19 |
20 |
23 |
24 | ```
25 |
26 | ## Settings
27 | You can enhance Torrents Time by simply providing one or more of these optional parameters:
28 | * `source` - **Required**, This is the URL or the magnet link of the torrent file, or any other static file on your server you wish to stream/download using Torrents Time.
29 |
30 | * `publisher_id` - **Optional**, This is your unique Publisher ID, if you haven't [registered](http://publishers.torrents-time.com/) yet as a Torrents Time publisher, check out the reasons [why you should register](http://publishers.torrents-time.com/).
31 |
32 | * `title` - **Optional**, Set the video/downloaded file title. If not specified, the title will get auto detected from file name or torrent info.
33 |
34 | * `autoPlay` - **Optional**, Default: false. providing `true` as the value will auto stream or download the file.
35 |
36 | * `imdbid` **Optional**, IMDB ID, If specified, Torrents Time will automatically search for poster images and subtitles across the web.
37 |
38 | * `poster` **Optional**, The poster parameter sets the image(s) that displays before the video begins playing. As soon as the user clicks play the poster will go away.
39 |
40 | ####Example
41 | For setting the parameters in the iframe/link URL:
42 | ```html
43 | https://embed.torrents-time.com/#source=TorrentURL&title=VideoName&imdb=tt1254207&autoPlay=1&publisher_id=1
44 | ```
45 |
46 | For using with the implemented Javascript:
47 | ```html
48 |
49 |
52 |
53 | ```
54 | You can set the parameters within the `torrentsTime.init` function or within the `data-setup` attribute of the containment `
56 |
57 |
58 | ****
59 | ##Documentation
60 | For more detailed info, please check out our short [Getting Started Guide](./docs/setup.md) to learn everything you need to know about our `Javascript API`.
61 | And if you're ready to dive in and discover more advanced options, the [documentation](./docs/index.md) is the first place to go for more information.
62 |
--------------------------------------------------------------------------------
/docs/api_usage.md:
--------------------------------------------------------------------------------
1 | [Torrents Time Documentation](./index.md)
2 |
3 | #API
4 | The Torrents Time API allows you to interact with the plugin through JavaScript.
5 |
6 | ##Initialize
7 | First, trigger the `torrentsTime.init` function to start the plugin's initialization process.
8 | The `init` function will embed the plugin `object` in the DOM and will prepare everything you need in order to interact with the plugin.
9 | ```javascript
10 | torrentsTime.init();
11 | ```
12 |
13 | While initializing, Torrents Time will trigger several key functions that you can use as event listeners.
14 |
15 | ####initEnded
16 | Will anounce the completion of prepration process.
17 | ```javascript
18 | torrentsTime.functions.initEnded = function(){
19 | //The Initialization process completed
20 |
21 | Alert("Is Torrents Time installed: " + torrentsTime.setup.isInstalled)
22 | };
23 | ```
24 | ####deviceIsNotSupported
25 | Will announce that the user's device is not supported by Torrents Time.
26 | If not supported device is detected, Torrents Time will remove every `class="torrentsTime"` element from the DOM by default.
27 | You can overwrite this behavior by setting your own function for this event:
28 | ```javascript
29 | torrentsTime.functions.deviceIsNotSupported = function(){
30 | Alert("Sorry, Your device is not support by Torrents Time :(");
31 | };
32 | ```
33 |
34 | ####initialized
35 | If the device is supported and the plugin is installed on the user's browser,
36 | Torrents Time will embed the plugin `object` in the DOM and will trigger this function at the moment the plugin is ready for interaction.
37 | ```javascript
38 | torrentsTime.init();
39 |
40 | torrentsTime.functions.initialized = function( instance ){
41 | Alert("The Torrents Time instance: " + instance.id + ", is ready for interaction!");
42 | };
43 | ```
44 |
45 | ##interaction
46 | You can interact directly with any Torrents Time instance embedded in the page, by specifying its `instance id`.
47 | You can set the `id` for each instance by passing it in the option parameters inside the `data-setup` attribute of the containment div:
48 | ```html
49 |
50 | ```
51 | >If the `id` parameter is not specified, the `instance id` will be generated automatically and it will consist of the letter `i` followed by an ascending digit.
52 | >For example, if you embedded only one instance in your web page and you didn't specify an `id` parameter, the instance id will be set automatically as `i0`
53 |
54 | After the plugin is embedded in the page, you can access the embedded instance methods and properties. For example:
55 | ```javascript
56 | torrentsTime.myPlayer.play();
57 | ```
58 | It is possible to reach all the embedded instances in the page by referring to `torrentsTime.instances`
59 | ```javascript
60 | var TTinstances = torrentsTime.intances;
61 |
62 | //example for pausing all Torrents Time instances at once:
63 | for(var instance in TTinstances){
64 | TTinstances[ instance ].pause();
65 | }
66 | ```
67 | ###Instance methods
68 | * [start](#start)
69 | * [beforeStart](#beforestart)
70 | * [play](#play)
71 | * [pause](#pause)
72 | * [stop](#stop)
73 | * [mute](#mute)
74 | * [setVolume](#setvolume)
75 | * [seek](#seek)
76 | * [setFullScreen](#setfullscreen)
77 |
78 | ####start
79 | The start function will initiate the download process of the file.
80 | This function will be triggered programmatically, or upon user interaction as soon as user hits play.
81 | ```javascript
82 | torrentsTime.myPlayer.start()
83 | ```
84 |
85 | ####beforeStart
86 | Just before Torrents Time is actually starting the download, you have the chance to execute your own code.
87 | You can do so, by adding functions to the `beforeStart` object. In a case your function will return `false` as value, the download process will be prevented. For example:
88 | ```javascript
89 | torrentsTime.myPlayer.beforeStart.showAdvertisement = function(){
90 | return confirm('Yes this is a fucking annoying advertisement, just for testing purposes, please do not actually use it in your site! \nDo you want to proceed? ');
91 |
92 | //let’s not show this ad like... EVER!
93 | delete torrentsTime.myPlayer.beforeStart.showAdvertisement;
94 | }
95 | ```
96 |
97 | ####play
98 | Start playing / download
99 | ```javascript
100 | torrentsTime.myPlayer.play()
101 | ```
102 |
103 | ####pause
104 | Pause playback / download
105 | ```javascript
106 | torrentsTime.myPlayer.pause()
107 | ```
108 |
109 | ####stop
110 | Stop the playback / download
111 | ```javascript
112 | torrentsTime.myPlayer.stop()
113 | ```
114 |
115 | ####mute
116 | `Boolean`
117 | ```javascript
118 | torrentsTime.myPlayer.mute(true)
119 | ```
120 |
121 | ####setVolume
122 | `0-100`
123 | ```javascript
124 | torrentsTime.myPlayer.setVolume(85)
125 | ```
126 |
127 | ####seek
128 | `seconds`
129 | ```javascript
130 | torrentsTime.myPlayer.seek(612)
131 | ```
132 |
133 | ####setFullScreen
134 | `Boolean`
135 | ```javascript
136 | torrentsTime.myPlayer.setFullScreen(true)
137 | ```
138 |
139 | ####displayPoster
140 | You can add / update the poster images even after the plugin is loaded and then trigger the `displayPoster` function to update the view
141 | ```javascript
142 | torrentsTime.myPlayer.setup.poster = "changePoster.png";
143 | torrentsTime.myPlayer.displayPoster()
144 | ```
145 |
146 | ###Instance properties
147 | * [id](#id)
148 | * [wrapper](#wrapper)
149 | * [setup](#setup)
150 |
151 |
152 | ####id
153 | You can grab the `id` string from any instance object
154 | ```javascript
155 | var instance_id = torrentsTime.myPlayer.id
156 | ```
157 |
158 | ####wrapper
159 | A reference to the instance's containment div DOM element
160 | ```javascript
161 | var wrappaer_div = torrentsTime.myPlayer.wrapper;
162 | ```
163 |
164 | ####setup
165 | An object containing all the options parameters that were set up at the initialize stage
166 | ```javascript
167 | console.log( torrentsTime.myPlayer.setup );
168 | ```
169 |
170 |
171 | ##Listeners function
172 | You can set up listeners function that will be triggered upon events.
173 | * [preload_started](#preload_started)
174 | * [preload_ongoing](#preload_ongoing)
175 | * [preload_complete](#preload_complete)
176 | * [playback_complete](#playback_complete)
177 | * [paused](#paused)
178 | * [stopped](#stopped)
179 | * [load_status](#load_status)
180 | * [playback_time](#playback_time)
181 | * [volume_changed](#volume_changed)
182 | * [fullscreen_changed](#fullscreen_changed)
183 | * [vpn_status](#vpn_status)
184 | * [crashed](#crashed)
185 |
186 | ####preload_started
187 | ```javascript
188 | torrentsTime.function.preload_started = function( params ){
189 | var instance_id = params.id
190 | }
191 | ```
192 |
193 | ####preload_ongoing
194 | Gives indication on streaming preloading
195 | ```javascript
196 | torrentsTime.function.preload_ongoing = function( params ){
197 | var instance_id = params.id;
198 | var percent = params.percent //int
199 | var seeders = params.seeders //int
200 | var peers = params.peers //int
201 | var speed = params.speed //int (bytes)
202 | }
203 | ```
204 |
205 | ####playback_complete
206 | The video playback is completed
207 | ```javascript
208 | torrentsTime.function.playback_complete = function( params ){
209 | var instance_id = params.id
210 | }
211 | ```
212 |
213 | ####preload_complete
214 | Preload is completed and the video is starting to play
215 | ```javascript
216 | torrentsTime.function.preload_complete = function( params ){
217 | var instance_id = params.id
218 | }
219 | ```
220 |
221 | ####paused
222 | Playback / download has paused
223 | ```javascript
224 | torrentsTime.function.paused = function( params ){
225 | var instance_id = params.id
226 | }
227 | ```
228 |
229 | ####stopped
230 | Playback / download has stopped
231 | ```javascript
232 | torrentsTime.function.stopped = function( params ){
233 | var instance_id = params.id
234 | }
235 | ```
236 |
237 | ####load_status
238 | ```javascript
239 | torrentsTime.function.load_status = function( params ){
240 | console.log( params );
241 | }
242 | ```
243 |
244 |
245 | ####playback_time
246 | ```javascript
247 | torrentsTime.function.playback_time = function( params ){
248 | var instance_id = params.id
249 | console.log( params );
250 | }
251 | ```
252 |
253 |
254 | ####volume_changed
255 | ```javascript
256 | torrentsTime.function.volume_changed = function( params ){
257 | var instance_id = params.id
258 | var level = params.state;
259 | }
260 | ```
261 |
262 | ####fullscreen_changed
263 | ```javascript
264 | torrentsTime.function.fullscreen_changed = function( params ){
265 | var instance_id = params.id
266 | var isFullScreen = params.state
267 | }
268 | ```
269 |
270 |
271 | ####vpn_status
272 | Indicates if the VPN status has changed
273 | * `0` - VPN is not installed
274 | * `1` - VPN is deactivated
275 | * `2` - VPN is turned off
276 | * `3` - VPN is turned on
277 |
278 | ```javascript
279 | torrentsTime.function.fullscreen_changed = function( params ){
280 | var instance_id = params.id
281 | var VPN_status = params.state;
282 | }
283 | ```
284 |
285 |
286 | ####crash
287 | An unexpected error occurred.
288 | Try to re-initialize the whole process
289 | ```javascript
290 | torrentsTime.function.crash = function( params ){
291 | var instance_id = params.id
292 | }
293 | ```
294 |
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | [Torrents Time homepage](https://torrents-time.com)
2 |
3 | #Torrens Time Documentation
4 | There are two categories of docs: ***Guides*** and ***API docs***.
5 | Guides explain general topics and use cases (e.g. setup/getting started).
6 | API docs gives specific details about functions, properties, and events.
7 |
8 | (Corrections and additions are welcome)
9 |
10 | ###Guides
11 | * [Getting started](./setup.md) - The setup documentation explains in detail how you can implement the Javascript API in your web page.
12 |
13 | * [Options](./options.md) - There are a number of options that can be used to change how Torrents Time looks and behaves.
14 |
15 | * [API usage](./api_usage.md) - Using the API and interacting with Torrents Time and customizing it to your needs is as simple as writing 1 line of code.
16 |
17 |
18 | ###API docs
19 |
20 | * [methods](./source.md) - explaining the Javascript API [source code](./../torrentstime.js).
21 |
--------------------------------------------------------------------------------
/docs/options.md:
--------------------------------------------------------------------------------
1 | [Torrents Time Documentation](./index.md)
2 |
3 | #Options
4 | ##Setting options
5 | You can set options parameters within the `torrentsTime.init` function or within the `data-setup` attribute of the containment `
11 | ```
12 |
13 | Example of passing options in an object with the javascript `torrentsTime.init` function:
14 | ```html
15 |
18 | ```
19 |
20 | ##Parameters
21 | All parameters are optional except for the `source` parameter that tells Torrents Time what file to stream or download.
22 | >
Every parameter in that list can be passed through the URL in case you are embedding Torrents Time using an `iframe` or an `
23 |
24 |
25 | * [source](#source)
26 | * [title](#title)
27 | * [autoPlay](#autoplay)
28 | * [imdbid](#imdbid)
29 | * [poster](#poster)
30 | * [querySelector](#queryselector)
31 | * [id](#id)
32 | * [tmdb_key](#tmdb_key)
33 | * [subtitles](#subtitles)
34 | * [file](#file)
35 | * [videoPlayer](#videopLayer)
36 | * [style](#style)
37 | * [publisher_id](#publisher_id)
38 | * [vpnAlert](#vpnalert)
39 |
40 |
41 | ###source
42 | This is the URL or the magnet link of the torrent or any other static file on your server you wish to stream / download.
43 | ```javascript
44 | { "source": "https://torcache.net/torrent/88594AAACBDE40EF3E2510C47374EC0AA396C08E/[kat.cr]big.buck.bunny.1080p.30fps.torrent"}
45 | ```
46 |
47 | ###title
48 | Set the file title. If not specified, the title will get auto detected from file name or torrent info.
49 | ```javascript
50 | { "title": "Big Buck Bunny" }
51 | ```
52 |
53 | ###autoPlay
54 | `Default: false`. Providing `true` as the value will auto stream or download the file.
55 | ```javascript
56 | { "autoPlay": true }
57 | ```
58 |
59 | ###imdbid
60 | IMDB ID, If specified, Torrents Time will automatically search for posters and subtitles across the web.
61 | ```javascript
62 | { "imdbid": "tt1254207" }
63 | ```
64 |
65 | ###poster
66 | The poster parameter sets the image(s) that displays before the video starts playing. As soon as the user hits play the poster will disappear.
67 | If a valid `imdbid` parameter is specified, Torrens Time will fetch poster images automatically from the web.
68 | You can set the poster image yourself by simply passing a URL for an image file.
69 | In case you wish to display multiple poster images (each one displaying for 5 seconds) you should pass an `Array` of images URLs
70 |
71 | Example of setting up a single poster image:
72 | ```javascript
73 | { "poster": "imageFile.png" }
74 | ```
75 |
76 | Example of setting up multiple poster images:
77 | ```javascript
78 | { "poster": ["imageFile1.png", "imageFile2.png"] }
79 | ```
80 | > You can dynamically change the poster images, even after the plugin was loaded
81 | using the [`displayPoster` method](./api_usage.md#displayposter) provided with the API
82 |
83 | ###querySelector
84 | By default, Torrents Time plugin will be embedded directly inside any DOM element with a `class="torrentsTime"` attribute.
85 | If you wish to change this, you can specify another selector string that will be used for DOM elements you wish to embed Torrents Time inside of.
86 | The selector string should be a valid CSS2 selector.
87 | ```html
88 |
91 |
92 | ```
93 | ###id
94 | If you have more than 1 instance of Torrents Time embedded in your page, you can specify an ID for each of them in order to make it easy for you to later interact with each instance.
95 | ```html
96 |
97 |
98 |
102 | ```
103 | In a case you will not specify an `id` parameter for a Torrents Time instance, that instance `id` will be set automatically.
104 | For more information on interaction with embedded instances see our [API usage guide](./api_usage.md)
105 |
106 | ###tmdb_key
107 | If you have your own API key from [themoviedb.org](https://www.themoviedb.org/documentation/api) you can specify it in this parameter and Torrents Time will be able to fetch additional data and poster images from [themoviedb.org](https://www.themoviedb.org/documentation/api) API
108 | ```javascript
109 | { "tmdb_key": "YourApiKey" }
110 | ```
111 |
112 | ###subtitles
113 | If a valid `imdbid` parameter is specified, Torrents Time will fetch subtitles automatically from the web.
114 | In case you wish to provide subtitles of your own, you can specify a URL for a single `.srt` or `.vtt` file or for a `.zip` containing multiple `.srt` or `.vtt` files.
115 | ```javascript
116 | { "subtitles": "subtitles.zip" }
117 | ```
118 |
119 | ###file
120 | For torrents which contain more than one file, you can specify a specific file to stream or download
121 | ```javascript
122 | { "file": "movie.mp4" }
123 | ```
124 |
125 | ###videoPlayer
126 | `Default: false`
127 | If you specified a video torrent or a video file as a source for Torrents Time, the plugin will automatically display a video player and start to stream the video.
128 | In a case you just wish to download the torrent without playing the video, you can set the value to `false`.
129 | ```javascript
130 | { "videoPlayer": false }
131 | ```
132 |
133 | ###Style
134 | You can overwrite basic style options
135 | * backgroundColor `Default: #333333`
136 | * textColor `Default: #ffffff`
137 | * textSize `Default: 14px`
138 | * buttonBgColor `Default: rgba(0,0,0,0.7)`
139 | * buttonHoverColor `Default: #2F6FD6`
140 | * barBgColor `Default: rgba(0,0,0,0.9)`
141 | ```javascript
142 | { "style": { "backgroundColor": "#000", "textColor": "#ccc", "textSize": "16px" } }
143 | ```
144 | > For additional styling options you will need to edit the [Javascript source](./../torrentstime.js) file. Look for the `injectCss()` function.
145 |
146 | ###publisher_id
147 | This is your unique Publisher ID, if you haven't [registered](http://publishers.torrents-time.com/) yet as a Torrents Time publisher, check out the reasons [why you should](http://publishers.torrents-time.com/).
148 | ```javascript
149 | { "publisher_id": 1 }
150 | ```
151 |
152 | ###vpnAlert
153 | `Default: true`
154 | If not disabled by the user, Torrents Time displays a warning message upon downloading if a VPN connection is not activated.
155 | You can disable this message yourself by setting `false` as value.
156 | ```javascript
157 | { "vpnAlert": false }
158 | ```
159 | ****
160 | See [API usage guide](./api_usage.md) to learn how to interact with Torrents Time.
161 |
--------------------------------------------------------------------------------
/docs/setup.md:
--------------------------------------------------------------------------------
1 | [Torrens Time Documentation](./index.md)
2 |
3 | #Getting started
4 | >This guide is here to give information about embedding Torrents Time using the `Javascript` API. You can also embed Torrents Time on your web page by simply using an `iframe` or an `
12 | ```
13 | #### CDN Version
14 | For those who are OK with including 3rd party elements in their site, it is recommended to use the CDN version in order to ensure that the code is up to date at all times.
15 | ```html
16 |
17 | ```
18 |
19 | ##Step 2: Add an HTML Div tag to your page.
20 | ```html
21 |
22 | ```
23 | In addition to the basic markup, Torrents Time needs a few extra pieces:
24 | 1. The `data-setup` attribute, contains one required `source` parameter and can have a few more optional parameters (in JSON format) for customizing Torrents Time to your needs. For more information see [Options guide](./options.md).
25 |
26 | 2. The `class` attribute which contains the `torrentsTime` class name.
27 |
28 | ##Step 3: Initialize Torrents Time
29 | Trigger the `torrentsTime.init` function to initialize Torrents Time
30 | ```html
31 |
34 | ```
35 | If you are registered as a Torrents Time publisher, don't forget to include your publisher ID in the `torrentstime.init()` parameters
36 | ```html
37 |
40 | ```
41 | If you haven't registered as a Torrents Time publisher yet, check out the reasons [why you should](http://publishers.torrents-time.com).
42 | Except for the `publisher_id` parameter, the `torrentsTime.init` function contains more optional parameters for customizing Torrents Time to your needs.
43 | For more info see [Options guide](./options.md).
44 |
45 | ##Full code
46 | ```html
47 |
48 |
51 |
52 | ```
53 | ****
54 | See [Options guide](./options.md) for more advanced options.
55 |
--------------------------------------------------------------------------------
/docs/source.md:
--------------------------------------------------------------------------------
1 | In the making.
2 |
3 | [Source code](./../torrentstime.js)
4 |
--------------------------------------------------------------------------------
/torrentstime.js:
--------------------------------------------------------------------------------
1 | (function(){
2 |
3 | var TT = window.torrentsTime = {};
4 |
5 | TT.setup = {
6 | tmdb_key: "57983e31fb435df4df77afb854740ea9",
7 | isDeviceSupported: null,
8 | platform: null,
9 | browser: null,
10 | isInstalled: null,
11 | port: null,
12 | publisher_id: null,
13 | querySelector: ".torrentsTime",
14 | id: null,
15 | source: null,
16 | file: null,
17 | fileType: "video",
18 | isHidden: false,
19 | videoPLayer: true,
20 | vpnAlert: true,
21 | autoPlay: false,
22 | title: null,
23 | poster: null,
24 | imdbid: null,
25 | subtitles: null,
26 | style: {
27 | backgroundColor: "#333333",
28 | textColor: "#ffffff",
29 | textSize: "14px",
30 | buttonBgColor: "rgba(0,0,0,0.7)",
31 | buttonHoverColor: "#2F6FD6",
32 | barBgColor: "rgba(0,0,0,0.9)"
33 |
34 | },
35 |
36 | installerURL: {
37 | windows: "https://cdn.torrents-time.com/torrentsTime-download.exe",
38 | macintosh: "https://cdn.torrents-time.com/torrentsTime-download.pkg"
39 | },
40 | localhost_domain: "localhost.ttconfig.xyz"
41 | }
42 |
43 |
44 | TT.init = function(settings){
45 |
46 | if(settings instanceof Object){
47 | for(var i in settings)
48 | TT.setup[i] = settings[i];
49 | }
50 |
51 |
52 | if(!isDeviceSupported())
53 | return TT.functions.deviceIsNotSupported();
54 |
55 | DOMReady(function(){
56 |
57 | wrappers = document.querySelectorAll( TT.setup.querySelector );
58 | if(!wrappers || !wrappers.length)
59 | return;
60 |
61 | injectCss();
62 |
63 |
64 | TT.instances = TT.instances || {};
65 | for(var i=0; ilimit){
123 | callback(false)
124 | return;
125 | }
126 |
127 | var
128 | ports = ["12400","11400","10400","9400"],
129 | imgs = [],
130 | cacheBuster = Math.random(),
131 | timer = setTimeout(function() { TT.isInstalled(callback,limit, ++counter);}, 1000);
132 |
133 |
134 | for(var i=0; i-1 || userAgent.indexOf("iemobile")>-1)
227 | return false;
228 |
229 |
230 | TT.setup.platform = platform[0].toLowerCase();
231 |
232 | //Duct tape: currently supporting only chrome on Mac
233 | //Safari and firefox are around the corent
234 | if(TT.setup.platform=='macintosh' && TT.setup.browser!='chrome')
235 | return false;
236 |
237 | TT.setup.isDeviceSupported = true;
238 | return true;
239 | },
240 | injectCss = function(){
241 | var css = {
242 | "._tt_wrapper":{
243 | width: "100%",
244 | height: "100%",
245 | "min-height": "250px",
246 | "min-width": "300px",
247 | position: "relative",
248 | background: TT.setup.style.backgroundColor,
249 | overflow: "hidden"
250 | },
251 | "._tt_initScreen":{
252 | height: "100%",
253 | overflow: "hidden",
254 | cursor: "pointer"
255 | },
256 | "._tt_initScreen ._tt_topbar":{
257 | "font-size": TT.setup.style.textSize,
258 | padding: "10px;",
259 | background: "linear-gradient(to top, rgba(0,0,0,0) 0%, " + TT.setup.style.barBgColor + " 100%)",
260 | "font-weight": "bold",
261 | position: "relative",
262 | "z-index": 10
263 | },
264 | "._tt_initScreen ._tt_button":{
265 | position: "absolute",
266 | width: "120px",
267 | height: "90px",
268 | overflow: "hidden",
269 | margin: "-45px 0 0 -60px",
270 | top: "50%",
271 | left: "50%",
272 | "border-radius": "10px",
273 | background: TT.setup.style.buttonBgColor,
274 | "z-index": 10
275 | },
276 | "._tt_initScreen ._tt_hover":{
277 | position: "absolute",
278 | width: "2px",
279 | height: "2px",
280 | margin: "-1px 0 0 -1px",
281 | top: "50%",
282 | left: "50%",
283 | "border-radius": "150px",
284 | background: TT.setup.style.buttonHoverColor,
285 | "transition": "all 0.15s ease-out",
286 | "z-index": 11
287 | },
288 | "._tt_initScreen:hover ._tt_hover":{
289 | width: "150px",
290 | height: "150px",
291 | margin: "-75px 0 0 -75px"
292 | },
293 | "._tt_setupDownload ._tt_hover":{
294 | display: "none"
295 | },
296 | "._tt_initScreen ._tt_icon":{
297 | width: "100%",
298 | height: "100%",
299 | background: "url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAA8CAYAAADL94L/AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAbdJREFUeNrcmu1twjAURZ0oA3QE2IBu0G7QblA2oBMUJqAb0A1gA9ig2YBsABu8+kqxGrVQ3Mhf913JP8iPiBOf+NmxjYjc2baX7xxtezCM+QEyDK5P2GBuZYne0wLj1HvSAsOhnoxLmerJ+EC9Fy0wQ/VmWmBc1tnVk7A5ZVVP4iSPehI3adWT+EmnnqTLZ/QJrKTPJpZ6dYYxB8qh4C5C37jCo8pYGVrbXquqOmiAcfnooc5smkVTr5SeGaazbT5GvdqUF6yXMIPY/nftVCKMC1a2qE1LZs1Gq1cbjnipxwLjpR6LZtfUQ23aaYBxwXv0jIJbG/5gJv6mpWdcprXRk4kmGKMJ5qwF5mBHs1bDAIA10L2F6dh75h2jGEDwoyEulKj+7fAiG8yvKQwrzApa/fWdoCFRau7eC9Y60/UTyEcfkJJ75qZSDDDeSpUM47XGL/2dgUYrCzEN8Yk2Z8/s+prRhbphw6pUbs2CKnUxiTaYtkmOqdBv/SWAOcXYGcsBs8l2UoNWqUgweZSKAJNPqYAw+yJP2FKdWgoIs5bST9FSnfTzgDlSKnUFZtb/cS6lLuRLgAEAzhfjt/6MW6sAAAAASUVORK5CYII=') center center no-repeat",
300 | "z-index": 12,
301 | position: "relative"
302 | },
303 | "._tt_wrapper._tt_setupDownload ._tt_icon": {
304 | animation: "fadeInOut 0.4s ease-out 3",
305 | background: "url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADoAAAA8CAYAAAA34qk1AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAadJREFUeNrs2YFRgzAUBmDgOkBHYARGaDfoBuIGuoFO0G5AncAR0AnqBnYDukF88dKTU3iQhLxQ/N9djl5rePkqySWvWSIUSqk1tVr9REOtTJYWv5Dt2CwJWaj+qCTGkAlZ18xn+ZKg0QNQQAEFFFBAAQUUUEABBRRQQAEFNBLUlC73prJXhazkmVwPErm6Ejcd1byS6bNhqoD1QK5TR58nCWjFDLqcCsogr5GHfnS5BNUU1XeNpIv+AgrHcYgsRl7YkUiRxeglFNYCeU7T9C32PP0zZ8fM0RFzsv3jVJFIhQ12CDpbpAOW+7vTrJEOWJ+IixTCzgMZGDstUm+pqH2am+vrbgZYJ6RZ2NrjeP2+j0F2RUys83+yZ2Frkp4NOrvZDoz1Qe76bppwGSPMWa85yTydKtjBm7Zo93Q5WnS5UNtSv4+bqzBYYIMiRUopI7DBkWI1IwYrgtSxktpQaCytCe/08u561KL2TO+fJfKLQQ32aLlAodwJKKCAAgoooDOI1cCxp74xT967WfE9d+LRBRTQ4NDDP3BeMjo6PS4cq8+72y8BBgDCpsnY/DeynQAAAABJRU5ErkJggg==') center center no-repeat"
306 | },
307 | "._tt_wrapper._tt_setupDownload.installing ._tt_icon": {
308 | "background-image": "none !important"
309 | },
310 | "._tt_wrapper._tt_setupDownload.installing ._tt_installing":{
311 | display: "block",
312 | animation: "fadeInOut 0.4s ease-out 3"
313 | },
314 | "._tt_wrapper ._tt_installing":{
315 | display: "none",
316 | "text-align": "center",
317 | "font-size": "13px",
318 | color: "#fff",
319 | "line-height": "20px",
320 | "padding-top": "25%"
321 | },
322 | "._tt_wrapper ._tt_ins_prgrsbar":{
323 | width: "80%",
324 | height: "10px",
325 | background: "#fff",
326 | "border-radius": "3px",
327 | margin: "0 auto",
328 | position: "relative",
329 | "margin-top":"10px"
330 | },
331 | "._tt_wrapper ._tt_ins_prgrsbar div":{
332 | position: "absolute",
333 | background: TT.setup.style.buttonHoverColor,
334 | "border-radius": "3px",
335 | left:"1px",
336 | top:"1px",
337 | height: "8px",
338 | width: "20px",
339 | animation: "sprinter 1s ease-out infinite"
340 | },
341 | "._tt_initScreen ._tt_caption":{
342 | width: "100%",
343 | padding: "7px",
344 | background: TT.setup.style.buttonBgColor,
345 | "font-size": "16px",
346 | "z-index": 12,
347 | "text-align": "center",
348 | position: "absolute",
349 | bottom: "-50px",
350 | left: 0,
351 | transition: "bottom 0.2s ease-in-out"
352 | },
353 | "._tt_initScreen ._tt_caption u":{
354 | "font-weight": "bold",
355 | "cursor": "pointer"
356 | },
357 | "._tt_wrapper._tt_setupDownload ._tt_caption":{
358 | bottom: "0 !important"
359 | },
360 | "._tt_initScreen ._tt_backdrop":{
361 | position: "absolute",
362 | top: 0,
363 | left: 0,
364 | width: "100%",
365 | height: "100%",
366 | "background-size":"cover",
367 | "transition": "opacity 0.5s ease-in",
368 | "z-index": 9
369 | },
370 | "._tt_initScreen ._tt_backdrop._tt_visible":{
371 | opacity: 1
372 | },
373 | "._tt_initScreen ._tt_backdrop._tt_hidden":{
374 | opacity: 0
375 | },
376 | "._tt_wrapper._tt_prepared ._tt_embed":{
377 | "top" : "-5000px",
378 | "left" : "-5000px"
379 | },
380 | "._tt_embed":{
381 | width: "100%",
382 | height: "100%",
383 | position: "absolute",
384 | left: "0",
385 | top: "0",
386 | "z-index": 8
387 | },
388 | "._tt_embed.visible":{
389 | visibility: "visible"
390 | },
391 | "._tt_pleaseWait":{
392 | position: "absolute",
393 | left: 0,
394 | top: "50%",
395 | width: "100%",
396 | "text-align":"center",
397 | "color": "#fff",
398 | "margin-top":"-55px",
399 | display: "none"
400 |
401 | },
402 | "._tt_pleaseWait_box":{
403 | padding: "15px",
404 | margin: "0 auto",
405 | background: "rgba(0,0,0,0.9)",
406 | "border-radius":"5px",
407 | width: "80%"
408 | },
409 | "._tt_pleaseWait ._tt_s1":{
410 | "font-size": "16px",
411 | "margin-bottom": "15px;"
412 | },
413 | "._tt_pleaseWait ._tt_s2":{
414 | "font-size": "36px",
415 | "font-weight": "bold"
416 | },
417 | "._tt_pleaseWait ._tt_progress":{
418 | height: "8px",
419 | width: "80%",
420 | margin: "0 auto",
421 | border: "1px #fff solid",
422 | "border-radius": "3px"
423 |
424 | },
425 | "._tt_pleaseWait ._tt_bar":{
426 | width: 0,
427 | height: "4px",
428 | margin: "2px",
429 | background: TT.setup.style.buttonHoverColor,
430 | "border-radius": "3px"
431 | },
432 | "._tt_wrapper.init ._tt_pleaseWait":{
433 | display: "inline",
434 | animation: "fadeInOut 2s linear infinite"
435 |
436 | },
437 | "@keyframes fadeInOut{0%{opacity: 1} 50%{opacity:0} 100%{opacity:1}} ._tt_null": {},
438 | "@keyframes sprinter{0%{left: 0} 50%{left:calc(100% - 20px)} 100%{left:0}} ._tt_null": {}
439 | },
440 | cssString = '';
441 | for(var cls in css){
442 | cssString += cls + "{";
443 | for(var prop in css[cls])
444 | cssString += prop + ":" + css[cls][prop] + ";"
445 | cssString += "}";
446 | }
447 |
448 | utils.createElement({
449 | name: "style",
450 | props:{innerHTML: cssString}
451 | }, (document.head || document.body || document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] || document.documentElement));
452 |
453 | },
454 | insertInitScreen = function(instance){
455 |
456 | instance.setup.title = instance.setup.title || (instance.setup.source && instance.setup.source.match(/\/?[^\/]+\/?$/)[0].replace(/\//g,'')) || "Torrents Time";
457 |
458 | var style = {};
459 | for(var prop in TT.setup.style)
460 | style[prop] = instance.setup.style[prop] || TT.setup.style[prop];
461 | instance.wrapper.innerHTML='';
462 | if(instance.setup.isHidden)
463 | return;
464 |
465 |
466 | var initScreen = utils.createElement({
467 | name: "div",
468 | props: {
469 | className: "_tt_initScreen",
470 | innerHTML: '' + instance.setup.title + '
Click Here if the download doesn\'t start automatically
'
471 | },
472 | attrs: {style: "background:" + style.backgroundColor + ";color:" + style.textColor}
473 | }, instance.wrapper.firstChild);
474 | utils.addListener(initScreen, "click", function(){instance.start()});
475 |
476 | instance.displayPoster = displayPoster;
477 | if(instance.setup.poster)
478 | instance.displayPoster();
479 | else if(instance.setup.imdbid){
480 |
481 | var backdropsHandler = function(resText) {
482 | try{
483 | var json = JSON.parse(resText);
484 | if(json.backdrops instanceof Array){
485 | instance.setup.poster = instance.setup.poster || [];
486 | for(var i=0; i= instance.setup.poster.length ? 0 : counter) : 0;
530 |
531 | var backdrop_hidden = initScreen.querySelector('._tt_backdrop._tt_hidden');
532 | if(!backdrop_hidden){
533 | var backdrop_hidden = utils.createElement(
534 | {
535 | name: "div",
536 | props: {className: "_tt_backdrop ._tt_hidden"}
537 | }, initScreen);
538 | }
539 |
540 | var img = new Image;
541 | img.onload = function(){
542 | backdrop_hidden.style.backgroundImage = 'url(' + instance.setup.poster[counter] + ')';
543 | var backdrop_visible = instance.wrapper.querySelector('._tt_backdrop._tt_visible');
544 | if(backdrop_visible) backdrop_visible.className='_tt_backdrop _tt_hidden';
545 | backdrop_hidden.className='_tt_backdrop _tt_visible';
546 |
547 | if(instance.setup.poster.length>1)
548 | setTimeout(function(){instance.displayPoster(++counter)}, 5000);
549 | }
550 | img.src = instance.setup.poster[counter];
551 |
552 | },
553 | embedTorrentsTime = function(){
554 | var embed = {};
555 | embed.explorer = embed.firefox = embed.safari = embed.trident = embed.msie = {
556 | name: "object",
557 | props: {className: "_tt_embed", width: "100%", height: "100%"},
558 | attrs: {type: "application/x-ttplugin"}
559 | };
560 | embed.chrome = {
561 | name: "embed",
562 | props:{
563 | className: "_tt_embed",
564 | type: "application/x-pnacl",
565 | name: "nacl_module",
566 | path: "pnacl/Release",
567 | src: "https://" + TT.setup.localhost_domain + ":" + TT.setup.port + "/ttplugin.nmf",
568 | width: "100%", height: "100%"
569 | },
570 | attrs:{}
571 | }
572 |
573 | for(var id in TT.instances){
574 | var instance = TT.instances[id];
575 | if(typeof instance.plugin != 'undefined') continue;
576 | embed[TT.setup.browser].attrs["data-src"] = instance.setup.source;
577 | instance.plugin = {
578 | object: utils.createElement(embed[ TT.setup.browser ], instance.wrapper.firstChild),
579 | isInitialized: false,
580 | isReBinded : false,
581 | initialize: function(){
582 |
583 | if(instance.plugin.isInitialized) return;
584 | if(TT.setup.browser == 'firefox' && !instance.plugin.isReBinded && instance.plugin.object.pushEvent) {
585 | instance.plugin.isRebinded = true;
586 | utils.log('horey!');
587 | utils.addListener(instance.plugin.object, "eventHandler", getMessage);
588 | }
589 |
590 | instance.plugin.sendMessage('{"command":"initialize", "id":"' + instance.id + '", "browser":"' + TT.setup.browser + '"}');
591 | setTimeout(instance.plugin.initialize, 1000);
592 | },
593 | sendMessage: sendMessage
594 | };
595 |
596 | utils.addListener(instance.plugin.object, "message", getMessage);
597 | utils.addListener(instance.plugin.object, "eventHandler", getMessage);
598 | instance.plugin.initialize();
599 |
600 | var prepareScreen = utils.createElement({
601 | name: "div",
602 | props:{
603 | className: "_tt_pleaseWait",
604 | innerHTML: '' + instance.setup.title + '
DOWNLOADING
'
605 | }
606 | }, instance.wrapper.firstChild);
607 |
608 | if(TT.setup.browser=='chrome'){
609 | var progressBar = prepareScreen.querySelector('._tt_bar');
610 | utils.addListener(instance.plugin.object, "progress", function(event){
611 | if (event.lengthComputable && event.total > 0) {
612 | var loadPercentString = (Math.floor(event.loaded / event.total * 100.0)-1) + '%';
613 | prepareScreen.innerHTML = 'Preparing to stream Torrent...
'
614 | }
615 | });
616 | }
617 |
618 | if(instance.setup.autoPlay)
619 | instance.start();
620 | }
621 | },
622 | sendMessage = function(data){
623 | utils.log(data);
624 | if(this.object){
625 | try{
626 | if(this.object.postMessage) this.object.postMessage(data);
627 | else if(this.object.pushEvent) this.object.pushEvent(data)
628 | else utils.log('no sendMessage1');
629 | }catch(e){utils.log(e)}
630 | }
631 | else if(this.instances instanceof Array){
632 | for(var i=0; ib)a(!1);else for(var f=["12400","11400","10400","9400"],g=[],k=setTimeout(function(){d.isInstalled(a,b,++c)},1E3),h=0;h ';if(!a.setup.isHidden)if(b=e.createElement({name:"div",props:{className:"_tt_initScreen",innerHTML:''+a.setup.title+'
Click Here if the download doesn\'t start automatically
'},attrs:{style:"background:"+b.backgroundColor+";color:"+b.textColor}},a.wrapper.firstChild),e.addListener(b,"click",function(){a.start()}),a.displayPoster=v,a.setup.poster)a.displayPoster();else if(a.setup.imdbid){var f=function(b){try{var c=JSON.parse(b);if(c.backdrops instanceof Array){a.setup.poster=a.setup.poster||[];for(b=0;b=b.setup.poster.length?0:a:0;var d=c.querySelector("._tt_backdrop._tt_hidden");d||(d=e.createElement({name:"div",props:{className:"_tt_backdrop ._tt_hidden"}},c));c=new Image;c.onload=function(){d.style.backgroundImage="url("+b.setup.poster[a]+")";var c=b.wrapper.querySelector("._tt_backdrop._tt_visible");c&&(c.className="_tt_backdrop _tt_hidden");d.className="_tt_backdrop _tt_visible";1'+c.setup.title+'
DOWNLOADING
'}},c.wrapper.firstChild);"chrome"==d.setup.browser&&(f.querySelector("._tt_bar"),e.addListener(c.plugin.object,"progress",function(a){a.lengthComputable&&0Preparing to stream Torrent...
')}));c.setup.autoPlay&&c.start()}}},w=function(a){e.log(a);if(this.object)try{this.object.postMessage?this.object.postMessage(a):this.object.pushEvent?this.object.pushEvent(a):e.log("no sendMessage1")}catch(d){e.log(d)}else if(this.instances instanceof Array)for(var b=0;b