File: components/webfan/nachrichten/app.js

Recommend this page to a friend!
  Classes of Till Wehowski   .Flow   components/webfan/nachrichten/app.js   Download  
File: components/webfan/nachrichten/app.js
Role: Application script
Content type: text/plain
Description: Application script
Class: .Flow
General purpose library of objects
Author: By
Last change: update components
Date: 7 years ago
Size: 2,718 bytes
 

Contents

Class file image Download
/* @copyright (c) Till Wehowski - All rights reserved @license (Basic/EULA) http://look-up.webfan.de/webdof-license @license (Source Code Re-Usage) http://look-up.webfan.de/bsd-license Copyright (c) 2015, Till Wehowski All rights reserved. @component https://github.com/frdl/-Flow/tree/master/components/webfan/marketplace */ (function( ){ 'use strict'; frdl_webfan_flow_advertising_external_linking(new frdl.Url(frdl.__FILE__()).getHost()); var _TOK_ = '*[data-frdl-component$="webfan\/nachrichten"]'; var __FILE__ = frdl.__FILE__(); var Url = new frdl.Url(__FILE__); var __DIR__ = Url.getScheme() + '://' + Url.getHost() + '/' + Url.getDirectory(); var __NEWSURL__ = 'http://interface.api.webfan.de/v1/public/frdl/webfan/nachrichten.json?start=0&count=400'; /* frdl.UI.defer(); alert('Test: ' + new frdl.Url(frdl.__FILE__()).urlMakeNew()); */ frdl.ready(function(){ angular.module('webfanNachrichten', []) .controller('webfanNachrichtenCtrl', ['$scope', '$element', '$compile', '$http', function($scope, $element, $compile, $http) { $scope.caption='Nachrichten'; function shuffle(array) { var counter = array.length, temp, index; while (counter > 0) { index = Math.floor(Math.random() * counter); counter--; temp = array[counter]; array[counter] = array[index]; array[index] = temp; } return array; } $http.get(__NEWSURL__) .success(function(data, status, headers, config) { var news = data.result.data.news; $scope.provider = data.result.data.service.provider; news = frdl.filter(news, function(v,i){ if(null === v.descritpion || null === v.title)return false; v.link = str_replace('&','&', v.link); return true; }, false); news = shuffle(news); $scope.news = news; $compile($element.contents())($scope); frdl.ready(function(){ if('function'===typeof frdl.getLang){ frdl.translate(frdl.getLang(), false, true); } }); /* alert(JSON.stringify($scope.news));*/ }) .error(function(data, status, headers, config) { console.error('cannot get components from server!'); }); }]) .run([function() { $(document).ready(function(){ frdl.UI.Compile(1); }); }]) ; }); }( ));