| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- function http(url, params) {
- return new Promise(function(resolve, reject) {
- httpRequest = new XMLHttpRequest();
-
- httpRequest.onreadystatechange = function() {
- if (httpRequest.readyState == XMLHttpRequest.DONE ) {
- if (httpRequest.status == 200) {
- resolve(httpRequest.responseText);
- } else {
- reject("pls fix later");
- }
- }
- };
-
- httpRequest.open('GET', url, true);
- httpRequest.setRequestHeader('lang', 'ES')
- var x = params ? params : null;
- httpRequest.send(null);
- });
- }
- http('http://192.168.1.127/api/products/category/58caba2ce53f0644597b74e8').then(function(data) {
- //console.log("2017 no frameworks", data);
- }, function(err){
- console.log("err",err);
- });
- var sections = [
- 'empresa',
- 'productos'
- ];
- var selectedSection_ = {
- empresa: true,
- productos: false
- };
- rivets.configure({
- executeFunctions: true
- })
- var app = document.getElementById('app');
- var view = rivets.bind(app, {
- sections: sections,
- selectedSection: selectedSection_,
- selectSection: function (event, scope) {
- var newValue = event.target.text;
- window.history.pushState({}, newValue, '#' + newValue)
- chooseSection(newValue);
- event.target.className = 'selected';
- }
- });
- function chooseSection(section) {
- var navbarList = window.document.querySelectorAll('ul.navbar-list > li > a');
- navbarList.forEach(function (el) {
- var isSelected = el.text === section;
- el.className = isSelected ? 'selected' : '';
- selectedSection_[el.text] = isSelected;
- })
- }
- var elements = [];
- window.onscroll = function () {
- elements = elements.reduce(function (acc, e) {
- if (isInViewport(e)) {
- e.className = 'discover-li'
- return acc;
- } else {
- acc.push(e);
- return acc;
- }
- }, [])
- if (elements.length === 0) {
- window.onscroll = function () {};
- }
- };
- function isInViewport(element) {
- var rect = element.getBoundingClientRect();
- var html = document.documentElement;
- return (rect.top >= 0 &&
- rect.left >= 0 &&
- rect.bottom <= (window.innerHeight || html.clientHeight) &&
- rect.right <= (window.innerWidth || html.clientWidth))
- }
- window.onload = function () {
- chooseSection(window.location.hash.substr(1));
- }
|