• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

[Webdialog] Javascript lerts with object bypass

Scheduled Pinned Locked Moved Developers' Forum
6 Posts 2 Posters 301 Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    chrisglasier
    last edited by chrisglasier 29 Jul 2012, 21:35

    Here is an alternative to using alert() I call lert:

    
    <script>
    var wlert;
    function lert(v){
        var html;
        if(!wlert || wlert.closed){
    	wlert = window.open("","_blank","width=300,height=400,resizable=yes,scrollbars=yes");
        }
        html = "<pre>";
        html += v;
        html += "</pre>";
        wlert.document.write(html);
    }
    
    //sample call = lert(JSON.stringify(nset[lab],null,'\t'))
    </script>
    
    

    lert.png
    Keeps format - useful for examining JSON strings as above
    While open collects results of any "lerts" in code.
    Close clears lerts
    Use deskpins to keep on top
    Scrollable/resizable/reconfigurable

    With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

    1 Reply Last reply Reply Quote 0
    • C Offline
      chrisglasier
      last edited by 30 Jul 2012, 01:55

      Also found it better to close lert window with reload.

      
      <body onBeforeUnload = "lertClose()">
      <script>
      function lertClose(){
          if(wlert && !wlert.closed){
              wlert.close();
          }
      }
      </script>
      
      

      With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

      1 Reply Last reply Reply Quote 0
      • C Offline
        chrisglasier
        last edited by 3 Aug 2012, 07:19

        I wanted to review objects that collects data from different activities/sources. If some are objects an error is called on the whole call. This bypasses the objects. I post this in case anyone has a similar need.

        
        <script>
        		var wlert;
        		
        		function lert(v,json){
            		var html,arr;
            		if(!wlert || wlert.closed){
           				wlert = window.open("","_blank","width=300,height=400,resizable=yes,scrollbars=yes");
           			 }
           			html = "<pre>";
           			if(json){
           				arr = [];
           				for(n in v){
           					arr.push(n + "; " + v[n]);
          				}
           				html += arr.join("<br>");
           			}
            		else{
           				html += v;
               		}
            		html += "</pre>";
            		wlert.document.write(html);
        		}
        		
        		function lertClose(){
            		if(wlert && !wlert.closed){
               		 	wlert.close();
           			}
        	}
        	
        	//call ; lert(variable,[optional]);
        	</script>
        

        lert2.png

        With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

        1 Reply Last reply Reply Quote 0
        • D Offline
          Dan Rathbun
          last edited by 3 Aug 2012, 16:43

          This applies to WebDialogs ??

          Why is the example a Chrome window ?

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • C Offline
            chrisglasier
            last edited by 3 Aug 2012, 22:09

            @dan rathbun said:

            This applies to WebDialogs ??

            Why is the example a Chrome window ?

            Only because I am currently using common (json) data with Kineticjs to display 2D shapes on html5 canvas. Later I intend the same data to be displayed as components in a Sketchup file (as I have demonstrated before). Same URL sits in a web dialog so the lert window will open with IE.

            Bit like going sideways to go forward, but 2D is easier on my limited coding ability to revamp old ideas.

            Did not mean to offend!

            With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

            1 Reply Last reply Reply Quote 0
            • D Offline
              Dan Rathbun
              last edited by 3 Aug 2012, 22:42

              @chrisglasier said:

              Did not mean to offend!

              Ya' did not...

              It was a half-tease... 😛

              ... and a half devil's advocate, asking the obvious question (that a novice might ask.).

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              1 / 1
              • First post
                1/6
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement