]> _ Git - psq.git/commitdiff
user id
authorLouis Jeckel <louis.jeckel@outlook.cm>
Tue, 22 Sep 2020 15:28:29 +0000 (17:28 +0200)
committerLouis Jeckel <louis.jeckel@outlook.cm>
Tue, 22 Sep 2020 15:28:29 +0000 (17:28 +0200)
public/js/flowpaper/flowpaper.js
resources/views/flowpaper/view.blade.php

index e04fac6b1bd902b05e5c19ea3e19e7af5f6120b0..e17cfce2ff8cda5a4d9effa3c350a57c081daab1 100644 (file)
@@ -11,7 +11,7 @@
 *
 * FlowPaper helper function for retrieving a active FlowPaper instance
 *
-*/ 
+*/
 window.$FlowPaper = window.getDocViewer = window["$FlowPaper"] = function(id){
        var instance = (id==="undefined")?"":id;
 
@@ -243,6 +243,10 @@ window.TrackFlowPaperEvent = function(trackingNumber,trackingDocument,eventType,
             eventAction: eventType,
             eventLabel: eventLabel
         });
+
+        if(user_id !== undefined && !isNan(user_id)) {
+            ga('set', 'userId', user_id);
+        }
     }
 };
 
@@ -565,7 +569,7 @@ window.TrackFlowPaperEvent = function(trackingNumber,trackingDocument,eventType,
 })();
 
 /**
- * 
+ *
  * FlowPaper embedding functionality. Based on FlashEmbed
  *
  */
@@ -574,29 +578,29 @@ window.TrackFlowPaperEvent = function(trackingNumber,trackingDocument,eventType,
     var  ua = navigator.userAgent.toLowerCase();
        var  IE = document.all,
                 URL = 'http://www.adobe.com/go/getflashplayer',
-                JQUERY = typeof jQuery == 'function', 
+                JQUERY = typeof jQuery == 'function',
                 RE = /(\d+)[^\d]+(\d+)[^\d]*(\d*)/,
          INMETRO = /msie/.test(ua) && (function(){try {return !!new ActiveXObject("htmlfile");} catch (e) {return false;} })() && navigator.platform == "Win64" && (document.documentElement.clientWidth == screen.width),
          MOBILE = (function(){try {return 'ontouchstart' in document.documentElement;} catch (e) {return false;} })() || ua.match(/touch/i),
          MOBILEOS = ((ua.indexOf("android") > -1) || ((ua.match(/iphone/i)) || (ua.match(/ipod/i)) || (ua.match(/ipad/i))) || ua.match(/Windows Phone/i) || ua.match(/BlackBerry/i) || ua.match(/webOS/i)),
-                GLOBAL_OPTS = { 
+                GLOBAL_OPTS = {
                        // very common opts
                        width: '100%',
-                       height: '100%',         
+                       height: '100%',
                        id: "_" + ("" + Math.random()).slice(9),
-                       
+
                        // flashembed defaults
                        allowfullscreen: true,
                        allowscriptaccess: 'always',
                        quality: 'high',
             allowFullScreenInteractive : true,
-                       
+
                        // flashembed specific options
                        version: [10, 0],
                        onFail: null,
-                       expressInstall: null, 
+                       expressInstall: null,
                        w3c: false,
-                       cachebusting: false                              
+                       cachebusting: false
        };
 
     window.isTouchScreen = MOBILE && (MOBILEOS || INMETRO);
@@ -607,7 +611,7 @@ window.TrackFlowPaperEvent = function(trackingNumber,trackingDocument,eventType,
                        __flash_savedUnloadHandler = function() {};
                });
        }
-       
+
        // simple extend
        function extend(to, from) {
                if (from) {
@@ -616,7 +620,7 @@ window.TrackFlowPaperEvent = function(trackingNumber,trackingDocument,eventType,
                                        to[key] = from[key];
                                }
                        }
-               } 
+               }
                return to;
        }
 
@@ -634,9 +638,9 @@ window.TrackFlowPaperEvent = function(trackingNumber,trackingDocument,eventType,
         jQuery('#'+elementId).trigger(eventName,args);
     }
 
-       // used by asString method      
+       // used by asString method
        function map(arr, func) {
-               var newArr = []; 
+               var newArr = [];
                for (var i in arr) {
                        if (arr.hasOwnProperty(i)) {
                                newArr[i] = func(arr[i]);
@@ -646,74 +650,74 @@ window.TrackFlowPaperEvent = function(trackingNumber,trackingDocument,eventType,
        }
 
        window.flashembed = function(root, opts, conf) {
-               // root must be found / loaded  
+               // root must be found / loaded
                if (typeof root == 'string') {
                        root = document.getElementById(root.replace("#", ""));
                }
-               
+
                // not found
                if (!root) { return; }
-               
+
                root.onclick = function(){return false;}
-               
+
                if (typeof opts == 'string') {
-                       opts = {src: opts};     
+                       opts = {src: opts};
                }
 
-               return new Flash(root, extend(extend({}, GLOBAL_OPTS), opts), conf); 
-       };      
-       
+               return new Flash(root, extend(extend({}, GLOBAL_OPTS), opts), conf);
+       };
+
        // flashembed "static" API
        var f = extend(window.flashembed, {
-               
+
                conf: GLOBAL_OPTS,
-       
+
                getVersion: function()  {
                        var fo, ver;
-                       
+
                        try {
-                               ver = navigator.plugins["Shockwave Flash"].description.slice(16); 
+                               ver = navigator.plugins["Shockwave Flash"].description.slice(16);
                        } catch(e) {
-                               
+
                                try  {
                                        fo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
                                        ver = fo && fo.GetVariable("$version");
-                                       
+
                                } catch(err) {
                 try  {
                     fo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
-                    ver = fo && fo.GetVariable("$version");  
-                } catch(err2) { }                                              
-                               } 
+                    ver = fo && fo.GetVariable("$version");
+                } catch(err2) { }
+                               }
                        }
-                       
+
                        ver = RE.exec(ver);
                        return ver ? [ver[1], ver[3]] : [0, 0];
                },
-               
-               asString: function(obj) { 
+
+               asString: function(obj) {
 
                        if (obj === null || obj === undefined) { return null; }
                        var type = typeof obj;
                        if (type == 'object' && obj.push) { type = 'array'; }
-                       
-                       switch (type){  
-                               
+
+                       switch (type){
+
                                case 'string':
                                        obj = obj.replace(new RegExp('(["\\\\])', 'g'), '\\$1');
-                                       
+
                                        // flash does not handle %- characters well. transforms "50%" to "50pct" (a dirty hack, I admit)
                                        obj = obj.replace(/^\s?(\d+\.?\d+)%/, "$1pct");
                                        return '"' +obj+ '"';
-                                       
+
                                case 'array':
                                        return '['+ map(obj, function(el) {
                                                return f.asString(el);
-                                       }).join(',') +']'; 
-                                       
+                                       }).join(',') +']';
+
                                case 'function':
                                        return '"function()"';
-                                       
+
                                case 'object':
                                        var str = [];
                                        for (var prop in obj) {
@@ -723,52 +727,52 @@ window.TrackFlowPaperEvent = function(trackingNumber,trackingDocument,eventType,
                                        }
                                        return '{'+str.join(',')+'}';
                        }
-                       
+
                        // replace ' --> "  and remove spaces
                        return String(obj).replace(/\s/g, " ").replace(/\'/g, "\"");
                },
-               
+
                getHTML: function(opts, conf) {
 
                        opts = extend({}, opts);
                        opts.id = opts.id + (" " + Math.random()).slice(9);
-                       
+
                        /******* OBJECT tag and it's attributes *******/
-                       var html = '<object width="' + opts.width + 
-                               '" height="' + opts.height + 
-                               '" id="' + opts.id + 
+                       var html = '<object width="' + opts.width +
+                               '" height="' + opts.height +
+                               '" id="' + opts.id +
                                '" name="' + opts.id + '"';
-                       
+
                        if (opts.cachebusting) {
-                               opts.src += ((opts.src.indexOf("?") != -1 ? "&" : "?") + Math.random());                
-                       }                       
-                       
+                               opts.src += ((opts.src.indexOf("?") != -1 ? "&" : "?") + Math.random());
+                       }
+
                        if (opts.w3c || !IE) {
-                               html += ' data="' +opts.src+ '" type="application/x-shockwave-flash"';          
+                               html += ' data="' +opts.src+ '" type="application/x-shockwave-flash"';
                        } else {
-                               html += ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';        
+                               html += ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
                        }
-                       
-                       html += '>'; 
-                       
+
+                       html += '>';
+
                        /******* nested PARAM tags *******/
                        if (opts.w3c || IE) {
-                               html += '<param name="movie" value="' +opts.src+ '" />';        
-                       } 
-                       
+                               html += '<param name="movie" value="' +opts.src+ '" />';
+                       }
+
                        // not allowed params
                        opts.width = opts.height = opts.id = opts.w3c = opts.src = null;
                        opts.onFail = opts.version = opts.expressInstall = null;
-                       
+
                        for (var key in opts) {
                                if (opts[key]) {
                                        html += '<param name="'+ key +'" value="'+ opts[key] +'" />';
                                }
-                       }       
-               
+                       }
+
                        /******* FLASHVARS *******/
                        var vars = "";
-                       
+
                        if (conf) {
                                for (var k in conf) {
                     if ((typeof conf[k] != "undefined") && (typeof conf[k] != "unknown") && k!='Toolbar' && k!='BottomToolbar') {
@@ -780,20 +784,20 @@ window.TrackFlowPaperEvent = function(trackingNumber,trackingDocument,eventType,
                                vars = vars.slice(0, -1);
                                html += '<param name="flashvars" value=\'' + vars + '\' />';
                        }
-                       
-                       html += "</object>";    
-                       
-                       return html;                            
+
+                       html += "</object>";
+
+                       return html;
                },
-               
+
                isSupported: function(ver) {
-                       return VERSION[0] > ver[0] || VERSION[0] == ver[0] && VERSION[1] >= ver[1];                     
-               }               
-               
+                       return VERSION[0] > ver[0] || VERSION[0] == ver[0] && VERSION[1] >= ver[1];
+               }
+
        });
-       
-       var VERSION = f.getVersion(); 
-       
+
+       var VERSION = f.getVersion();
+
        function Flash(root, opts, conf) {
         var browser = window["eb.browser"];
             browser.version = browser.version?browser.version:"";
@@ -848,7 +852,7 @@ window.TrackFlowPaperEvent = function(trackingNumber,trackingDocument,eventType,
             if(conf.Toolbar){
                 var wrapper = jQuery(root).wrap("<div class='flowpaper_toolbar_wrapper' style='"+jQuery(root).attr('style')+"'></div>").parent();
                 wrapper.prepend(jQuery(conf.Toolbar));
-                
+
                 jQuery(root).css({
                     left : '0px',
                     top: '0px',
@@ -863,7 +867,7 @@ window.TrackFlowPaperEvent = function(trackingNumber,trackingDocument,eventType,
             if(conf.BottomToolbar && conf.AnnotationToolsVisible!=false){
                 jQuery.get(conf.BottomToolbar,function(toolbarData){
                     wrapper.append(toolbarData);
-                    
+
                     jQuery(root).css({
                         height : jQuery(root).height() - jQuery(wrapper).find('.flowpaper_bottomToolbar').height()
                     });
@@ -915,7 +919,7 @@ window.TrackFlowPaperEvent = function(trackingNumber,trackingDocument,eventType,
             if(conf.BottomToolbar && conf.AnnotationToolsVisible!=false){
                 jQuery.get(conf.BottomToolbar,function(toolbarData){
                     wrapper.append(toolbarData);
-                    
+
                     jQuery(root).css({
                         height : jQuery(root).height() - jQuery(wrapper).find('.flowpaper_bottomToolbar').height()
                     });
@@ -1172,27 +1176,27 @@ window.TrackFlowPaperEvent = function(trackingNumber,trackingDocument,eventType,
                                // fail #2.1 custom content inside container
                                if (!root.innerHTML.replace(/\s/g, '')) {
                                        var pageHost = ((document.location.protocol == "https:") ? "https://" : "http://");
-                                       
-                                       root.innerHTML = 
+
+                                       root.innerHTML =
                                                "<h2>Your browser is not compatible with FlowPaper</h2>" +
-                                               "<h3>Upgrade to a newer browser or download Adobe Flash Player 10 or higher.</h3>" + 
-                                               "<p>Click on the icon below to download the latest version of Adobe Flash" + 
-                                               "<a href='http://www.adobe.com/go/getflashplayer'><img src='" 
+                                               "<h3>Upgrade to a newer browser or download Adobe Flash Player 10 or higher.</h3>" +
+                                               "<p>Click on the icon below to download the latest version of Adobe Flash" +
+                                               "<a href='http://www.adobe.com/go/getflashplayer'><img src='"
                                                                                        + pageHost + "www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /></a>";
-                                                                                                                                                                                       
-                                       if (root.tagName == 'A') {      
+
+                                       if (root.tagName == 'A') {
                                                root.onclick = function() {
                                                        location.href = URL;
                                                };
-                                       }                               
+                                       }
                                }
-                               
+
                                // onFail
                                if (opts.onFail) {
                                        var ret = opts.onFail.call(this);
-                                       if (typeof ret == 'string') { root.innerHTML = ret; }   
-                               }               
-                       }       
+                                       if (typeof ret == 'string') { root.innerHTML = ret; }
+                               }
+                       }
                }
 
         // bind a listener to the hash change event and change page if the user changes the page hash parameter
@@ -1202,7 +1206,7 @@ window.TrackFlowPaperEvent = function(trackingNumber,trackingDocument,eventType,
                 $FlowPaper(viewerId).gotoPage(page);
             }
         }));
-               
+
                // http://flowplayer.org/forum/8/18186#post-18593
                if (IE) {
                        window[opts.id] = document.getElementById(opts.id);
@@ -1234,7 +1238,7 @@ window.TrackFlowPaperEvent = function(trackingNumber,trackingDocument,eventType,
        // setup jquery support
        if (JQUERY) {
                jQuery.fn.flashembed = function(opts, conf) {
-                       return this.each(function() { 
+                       return this.each(function() {
                                jQuery(this).data("flashembed", flashembed(this, opts, conf));
                        });
                };
@@ -1251,7 +1255,7 @@ window.TrackFlowPaperEvent = function(trackingNumber,trackingDocument,eventType,
     }
 })();
 function getIEversion()
-// Returns the version of Internet Explorer or a -1. 
+// Returns the version of Internet Explorer or a -1.
 // (indicating the use of another browser).
 {
     var rv = -1; // Return value assumes failure.
index c858fe13bf5eef8baef57c75bf843a268c2e6a57..3c28e8b74d5fedaf55579a634995d59707ae35e5 100644 (file)
@@ -29,6 +29,9 @@
     <script type="text/javascript" defer>
 
 
+        @auth
+        let user_id = '{{\Auth::user()->id}}';
+        @endauth
 
         window.onload = function () {
             let url = '{!! $pdfPath !!}';
@@ -38,7 +41,6 @@
             json = json.replace(/&amp;/g, '&');
 
 
-
             // $.get(url)
             //     .then(function(d) {
 
 
                             }
                         }
-                    ).on('onDocumentLoaded', function() {
-                @auth
-                        ga('set', 'userId', '{{\Auth::user()->id}}');
-                    @endauth
-            })
+                    )
         }