sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    [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.
    • chrisglasierC Offline
      chrisglasier
      last edited by chrisglasier

      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
      • chrisglasierC Offline
        chrisglasier
        last edited by

        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
        • chrisglasierC Offline
          chrisglasier
          last edited by

          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
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            This applies to WebDialogs ??

            Why is the example a Chrome window ?

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • chrisglasierC Offline
              chrisglasier
              last edited by

              @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
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                @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
                • First post
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement