File: components/webfan/tmock/app.js

Recommend this page to a friend!
  Classes of Till Wehowski   µ.Flow   components/webfan/tmock/app.js   Download  
File: components/webfan/tmock/app.js
Role: Example script
Content type: text/plain
Description: Example script
Class: µ.Flow
General purpose library of objects
Author: By
Last change: auto commit
Date: 8 years ago
Size: 6,759 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/fmozapps */ (function(global){ 'use strict'; frdl_webfan_flow_advertising_external_linking(new frdl.Url(frdl.__FILE__()).getHost()); var _TOK_ = '*[data-frdl-component$="webfan\/tmock"]'; var __FILE__ = frdl.__FILE__(); var Url = new frdl.Url(__FILE__); var __DIR__ = Url.getScheme() + '://' + Url.getHost() + '/' + Url.getDirectory(); /* frdl.UI.defer(); alert('Test: ' + new frdl.Url(frdl.__FILE__()).urlMakeNew()); */ frdl.each(document.querySelectorAll(_TOK_), function(i,el){ if('true'===el.getAttribute('data-frdl-component-loaded-script'))return true; el.setAttribute('data-frdl-component-initiated', 'true'); el.setAttribute('data-frdl-component-loaded-script', 'true'); el.style.position='relative'; el.style.display='inline'; /*el.setAttribute('ng-flow', 'fmozapp'); */ /*el.setAttribute('ng-app', 'webfan.fmozapp'); */ /*el.setAttribute('ng-controller', 'webfan.fmozappMainCtrl'); */ /* var ctrlDiv = frdl.Dom.create('div'); ctrlDiv.setAttribute('ng-controller', 'tmockMainCtrl as tmockMainCtrlInstance'); frdl.Dom.add(ctrlDiv, el); ctrlDiv.style.position='relative'; ctrlDiv.style.display='inline'; var dir = frdl.Dom.create('frdl-tmock'); frdl.Dom.add(dir, ctrlDiv); el.setAttribute('ng-flows', 'tmock, csrf-cross-domain'); $(ctrlDiv).prepend('<script type="text/ng-template" id="{{TemplateURL}}" ng-src="{{TemplateURL}}"></script>');*/ }); frdl.ready(function(){ /* frdl.ready(function(){ // frdl.getScript( //'http://webfan.de/cdn/frdl/flow/components/frdl/intent/webintents.js' // , function(){ $(document).trigger('readystatechange'); setTimeout(function(){ $(document).trigger('readystatechange'); setTimeout(function(){ window.navigator.startActivity(new Intent( 'http://webintents.org/shorten', 'text/uri-list' , 'http://example.com'), function (data) { alert(data); }); },1000); },1000); // }, true, true); }); $(document).trigger('readystatechange'); */ setTimeout(function(){ $(document).trigger('readystatechange'); },1500); angular.module('tmock', []) .config(function($sceDelegateProvider) { $sceDelegateProvider.resourceUrlWhitelist([ /*Allow same origin resource loads. */ 'self', /* Allow loading from our assets domain. Notice the difference between * and **. */ 'http://*.webfan.de/**', 'http://*.frdl.de/**' ]); /* The blacklist overrides the whitelist so the open redirect here is blocked. */ /* $sceDelegateProvider.resourceUrlBlacklist([ 'http://myapp.example.com/clickThru**' ]); */ }) .config(function($httpProvider) { $httpProvider.defaults.withCredentials = true; $httpProvider.defaults.useXDomain = true; $httpProvider.interceptors.push('csrfCD'); }) /* .factory('webfanMozAppGetManifest', function($resource, url) { return $resource(url); }) */ .controller('tmockMainCtrl', ['$scope', function($scope) { }]) .directive('frdlTmock' , [ '$compile', '$templateCache', '$http', '$window', '$templateRequest', 'csrfCD', function($compile, $templateCache, $http,$window, $templateRequest, csrfCD){ var getTemplateUrl = function(elem,attrs){ var url = __DIR__ + 'templates/view1.html'; return url; }; $templateCache.get(getTemplateUrl()) return { restrict: 'E', config : function($sceDelegateProvider) { $sceDelegateProvider.resourceUrlWhitelist([ 'self', '*', 'http://*.webfan.de/**', 'http://*.frdl.de/**' ]); }, controller:function($scope, $element, $attrs, $transclude){ $scope.__DIR__ = __DIR__; /* alert($scope.__DIR__); */ var url = $scope.__DIR__ + 'config.xml'; $scope.TemplateURL = getTemplateUrl(); /* $templateRequest($scope.TemplateURL); */ $scope.config = null; /* $http({ crossDomain: false, method : 'GET', url : url, headers: {'X-Requested-With': 'XMLHttpRequest', 'Origin' : '*'}, timeout : 10000, params : {}, transformResponse : function(data) { return $.parseXML(data); } }).success(function(data, status, headers, config) { console.dir(data); $scope.config = data.documentElement.innerHTML; alert(JSON.stringify($scope.config)); }).error(function(data, status, headers, config) { $window.alert('Failed loading config in '+ __FILE__); }); */ $.ajax( { url: url, crossDomain: true, headers: {'X-Requested-With': 'XMLHttpRequest'}, type: 'GET', dataType: 'XML', data: {}, cache:true } ) .done(function(response) { $scope.config = wjslX2JS.xml2json(response); /* alert($scope.config.widget.name); */ alert(JSON.stringify($scope.config)); }) .fail(function(jqXHR, textStatus) { console.error('Error: ' + jqXHR.status); }) .always(function() { }); }, /* templateUrl: getTemplateUrl, */ link: function($scope, $element, $attrs ) { /* $element.html($templateCache); $compile($element.contents())($scope); */ } }; }]) ; /* frdl.UI.load(); */ }); }(typeof exports !== 'undefined' ? global : (typeof this !== 'undefined' ? this : window)));