<commit_before>/*
 * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

//node.js deps
var gpio = require('gpio');
//npm deps

//app deps
const deviceModule = require('..').device;
const cmdLineProcess = require('./lib/cmdline');

//begin module
var blueLedGpio, yellowLedGpio, intervalTimer;

blueLedGpio = gpio.export(23, {
   ready: function() {
      console.log("Blue LED Ready");
      intervalTimer = setInterval(function() {
      }, 1000);
   }
});

yellowLedGpio = gpio.export(24, {
   ready: function() {
      console.log("Yellow LED Ready");
   }
});

// // Lets assume a different LED is hooked up to pin 4, the following code
// // will make that LED blink inversely with LED from pin 22
// gpio24 = gpio.export(23, {
//    ready: function() {
//       // bind to blueLedGpio's change event
//       blueLedGpio.on("change", function(val) {
//          gpio24.set(1 - val); // set gpio24 to the opposite value
//       });
//    }
// });

// // reset the headers and unexport after 10 seconds
// setTimeout(function() {
//    clearInterval(intervalTimer);          // stops the voltage cycling
//    blueLedGpio.removeAllListeners('change');   // unbinds change event
//    blueLedGpio.reset();                        // sets header to low
//    blueLedGpio.unexport();                     // unexport the header
//
//    gpio24.reset();
//    gpio24.unexport(function() {
//       // unexport takes a callback which gets fired as soon as unexporting is done
//       process.exit(); // exits your node program
//    });
// }, 10000);

function processTest(args) {
   //
   // The device module exports an MQTT instance, which will attempt
   // to connect to the AWS IoT endpoint configured in the arguments.
   // Once connected, it will emit events which our application can
   // handle.
   //
   const device = deviceModule({
      keyPath: args.privateKey,
      certPath: args.clientCert,
      caPath: args.caCert,
      clientId: args.clientId,
      region: args.region,
      baseReconnectTimeMs: args.baseReconnectTimeMs,
      keepalive: args.keepAlive,
      protocol: args.Protocol,
      port: args.Port,
      host: args.Host,
      debug: args.Debug
   });

   var timeout;
   var count = 0;
   const minimumDelay = 250;

   if (args.testMode === 1) {
      device.subscribe('topic_1');
   } else {
      device.subscribe('topic_2');
   }
   device.subscribe('led');
   if ((Math.max(args.delay, minimumDelay)) !== args.delay) {
      console.log('substituting ' + minimumDelay + 'ms delay for ' + args.delay + 'ms...');
   }
   timeout = setInterval(function() {
      count++;

      if (args.testMode === 1) {
         device.publish('topic_2', JSON.stringify({
            mode1Process: count
         }));
      } else {
         device.publish('topic_1', JSON.stringify({
            mode2Process: count
         }));
      }
   }, Math.max(args.delay, minimumDelay)); // clip to minimum

   //
   // Do a simple publish/subscribe demo based on the test-mode passed
   // in the command line arguments.  If test-mode is 1, subscribe to
   // 'topic_1' and publish to 'topic_2'; otherwise vice versa.  Publish
   // a message every four seconds.
   //
   device
      .on('connect', function() {
         console.log('connected');
      });
   device
      .on('close', function() {
         console.log('close');
      });
   device
      .on('reconnect', function() {
         console.log('reconnect');
      });
   device
      .on('offline', function() {
         console.log('offline');
      });
   device
      .on('error', function(error) {
         console.log('error', error);
      });
   device
      .on('message', function(topic, payload) {

         if(topic == "led") {
            console.log("led");
            if(payload!=null) {
               console.log(payload);
               if(payload.color == "yellow") {
                  yellowLedGpio.set();
                  setTimeout(function() { yellowLedGpio.reset(); }, 2000);
               }
               if(payload.color == "blue") {
                  blueLedGpio.set();
                  setTimeout(function() { blueLedGpio.reset(); }, 2000);
               }

            }
         }
         console.log('message', topic, payload.toString());
      });
}

module.exports = cmdLineProcess;

if (require.main === module) {
   cmdLineProcess('connect to the AWS IoT service and publish/subscribe to topics using MQTT, test modes 1-2',
      process.argv.slice(2), processTest);
}<commit_msg>LED fun<commit_after>/*
 * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

//node.js deps
var gpio = require('gpio');
//npm deps

//app deps
const deviceModule = require('..').device;
const cmdLineProcess = require('./lib/cmdline');

//begin module
var blueLedGpio, yellowLedGpio, intervalTimer;

blueLedGpio = gpio.export(23, {
   ready: function() {
      console.log("Blue LED Ready");
      intervalTimer = setInterval(function() {
      }, 1000);
   }
});

yellowLedGpio = gpio.export(24, {
   ready: function() {
      console.log("Yellow LED Ready");
   }
});

// // Lets assume a different LED is hooked up to pin 4, the following code
// // will make that LED blink inversely with LED from pin 22
// gpio24 = gpio.export(23, {
//    ready: function() {
//       // bind to blueLedGpio's change event
//       blueLedGpio.on("change", function(val) {
//          gpio24.set(1 - val); // set gpio24 to the opposite value
//       });
//    }
// });

// // reset the headers and unexport after 10 seconds
// setTimeout(function() {
//    clearInterval(intervalTimer);          // stops the voltage cycling
//    blueLedGpio.removeAllListeners('change');   // unbinds change event
//    blueLedGpio.reset();                        // sets header to low
//    blueLedGpio.unexport();                     // unexport the header
//
//    gpio24.reset();
//    gpio24.unexport(function() {
//       // unexport takes a callback which gets fired as soon as unexporting is done
//       process.exit(); // exits your node program
//    });
// }, 10000);

function processTest(args) {
   //
   // The device module exports an MQTT instance, which will attempt
   // to connect to the AWS IoT endpoint configured in the arguments.
   // Once connected, it will emit events which our application can
   // handle.
   //
   const device = deviceModule({
      keyPath: args.privateKey,
      certPath: args.clientCert,
      caPath: args.caCert,
      clientId: args.clientId,
      region: args.region,
      baseReconnectTimeMs: args.baseReconnectTimeMs,
      keepalive: args.keepAlive,
      protocol: args.Protocol,
      port: args.Port,
      host: args.Host,
      debug: args.Debug
   });

   var timeout;
   var count = 0;
   const minimumDelay = 250;

   if (args.testMode === 1) {
      device.subscribe('topic_1');
   } else {
      device.subscribe('topic_2');
   }
   device.subscribe('led');
   if ((Math.max(args.delay, minimumDelay)) !== args.delay) {
      console.log('substituting ' + minimumDelay + 'ms delay for ' + args.delay + 'ms...');
   }
   timeout = setInterval(function() {
      count++;

      if (args.testMode === 1) {
         device.publish('topic_2', JSON.stringify({
            mode1Process: count
         }));
      } else {
         device.publish('topic_1', JSON.stringify({
            mode2Process: count
         }));
      }
   }, Math.max(args.delay, minimumDelay)); // clip to minimum

   //
   // Do a simple publish/subscribe demo based on the test-mode passed
   // in the command line arguments.  If test-mode is 1, subscribe to
   // 'topic_1' and publish to 'topic_2'; otherwise vice versa.  Publish
   // a message every four seconds.
   //
   device
      .on('connect', function() {
         console.log('connected');
      });
   device
      .on('close', function() {
         console.log('close');
      });
   device
      .on('reconnect', function() {
         console.log('reconnect');
      });
   device
      .on('offline', function() {
         console.log('offline');
      });
   device
      .on('error', function(error) {
         console.log('error', error);
      });
   device
      .on('message', function(topic, payload) {

         if(topic == "led") {
            console.log("led");
            if(payload!=null) {
               var jsonPayload = JSON.parse(payload.toString());
               if(jsonPayload.color == "yellow") {
                  yellowLedGpio.set();
                  setTimeout(function() { yellowLedGpio.reset(); }, 2000);
               }
               if(jsonPayload.color == "blue") {
                  blueLedGpio.set();
                  setTimeout(function() { blueLedGpio.reset(); }, 2000);
               }

            }
         }
         console.log('message', topic, payload.toString());
      });
}

module.exports = cmdLineProcess;

if (require.main === module) {
   cmdLineProcess('connect to the AWS IoT service and publish/subscribe to topics using MQTT, test modes 1-2',
      process.argv.slice(2), processTest);
}<|endoftext|>


<commit_before>'use strict';

angular.module('myApp.remoteimage')
    .factory('RemoteimageServices', ['$http', '$q', '$cacheFactory',
        function ($http, $q, $cacheFactory) {
            var obj = {};

            obj.convertDate = function(dd) {
                var y = dd.substring(0, 4);
                var m = dd.substring(4, 6);
                var d = dd.substring(6, 8);

                var compatibleDate = y + "-" + m + "-" + d;
                var nativeTime = Date.parse(compatibleDate);

                return nativeTime;
            }

            // I'm not proud of this
            obj.downloadRemoteimageListImages = function() {
                var url = "https://images.linuxcontainers.org/";

                return $http.get("https://images.linuxcontainers.org/1.0/images", {cache: true}).then(function(data) {

                    var promises = data.data.metadata.map(function(imageUrl) {
                        return $http.get(url + imageUrl, {cache: true}).then(function(resp) {
                            resp.data.metadata.source = 'images';
                            resp.data.metadata.sourceUrl = url;
                            resp.data.metadata.sourceProto = 'lxd';
                            return resp.data.metadata;
                        });
                    });

                    return $q.all(promises).then(function(data) {
                        var ret = [];
                        var res = {};

                        // Create hashmap of all the returned linux distris
                        for(var n=0; n<data.length; n++) {
                            var i = data[n];

                            if (! res[i.properties.distribution]) {
                                res[i.properties.distribution] = {};
                            }
                            if (! res[i.properties.distribution][i.properties.release]) {
                                res[i.properties.distribution][i.properties.release] = {};
                            }
                            if (! res[i.properties.distribution][i.properties.release][i.properties.architecture]) {
                                res[i.properties.distribution][i.properties.release][i.properties.architecture] = {};
                            }

                            var dd = i.properties.build.split("_")[0];
                            var nativeDate = obj.convertDate(dd);

                            if (! res[i.properties.distribution][i.properties.release][i.properties.architecture].date) {
                                res[i.properties.distribution][i.properties.release][i.properties.architecture].date = nativeDate;
                                res[i.properties.distribution][i.properties.release][i.properties.architecture].data = i;
                            } else {
                                if (nativeDate > res[i.properties.distribution][i.properties.release][i.properties.architecture].date) {
                                    res[i.properties.distribution][i.properties.release][i.properties.architecture].date = nativeDate;
                                    res[i.properties.distribution][i.properties.release][i.properties.architecture].data = i;
                                }
                            }
                        }

                        // Extract the one's inserted
                        for(var distribution in res) {
                            for (var release in res[distribution]) {
                                for (var architecture in res[distribution][release]) {
                                    ret.push(res[distribution][release][architecture].data);
                                }
                            }
                        }

                        //return data;
                        return ret;
                    });
                });
            }

            obj.downloadRemoteimageListImages_bak = function() {
                return $http.get("/data/index-user.txt", {cache: true}).then(function(data) {
                    var baseUrl = "https://images.linuxcontainers.org/";
                    var baseImageName = "rootfs.tar.xz";

                    data = data.data;

                    var results = [];
                    var dataArr = data.split('\n');
                    dataArr.forEach(function(line) {
                        var entry = line.split(";");
                        if (entry.length == 6) {
                            var entryHash = {
                                source: 'images',
                                os: entry[0],
                                release: entry[1],
                                arch: entry[2],
                                unkown: entry[3],
                                date: entry[4],
                                path: entry[5],
                                url: baseUrl + entry[5] + baseImageName,
                                pubname: entry[0] + " " + entry[1] + " / " + entry[4],
                            }

                            results.push(entryHash);
                        }
                    });

                    return results;
                })
            }

            obj.downloadRemoteimageListUbuntu = function () {
                return $http.get("/data/ubuntudata.json", {cache: true}).then(function (data) {
                    var results = [];

                    var baseUrl = "https://cloud-images.ubuntu.com/releases/";

                    data = data.data;

                    // Inefficient implementation of parsing the strem data
                    for (var product in data.products) {
                        var productData = data.products[product];

                        //  "com.ubuntu.cloud:server:15.04:armhf": {
                        for (var shortdesc in productData) {
                            var shortData = productData[shortdesc];

                            var newestVersion = 0;
                            var newestVersionData = null;

                            //    "versions": {
                            for (var version in shortData) {
                                // "20150325": {
                                var versionData = shortData[version];

                                if (versionData.items == undefined) {
                                    continue;
                                }

                                //      "items": {
                                for (var item in versionData.items) {
                                    if (item == "lxd.tar.xz") {
                                        var dd = "";
                                        if (version.indexOf(".") > -1) {
                                            dd = version.split(".")[0];
                                        } else {
                                            dd = version;
                                        }

                                        var nativeTime = obj.convertDate(dd);
                                        /*
                                         var y = dd.substring(0, 4);
                                         var m = dd.substring(4, 6);
                                         var d = dd.substring(6, 8);

                                         var compatibleDate = y + "-" + m + "-" + d;
                                         var nativeTime = Date.parse(compatibleDate);
                                         */

                                        var itemData = versionData.items[item];

                                        var entry = {
                                            sourceUrl: baseUrl,
                                            sourceProto: 'simplestreams',
                                            source: 'ubuntu',
                                            os: "ubuntu",
                                            arch: productData.arch,
                                            release_title: productData.release_title,
                                            release_codename: productData.release_codename,
                                            release: productData.release,
                                            version: productData.version,
                                            product: product,
                                            size: itemData.size,
                                            path: itemData.path,
                                            url: baseUrl + itemData.path,
                                            sha256: itemData.sha256,
                                            pubname: versionData.pubname,
                                            combined_sha256: itemData.combined_sha256,

                                            // compatibility
                                            fingerprint: itemData.combined_sha256,
                                            architecture: productData.arch,
                                            properties: {
                                                description: "Ubuntu " + productData.release_title + " " + productData.release_codename + " (" + productData.release + ')',
                                            }
                                        }

                                        if (nativeTime > newestVersion) {
                                            newestVersion = nativeTime;
                                            newestVersionData = entry;
                                        }

                                        //results.push(entry);
                                    }
                                }

                            }

                            if (newestVersion > 0) {
                                results.push(newestVersionData);
                            }
                        }
                    }

                    data = results;

                    return data;
                })

            }

            obj.cacheData = {
                isCached: false,
            };

            obj.checkFilter = function(result, filter) {
                if (filter.search) {
                    if (result.properties.description.toLowerCase().indexOf(filter.search.toLowerCase()) > -1) {
                        if (filter.architecture) {
                            if (result.architecture == filter.architecture) {
                                return true;
                            }
                        } else {
                            return true;
                        }
                    }
                } else {
                    if (filter.architecture) {
                        if (result.architecture == filter.architecture) {
                            return true;
                        }
                    } else {
                        return true;
                    }
                }

                return false;
            }

            obj.getByFilter = function(filter) {
                //return obj.getAll();

                return obj.getAll().then(function(data) {
                    if ( _.isEmpty(filter)) {
                        return data;
                    }

                    var d = $q.defer();

                    var results = [];

                    for(var n=0; n<2; n++) {
                        // wow this is fugly
                        data[n].forEach(function(result) {
                            if (obj.checkFilter(result, filter)) {
                                results.push(result);
                            }
                        });
                    }

                    d.resolve([ results ]);

                    return d.promise;
                });
            }

            obj.getAll = function() {
                if (obj.cacheData.isCached == true) {
                    console.log("cached");
                    return obj.cacheData.p;
                } else {
                    console.log("not cached");
                    var requests = [];

                    requests.push(obj.downloadRemoteimageListUbuntu());
                    requests.push(obj.downloadRemoteimageListImages());

                    var p =  $q.all(requests);

                    obj.cacheData.p = p;
                    obj.cacheData.isCached = true;

                    return p;
                }

            }

            return obj;
        }])
;
<commit_msg>Always send without with-credentials header for addremoteimage<commit_after>'use strict';

angular.module('myApp.remoteimage')
    .factory('RemoteimageServices', ['$http', '$q', '$cacheFactory',
        function ($http, $q, $cacheFactory) {
            var obj = {};

            obj.convertDate = function(dd) {
                var y = dd.substring(0, 4);
                var m = dd.substring(4, 6);
                var d = dd.substring(6, 8);

                var compatibleDate = y + "-" + m + "-" + d;
                var nativeTime = Date.parse(compatibleDate);

                return nativeTime;
            }

            // I'm not proud of this
            obj.downloadRemoteimageListImages = function() {
                var url = "https://images.linuxcontainers.org/";

                return $http.get("https://images.linuxcontainers.org/1.0/images", {withCredentials:false, cache: true}).then(function(data) {

                    var promises = data.data.metadata.map(function(imageUrl) {
                        return $http.get(url + imageUrl, {withCredentials: false, cache: true}).then(function(resp) {
                            resp.data.metadata.source = 'images';
                            resp.data.metadata.sourceUrl = url;
                            resp.data.metadata.sourceProto = 'lxd';
                            return resp.data.metadata;
                        });
                    });

                    return $q.all(promises).then(function(data) {
                        var ret = [];
                        var res = {};

                        // Create hashmap of all the returned linux distris
                        for(var n=0; n<data.length; n++) {
                            var i = data[n];

                            if (! res[i.properties.distribution]) {
                                res[i.properties.distribution] = {};
                            }
                            if (! res[i.properties.distribution][i.properties.release]) {
                                res[i.properties.distribution][i.properties.release] = {};
                            }
                            if (! res[i.properties.distribution][i.properties.release][i.properties.architecture]) {
                                res[i.properties.distribution][i.properties.release][i.properties.architecture] = {};
                            }

                            var dd = i.properties.build.split("_")[0];
                            var nativeDate = obj.convertDate(dd);

                            if (! res[i.properties.distribution][i.properties.release][i.properties.architecture].date) {
                                res[i.properties.distribution][i.properties.release][i.properties.architecture].date = nativeDate;
                                res[i.properties.distribution][i.properties.release][i.properties.architecture].data = i;
                            } else {
                                if (nativeDate > res[i.properties.distribution][i.properties.release][i.properties.architecture].date) {
                                    res[i.properties.distribution][i.properties.release][i.properties.architecture].date = nativeDate;
                                    res[i.properties.distribution][i.properties.release][i.properties.architecture].data = i;
                                }
                            }
                        }

                        // Extract the one's inserted
                        for(var distribution in res) {
                            for (var release in res[distribution]) {
                                for (var architecture in res[distribution][release]) {
                                    ret.push(res[distribution][release][architecture].data);
                                }
                            }
                        }

                        //return data;
                        return ret;
                    });
                });
            }

            obj.downloadRemoteimageListImages_bak = function() {
                return $http.get("/data/index-user.txt", {cache: true}).then(function(data) {
                    var baseUrl = "https://images.linuxcontainers.org/";
                    var baseImageName = "rootfs.tar.xz";

                    data = data.data;

                    var results = [];
                    var dataArr = data.split('\n');
                    dataArr.forEach(function(line) {
                        var entry = line.split(";");
                        if (entry.length == 6) {
                            var entryHash = {
                                source: 'images',
                                os: entry[0],
                                release: entry[1],
                                arch: entry[2],
                                unkown: entry[3],
                                date: entry[4],
                                path: entry[5],
                                url: baseUrl + entry[5] + baseImageName,
                                pubname: entry[0] + " " + entry[1] + " / " + entry[4],
                            }

                            results.push(entryHash);
                        }
                    });

                    return results;
                })
            }

            obj.downloadRemoteimageListUbuntu = function () {
                return $http.get("/data/ubuntudata.json", {cache: true}).then(function (data) {
                    var results = [];

                    var baseUrl = "https://cloud-images.ubuntu.com/releases/";

                    data = data.data;

                    // Inefficient implementation of parsing the strem data
                    for (var product in data.products) {
                        var productData = data.products[product];

                        //  "com.ubuntu.cloud:server:15.04:armhf": {
                        for (var shortdesc in productData) {
                            var shortData = productData[shortdesc];

                            var newestVersion = 0;
                            var newestVersionData = null;

                            //    "versions": {
                            for (var version in shortData) {
                                // "20150325": {
                                var versionData = shortData[version];

                                if (versionData.items == undefined) {
                                    continue;
                                }

                                //      "items": {
                                for (var item in versionData.items) {
                                    if (item == "lxd.tar.xz") {
                                        var dd = "";
                                        if (version.indexOf(".") > -1) {
                                            dd = version.split(".")[0];
                                        } else {
                                            dd = version;
                                        }

                                        var nativeTime = obj.convertDate(dd);
                                        /*
                                         var y = dd.substring(0, 4);
                                         var m = dd.substring(4, 6);
                                         var d = dd.substring(6, 8);

                                         var compatibleDate = y + "-" + m + "-" + d;
                                         var nativeTime = Date.parse(compatibleDate);
                                         */

                                        var itemData = versionData.items[item];

                                        var entry = {
                                            sourceUrl: baseUrl,
                                            sourceProto: 'simplestreams',
                                            source: 'ubuntu',
                                            os: "ubuntu",
                                            arch: productData.arch,
                                            release_title: productData.release_title,
                                            release_codename: productData.release_codename,
                                            release: productData.release,
                                            version: productData.version,
                                            product: product,
                                            size: itemData.size,
                                            path: itemData.path,
                                            url: baseUrl + itemData.path,
                                            sha256: itemData.sha256,
                                            pubname: versionData.pubname,
                                            combined_sha256: itemData.combined_sha256,

                                            // compatibility
                                            fingerprint: itemData.combined_sha256,
                                            architecture: productData.arch,
                                            properties: {
                                                description: "Ubuntu " + productData.release_title + " " + productData.release_codename + " (" + productData.release + ')',
                                            }
                                        }

                                        if (nativeTime > newestVersion) {
                                            newestVersion = nativeTime;
                                            newestVersionData = entry;
                                        }

                                        //results.push(entry);
                                    }
                                }

                            }

                            if (newestVersion > 0) {
                                results.push(newestVersionData);
                            }
                        }
                    }

                    data = results;

                    return data;
                })

            }

            obj.cacheData = {
                isCached: false,
            };

            obj.checkFilter = function(result, filter) {
                if (filter.search) {
                    if (result.properties.description.toLowerCase().indexOf(filter.search.toLowerCase()) > -1) {
                        if (filter.architecture) {
                            if (result.architecture == filter.architecture) {
                                return true;
                            }
                        } else {
                            return true;
                        }
                    }
                } else {
                    if (filter.architecture) {
                        if (result.architecture == filter.architecture) {
                            return true;
                        }
                    } else {
                        return true;
                    }
                }

                return false;
            }

            obj.getByFilter = function(filter) {
                //return obj.getAll();

                return obj.getAll().then(function(data) {
                    if ( _.isEmpty(filter)) {
                        return data;
                    }

                    var d = $q.defer();

                    var results = [];

                    for(var n=0; n<2; n++) {
                        // wow this is fugly
                        data[n].forEach(function(result) {
                            if (obj.checkFilter(result, filter)) {
                                results.push(result);
                            }
                        });
                    }

                    d.resolve([ results ]);

                    return d.promise;
                });
            }

            obj.getAll = function() {
                if (obj.cacheData.isCached == true) {
                    console.log("cached");
                    return obj.cacheData.p;
                } else {
                    console.log("not cached");
                    var requests = [];

                    requests.push(obj.downloadRemoteimageListUbuntu());
                    requests.push(obj.downloadRemoteimageListImages());

                    var p =  $q.all(requests);

                    obj.cacheData.p = p;
                    obj.cacheData.isCached = true;

                    return p;
                }

            }

            return obj;
        }])
;
<|endoftext|>


<commit_before>goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.layer.Tile');
goog.require('ol.source.TileWMS');

var wmsSource = new ol.source.TileWMS({
  url: 'http://demo.opengeo.org/geoserver/wms',
  params: {'LAYERS': 'ne:ne'}
});

var wmsLayer = new ol.layer.Tile({
  source: wmsSource
});

var view = new ol.View2D({
  center: [0, 0],
  zoom: 1
});

var viewProjection = /** @type {ol.proj.Projection} */
    (view.getProjection());

var map = new ol.Map({
  layers: [wmsLayer],
  renderer: ol.RendererHint.CANVAS,
  target: 'map',
  view: view
});

map.on('singleclick', function(evt) {
  document.getElementById('info').innerHTML = '';
  var viewResolution = /** @type {number} */ (view.getResolution());
  var url = wmsSource.getGetFeatureInfoUrl(
      evt.getCoordinate(), viewResolution, viewProjection,
      {'INFO_FORMAT': 'text/html'});
  if (url) {
    document.getElementById('info').innerHTML =
        '';
  }
});
<commit_msg>Use evt.coordinate instead of evt.getCoordinate()<commit_after>goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.layer.Tile');
goog.require('ol.source.TileWMS');

var wmsSource = new ol.source.TileWMS({
  url: 'http://demo.opengeo.org/geoserver/wms',
  params: {'LAYERS': 'ne:ne'}
});

var wmsLayer = new ol.layer.Tile({
  source: wmsSource
});

var view = new ol.View2D({
  center: [0, 0],
  zoom: 1
});

var viewProjection = /** @type {ol.proj.Projection} */
    (view.getProjection());

var map = new ol.Map({
  layers: [wmsLayer],
  renderer: ol.RendererHint.CANVAS,
  target: 'map',
  view: view
});

map.on('singleclick', function(evt) {
  document.getElementById('info').innerHTML = '';
  var viewResolution = /** @type {number} */ (view.getResolution());
  var url = wmsSource.getGetFeatureInfoUrl(
      evt.coordinate, viewResolution, viewProjection,
      {'INFO_FORMAT': 'text/html'});
  if (url) {
    document.getElementById('info').innerHTML =
        '';
  }
});
<|endoftext|>


<commit_before>////////////////////////////////////////////////
/*   Provided Code - Please Don't Edit   */
////////////////////////////////////////////////
'use strict';

function getInput() {
    console.log("Please choose either 'rock', 'paper', or 'scissors'.")
    return prompt();
}
function randomPlay() {
    var randomNumber = Math.random();
    if (randomNumber < 0.33) {
        return "rock";
    } else if (randomNumber < 0.66) {
        return "paper";
    } else {
        return "scissors";
    }
}
////////////////////////////////////////////////
/*           Write Your Code Below            */
////////////////////////////////////////////////

function getPlayerMove(move) {
    // Write an expression that operates on a variable called `move`
    // If a `move` has a value, your expression should evaluate to that value.
    // However, if `move` is not specified / is null, your expression should equal `getInput()`.
      if (move !== null) {
        return move;
    }
    else {
        return getInput();
    }

}

function getComputerMove(move) {
    // Write an expression that operates on a variable called `move`
    // If a `move` has a value, your expression should evaluate to that value.
    // However, if `move` is not specified / is null, your expression should equal `randomPlay()`.
     if (move !== null) {
        return move;
    }
    else {
        return randomPlay();
    }

}

function getWinner(playerMove,computerMove) {
    var winner;
    // Write code that will set winner to either 'player', 'computer', or 'tie' based on the values of playerMove and computerMove.
    // Assume that the only values playerMove and computerMove can have are 'rock', 'paper', and 'scissors'.
    // The rules of the game are that 'rock' beats 'scissors', 'scissors' beats 'paper', and 'paper' beats 'rock'.
    /* YOUR CODE HERE */
	    if (playerMove === computerMove) {
        return "The result is a tie!";
    }
    else if(playerMove === "rock") {

        if(computerMove === "scissors") {
            winner = 'player';
        }
        else  {
            winner = 'computer';
        }
    }
    else if(playerMove === "paper"){

        if(computerMove === "rock") {
            winner = 'player';
        }
        else{
            winner = 'computer';
        }
     }
    else if(playerMove === "scissors"){

        if(computerMove === "paper") {
            winner = 'player';
        }
        else{
            winner = 'computer';
        }
     }
     return winner;
};

function playToFive() {
    console.log("Let's play Rock, Paper, Scissors");
    var playerWins = 0;
    var computerWins = 0;
    // Write code that plays 'Rock, Paper, Scissors' until either the player or the computer has won five times.
    /* YOUR CODE HERE */
   while ((playerWins < 5) && (computerWins < 5)) {
       var playersAction = getPlayerMove();
       var computersAction = getComputerMove();
       var whoWon = getWinner(playersAction, computersAction);
       if  (whoWon == 'player') {
        playerWins++;
       }
       if (whoWon == 'computer') {
        computerWins++;
       }
       console.log('Player chose ' + playersAction + ' while Computer chose ' + computersAction);
       console.log('The score is currently ' + playerWins + ' to ' + computerWins + '\n');
    }
    return [playerWins, computerWins];
}

<commit_msg>Final game<commit_after>////////////////////////////////////////////////
/*   Provided Code - Please Don't Edit   */
////////////////////////////////////////////////
'use strict';

function getInput() {
    console.log("Please choose either 'rock', 'paper', or 'scissors'.");
    return prompt();
}
function randomPlay() {
    var randomNumber = Math.random();
    if (randomNumber < 0.33) {
        return "rock";
    } else if (randomNumber < 0.66) {
        return "paper";
    } else {
        return "scissors";
    }
}
////////////////////////////////////////////////
/*           Write Your Code Below            */
////////////////////////////////////////////////

function getPlayerMove(move) {
    // Write an expression that operates on a variable called `move`
    // If a `move` has a value, your expression should evaluate to that value.
    // However, if `move` is not specified / is null, your expression should equal `getInput()`.
    if (move !== null) {
        return move;
    }
    else {
        return getInput();
    }
}

function getComputerMove(move) {
    // Write an expression that operates on a variable called `move`
    // If a `move` has a value, your expression should evaluate to that value.
    // However, if `move` is not specified / is null, your expression should equal `randomPlay()`.
    if (move !== null) {
        return move;
    }
    else {
        return randomPlay();
    }
}

function getWinner(playerMove,computerMove) {
    var winner;
    // Write code that will set winner to either 'player', 'computer', or 'tie' based on the values of playerMove and computerMove.
    // Assume that the only values playerMove and computerMove can have are 'rock', 'paper', and 'scissors'.
    // The rules of the game are that 'rock' beats 'scissors', 'scissors' beats 'paper', and 'paper' beats 'rock'.
    /* YOUR CODE HERE */
    if (playerMove === computerMove) {
        return "The result is a tie!";
    }
    else if(playerMove === "rock") {

        if(computerMove === "scissors") {
            winner = 'player';
        }
        else  {
            winner = 'computer';
        }
    }
    else if(playerMove === "paper"){

        if(computerMove === "rock") {
            winner = 'player';
        }
        else{
            winner = 'computer';
        }
    }
    else if(playerMove === "scissors"){

        if(computerMove === "paper") {
            winner = 'player';
        }
        else{
            winner = 'computer';
        }
    }
    return winner;
};

function playToFive() {
    console.log("Let's play Rock, Paper, Scissors");
    var playerWins = 0;
    var computerWins = 0;
    // Write code that plays 'Rock, Paper, Scissors' until either the player or the computer has won five times.
    /* YOUR CODE HERE */
    while ((playerWins < 5) && (computerWins < 5)) {
        var playersAction = getPlayerMove(null);
        var computersAction = getComputerMove(null);
        var whoWon = getWinner(playersAction, computersAction);
        if  (whoWon == 'player') {
            playerWins++;
        }
        if (whoWon == 'computer') {
            computerWins++;
        }
        console.log('Player chose ' + playersAction + ' while Computer chose ' + computersAction);
        console.log('The score is currently ' + playerWins + ' to ' + computerWins + '\n');
    }
    console.log("Game Over!");
    return [playerWins, computerWins];

}
playToFive();
<|endoftext|>


<commit_before>(function ($) {
	$.fn.countTo = function (options) {
		// merge the default plugin settings with the custom options
		options = $.extend({}, $.fn.countTo.defaults, options || {});

		return $(this).each(function () {
			// set options for current element
			var settings = $.extend({}, options, {
				from:            parseInt($(this).attr('data-from') || options.from, 10),
				to:              parseInt($(this).attr('data-to') || options.to, 10),
				speed:           parseInt($(this).attr('data-speed') || options.speed, 10),
				refreshInterval: parseInt($(this).attr('data-refresh-interval') || options.refreshInterval, 10),
				decimals:        parseInt($(this).attr('data-decimals') || options.decimals, 10)
			});

			// how many times to update the value, and how much to increment the value on each update
			var loops = Math.ceil(settings.speed / settings.refreshInterval),
				increment = (settings.to - settings.from) / loops;

			// references & variables that will change with each update
			var self = this,
				loopCount = 0,
				value = settings.from,
				interval = setInterval(updateTimer, settings.refreshInterval);

			// initialize the element with the starting value
			render(value);

			function updateTimer() {
				value += increment;
				loopCount++;

				render(value);

				if (typeof(settings.onUpdate) == 'function') {
					settings.onUpdate.call(self, value);
				}

				if (loopCount >= loops) {
					clearInterval(interval);
					value = settings.to;

					if (typeof(settings.onComplete) == 'function') {
						settings.onComplete.call(self, value);
					}
				}
			}

			function render(value) {
				var formattedValue = settings.formatter.call(self, value, settings);
				$(self).html(formattedValue);
			}
		});
	};

	$.fn.countTo.defaults = {
		from: 0,               // the number the element should start at
		to: 0,                 // the number the element should end at
		speed: 1000,           // how long it should take to count between the target numbers
		refreshInterval: 100,  // how often the element should be updated
		decimals: 0,           // the number of decimal places to show
		formatter: formatter,  // handler for formatting the value before rendering
		onUpdate: null,        // callback method for every time the element is updated
		onComplete: null       // callback method for when the element finishes updating
	};

	function formatter(value, settings) {
		return value.toFixed(settings.decimals);
	}
}(jQuery));
<commit_msg>clear (possibly) existing timer before starting new one<commit_after>(function ($) {
	$.fn.countTo = function (options) {
		// merge the default plugin settings with the custom options
		options = $.extend({}, $.fn.countTo.defaults, options || {});

		return $(this).each(function () {
			// set options for current element
			var settings = $.extend({}, options, {
				from:            parseInt($(this).attr('data-from') || options.from, 10),
				to:              parseInt($(this).attr('data-to') || options.to, 10),
				speed:           parseInt($(this).attr('data-speed') || options.speed, 10),
				refreshInterval: parseInt($(this).attr('data-refresh-interval') || options.refreshInterval, 10),
				decimals:        parseInt($(this).attr('data-decimals') || options.decimals, 10)
			});

			// how many times to update the value, and how much to increment the value on each update
			var loops = Math.ceil(settings.speed / settings.refreshInterval),
				increment = (settings.to - settings.from) / loops;

			// references & variables that will change with each update
			var self = this,
				$self = $(this),
				loopCount = 0,
				value = settings.from,
				interval = setInterval(updateTimer, settings.refreshInterval);
			var countToData = $self.data('countTo');
			if (!countToData) {
				countToData = {};
				$self.data('countTo', countToData);
			}
			// if an existing interval can be found, clear it first
			if (countToData.interval) {
				clearInterval(countToData.interval);
			}
			countToData.interval = interval;
			// initialize the element with the starting value
			render(value);

			function updateTimer() {
				value += increment;
				loopCount++;

				render(value);

				if (typeof(settings.onUpdate) == 'function') {
					settings.onUpdate.call(self, value);
				}

				if (loopCount >= loops) {
					// remove the interval
					$self.removeData('countTo');
					clearInterval(interval);
					value = settings.to;

					if (typeof(settings.onComplete) == 'function') {
						settings.onComplete.call(self, value);
					}
				}
			}

			function render(value) {
				var formattedValue = settings.formatter.call(self, value, settings);
				$self.html(formattedValue);
			}
		});
	};

	$.fn.countTo.defaults = {
		from: 0,               // the number the element should start at
		to: 0,                 // the number the element should end at
		speed: 1000,           // how long it should take to count between the target numbers
		refreshInterval: 100,  // how often the element should be updated
		decimals: 0,           // the number of decimal places to show
		formatter: formatter,  // handler for formatting the value before rendering
		onUpdate: null,        // callback method for every time the element is updated
		onComplete: null       // callback method for when the element finishes updating
	};

	function formatter(value, settings) {
		return value.toFixed(settings.decimals);
	}
}(jQuery));
<|endoftext|>


<commit_before>(function() {
  // helper functions
  function is_touch_device() {
    return 'ontouchstart' in window // works on most browsers
        || 'onmsgesturechange' in window; // works on ie10
  }

  function fill(value, target, container) {
    if (value + target < container)
      value = container - target;
    return value > 0 ? 0 : value;
  }

  function uri2blob(dataURI) {
      var uriComponents = dataURI.split(',');
      var byteString = atob(uriComponents[1]);
      var mimeString = uriComponents[0].split(':')[1].split(';')[0]
      var ab = new ArrayBuffer(byteString.length);
      var ia = new Uint8Array(ab);
      for (var i = 0; i < byteString.length; i++)
          ia[i] = byteString.charCodeAt(i);
      return new Blob([ab], { type: mimeString });
  }

	var pluginName = 'cropbox';

  function factory($) {
    function Crop($image, options) {
      this.width = null;
      this.height = null;
      this.minPercent = null;
      this.options = options;
      this.$image = $image;
      this.$image.hide().addClass('cropImage').wrap('
'); // wrap image in frame;
      this.$frame = this.$image.parent();
      this.init();
    }

    Crop.prototype = {
      init: function () {
        var self = this;

        if (is_touch_device())
          this.$frame.addClass('hover');
        else
          this.$frame.hover(function () { self.$frame.toggleClass('hover'); });

        var defaultControls = $('
', { 'class' : 'cropControls' })
              .append($('Drag to crop'))
              .append($('', { 'class' : 'cropZoomIn' }).on('click', $.proxy(this.zoomIn, this)))
              .append($('', { 'class' : 'cropZoomOut' }).on('click', $.proxy(this.zoomOut, this)));

        this.$frame.width(self.options.width).height(self.options.height);
        this.$frame.append(this.options.controls || defaultControls);

        this.$image.on('load', function() {
          self.width = this.width;
          self.height = this.height;
          self.focal = { x: Math.round(self.width / 2) ,y: Math.round(self.height / 2) };
          self.computeMinPercent();
          self.$image.fadeIn('fast'); //display image now that it has loaded
          self.update();
        }).prop('draggable', false).attr('src', self.$image.attr('src'));

        if (typeof $.fn.hammer === 'function' || typeof Hammer !== 'undefined') {
          var hammerit, dragData;
          if (typeof $.fn.hammer === 'function')
            hammerit = this.$image.hammer();
          else
            hammerit = Hammer(this.$image.get(0));

          hammerit.on('mousedown', function(e) {
            e.preventDefault(); // this prevents firefox's default image dragging
            e.stopPropagation();
          }).on("dragleft dragright dragup dragdown", function(e) {
            if (!dragData)
              dragData = {
                imgX: parseInt(self.$image.css('left'), 10),
                imgY: parseInt(self.$image.css('top'), 10)
              };
            dragData.dx = e.gesture.deltaX;
            dragData.dy = e.gesture.deltaY;
            e.gesture.preventDefault();
            e.gesture.stopPropagation();
            self.drag.call(self, dragData);
          }).on('release', function(e) {
            e.gesture.preventDefault();
            dragData = null;
            self.update.call(self);
          }).on('doubletap', function(e) {
            e.gesture.preventDefault();
            self.zoomIn.call(self);
          }).on('pinchin', function (e) {
            e.gesture.preventDefault();
            self.zoom.call(self, self.percent - e.gesture.scale / 110);
          }).on('pinchout', function (e) {
            e.gesture.preventDefault();
            self.zoom.call(self, self.percent + (e.gesture.scale - 1) / 110);
          });
        } else {
          this.$image.on('mousedown.' + pluginName, function(e1) {
            var dragData = {
              imgX: parseInt(self.$image.css('left'), 10),
              imgY: parseInt(self.$image.css('top'), 10)
            };
            e1.preventDefault();
            $(document).on('mousemove.' + pluginName, function (e2) {
              dragData.dx = e2.pageX - e1.pageX;
              dragData.dy = e2.pageY - e1.pageY;
              self.drag.call(self, dragData);
            }).on('mouseup.' + pluginName, function() {
              $(document).off('.' + pluginName);
            });
          });
        }
        if ($.fn.mousewheel) {
          this.$image.on('mousewheel', function (e) {
            e.preventDefault();
            if (e.deltaY < 0)
              self.zoomIn.call(self);
            else
              self.zoomOut.call(self);
          });
        }
      },

      computeMinPercent: function () {
        var widthRatio = this.options.width / this.width, heightRatio = this.options.height / this.height;
        if (widthRatio >= heightRatio)
          this.minPercent = this.width < this.options.width ? this.options.width / this.width : widthRatio;
        else
          this.minPercent = this.height < this.options.height ? this.options.height / this.height : heightRatio;
        this.zoom(this.percent || this.minPercent);
      },

      zoom: function(percent) {
        this.percent = Math.max(this.minPercent, Math.min(1, percent));
        this.$image.width(Math.ceil(this.width * this.percent));
        this.$image.css({
          left: fill(-Math.round(this.focal.x * this.percent - this.options.width / 2), this.$image.width(), this.options.width),
          top: fill(-Math.round(this.focal.y * this.percent - this.options.height / 2), this.$image.height(), this.options.height)
        });
      },
      zoomIn: function() {
        this.zoom(this.percent + (1 - this.minPercent) / (this.options.zoom - 1 || 1));
        this.update();
      },
      zoomOut: function() {
        this.zoom(this.percent - (1 - this.minPercent) / (this.options.zoom - 1 || 1));
        this.update();
      },
      drag: function(data) {
        this.$image.css({
          left: fill(data.imgX + data.dx, this.$image.width(), this.options.width),
          top: fill(data.imgY + data.dy, this.$image.height(), this.options.height)
        });
      },
      update: function() {
        this.focal = {
          x: Math.round((this.options.width / 2 - parseInt(this.$image.css('left'), 10)) / this.percent),
          y: Math.round((this.options.height / 2 - parseInt(this.$image.css ('top'), 10)) / this.percent)
        };
        this.result = {
          cropX: -Math.floor(parseInt(this.$image.css('left'), 10) / this.percent),
          cropY: -Math.floor(parseInt(this.$image.css('top'), 10) / this.percent),
          cropW: Math.round(this.options.width / this.percent),
          cropH: Math.round(this.options.height / this.percent),
          stretch: this.minPercent > 1
        };

        this.$image.trigger(pluginName, this.result);
      },
      getDataURI: function () {
        var canvas = document.createElement('canvas');
        canvas.width = this.options.width;
        canvas.height = this.options.height;

        var ctx = canvas.getContext('2d')
        ctx.drawImage(this.$image.get(0), this.result.cropX, this.result.cropY, this.result.cropW, this.result.cropH, 0, 0, this.options.width, this.options.height);

        return canvas.toDataURL();
      },
      getAsBlob: function () {
        return uri2blob(this.getDataURI());
      },
    };

    $.fn[pluginName] = function(options) {
      return this.each(function() {
        var inst = $.data(this, pluginName);
        if (!inst) {
          var opts = $.extend($.fn[pluginName].defaultOptions, options);
          $.data(this, pluginName, new Crop($(this), opts));
        } else if (options) {
          $.extend(inst.options, options);
          inst.computeMinPercent();
        }
      });
    };

    $.fn[pluginName].defaultOptions = {
      width: 200,
      height: 200,
      zoom: 10,
      controls: null
    };
  }

  if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
      factory(require("jquery"));
  else if (typeof define === "function" && define.amd)
      define(["jquery"], factory);
  else
      factory(window.jQuery || window.Zepto);

})();
<commit_msg>Fixed options.<commit_after>(function() {
  // helper functions
  function is_touch_device() {
    return 'ontouchstart' in window // works on most browsers
        || 'onmsgesturechange' in window; // works on ie10
  }

  function fill(value, target, container) {
    if (value + target < container)
      value = container - target;
    return value > 0 ? 0 : value;
  }

  function uri2blob(dataURI) {
      var uriComponents = dataURI.split(',');
      var byteString = atob(uriComponents[1]);
      var mimeString = uriComponents[0].split(':')[1].split(';')[0]
      var ab = new ArrayBuffer(byteString.length);
      var ia = new Uint8Array(ab);
      for (var i = 0; i < byteString.length; i++)
          ia[i] = byteString.charCodeAt(i);
      return new Blob([ab], { type: mimeString });
  }

	var pluginName = 'cropbox';

  function factory($) {
    function Crop($image, options) {
      this.width = null;
      this.height = null;
      this.minPercent = null;
      this.options = options;
      this.$image = $image;
      this.$image.hide().addClass('cropImage').wrap('
'); // wrap image in frame;
      this.$frame = this.$image.parent();
      this.init();
    }

    Crop.prototype = {
      init: function () {
        var self = this;

        if (is_touch_device())
          this.$frame.addClass('hover');
        else
          this.$frame.hover(function () { self.$frame.toggleClass('hover'); });

        var defaultControls = $('
', { 'class' : 'cropControls' })
              .append($('Drag to crop'))
              .append($('', { 'class' : 'cropZoomIn' }).on('click', $.proxy(this.zoomIn, this)))
              .append($('', { 'class' : 'cropZoomOut' }).on('click', $.proxy(this.zoomOut, this)));

        this.$frame.width(self.options.width).height(self.options.height);
        this.$frame.append(this.options.controls || defaultControls);

        this.$image.on('load', function() {
          self.width = this.width;
          self.height = this.height;
          self.focal = { x: Math.round(self.width / 2) ,y: Math.round(self.height / 2) };
          self.computeMinPercent();
          self.$image.fadeIn('fast'); //display image now that it has loaded
          self.update();
        }).prop('draggable', false).attr('src', self.$image.attr('src'));

        if (typeof $.fn.hammer === 'function' || typeof Hammer !== 'undefined') {
          var hammerit, dragData;
          if (typeof $.fn.hammer === 'function')
            hammerit = this.$image.hammer();
          else
            hammerit = Hammer(this.$image.get(0));

          hammerit.on('mousedown', function(e) {
            e.preventDefault(); // this prevents firefox's default image dragging
            e.stopPropagation();
          }).on("dragleft dragright dragup dragdown", function(e) {
            if (!dragData)
              dragData = {
                imgX: parseInt(self.$image.css('left'), 10),
                imgY: parseInt(self.$image.css('top'), 10)
              };
            dragData.dx = e.gesture.deltaX;
            dragData.dy = e.gesture.deltaY;
            e.gesture.preventDefault();
            e.gesture.stopPropagation();
            self.drag.call(self, dragData);
          }).on('release', function(e) {
            e.gesture.preventDefault();
            dragData = null;
            self.update.call(self);
          }).on('doubletap', function(e) {
            e.gesture.preventDefault();
            self.zoomIn.call(self);
          }).on('pinchin', function (e) {
            e.gesture.preventDefault();
            self.zoom.call(self, self.percent - e.gesture.scale / 110);
          }).on('pinchout', function (e) {
            e.gesture.preventDefault();
            self.zoom.call(self, self.percent + (e.gesture.scale - 1) / 110);
          });
        } else {
          this.$image.on('mousedown.' + pluginName, function(e1) {
            var dragData = {
              imgX: parseInt(self.$image.css('left'), 10),
              imgY: parseInt(self.$image.css('top'), 10)
            };
            e1.preventDefault();
            $(document).on('mousemove.' + pluginName, function (e2) {
              dragData.dx = e2.pageX - e1.pageX;
              dragData.dy = e2.pageY - e1.pageY;
              self.drag.call(self, dragData);
            }).on('mouseup.' + pluginName, function() {
              $(document).off('.' + pluginName);
            });
          });
        }
        if ($.fn.mousewheel) {
          this.$image.on('mousewheel', function (e) {
            e.preventDefault();
            if (e.deltaY < 0)
              self.zoomIn.call(self);
            else
              self.zoomOut.call(self);
          });
        }
      },

      computeMinPercent: function () {
        var widthRatio = this.options.width / this.width, heightRatio = this.options.height / this.height;
        if (widthRatio >= heightRatio)
          this.minPercent = this.width < this.options.width ? this.options.width / this.width : widthRatio;
        else
          this.minPercent = this.height < this.options.height ? this.options.height / this.height : heightRatio;
        this.zoom(this.percent || this.minPercent);
      },

      zoom: function(percent) {
        this.percent = Math.max(this.minPercent, Math.min(1, percent));
        this.$image.width(Math.ceil(this.width * this.percent));
        this.$image.css({
          left: fill(-Math.round(this.focal.x * this.percent - this.options.width / 2), this.$image.width(), this.options.width),
          top: fill(-Math.round(this.focal.y * this.percent - this.options.height / 2), this.$image.height(), this.options.height)
        });
      },
      zoomIn: function() {
        this.zoom(this.percent + (1 - this.minPercent) / (this.options.zoom - 1 || 1));
        this.update();
      },
      zoomOut: function() {
        this.zoom(this.percent - (1 - this.minPercent) / (this.options.zoom - 1 || 1));
        this.update();
      },
      drag: function(data) {
        this.$image.css({
          left: fill(data.imgX + data.dx, this.$image.width(), this.options.width),
          top: fill(data.imgY + data.dy, this.$image.height(), this.options.height)
        });
      },
      update: function() {
        this.focal = {
          x: Math.round((this.options.width / 2 - parseInt(this.$image.css('left'), 10)) / this.percent),
          y: Math.round((this.options.height / 2 - parseInt(this.$image.css ('top'), 10)) / this.percent)
        };
        this.result = {
          cropX: -Math.floor(parseInt(this.$image.css('left'), 10) / this.percent),
          cropY: -Math.floor(parseInt(this.$image.css('top'), 10) / this.percent),
          cropW: Math.round(this.options.width / this.percent),
          cropH: Math.round(this.options.height / this.percent),
          stretch: this.minPercent > 1
        };

        this.$image.trigger(pluginName, [this.result, this]);
      },
      getDataURI: function () {
        var canvas = document.createElement('canvas');
        canvas.width = this.options.width;
        canvas.height = this.options.height;

        var ctx = canvas.getContext('2d')
        ctx.drawImage(this.$image.get(0), this.result.cropX, this.result.cropY, this.result.cropW, this.result.cropH, 0, 0, this.options.width, this.options.height);

        return canvas.toDataURL();
      },
      getBlob: function () {
        return uri2blob(this.getDataURI());
      },
    };

    $.fn[pluginName] = function(options) {
      return this.each(function() {
        var inst = $.data(this, pluginName);
        if (!inst) {
          var opts = $.extend({}, $.fn[pluginName].defaultOptions, options);
          $.data(this, pluginName, new Crop($(this), opts));
        } else if (options) {
          $.extend(inst.options, options);
          inst.computeMinPercent();
        }
      });
    };

    $.fn[pluginName].defaultOptions = {
      width: 200,
      height: 200,
      zoom: 10,
      controls: null
    };
  }

  if (typeof require === "function" && typeof exports === "object" && typeof module === "object")
      factory(require("jquery"));
  else if (typeof define === "function" && define.amd)
      define(["jquery"], factory);
  else
      factory(window.jQuery || window.Zepto);

})();
<|endoftext|>


<commit_before>/**
 * jQuery Input Sheeper plugin.
 *
 */
(function($) {
    $.sheeper = $.inputSheeper = function(element, options) {
        var plugin = this,
            defaults = {
                selector: ".sheep", // Each sheep must have this selector in template.
                addSelector: ".sheep-link", // Add button (new sheep in the list).
                removeSelector: ".unsheep-link", // Remove button in the prototype.
                moveUpSelector: ".sheepup-link", // Move up button in the prototype.
                moveDownSelector: ".sheepdown-link", // Move up button in the prototype.
                min: 1, // Minimum number of sheeps in the list.
                max: 100,
                prepend: false, // By default, append new element. Set prepend to true to prepend new sheeps.
                afterInit: function(element) {
                    return true;
                },
                afterSheep: function(element) {
                    return true;
                },
                beforeUnsheep: function(element) {
                    return true;
                },
                afterUnsheep: function(element) {
                    return true;
                }
            },
            $element = $(element),
            $wrapper,
            ids = [];
        plugin.settings = {};
        /**
         *
         * @return {[type]} [description]
         */
        plugin.init = function()
        {
            plugin.settings = $.extend({}, defaults, $element.data(), options);
            // Container for sheeps.
            $wrapper = (plugin.settings.container) ? $element.find(plugin.settings.container) : $element;

            if(plugin.settings.prototype.match('^(#|\\.)[a-zA-Z].*')) {
                // Prototype is an id (#) or a class (.)
                var $template = $(plugin.settings.prototype);

                // Hide the template and retrieve its content for latter use.
                $template.hide();
                plugin.settings.prototype = $template.html();
            }

            if(! plugin.settings.prototype) {
                console.error("No template found. Please provide a template using the 'prototype' javascript option or data-prototype HTML attribute");
                return;
            }

            // Do some init / apply stuffs.
            plugin.execute();
            plugin.settings.afterInit($element);
        };
        /**
         * Inits / apply DOM to this sheeper.
         *   - Called when init. @see init.
         *   - Called after an AJAX call. (that's why it's public ;) )
         * @return void
         */
        plugin.execute = function()
        {
            // Init the sheeper with existing sheeps.
            if (numberOfSheeps() > 0) {
                $wrapper.children().each(function() {
                    sheep(this);
                });
            }
            // If there's not enough sheeps in the herd, just sheep !
            if (numberOfSheeps() < plugin.settings.min) {
                for (var i = 0; i < (plugin.settings.min - numberOfSheeps()); i++) {
                    sheep();
                }
            }
            if (numberOfSheeps() === plugin.settings.min) {
                disableUnsheep();
            }
            // Actives the add link.
            $element.find(plugin.settings.addSelector).on("click", function(e) {
                e.preventDefault();
                sheep();
            });
            $wrapper.on("click", plugin.settings.removeSelector, function(e) {
                e.preventDefault();
                unsheep(this);
            });
            $wrapper.on("click", plugin.settings.moveUpSelector, function(e) {
                e.preventDefault();
                moveUp(this);
            });
            $wrapper.on("click", plugin.settings.moveDownSelector, function(e) {
                e.preventDefault();
                moveDown(this);
            });
        }
        /**
         * Creates (or registers) a new sheep in the herd.
         * @param  Element e  Opt: the sheep to add to the herd.
         * @return void.
         */
        var sheep = function(e)
        {
            if (numberOfSheeps() >= plugin.settings.max) {
                return;
            }
            if (e) {
                // Only registers the sheep in the herd.
                var $e = $(e),
                    id = $(e).data("sid");

                ids.push(id);

                plugin.settings.afterSheep($e);
                $e.trigger(
                    $.Event('sheeped.jq.sheeper', {})
                );
            } else {
                var id = getId();

                // Creates a new sheep.
                var $sheep = $(plugin.settings.prototype.replace(/(__|\{\{)\s?name\s?(__|\}\})/gi, id));

                // Sets the sheep ID.
                $sheep.data("sid", id);
                ids.push(id);

                if (plugin.settings.prepend) {
                    $wrapper.prepend($sheep);
                } else {
                    $wrapper.append($sheep);
                }
                // Registers the sheep in the herd.
                plugin.settings.afterSheep($sheep);
                $sheep.trigger(
                    $.Event('sheeped.jq.sheeper', {})
                );
            }
            if (numberOfSheeps() > plugin.settings.min) {
                enableUnsheep();
            } else {
                disableUnsheep();
            }
            if (numberOfSheeps() < plugin.settings.max) {
                enableSheep();
            } else {
                disableSheep();
            }

            refresh();
        }
        /**
         * Deletes a sheep element.
         * @param  Element e The '.unsheep-link' clicked.
         * @return void
         */
        var unsheep = function(e)
        {
            if (numberOfSheeps() > plugin.settings.min) {
                var $sheep = $(e).parents(plugin.settings.selector);
                plugin.settings.beforeUnsheep($sheep);
                $sheep.trigger(
                    $.Event('unsheep.jq.sheeper', {})
                );

                // Removes the sheep.
                $sheep.remove();

                plugin.settings.afterUnsheep($sheep);
                $wrapper.trigger(
                    $.Event('unsheeped.jq.sheeper', {
                        relatedTarget: $sheep
                    })
                );
            }
            if (numberOfSheeps() === plugin.settings.min) {
                disableUnsheep();
            }

            refresh();
        }

        var moveUp = function(e)
        {
            var $sheep = $(e).parents(plugin.settings.selector),
                $previous = $sheep.prev();
            if($previous.length) {
                $sheep.detach().insertBefore($previous);
            }

            refresh();
        }

        var moveDown = function(e)
        {
            var $sheep = $(e).parents(plugin.settings.selector),
                $next = $sheep.next();
            if($next.length) {
                $sheep.detach().insertAfter($next);
            }

            refresh();
        }

        var numberOfSheeps = function()
        {
            return $wrapper.find(plugin.settings.selector).length;
        }

        var refresh = function()
        {
            var $sheeps = $wrapper.children();
            $sheeps.each(function(i, e) {
                var $e = $(e);
                $e.find(plugin.settings.moveUpSelector).each(function(i, e) {
                    $(e).removeClass("disabled");
                });
                $e.find(plugin.settings.moveDownSelector).each(function(i, e) {
                    $(e).removeClass("disabled");
                });
            });

            $sheeps.first().find(plugin.settings.moveUpSelector).addClass("disabled");
            $sheeps.last().find(plugin.settings.moveDownSelector).addClass("disabled");
        }

        var enableSheep = function()
        {
            $wrapper.find(plugin.settings.addSelector).removeClass("disabled");
        }

        var disableSheep = function()
        {
            $wrapper.find(plugin.settings.addSelector).addClass("disabled");
        }

        /**
         * Enable the ability to unhseep.
         * @return void
         */
        var enableUnsheep = function()
        {
            $wrapper.find(plugin.settings.removeSelector).removeClass("disabled");
        }
        /**
         * Disable the ability to unsheep.
         * @return void
         */
        var disableUnsheep = function()
        {
            $wrapper.find(plugin.settings.removeSelector).addClass("disabled");
        }

        var getId = function()
        {
            var id = 0;
            while(ids.indexOf(id) !== -1) {
                id++;
            }

            return id;
        }

        plugin.init();
    }

    $.fn.sheeper = $.fn.inputSheeper = function(options) {
        return this.each(function() {
            if (undefined == $(this).data('inputSheeper')) {
                var plugin = new $.sheeper(this, options);
                $(this).data('inputSheeper', plugin);
            }
        });
    }

    /**
     * DATA-* ATTRIBUTES API
     *
     * Use data-* attributes to enable/configure your sheeper components.
     */
    $(document).ready(function() {
        $('[data-toggle="sheeper"]').sheeper({});
    });
})(jQuery);
<commit_msg>Make numberOfSheeps() a public method<commit_after>/**
 * jQuery Input Sheeper plugin.
 *
 */
(function($) {
    $.sheeper = $.inputSheeper = function(element, options) {
        var plugin = this,
            defaults = {
                selector: ".sheep", // Each sheep must have this selector in template.
                addSelector: ".sheep-link", // Add button (new sheep in the list).
                removeSelector: ".unsheep-link", // Remove button in the prototype.
                moveUpSelector: ".sheepup-link", // Move up button in the prototype.
                moveDownSelector: ".sheepdown-link", // Move up button in the prototype.
                min: 1, // Minimum number of sheeps in the list.
                max: 100,
                prepend: false, // By default, append new element. Set prepend to true to prepend new sheeps.
                afterInit: function(element) {
                    return true;
                },
                afterSheep: function(element) {
                    return true;
                },
                beforeUnsheep: function(element) {
                    return true;
                },
                afterUnsheep: function(element) {
                    return true;
                }
            },
            $element = $(element),
            $wrapper,
            ids = [];
        plugin.settings = {};
        /**
         *
         * @return {[type]} [description]
         */
        plugin.init = function()
        {
            plugin.settings = $.extend({}, defaults, $element.data(), options);
            // Container for sheeps.
            $wrapper = (plugin.settings.container) ? $element.find(plugin.settings.container) : $element;

            if(plugin.settings.prototype.match('^(#|\\.)[a-zA-Z].*')) {
                // Prototype is an id (#) or a class (.)
                var $template = $(plugin.settings.prototype);

                // Hide the template and retrieve its content for latter use.
                $template.hide();
                plugin.settings.prototype = $template.html();
            }

            if(! plugin.settings.prototype) {
                console.error("No template found. Please provide a template using the 'prototype' javascript option or data-prototype HTML attribute");
                return;
            }

            // Do some init / apply stuffs.
            plugin.execute();
            plugin.settings.afterInit($element);
        };
        /**
         * Inits / apply DOM to this sheeper.
         *   - Called when init. @see init.
         *   - Called after an AJAX call. (that's why it's public ;) )
         * @return void
         */
        plugin.execute = function()
        {
            // Init the sheeper with existing sheeps.
            if (plugin.numberOfSheeps() > 0) {
                $wrapper.children().each(function() {
                    sheep(this);
                });
            }
            // If there's not enough sheeps in the herd, just sheep !
            if (plugin.numberOfSheeps() < plugin.settings.min) {
                for (var i = 0; i < (plugin.settings.min - plugin.numberOfSheeps()); i++) {
                    sheep();
                }
            }
            if (plugin.numberOfSheeps() === plugin.settings.min) {
                disableUnsheep();
            }
            // Actives the add link.
            $element.find(plugin.settings.addSelector).on("click", function(e) {
                e.preventDefault();
                sheep();
            });
            $wrapper.on("click", plugin.settings.removeSelector, function(e) {
                e.preventDefault();
                unsheep(this);
            });
            $wrapper.on("click", plugin.settings.moveUpSelector, function(e) {
                e.preventDefault();
                moveUp(this);
            });
            $wrapper.on("click", plugin.settings.moveDownSelector, function(e) {
                e.preventDefault();
                moveDown(this);
            });
        }
        /**
         * Creates (or registers) a new sheep in the herd.
         * @param  Element e  Opt: the sheep to add to the herd.
         * @return void.
         */
        var sheep = function(e)
        {
            if (plugin.numberOfSheeps() >= plugin.settings.max) {
                return;
            }
            if (e) {
                // Only registers the sheep in the herd.
                var $e = $(e),
                    id = $(e).data("sid");

                ids.push(id);

                plugin.settings.afterSheep($e);
                $e.trigger(
                    $.Event('sheeped.jq.sheeper', {})
                );
            } else {
                var id = getId();

                // Creates a new sheep.
                var $sheep = $(plugin.settings.prototype.replace(/(__|\{\{)\s?name\s?(__|\}\})/gi, id));

                // Sets the sheep ID.
                $sheep.data("sid", id);
                ids.push(id);

                if (plugin.settings.prepend) {
                    $wrapper.prepend($sheep);
                } else {
                    $wrapper.append($sheep);
                }
                // Registers the sheep in the herd.
                plugin.settings.afterSheep($sheep);
                $sheep.trigger(
                    $.Event('sheeped.jq.sheeper', {})
                );
            }
            if (plugin.numberOfSheeps() > plugin.settings.min) {
                enableUnsheep();
            } else {
                disableUnsheep();
            }
            if (plugin.numberOfSheeps() < plugin.settings.max) {
                enableSheep();
            } else {
                disableSheep();
            }

            refresh();
        }
        /**
         * Deletes a sheep element.
         * @param  Element e The '.unsheep-link' clicked.
         * @return void
         */
        var unsheep = function(e)
        {
            if (plugin.numberOfSheeps() > plugin.settings.min) {
                var $sheep = $(e).parents(plugin.settings.selector);
                plugin.settings.beforeUnsheep($sheep);
                $sheep.trigger(
                    $.Event('unsheep.jq.sheeper', {})
                );

                // Removes the sheep.
                $sheep.remove();

                plugin.settings.afterUnsheep($sheep);
                $wrapper.trigger(
                    $.Event('unsheeped.jq.sheeper', {
                        relatedTarget: $sheep
                    })
                );
            }
            if (plugin.numberOfSheeps() === plugin.settings.min) {
                disableUnsheep();
            }

            refresh();
        }

        var moveUp = function(e)
        {
            var $sheep = $(e).parents(plugin.settings.selector),
                $previous = $sheep.prev();
            if($previous.length) {
                $sheep.detach().insertBefore($previous);
            }

            refresh();
        }

        var moveDown = function(e)
        {
            var $sheep = $(e).parents(plugin.settings.selector),
                $next = $sheep.next();
            if($next.length) {
                $sheep.detach().insertAfter($next);
            }

            refresh();
        }

        plugin.numberOfSheeps = function()
        {
            return $wrapper.find(plugin.settings.selector).length;
        }

        var refresh = function()
        {
            var $sheeps = $wrapper.children();
            $sheeps.each(function(i, e) {
                var $e = $(e);
                $e.find(plugin.settings.moveUpSelector).each(function(i, e) {
                    $(e).removeClass("disabled");
                });
                $e.find(plugin.settings.moveDownSelector).each(function(i, e) {
                    $(e).removeClass("disabled");
                });
            });

            $sheeps.first().find(plugin.settings.moveUpSelector).addClass("disabled");
            $sheeps.last().find(plugin.settings.moveDownSelector).addClass("disabled");
        }

        var enableSheep = function()
        {
            $wrapper.find(plugin.settings.addSelector).removeClass("disabled");
        }

        var disableSheep = function()
        {
            $wrapper.find(plugin.settings.addSelector).addClass("disabled");
        }

        /**
         * Enable the ability to unhseep.
         * @return void
         */
        var enableUnsheep = function()
        {
            $wrapper.find(plugin.settings.removeSelector).removeClass("disabled");
        }
        /**
         * Disable the ability to unsheep.
         * @return void
         */
        var disableUnsheep = function()
        {
            $wrapper.find(plugin.settings.removeSelector).addClass("disabled");
        }

        var getId = function()
        {
            var id = 0;
            while(ids.indexOf(id) !== -1) {
                id++;
            }

            return id;
        }

        plugin.init();
    }

    $.fn.sheeper = $.fn.inputSheeper = function(options) {
        return this.each(function() {
            if (undefined == $(this).data('inputSheeper')) {
                var plugin = new $.sheeper(this, options);
                $(this).data('inputSheeper', plugin);
            }
        });
    }

    /**
     * DATA-* ATTRIBUTES API
     *
     * Use data-* attributes to enable/configure your sheeper components.
     */
    $(document).ready(function() {
        $('[data-toggle="sheeper"]').sheeper({});
    });
})(jQuery);
<|endoftext|>


<commit_before>(function( $ ){

	var methods = {
		init : function( options ) {
			var $wrapper = this; //expecting a wrapper in selector

			//default options, overriden by the options param
			var settings = $.extend({
				selector : this.selector,
				offset: 0, //multiplier; not a css unit
				overflow: "hidden"
			}, options);

			//FYI: Math.abs() always returns a positive number
			settings.offset = Math.abs(settings.offset);

			/*
				first element will be this many items to the left, and the rest will be to the right of it
				For example, if #wrapper is 500px and settings.offset is 1 then "#wrapper > div:first" will be "left: -500px;"
			*/
			var lastposition = (settings.offset - (settings.offset * 2));
			//how much each slide should move. This is the 500px mentioned in the example.
			var increase = $wrapper.width();
			var $children = $wrapper.children();
			this.children().each(function(){
				jQuery(this).css({left: (lastposition * increase)+"px", position: "absolute", "width": "100%"});
				if((lastposition * increase) === 0) jQuery(this).addClass("slidetoActive");
				lastposition++;
			});
			this.css({
				//because the children are absolute, the height of #wrapper will be 0px unless we set it explicitly
				"min-height": $children.eq(settings.offset).height() + "px",
				"overflow": settings.overflow,
				"position": "relative"
			}).addClass("slidetoWrapper");
			//ready to slide.
		},
		slide : function( options ) {
			var $elem = this; //expecting a slideto-child in selector

			var settings = $.extend({
				instant : false, //animate movement or just css it
				selector : this.selector,
				speed: "fast"
			}, options);

			var $wrapper = $elem.parents(".slidetoWrapper").first();
			//set wrapper height to fit $elem, and change the slidetoActive
			$wrapper.css("min-height", $elem.height() + "px").children(".slidetoActive").removeClass("slidetoActive");
			$elem.addClass("slidetoActive");
			var currentleft = $elem.css("left");
			//slide all until we get there.
			$wrapper.children().each(function(){
				if(!settings.instant){
					jQuery(this).animate({left: "-="+currentleft}, settings.fast);
				}else{
					jQuery(this).css({left: "-="+currentleft});
				}
			});
			return $elem;
		},
		next : function( options ){
			var $wrapper = this; //expecting a wrapper in selector
			//using one function for both next() and prev()
			methods.nextprev($wrapper, 1, options);
		},
		prev : function( options ){
			var $wrapper = this; //expecting a wrapper in selector
			methods.nextprev($wrapper, -1, options);
		},
		nextprev : function( $wrapper, direction, options ){
			//loop through children and see which one is active
			var i = 0;
			var current;
			$wrapper.children().each(function(){
				if(jQuery(this).hasClass("slidetoActive")) current = i;
				i++;
			});
			//now either add 1 or -1 to that, and slide there!
			$wrapper.children().eq(current + direction).slideto(options);
		}
	};

	$.fn.slideto = function( method ) {

		// Method calling logic
		if ( methods[method] ) {
			return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
		} else if ( typeof method === 'object' || ! method ) {
			//simply calling jQuery("#some-element").slideto() will simply slide to that one
			return methods.slide.apply( this, arguments );
		} else {
			$.error( 'Method ' +  method + ' does not exist in jQuery.slideto' );
		}

	};

})( jQuery );<commit_msg>Dont ignore speed<commit_after>(function( $ ){

	var methods = {
		init : function( options ) {
			var $wrapper = this; //expecting a wrapper in selector

			//default options, overriden by the options param
			var settings = $.extend({
				selector : this.selector,
				offset: 0, //multiplier; not a css unit
				overflow: "hidden"
			}, options);

			//FYI: Math.abs() always returns a positive number
			settings.offset = Math.abs(settings.offset);

			/*
				first element will be this many items to the left, and the rest will be to the right of it
				For example, if #wrapper is 500px and settings.offset is 1 then "#wrapper > div:first" will be "left: -500px;"
			*/
			var lastposition = (settings.offset - (settings.offset * 2));
			//how much each slide should move. This is the 500px mentioned in the example.
			var increase = $wrapper.width();
			var $children = $wrapper.children();
			this.children().each(function(){
				jQuery(this).css({left: (lastposition * increase)+"px", position: "absolute", "width": "100%"});
				if((lastposition * increase) === 0) jQuery(this).addClass("slidetoActive");
				lastposition++;
			});
			this.css({
				//because the children are absolute, the height of #wrapper will be 0px unless we set it explicitly
				"min-height": $children.eq(settings.offset).height() + "px",
				"overflow": settings.overflow,
				"position": "relative"
			}).addClass("slidetoWrapper");
			//ready to slide.
		},
		slide : function( options ) {
			var $elem = this; //expecting a slideto-child in selector

			var settings = $.extend({
				instant : false, //animate movement or just css it
				selector : this.selector,
				speed: "fast"
			}, options);

			var $wrapper = $elem.parents(".slidetoWrapper").first();
			//set wrapper height to fit $elem, and change the slidetoActive
			$wrapper.css("min-height", $elem.height() + "px").children(".slidetoActive").removeClass("slidetoActive");
			$elem.addClass("slidetoActive");
			var currentleft = $elem.css("left");
			//slide all until we get there.
			$wrapper.children().each(function(){
				if(!settings.instant){
					jQuery(this).animate({left: "-="+currentleft}, settings.speed);
				}else{
					jQuery(this).css({left: "-="+currentleft});
				}
			});
			return $elem;
		},
		next : function( options ){
			var $wrapper = this; //expecting a wrapper in selector
			//using one function for both next() and prev()
			methods.nextprev($wrapper, 1, options);
		},
		prev : function( options ){
			var $wrapper = this; //expecting a wrapper in selector
			methods.nextprev($wrapper, -1, options);
		},
		nextprev : function( $wrapper, direction, options ){
			//loop through children and see which one is active
			var i = 0;
			var current;
			$wrapper.children().each(function(){
				if(jQuery(this).hasClass("slidetoActive")) current = i;
				i++;
			});
			//now either add 1 or -1 to that, and slide there!
			$wrapper.children().eq(current + direction).slideto(options);
		}
	};

	$.fn.slideto = function( method ) {

		// Method calling logic
		if ( methods[method] ) {
			return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
		} else if ( typeof method === 'object' || ! method ) {
			//simply calling jQuery("#some-element").slideto() will simply slide to that one
			return methods.slide.apply( this, arguments );
		} else {
			$.error( 'Method ' +  method + ' does not exist in jQuery.slideto' );
		}

	};

})( jQuery );<|endoftext|>