Example #1
0
function setIframePositions()
{
    //Do the widgets first
    $sm = screenMap();
    //TODO HACK ALERT implement screen size feedback
    $screenRect = loadJSON("screenRect", array("width" => 1920, "height" => 1080));
    for ($widx = 0; $widx < count($sm["widgetAppMap"]); $widx++) {
        if (!$sm['widgetAppMap'][$widx]) {
            continue;
        }
        $sm['widgetAppMap'][$widx]['location'] = array("top" => 0, "left" => 0);
        //TODO implement server side nudge
        //var nudge = {
        //top:
        //0, left: 0 };
        $nudge = array("top" => 0, "left" => 0);
        switch ($widx) {
            case 0:
                $sm['widgetAppMap'][$widx]['location']['top'] = floor(0.05 * $screenRect['height']) + $nudge['top'] . 'px';
                $sm['widgetAppMap'][$widx]['location']['left'] = floor(0.03 * $screenRect['width']) + $nudge['left'] . 'px';
                break;
            case 1:
                $sm['widgetAppMap'][$widx]['location']['top'] = floor(0.05 * $screenRect['height']) + $nudge['top'] . 'px';
                $sm['widgetAppMap'][$widx]['location']['left'] = floor(0.85 * $screenRect['width']) + $nudge['left'] . 'px';
                break;
            case 2:
                $sm['widgetAppMap'][$widx]['location']['top'] = floor(0.6 * $screenRect['height']) + $nudge['top'] . 'px';
                $sm['widgetAppMap'][$widx]['location']['left'] = floor(0.85 * $screenRect['width']) + $nudge['left'] . 'px';
                break;
            case 3:
                $sm['widgetAppMap'][$widx]['location']['top'] = floor(0.6 * $screenRect['height']) + $nudge['top'] . 'px';
                $sm['widgetAppMap'][$widx]['location']['left'] = floor(0.03 * $screenRect['width']) + $nudge['left'] . 'px';
                break;
        }
    }
    //Do the crawler next
    for ($cidx = 0; $cidx < count($sm["crawlerAppMap"]); $cidx++) {
        if (!$sm['widgetAppMap'][$cidx]) {
            continue;
        }
        $sm['widgetAppMap'][$cidx]['location'] = array("top" => 0, "left" => 0);
        //TODO implement server side nudge
        //var nudge = {
        //top:
        //0, left: 0 };
        $nudge = array("top" => 0, "left" => 0);
        //HARD CODE for DEMO
        $sm['widgetAppMap'][$cidx]['location']['left'] = '0px';
        switch ($cidx) {
            case 0:
                $sm['widgetAppMap'][$cidx]['location']['top'] = floor(0.89 * $screenRect['height']) . $nudge['top'] . 'px';
                break;
            case 1:
                $sm['widgetAppMap'][$cidx]['location']['top'] = floor(0.03 * $screenRect['height']) . $nudge['top'] . 'px';
                break;
        }
    }
    if (count($sm['fullScreenAppMap']) > 0) {
        $sm['fullScreenAppMap'][0]['location'] = array("top" => 0, "left" => 0);
    }
    saveJSON("screenMap", $sm);
}
Example #2
0
         badReq('GET only');
     }
     break;
 case 'reset':
     if (isPOST()) {
         array_map('unlink', glob("../data/appdata/*.json"));
         array_map('unlink', glob("../data/messages/*.json"));
         array_map('unlink', glob("../data/*.json"));
         jsonOut(json_encode(array("cool" => "beans")));
     } else {
         badReq('POST only');
     }
     break;
 case 'screenmap':
     header('Content-Type: application/json');
     echo json_encode(screenMap());
     break;
 case 'running':
     header('Content-Type: application/json');
     echo json_encode(runningApps());
     break;
 case 'kill':
     if (isPOST() && isset($_REQUEST['appid'])) {
         $kill = killApp($_REQUEST['appid']);
         if ($kill["success"]) {
             jsonOut(json_encode(array("killed" => $_REQUEST['appid'])));
         } else {
             badReq($kill["msg"]);
         }
     } else {
         badReq('Wrong verb or no appid');